babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004
  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 http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see http://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 http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see http://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. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @returns true if the loader can load the specified file
  1073. */
  1074. canLoad(extension: string): boolean;
  1075. /**
  1076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param createPolynomials will be true if polynomials have been requested
  1080. * @param onLoad defines the callback to trigger once the texture is ready
  1081. * @param onError defines the callback to trigger in case of error
  1082. */
  1083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1084. /**
  1085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1086. * @param data contains the texture data
  1087. * @param texture defines the BabylonJS internal texture
  1088. * @param callback defines the method to call once ready to upload
  1089. */
  1090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1091. }
  1092. }
  1093. declare module "babylonjs/Engines/IPipelineContext" {
  1094. /**
  1095. * Class used to store and describe the pipeline context associated with an effect
  1096. */
  1097. export interface IPipelineContext {
  1098. /**
  1099. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1100. */
  1101. isAsync: boolean;
  1102. /**
  1103. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1104. */
  1105. isReady: boolean;
  1106. /** @hidden */
  1107. _getVertexShaderCode(): string | null;
  1108. /** @hidden */
  1109. _getFragmentShaderCode(): string | null;
  1110. /** @hidden */
  1111. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1112. }
  1113. }
  1114. declare module "babylonjs/Meshes/dataBuffer" {
  1115. /**
  1116. * Class used to store gfx data (like WebGLBuffer)
  1117. */
  1118. export class DataBuffer {
  1119. /**
  1120. * Gets or sets the number of objects referencing this buffer
  1121. */
  1122. references: number;
  1123. /** Gets or sets the size of the underlying buffer */
  1124. capacity: number;
  1125. /**
  1126. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1127. */
  1128. is32Bits: boolean;
  1129. /**
  1130. * Gets the underlying buffer
  1131. */
  1132. get underlyingResource(): any;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1136. /** @hidden */
  1137. export interface IShaderProcessor {
  1138. attributeProcessor?: (attribute: string) => string;
  1139. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1140. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1141. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1142. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1143. lineProcessor?: (line: string, isFragment: boolean) => string;
  1144. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. }
  1147. }
  1148. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1149. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1150. /** @hidden */
  1151. export interface ProcessingOptions {
  1152. defines: string[];
  1153. indexParameters: any;
  1154. isFragment: boolean;
  1155. shouldUseHighPrecisionShader: boolean;
  1156. supportsUniformBuffers: boolean;
  1157. shadersRepository: string;
  1158. includesShadersStore: {
  1159. [key: string]: string;
  1160. };
  1161. processor?: IShaderProcessor;
  1162. version: string;
  1163. platformName: string;
  1164. lookForClosingBracketForUniformBuffer?: boolean;
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1168. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1169. /** @hidden */
  1170. export class ShaderCodeNode {
  1171. line: string;
  1172. children: ShaderCodeNode[];
  1173. additionalDefineKey?: string;
  1174. additionalDefineValue?: string;
  1175. isValid(preprocessors: {
  1176. [key: string]: string;
  1177. }): boolean;
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1184. /** @hidden */
  1185. export class ShaderCodeCursor {
  1186. private _lines;
  1187. lineIndex: number;
  1188. get currentLine(): string;
  1189. get canRead(): boolean;
  1190. set lines(value: string[]);
  1191. }
  1192. }
  1193. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1194. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1195. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1196. /** @hidden */
  1197. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1198. process(preprocessors: {
  1199. [key: string]: string;
  1200. }, options: ProcessingOptions): string;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1204. /** @hidden */
  1205. export class ShaderDefineExpression {
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. private static _OperatorPriority;
  1210. private static _Stack;
  1211. static postfixToInfix(postfix: string[]): string;
  1212. static infixToPostfix(infix: string): string[];
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. 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>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. 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;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. 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;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. import { WebRequest } from "babylonjs/Misc/webRequest";
  1474. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1477. /** @hidden */
  1478. export class ShaderProcessor {
  1479. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1480. private static _ProcessPrecision;
  1481. private static _ExtractOperation;
  1482. private static _BuildSubExpression;
  1483. private static _BuildExpression;
  1484. private static _MoveCursorWithinIf;
  1485. private static _MoveCursor;
  1486. private static _EvaluatePreProcessors;
  1487. private static _PreparePreProcessors;
  1488. private static _ProcessShaderConversion;
  1489. private static _ProcessIncludes;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. * @hidden
  1500. */
  1501. 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;
  1502. }
  1503. }
  1504. declare module "babylonjs/Maths/math.like" {
  1505. import { float, int, DeepImmutable } from "babylonjs/types";
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IColor4Like {
  1510. r: float;
  1511. g: float;
  1512. b: float;
  1513. a: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IColor3Like {
  1519. r: float;
  1520. g: float;
  1521. b: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector4Like {
  1527. x: float;
  1528. y: float;
  1529. z: float;
  1530. w: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector3Like {
  1536. x: float;
  1537. y: float;
  1538. z: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector2Like {
  1544. x: float;
  1545. y: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IMatrixLike {
  1551. toArray(): DeepImmutable<Float32Array>;
  1552. updateFlag: int;
  1553. }
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IViewportLike {
  1558. x: float;
  1559. y: float;
  1560. width: float;
  1561. height: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IPlaneLike {
  1567. normal: IVector3Like;
  1568. d: float;
  1569. normalize(): void;
  1570. }
  1571. }
  1572. declare module "babylonjs/Materials/iEffectFallbacks" {
  1573. import { Effect } from "babylonjs/Materials/effect";
  1574. /**
  1575. * Interface used to define common properties for effect fallbacks
  1576. */
  1577. export interface IEffectFallbacks {
  1578. /**
  1579. * Removes the defines that should be removed when falling back.
  1580. * @param currentDefines defines the current define statements for the shader.
  1581. * @param effect defines the current effect we try to compile
  1582. * @returns The resulting defines with defines of the current rank removed.
  1583. */
  1584. reduce(currentDefines: string, effect: Effect): string;
  1585. /**
  1586. * Removes the fallback from the bound mesh.
  1587. */
  1588. unBindMesh(): void;
  1589. /**
  1590. * Checks to see if more fallbacks are still availible.
  1591. */
  1592. hasMoreFallbacks: boolean;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1596. /**
  1597. * Class used to evalaute queries containing `and` and `or` operators
  1598. */
  1599. export class AndOrNotEvaluator {
  1600. /**
  1601. * Evaluate a query
  1602. * @param query defines the query to evaluate
  1603. * @param evaluateCallback defines the callback used to filter result
  1604. * @returns true if the query matches
  1605. */
  1606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1607. private static _HandleParenthesisContent;
  1608. private static _SimplifyNegation;
  1609. }
  1610. }
  1611. declare module "babylonjs/Misc/tags" {
  1612. /**
  1613. * Class used to store custom tags
  1614. */
  1615. export class Tags {
  1616. /**
  1617. * Adds support for tags on the given object
  1618. * @param obj defines the object to use
  1619. */
  1620. static EnableFor(obj: any): void;
  1621. /**
  1622. * Removes tags support
  1623. * @param obj defines the object to use
  1624. */
  1625. static DisableFor(obj: any): void;
  1626. /**
  1627. * Gets a boolean indicating if the given object has tags
  1628. * @param obj defines the object to use
  1629. * @returns a boolean
  1630. */
  1631. static HasTags(obj: any): boolean;
  1632. /**
  1633. * Gets the tags available on a given object
  1634. * @param obj defines the object to use
  1635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1636. * @returns the tags
  1637. */
  1638. static GetTags(obj: any, asString?: boolean): any;
  1639. /**
  1640. * Adds tags to an object
  1641. * @param obj defines the object to use
  1642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1644. */
  1645. static AddTagsTo(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _AddTagTo(obj: any, tag: string): void;
  1650. /**
  1651. * Removes specific tags from a specific object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tags to remove
  1654. */
  1655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1656. /**
  1657. * @hidden
  1658. */
  1659. static _RemoveTagFrom(obj: any, tag: string): void;
  1660. /**
  1661. * Defines if tags hosted on an object match a given query
  1662. * @param obj defines the object to use
  1663. * @param tagsQuery defines the tag query
  1664. * @returns a boolean
  1665. */
  1666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1667. }
  1668. }
  1669. declare module "babylonjs/Maths/math.scalar" {
  1670. /**
  1671. * Scalar computation library
  1672. */
  1673. export class Scalar {
  1674. /**
  1675. * Two pi constants convenient for computation.
  1676. */
  1677. static TwoPi: number;
  1678. /**
  1679. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1680. * @param a number
  1681. * @param b number
  1682. * @param epsilon (default = 1.401298E-45)
  1683. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1684. */
  1685. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1686. /**
  1687. * Returns a string : the upper case translation of the number i to hexadecimal.
  1688. * @param i number
  1689. * @returns the upper case translation of the number i to hexadecimal.
  1690. */
  1691. static ToHex(i: number): string;
  1692. /**
  1693. * Returns -1 if value is negative and +1 is value is positive.
  1694. * @param value the value
  1695. * @returns the value itself if it's equal to zero.
  1696. */
  1697. static Sign(value: number): number;
  1698. /**
  1699. * Returns the value itself if it's between min and max.
  1700. * Returns min if the value is lower than min.
  1701. * Returns max if the value is greater than max.
  1702. * @param value the value to clmap
  1703. * @param min the min value to clamp to (default: 0)
  1704. * @param max the max value to clamp to (default: 1)
  1705. * @returns the clamped value
  1706. */
  1707. static Clamp(value: number, min?: number, max?: number): number;
  1708. /**
  1709. * the log2 of value.
  1710. * @param value the value to compute log2 of
  1711. * @returns the log2 of value.
  1712. */
  1713. static Log2(value: number): number;
  1714. /**
  1715. * Loops the value, so that it is never larger than length and never smaller than 0.
  1716. *
  1717. * This is similar to the modulo operator but it works with floating point numbers.
  1718. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1719. * With t = 5 and length = 2.5, the result would be 0.0.
  1720. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1721. * @param value the value
  1722. * @param length the length
  1723. * @returns the looped value
  1724. */
  1725. static Repeat(value: number, length: number): number;
  1726. /**
  1727. * Normalize the value between 0.0 and 1.0 using min and max values
  1728. * @param value value to normalize
  1729. * @param min max to normalize between
  1730. * @param max min to normalize between
  1731. * @returns the normalized value
  1732. */
  1733. static Normalize(value: number, min: number, max: number): number;
  1734. /**
  1735. * Denormalize the value from 0.0 and 1.0 using min and max values
  1736. * @param normalized value to denormalize
  1737. * @param min max to denormalize between
  1738. * @param max min to denormalize between
  1739. * @returns the denormalized value
  1740. */
  1741. static Denormalize(normalized: number, min: number, max: number): number;
  1742. /**
  1743. * Calculates the shortest difference between two given angles given in degrees.
  1744. * @param current current angle in degrees
  1745. * @param target target angle in degrees
  1746. * @returns the delta
  1747. */
  1748. static DeltaAngle(current: number, target: number): number;
  1749. /**
  1750. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1751. * @param tx value
  1752. * @param length length
  1753. * @returns The returned value will move back and forth between 0 and length
  1754. */
  1755. static PingPong(tx: number, length: number): number;
  1756. /**
  1757. * Interpolates between min and max with smoothing at the limits.
  1758. *
  1759. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1760. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1761. * @param from from
  1762. * @param to to
  1763. * @param tx value
  1764. * @returns the smooth stepped value
  1765. */
  1766. static SmoothStep(from: number, to: number, tx: number): number;
  1767. /**
  1768. * Moves a value current towards target.
  1769. *
  1770. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1771. * Negative values of maxDelta pushes the value away from target.
  1772. * @param current current value
  1773. * @param target target value
  1774. * @param maxDelta max distance to move
  1775. * @returns resulting value
  1776. */
  1777. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1778. /**
  1779. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1780. *
  1781. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1782. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting angle
  1787. */
  1788. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1791. * @param start start value
  1792. * @param end target value
  1793. * @param amount amount to lerp between
  1794. * @returns the lerped value
  1795. */
  1796. static Lerp(start: number, end: number, amount: number): number;
  1797. /**
  1798. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1800. * @param start start value
  1801. * @param end target value
  1802. * @param amount amount to lerp between
  1803. * @returns the lerped value
  1804. */
  1805. static LerpAngle(start: number, end: number, amount: number): number;
  1806. /**
  1807. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1808. * @param a start value
  1809. * @param b target value
  1810. * @param value value between a and b
  1811. * @returns the inverseLerp value
  1812. */
  1813. static InverseLerp(a: number, b: number, value: number): number;
  1814. /**
  1815. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1816. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1817. * @param value1 spline value
  1818. * @param tangent1 spline value
  1819. * @param value2 spline value
  1820. * @param tangent2 spline value
  1821. * @param amount input value
  1822. * @returns hermite result
  1823. */
  1824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1825. /**
  1826. * Returns a random float number between and min and max values
  1827. * @param min min value of random
  1828. * @param max max value of random
  1829. * @returns random value
  1830. */
  1831. static RandomRange(min: number, max: number): number;
  1832. /**
  1833. * This function returns percentage of a number in a given range.
  1834. *
  1835. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1836. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1837. * @param number to convert to percentage
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the percentage
  1841. */
  1842. static RangeToPercent(number: number, min: number, max: number): number;
  1843. /**
  1844. * This function returns number that corresponds to the percentage in a given range.
  1845. *
  1846. * PercentToRange(0.34,0,100) will return 34.
  1847. * @param percent to convert to number
  1848. * @param min min range
  1849. * @param max max range
  1850. * @returns the number
  1851. */
  1852. static PercentToRange(percent: number, min: number, max: number): number;
  1853. /**
  1854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1855. * @param angle The angle to normalize in radian.
  1856. * @return The converted angle.
  1857. */
  1858. static NormalizeRadians(angle: number): number;
  1859. }
  1860. }
  1861. declare module "babylonjs/Maths/math.constants" {
  1862. /**
  1863. * Constant used to convert a value to gamma space
  1864. * @ignorenaming
  1865. */
  1866. export const ToGammaSpace: number;
  1867. /**
  1868. * Constant used to convert a value to linear space
  1869. * @ignorenaming
  1870. */
  1871. export const ToLinearSpace = 2.2;
  1872. /**
  1873. * Constant used to define the minimal number value in Babylon.js
  1874. * @ignorenaming
  1875. */
  1876. let Epsilon: number;
  1877. export { Epsilon };
  1878. }
  1879. declare module "babylonjs/Maths/math.viewport" {
  1880. /**
  1881. * Class used to represent a viewport on screen
  1882. */
  1883. export class Viewport {
  1884. /** viewport left coordinate */
  1885. x: number;
  1886. /** viewport top coordinate */
  1887. y: number;
  1888. /**viewport width */
  1889. width: number;
  1890. /** viewport height */
  1891. height: number;
  1892. /**
  1893. * Creates a Viewport object located at (x, y) and sized (width, height)
  1894. * @param x defines viewport left coordinate
  1895. * @param y defines viewport top coordinate
  1896. * @param width defines the viewport width
  1897. * @param height defines the viewport height
  1898. */
  1899. constructor(
  1900. /** viewport left coordinate */
  1901. x: number,
  1902. /** viewport top coordinate */
  1903. y: number,
  1904. /**viewport width */
  1905. width: number,
  1906. /** viewport height */
  1907. height: number);
  1908. /**
  1909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1910. * @param renderWidth defines the rendering width
  1911. * @param renderHeight defines the rendering height
  1912. * @returns a new Viewport
  1913. */
  1914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1915. /**
  1916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1917. * @param renderWidth defines the rendering width
  1918. * @param renderHeight defines the rendering height
  1919. * @param ref defines the target viewport
  1920. * @returns the current viewport
  1921. */
  1922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1923. /**
  1924. * Returns a new Viewport copied from the current one
  1925. * @returns a new Viewport
  1926. */
  1927. clone(): Viewport;
  1928. }
  1929. }
  1930. declare module "babylonjs/Misc/arrayTools" {
  1931. /**
  1932. * Class containing a set of static utilities functions for arrays.
  1933. */
  1934. export class ArrayTools {
  1935. /**
  1936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1937. * @param size the number of element to construct and put in the array
  1938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1939. * @returns a new array filled with new objects
  1940. */
  1941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1942. }
  1943. }
  1944. declare module "babylonjs/Maths/math.plane" {
  1945. import { DeepImmutable } from "babylonjs/types";
  1946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1947. /**
  1948. * Represents a plane by the equation ax + by + cz + d = 0
  1949. */
  1950. export class Plane {
  1951. private static _TmpMatrix;
  1952. /**
  1953. * Normal of the plane (a,b,c)
  1954. */
  1955. normal: Vector3;
  1956. /**
  1957. * d component of the plane
  1958. */
  1959. d: number;
  1960. /**
  1961. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1962. * @param a a component of the plane
  1963. * @param b b component of the plane
  1964. * @param c c component of the plane
  1965. * @param d d component of the plane
  1966. */
  1967. constructor(a: number, b: number, c: number, d: number);
  1968. /**
  1969. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * @returns a new plane copied from the current Plane.
  1974. */
  1975. clone(): Plane;
  1976. /**
  1977. * @returns the string "Plane".
  1978. */
  1979. getClassName(): string;
  1980. /**
  1981. * @returns the Plane hash code.
  1982. */
  1983. getHashCode(): number;
  1984. /**
  1985. * Normalize the current Plane in place.
  1986. * @returns the updated Plane.
  1987. */
  1988. normalize(): Plane;
  1989. /**
  1990. * Applies a transformation the plane and returns the result
  1991. * @param transformation the transformation matrix to be applied to the plane
  1992. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1993. */
  1994. transform(transformation: DeepImmutable<Matrix>): Plane;
  1995. /**
  1996. * Compute the dot product between the point and the plane normal
  1997. * @param point point to calculate the dot product with
  1998. * @returns the dot product (float) of the point coordinates and the plane normal.
  1999. */
  2000. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2001. /**
  2002. * Updates the current Plane from the plane defined by the three given points.
  2003. * @param point1 one of the points used to contruct the plane
  2004. * @param point2 one of the points used to contruct the plane
  2005. * @param point3 one of the points used to contruct the plane
  2006. * @returns the updated Plane.
  2007. */
  2008. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2009. /**
  2010. * Checks if the plane is facing a given direction
  2011. * @param direction the direction to check if the plane is facing
  2012. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2013. * @returns True is the vector "direction" is the same side than the plane normal.
  2014. */
  2015. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2016. /**
  2017. * Calculates the distance to a point
  2018. * @param point point to calculate distance to
  2019. * @returns the signed distance (float) from the given point to the Plane.
  2020. */
  2021. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2022. /**
  2023. * Creates a plane from an array
  2024. * @param array the array to create a plane from
  2025. * @returns a new Plane from the given array.
  2026. */
  2027. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2028. /**
  2029. * Creates a plane from three points
  2030. * @param point1 point used to create the plane
  2031. * @param point2 point used to create the plane
  2032. * @param point3 point used to create the plane
  2033. * @returns a new Plane defined by the three given points.
  2034. */
  2035. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Creates a plane from an origin point and a normal
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @returns a new Plane the normal vector to this plane at the given origin point.
  2041. * Note : the vector "normal" is updated because normalized.
  2042. */
  2043. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Calculates the distance from a plane and a point
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @param point point to calculate distance to
  2049. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2050. */
  2051. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2052. }
  2053. }
  2054. declare module "babylonjs/Maths/math.vector" {
  2055. import { Viewport } from "babylonjs/Maths/math.viewport";
  2056. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2057. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2058. import { Plane } from "babylonjs/Maths/math.plane";
  2059. /**
  2060. * Class representing a vector containing 2 coordinates
  2061. */
  2062. export class Vector2 {
  2063. /** defines the first coordinate */
  2064. x: number;
  2065. /** defines the second coordinate */
  2066. y: number;
  2067. /**
  2068. * Creates a new Vector2 from the given x and y coordinates
  2069. * @param x defines the first coordinate
  2070. * @param y defines the second coordinate
  2071. */
  2072. constructor(
  2073. /** defines the first coordinate */
  2074. x?: number,
  2075. /** defines the second coordinate */
  2076. y?: number);
  2077. /**
  2078. * Gets a string with the Vector2 coordinates
  2079. * @returns a string with the Vector2 coordinates
  2080. */
  2081. toString(): string;
  2082. /**
  2083. * Gets class name
  2084. * @returns the string "Vector2"
  2085. */
  2086. getClassName(): string;
  2087. /**
  2088. * Gets current vector hash code
  2089. * @returns the Vector2 hash code as a number
  2090. */
  2091. getHashCode(): number;
  2092. /**
  2093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2094. * @param array defines the source array
  2095. * @param index defines the offset in source array
  2096. * @returns the current Vector2
  2097. */
  2098. toArray(array: FloatArray, index?: number): Vector2;
  2099. /**
  2100. * Copy the current vector to an array
  2101. * @returns a new array with 2 elements: the Vector2 coordinates.
  2102. */
  2103. asArray(): number[];
  2104. /**
  2105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2106. * @param source defines the source Vector2
  2107. * @returns the current updated Vector2
  2108. */
  2109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2110. /**
  2111. * Sets the Vector2 coordinates with the given floats
  2112. * @param x defines the first coordinate
  2113. * @param y defines the second coordinate
  2114. * @returns the current updated Vector2
  2115. */
  2116. copyFromFloats(x: number, y: number): Vector2;
  2117. /**
  2118. * Sets the Vector2 coordinates with the given floats
  2119. * @param x defines the first coordinate
  2120. * @param y defines the second coordinate
  2121. * @returns the current updated Vector2
  2122. */
  2123. set(x: number, y: number): Vector2;
  2124. /**
  2125. * Add another vector with the current one
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2128. */
  2129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @param result defines the target vector
  2134. * @returns the unmodified current Vector2
  2135. */
  2136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2137. /**
  2138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2139. * @param otherVector defines the other vector
  2140. * @returns the current updated Vector2
  2141. */
  2142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns a new Vector2
  2147. */
  2148. addVector3(otherVector: Vector3): Vector2;
  2149. /**
  2150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2151. * @param otherVector defines the other vector
  2152. * @returns a new Vector2
  2153. */
  2154. subtract(otherVector: Vector2): Vector2;
  2155. /**
  2156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2157. * @param otherVector defines the other vector
  2158. * @param result defines the target vector
  2159. * @returns the unmodified current Vector2
  2160. */
  2161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2162. /**
  2163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @returns the current updated Vector2
  2166. */
  2167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Multiplies in place the current Vector2 coordinates by the given ones
  2170. * @param otherVector defines the other vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2176. * @param otherVector defines the other vector
  2177. * @returns a new Vector2
  2178. */
  2179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2182. * @param otherVector defines the other vector
  2183. * @param result defines the target vector
  2184. * @returns the unmodified current Vector2
  2185. */
  2186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns a new Vector2
  2192. */
  2193. multiplyByFloats(x: number, y: number): Vector2;
  2194. /**
  2195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2
  2198. */
  2199. divide(otherVector: Vector2): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Divides the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 with current Vector2 negated coordinates
  2215. * @returns a new Vector2
  2216. */
  2217. negate(): Vector2;
  2218. /**
  2219. * Negate this vector in place
  2220. * @returns this
  2221. */
  2222. negateInPlace(): Vector2;
  2223. /**
  2224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2225. * @param result defines the Vector3 object where to store the result
  2226. * @returns the current Vector2
  2227. */
  2228. negateToRef(result: Vector2): Vector2;
  2229. /**
  2230. * Multiply the Vector2 coordinates by scale
  2231. * @param scale defines the scaling factor
  2232. * @returns the current updated Vector2
  2233. */
  2234. scaleInPlace(scale: number): Vector2;
  2235. /**
  2236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2237. * @param scale defines the scaling factor
  2238. * @returns a new Vector2
  2239. */
  2240. scale(scale: number): Vector2;
  2241. /**
  2242. * Scale the current Vector2 values by a factor to a given Vector2
  2243. * @param scale defines the scale factor
  2244. * @param result defines the Vector2 object where to store the result
  2245. * @returns the unmodified current Vector2
  2246. */
  2247. scaleToRef(scale: number, result: Vector2): Vector2;
  2248. /**
  2249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2250. * @param scale defines the scale factor
  2251. * @param result defines the Vector2 object where to store the result
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a boolean if two vectors are equals
  2257. * @param otherVector defines the other vector
  2258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2259. */
  2260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2261. /**
  2262. * Gets a boolean if two vectors are equals (using an epsilon value)
  2263. * @param otherVector defines the other vector
  2264. * @param epsilon defines the minimal distance to consider equality
  2265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2266. */
  2267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2268. /**
  2269. * Gets a new Vector2 from current Vector2 floored values
  2270. * @returns a new Vector2
  2271. */
  2272. floor(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 from current Vector2 floored values
  2275. * @returns a new Vector2
  2276. */
  2277. fract(): Vector2;
  2278. /**
  2279. * Gets the length of the vector
  2280. * @returns the vector length (float)
  2281. */
  2282. length(): number;
  2283. /**
  2284. * Gets the vector squared length
  2285. * @returns the vector squared length (float)
  2286. */
  2287. lengthSquared(): number;
  2288. /**
  2289. * Normalize the vector
  2290. * @returns the current updated Vector2
  2291. */
  2292. normalize(): Vector2;
  2293. /**
  2294. * Gets a new Vector2 copied from the Vector2
  2295. * @returns a new Vector2
  2296. */
  2297. clone(): Vector2;
  2298. /**
  2299. * Gets a new Vector2(0, 0)
  2300. * @returns a new Vector2
  2301. */
  2302. static Zero(): Vector2;
  2303. /**
  2304. * Gets a new Vector2(1, 1)
  2305. * @returns a new Vector2
  2306. */
  2307. static One(): Vector2;
  2308. /**
  2309. * Gets a new Vector2 set from the given index element of the given array
  2310. * @param array defines the data source
  2311. * @param offset defines the offset in the data source
  2312. * @returns a new Vector2
  2313. */
  2314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2315. /**
  2316. * Sets "result" from the given index element of the given array
  2317. * @param array defines the data source
  2318. * @param offset defines the offset in the data source
  2319. * @param result defines the target vector
  2320. */
  2321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2322. /**
  2323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2324. * @param value1 defines 1st point of control
  2325. * @param value2 defines 2nd point of control
  2326. * @param value3 defines 3rd point of control
  2327. * @param value4 defines 4th point of control
  2328. * @param amount defines the interpolation factor
  2329. * @returns a new Vector2
  2330. */
  2331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2332. /**
  2333. * 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".
  2334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2336. * @param value defines the value to clamp
  2337. * @param min defines the lower limit
  2338. * @param max defines the upper limit
  2339. * @returns a new Vector2
  2340. */
  2341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2342. /**
  2343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2344. * @param value1 defines the 1st control point
  2345. * @param tangent1 defines the outgoing tangent
  2346. * @param value2 defines the 2nd control point
  2347. * @param tangent2 defines the incoming tangent
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2354. * @param start defines the start vector
  2355. * @param end defines the end vector
  2356. * @param amount defines the interpolation factor
  2357. * @returns a new Vector2
  2358. */
  2359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2360. /**
  2361. * Gets the dot product of the vector "left" and the vector "right"
  2362. * @param left defines first vector
  2363. * @param right defines second vector
  2364. * @returns the dot product (float)
  2365. */
  2366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2367. /**
  2368. * Returns a new Vector2 equal to the normalized given vector
  2369. * @param vector defines the vector to normalize
  2370. * @returns a new Vector2
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2373. /**
  2374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2375. * @param left defines 1st vector
  2376. * @param right defines 2nd vector
  2377. * @returns a new Vector2
  2378. */
  2379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2380. /**
  2381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2382. * @param left defines 1st vector
  2383. * @param right defines 2nd vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2389. * @param vector defines the vector to transform
  2390. * @param transformation defines the matrix to apply
  2391. * @returns a new Vector2
  2392. */
  2393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2394. /**
  2395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2396. * @param vector defines the vector to transform
  2397. * @param transformation defines the matrix to apply
  2398. * @param result defines the target vector
  2399. */
  2400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2401. /**
  2402. * Determines if a given vector is included in a triangle
  2403. * @param p defines the vector to test
  2404. * @param p0 defines 1st triangle point
  2405. * @param p1 defines 2nd triangle point
  2406. * @param p2 defines 3rd triangle point
  2407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2408. */
  2409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2410. /**
  2411. * Gets the distance between the vectors "value1" and "value2"
  2412. * @param value1 defines first vector
  2413. * @param value2 defines second vector
  2414. * @returns the distance between vectors
  2415. */
  2416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2417. /**
  2418. * Returns the squared distance between the vectors "value1" and "value2"
  2419. * @param value1 defines first vector
  2420. * @param value2 defines second vector
  2421. * @returns the squared distance between vectors
  2422. */
  2423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2424. /**
  2425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2426. * @param value1 defines first vector
  2427. * @param value2 defines second vector
  2428. * @returns a new Vector2
  2429. */
  2430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2433. * @param p defines the middle point
  2434. * @param segA defines one point of the segment
  2435. * @param segB defines the other point of the segment
  2436. * @returns the shortest distance
  2437. */
  2438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2439. }
  2440. /**
  2441. * Class used to store (x,y,z) vector representation
  2442. * A Vector3 is the main object used in 3D geometry
  2443. * It can represent etiher the coordinates of a point the space, either a direction
  2444. * Reminder: js uses a left handed forward facing system
  2445. */
  2446. export class Vector3 {
  2447. /**
  2448. * Defines the first coordinates (on X axis)
  2449. */
  2450. x: number;
  2451. /**
  2452. * Defines the second coordinates (on Y axis)
  2453. */
  2454. y: number;
  2455. /**
  2456. * Defines the third coordinates (on Z axis)
  2457. */
  2458. z: number;
  2459. private static _UpReadOnly;
  2460. private static _ZeroReadOnly;
  2461. /**
  2462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2463. * @param x defines the first coordinates (on X axis)
  2464. * @param y defines the second coordinates (on Y axis)
  2465. * @param z defines the third coordinates (on Z axis)
  2466. */
  2467. constructor(
  2468. /**
  2469. * Defines the first coordinates (on X axis)
  2470. */
  2471. x?: number,
  2472. /**
  2473. * Defines the second coordinates (on Y axis)
  2474. */
  2475. y?: number,
  2476. /**
  2477. * Defines the third coordinates (on Z axis)
  2478. */
  2479. z?: number);
  2480. /**
  2481. * Creates a string representation of the Vector3
  2482. * @returns a string with the Vector3 coordinates.
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name
  2487. * @returns the string "Vector3"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Creates the Vector3 hash code
  2492. * @returns a number which tends to be unique between Vector3 instances
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Creates an array containing three elements : the coordinates of the Vector3
  2497. * @returns a new array of numbers
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2502. * @param array defines the destination array
  2503. * @param index defines the offset in the destination array
  2504. * @returns the current Vector3
  2505. */
  2506. toArray(array: FloatArray, index?: number): Vector3;
  2507. /**
  2508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2510. */
  2511. toQuaternion(): Quaternion;
  2512. /**
  2513. * Adds the given vector to the current Vector3
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Adds the given coordinates to the current Vector3
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the current updated Vector3
  2524. */
  2525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2528. * @param otherVector defines the second operand
  2529. * @returns the resulting Vector3
  2530. */
  2531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Subtract the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2547. * @param otherVector defines the second operand
  2548. * @returns the resulting Vector3
  2549. */
  2550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2553. * @param otherVector defines the second operand
  2554. * @param result defines the Vector3 object where to store the result
  2555. * @returns the current Vector3
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2566. /**
  2567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2568. * @param x defines the x coordinate of the operand
  2569. * @param y defines the y coordinate of the operand
  2570. * @param z defines the z coordinate of the operand
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the current Vector3
  2573. */
  2574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2575. /**
  2576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2577. * @returns a new Vector3
  2578. */
  2579. negate(): Vector3;
  2580. /**
  2581. * Negate this vector in place
  2582. * @returns this
  2583. */
  2584. negateInPlace(): Vector3;
  2585. /**
  2586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the current Vector3
  2589. */
  2590. negateToRef(result: Vector3): Vector3;
  2591. /**
  2592. * Multiplies the Vector3 coordinates by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns the current updated Vector3
  2595. */
  2596. scaleInPlace(scale: number): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2599. * @param scale defines the multiplier factor
  2600. * @returns a new Vector3
  2601. */
  2602. scale(scale: number): Vector3;
  2603. /**
  2604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2605. * @param scale defines the multiplier factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the current Vector3
  2608. */
  2609. scaleToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2612. * @param scale defines the scale factor
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the unmodified current Vector3
  2615. */
  2616. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2617. /**
  2618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2619. * @param origin defines the origin of the projection ray
  2620. * @param plane defines the plane to project to
  2621. * @returns the projected vector3
  2622. */
  2623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2624. /**
  2625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2626. * @param origin defines the origin of the projection ray
  2627. * @param plane defines the plane to project to
  2628. * @param result defines the Vector3 where to store the result
  2629. */
  2630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2633. * @param otherVector defines the second operand
  2634. * @returns true if both vectors are equals
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2639. * @param otherVector defines the second operand
  2640. * @param epsilon defines the minimal distance to define values as equals
  2641. * @returns true if both vectors are distant less than epsilon
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2644. /**
  2645. * Returns true if the current Vector3 coordinates equals the given floats
  2646. * @param x defines the x coordinate of the operand
  2647. * @param y defines the y coordinate of the operand
  2648. * @param z defines the z coordinate of the operand
  2649. * @returns true if both vectors are equals
  2650. */
  2651. equalsToFloats(x: number, y: number, z: number): boolean;
  2652. /**
  2653. * Multiplies the current Vector3 coordinates by the given ones
  2654. * @param otherVector defines the second operand
  2655. * @returns the current updated Vector3
  2656. */
  2657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2660. * @param otherVector defines the second operand
  2661. * @returns the new Vector3
  2662. */
  2663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2666. * @param otherVector defines the second operand
  2667. * @param result defines the Vector3 object where to store the result
  2668. * @returns the current Vector3
  2669. */
  2670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the new Vector3
  2677. */
  2678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2681. * @param otherVector defines the second operand
  2682. * @returns the new Vector3
  2683. */
  2684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2687. * @param otherVector defines the second operand
  2688. * @param result defines the Vector3 object where to store the result
  2689. * @returns the current Vector3
  2690. */
  2691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2692. /**
  2693. * Divides the current Vector3 coordinates by the given ones.
  2694. * @param otherVector defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. divideInPlace(otherVector: Vector3): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2706. * @param other defines the second operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  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 current updated Vector3
  2716. */
  2717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2720. * @param x defines the x coordinate of the operand
  2721. * @param y defines the y coordinate of the operand
  2722. * @param z defines the z coordinate of the operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2726. /**
  2727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2728. * Check if is non uniform within a certain amount of decimal places to account for this
  2729. * @param epsilon the amount the values can differ
  2730. * @returns if the the vector is non uniform to a certain number of decimal places
  2731. */
  2732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2733. /**
  2734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2735. */
  2736. get isNonUniform(): boolean;
  2737. /**
  2738. * Gets a new Vector3 from current Vector3 floored values
  2739. * @returns a new Vector3
  2740. */
  2741. floor(): Vector3;
  2742. /**
  2743. * Gets a new Vector3 from current Vector3 floored values
  2744. * @returns a new Vector3
  2745. */
  2746. fract(): Vector3;
  2747. /**
  2748. * Gets the length of the Vector3
  2749. * @returns the length of the Vector3
  2750. */
  2751. length(): number;
  2752. /**
  2753. * Gets the squared length of the Vector3
  2754. * @returns squared length of the Vector3
  2755. */
  2756. lengthSquared(): number;
  2757. /**
  2758. * Normalize the current Vector3.
  2759. * Please note that this is an in place operation.
  2760. * @returns the current updated Vector3
  2761. */
  2762. normalize(): Vector3;
  2763. /**
  2764. * Reorders the x y z properties of the vector in place
  2765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2766. * @returns the current updated vector
  2767. */
  2768. reorderInPlace(order: string): this;
  2769. /**
  2770. * Rotates the vector around 0,0,0 by a quaternion
  2771. * @param quaternion the rotation quaternion
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2776. /**
  2777. * Rotates a vector around a given point
  2778. * @param quaternion the rotation quaternion
  2779. * @param point the point to rotate around
  2780. * @param result vector to store the result
  2781. * @returns the resulting vector
  2782. */
  2783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2784. /**
  2785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2786. * The cross product is then orthogonal to both current and "other"
  2787. * @param other defines the right operand
  2788. * @returns the cross product
  2789. */
  2790. cross(other: Vector3): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 with the given input length.
  2793. * Please note that this is an in place operation.
  2794. * @param len the length of the vector
  2795. * @returns the current updated Vector3
  2796. */
  2797. normalizeFromLength(len: number): Vector3;
  2798. /**
  2799. * Normalize the current Vector3 to a new vector
  2800. * @returns the new Vector3
  2801. */
  2802. normalizeToNew(): Vector3;
  2803. /**
  2804. * Normalize the current Vector3 to the reference
  2805. * @param reference define the Vector3 to update
  2806. * @returns the updated Vector3
  2807. */
  2808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Creates a new Vector3 copied from the current Vector3
  2811. * @returns the new Vector3
  2812. */
  2813. clone(): Vector3;
  2814. /**
  2815. * Copies the given vector coordinates to the current Vector3 ones
  2816. * @param source defines the source Vector3
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. copyFromFloats(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given floats to the current Vector3 coordinates
  2830. * @param x defines the x coordinate of the operand
  2831. * @param y defines the y coordinate of the operand
  2832. * @param z defines the z coordinate of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. set(x: number, y: number, z: number): Vector3;
  2836. /**
  2837. * Copies the given float to the current Vector3 coordinates
  2838. * @param v defines the x, y and z coordinates of the operand
  2839. * @returns the current updated Vector3
  2840. */
  2841. setAll(v: number): Vector3;
  2842. /**
  2843. * Get the clip factor between two vectors
  2844. * @param vector0 defines the first operand
  2845. * @param vector1 defines the second operand
  2846. * @param axis defines the axis to use
  2847. * @param size defines the size along the axis
  2848. * @returns the clip factor
  2849. */
  2850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2851. /**
  2852. * Get angle between two vectors
  2853. * @param vector0 angle between vector0 and vector1
  2854. * @param vector1 angle between vector0 and vector1
  2855. * @param normal direction of the normal
  2856. * @return the angle between vector0 and vector1
  2857. */
  2858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. */
  2865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @returns the new Vector3
  2871. * @deprecated Please use FromArray instead.
  2872. */
  2873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2876. * @param array defines the source array
  2877. * @param offset defines the offset in the source array
  2878. * @param result defines the Vector3 where to store the result
  2879. */
  2880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @param result defines the Vector3 where to store the result
  2886. * @deprecated Please use FromArrayToRef instead.
  2887. */
  2888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2889. /**
  2890. * Sets the given vector "result" with the given floats.
  2891. * @param x defines the x coordinate of the source
  2892. * @param y defines the y coordinate of the source
  2893. * @param z defines the z coordinate of the source
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2899. * @returns a new empty Vector3
  2900. */
  2901. static Zero(): Vector3;
  2902. /**
  2903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2904. * @returns a new unit Vector3
  2905. */
  2906. static One(): Vector3;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2909. * @returns a new up Vector3
  2910. */
  2911. static Up(): Vector3;
  2912. /**
  2913. * Gets a up Vector3 that must not be updated
  2914. */
  2915. static get UpReadOnly(): DeepImmutable<Vector3>;
  2916. /**
  2917. * Gets a zero Vector3 that must not be updated
  2918. */
  2919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2922. * @returns a new down Vector3
  2923. */
  2924. static Down(): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Forward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2933. * @param rightHandedSystem is the scene right-handed (negative-z)
  2934. * @returns a new forward Vector3
  2935. */
  2936. static Backward(rightHandedSystem?: boolean): Vector3;
  2937. /**
  2938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2939. * @returns a new right Vector3
  2940. */
  2941. static Right(): Vector3;
  2942. /**
  2943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2944. * @returns a new left Vector3
  2945. */
  2946. static Left(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the transformed Vector3
  2953. */
  2954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2965. * This method computes tranformed coordinates only, not transformed direction vectors
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the new Vector3
  2979. */
  2980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3001. * @param value1 defines the first control point
  3002. * @param value2 defines the second control point
  3003. * @param value3 defines the third control point
  3004. * @param value4 defines the fourth control point
  3005. * @param amount defines the amount on the spline to use
  3006. * @returns the new Vector3
  3007. */
  3008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3009. /**
  3010. * 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"
  3011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3013. * @param value defines the current value
  3014. * @param min defines the lower range value
  3015. * @param max defines the upper range value
  3016. * @returns the new Vector3
  3017. */
  3018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3019. /**
  3020. * 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"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @param result defines the Vector3 where to store the result
  3027. */
  3028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3029. /**
  3030. * Checks if a given vector is inside a specific range
  3031. * @param v defines the vector to test
  3032. * @param min defines the minimum range
  3033. * @param max defines the maximum range
  3034. */
  3035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3036. /**
  3037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3038. * @param value1 defines the first control point
  3039. * @param tangent1 defines the first tangent vector
  3040. * @param value2 defines the second control point
  3041. * @param tangent2 defines the second tangent vector
  3042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @returns the new Vector3
  3052. */
  3053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3054. /**
  3055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3056. * @param start defines the start value
  3057. * @param end defines the end value
  3058. * @param amount max defines amount between both (between 0 and 1)
  3059. * @param result defines the Vector3 where to store the result
  3060. */
  3061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3062. /**
  3063. * Returns the dot product (float) between the vectors "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the dot product
  3067. */
  3068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3069. /**
  3070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @returns the cross product
  3075. */
  3076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the cross product of "left" and "right"
  3079. * The cross product is then orthogonal to both "left" and "right"
  3080. * @param left defines the left operand
  3081. * @param right defines the right operand
  3082. * @param result defines the Vector3 where to store the result
  3083. */
  3084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3085. /**
  3086. * Returns a new Vector3 as the normalization of the given vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @returns the new Vector3
  3089. */
  3090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the normalization of the given first vector
  3093. * @param vector defines the Vector3 to normalize
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Project a Vector3 onto screen space
  3099. * @param vector defines the Vector3 to project
  3100. * @param world defines the world matrix to use
  3101. * @param transform defines the transform (view x projection) matrix to use
  3102. * @param viewport defines the screen viewport to use
  3103. * @returns the new Vector3
  3104. */
  3105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3106. /** @hidden */
  3107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3108. /**
  3109. * Unproject from screen space to object space
  3110. * @param source defines the screen space Vector3 to use
  3111. * @param viewportWidth defines the current width of the viewport
  3112. * @param viewportHeight defines the current height of the viewport
  3113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3114. * @param transform defines the transform (view x projection) matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @returns the new Vector3
  3127. */
  3128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param source defines the screen space Vector3 to use
  3132. * @param viewportWidth defines the current width of the viewport
  3133. * @param viewportHeight defines the current height of the viewport
  3134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3135. * @param view defines the view matrix to use
  3136. * @param projection defines the projection matrix to use
  3137. * @param result defines the Vector3 where to store the result
  3138. */
  3139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param sourceX defines the screen space x coordinate to use
  3143. * @param sourceY defines the screen space y coordinate to use
  3144. * @param sourceZ defines the screen space z coordinate to use
  3145. * @param viewportWidth defines the current width of the viewport
  3146. * @param viewportHeight defines the current height of the viewport
  3147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3148. * @param view defines the view matrix to use
  3149. * @param projection defines the projection matrix to use
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3153. /**
  3154. * Gets the minimal coordinate values between two Vector3
  3155. * @param left defines the first operand
  3156. * @param right defines the second operand
  3157. * @returns the new Vector3
  3158. */
  3159. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Gets the maximal coordinate values between two Vector3
  3162. * @param left defines the first operand
  3163. * @param right defines the second operand
  3164. * @returns the new Vector3
  3165. */
  3166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3167. /**
  3168. * Returns the distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the distance
  3172. */
  3173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns the squared distance between the vectors "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the squared distance
  3179. */
  3180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3181. /**
  3182. * Returns a new Vector3 located at the center between "value1" and "value2"
  3183. * @param value1 defines the first operand
  3184. * @param value2 defines the second operand
  3185. * @returns the new Vector3
  3186. */
  3187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3191. * to something in order to rotate it from its local system to the given target system
  3192. * Note: axis1, axis2 and axis3 are normalized during this operation
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @returns a new Vector3
  3197. */
  3198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3201. * @param axis1 defines the first axis
  3202. * @param axis2 defines the second axis
  3203. * @param axis3 defines the third axis
  3204. * @param ref defines the Vector3 where to store the result
  3205. */
  3206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3207. }
  3208. /**
  3209. * Vector4 class created for EulerAngle class conversion to Quaternion
  3210. */
  3211. export class Vector4 {
  3212. /** x value of the vector */
  3213. x: number;
  3214. /** y value of the vector */
  3215. y: number;
  3216. /** z value of the vector */
  3217. z: number;
  3218. /** w value of the vector */
  3219. w: number;
  3220. /**
  3221. * Creates a Vector4 object from the given floats.
  3222. * @param x x value of the vector
  3223. * @param y y value of the vector
  3224. * @param z z value of the vector
  3225. * @param w w value of the vector
  3226. */
  3227. constructor(
  3228. /** x value of the vector */
  3229. x: number,
  3230. /** y value of the vector */
  3231. y: number,
  3232. /** z value of the vector */
  3233. z: number,
  3234. /** w value of the vector */
  3235. w: number);
  3236. /**
  3237. * Returns the string with the Vector4 coordinates.
  3238. * @returns a string containing all the vector values
  3239. */
  3240. toString(): string;
  3241. /**
  3242. * Returns the string "Vector4".
  3243. * @returns "Vector4"
  3244. */
  3245. getClassName(): string;
  3246. /**
  3247. * Returns the Vector4 hash code.
  3248. * @returns a unique hash code
  3249. */
  3250. getHashCode(): number;
  3251. /**
  3252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3253. * @returns the resulting array
  3254. */
  3255. asArray(): number[];
  3256. /**
  3257. * Populates the given array from the given index with the Vector4 coordinates.
  3258. * @param array array to populate
  3259. * @param index index of the array to start at (default: 0)
  3260. * @returns the Vector4.
  3261. */
  3262. toArray(array: FloatArray, index?: number): Vector4;
  3263. /**
  3264. * Adds the given vector to the current Vector4.
  3265. * @param otherVector the vector to add
  3266. * @returns the updated Vector4.
  3267. */
  3268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @returns the resulting vector
  3273. */
  3274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3277. * @param otherVector the vector to add
  3278. * @param result the vector to store the result
  3279. * @returns the current Vector4.
  3280. */
  3281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3282. /**
  3283. * Subtract in place the given vector from the current Vector4.
  3284. * @param otherVector the vector to subtract
  3285. * @returns the updated Vector4.
  3286. */
  3287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the new vector with the result
  3292. */
  3293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3296. * @param otherVector the vector to subtract
  3297. * @param result the vector to store the result
  3298. * @returns the current Vector4.
  3299. */
  3300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3303. */
  3304. /**
  3305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3306. * @param x value to subtract
  3307. * @param y value to subtract
  3308. * @param z value to subtract
  3309. * @param w value to subtract
  3310. * @returns new vector containing the result
  3311. */
  3312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3315. * @param x value to subtract
  3316. * @param y value to subtract
  3317. * @param z value to subtract
  3318. * @param w value to subtract
  3319. * @param result the vector to store the result in
  3320. * @returns the current Vector4.
  3321. */
  3322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3325. * @returns a new vector with the negated values
  3326. */
  3327. negate(): Vector4;
  3328. /**
  3329. * Negate this vector in place
  3330. * @returns this
  3331. */
  3332. negateInPlace(): Vector4;
  3333. /**
  3334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3335. * @param result defines the Vector3 object where to store the result
  3336. * @returns the current Vector4
  3337. */
  3338. negateToRef(result: Vector4): Vector4;
  3339. /**
  3340. * Multiplies the current Vector4 coordinates by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns the updated Vector4.
  3343. */
  3344. scaleInPlace(scale: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @returns a new vector with the result
  3349. */
  3350. scale(scale: number): Vector4;
  3351. /**
  3352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3353. * @param scale the number to scale with
  3354. * @param result a vector to store the result in
  3355. * @returns the current Vector4.
  3356. */
  3357. scaleToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3360. * @param scale defines the scale factor
  3361. * @param result defines the Vector4 object where to store the result
  3362. * @returns the unmodified current Vector4
  3363. */
  3364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3367. * @param otherVector the vector to compare against
  3368. * @returns true if they are equal
  3369. */
  3370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3371. /**
  3372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3373. * @param otherVector vector to compare against
  3374. * @param epsilon (Default: very small number)
  3375. * @returns true if they are equal
  3376. */
  3377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3378. /**
  3379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3380. * @param x x value to compare against
  3381. * @param y y value to compare against
  3382. * @param z z value to compare against
  3383. * @param w w value to compare against
  3384. * @returns true if equal
  3385. */
  3386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3387. /**
  3388. * Multiplies in place the current Vector4 by the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns the updated Vector4.
  3391. */
  3392. multiplyInPlace(otherVector: Vector4): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @returns resulting new vector
  3397. */
  3398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3401. * @param otherVector vector to multiple with
  3402. * @param result vector to store the result
  3403. * @returns the current Vector4.
  3404. */
  3405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3408. * @param x x value multiply with
  3409. * @param y y value multiply with
  3410. * @param z z value multiply with
  3411. * @param w w value multiply with
  3412. * @returns resulting new vector
  3413. */
  3414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3415. /**
  3416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @returns resulting new vector
  3419. */
  3420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3423. * @param otherVector vector to devide with
  3424. * @param result vector to store the result
  3425. * @returns the current Vector4.
  3426. */
  3427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3428. /**
  3429. * Divides the current Vector3 coordinates by the given ones.
  3430. * @param otherVector vector to devide with
  3431. * @returns the updated Vector3.
  3432. */
  3433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3442. * @param other defines the second operand
  3443. * @returns the current updated Vector4
  3444. */
  3445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Gets a new Vector4 from current Vector4 floored values
  3448. * @returns a new Vector4
  3449. */
  3450. floor(): Vector4;
  3451. /**
  3452. * Gets a new Vector4 from current Vector3 floored values
  3453. * @returns a new Vector4
  3454. */
  3455. fract(): Vector4;
  3456. /**
  3457. * Returns the Vector4 length (float).
  3458. * @returns the length
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Returns the Vector4 squared length (float).
  3463. * @returns the length squared
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalizes in place the Vector4.
  3468. * @returns the updated Vector4.
  3469. */
  3470. normalize(): Vector4;
  3471. /**
  3472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3473. * @returns this converted to a new vector3
  3474. */
  3475. toVector3(): Vector3;
  3476. /**
  3477. * Returns a new Vector4 copied from the current one.
  3478. * @returns the new cloned vector
  3479. */
  3480. clone(): Vector4;
  3481. /**
  3482. * Updates the current Vector4 with the given one coordinates.
  3483. * @param source the source vector to copy from
  3484. * @returns the updated Vector4.
  3485. */
  3486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3487. /**
  3488. * Updates the current Vector4 coordinates with the given floats.
  3489. * @param x float to copy from
  3490. * @param y float to copy from
  3491. * @param z float to copy from
  3492. * @param w float to copy from
  3493. * @returns the updated Vector4.
  3494. */
  3495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3496. /**
  3497. * Updates the current Vector4 coordinates with the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @returns the updated Vector4.
  3503. */
  3504. set(x: number, y: number, z: number, w: number): Vector4;
  3505. /**
  3506. * Copies the given float to the current Vector3 coordinates
  3507. * @param v defines the x, y, z and w coordinates of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. setAll(v: number): Vector4;
  3511. /**
  3512. * Returns a new Vector4 set from the starting index of the given array.
  3513. * @param array the array to pull values from
  3514. * @param offset the offset into the array to start at
  3515. * @returns the new vector
  3516. */
  3517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given array.
  3520. * @param array the array to pull values from
  3521. * @param offset the offset into the array to start at
  3522. * @param result the vector to store the result in
  3523. */
  3524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" from the starting index of the given Float32Array.
  3527. * @param array the array to pull values from
  3528. * @param offset the offset into the array to start at
  3529. * @param result the vector to store the result in
  3530. */
  3531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3532. /**
  3533. * Updates the given vector "result" coordinates from the given floats.
  3534. * @param x float to set from
  3535. * @param y float to set from
  3536. * @param z float to set from
  3537. * @param w float to set from
  3538. * @param result the vector to the floats in
  3539. */
  3540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3541. /**
  3542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3543. * @returns the new vector
  3544. */
  3545. static Zero(): Vector4;
  3546. /**
  3547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3548. * @returns the new vector
  3549. */
  3550. static One(): Vector4;
  3551. /**
  3552. * Returns a new normalized Vector4 from the given one.
  3553. * @param vector the vector to normalize
  3554. * @returns the vector
  3555. */
  3556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the normalization of the given one.
  3559. * @param vector the vector to normalize
  3560. * @param result the vector to store the result in
  3561. */
  3562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3563. /**
  3564. * Returns a vector with the minimum values from the left and right vectors
  3565. * @param left left vector to minimize
  3566. * @param right right vector to minimize
  3567. * @returns a new vector with the minimum of the left and right vector values
  3568. */
  3569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns a vector with the maximum values from the left and right vectors
  3572. * @param left left vector to maximize
  3573. * @param right right vector to maximize
  3574. * @returns a new vector with the maximum of the left and right vector values
  3575. */
  3576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3577. /**
  3578. * Returns the distance (float) between the vectors "value1" and "value2".
  3579. * @param value1 value to calulate the distance between
  3580. * @param value2 value to calulate the distance between
  3581. * @return the distance between the two vectors
  3582. */
  3583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the distance between
  3587. * @param value2 value to calulate the distance between
  3588. * @return the distance between the two vectors squared
  3589. */
  3590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3591. /**
  3592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3593. * @param value1 value to calulate the center between
  3594. * @param value2 value to calulate the center between
  3595. * @return the center between the two vectors
  3596. */
  3597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @returns the new vector
  3604. */
  3605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param vector the vector to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the result in
  3612. */
  3613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3616. * This methods computes transformed normalized direction vectors only.
  3617. * @param x value to transform
  3618. * @param y value to transform
  3619. * @param z value to transform
  3620. * @param w value to transform
  3621. * @param transformation the transformation matrix to apply
  3622. * @param result the vector to store the results in
  3623. */
  3624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3625. /**
  3626. * Creates a new Vector4 from a Vector3
  3627. * @param source defines the source data
  3628. * @param w defines the 4th component (default is 0)
  3629. * @returns a new Vector4
  3630. */
  3631. static FromVector3(source: Vector3, w?: number): Vector4;
  3632. }
  3633. /**
  3634. * Class used to store quaternion data
  3635. * @see https://en.wikipedia.org/wiki/Quaternion
  3636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3637. */
  3638. export class Quaternion {
  3639. /** defines the first component (0 by default) */
  3640. x: number;
  3641. /** defines the second component (0 by default) */
  3642. y: number;
  3643. /** defines the third component (0 by default) */
  3644. z: number;
  3645. /** defines the fourth component (1.0 by default) */
  3646. w: number;
  3647. /**
  3648. * Creates a new Quaternion from the given floats
  3649. * @param x defines the first component (0 by default)
  3650. * @param y defines the second component (0 by default)
  3651. * @param z defines the third component (0 by default)
  3652. * @param w defines the fourth component (1.0 by default)
  3653. */
  3654. constructor(
  3655. /** defines the first component (0 by default) */
  3656. x?: number,
  3657. /** defines the second component (0 by default) */
  3658. y?: number,
  3659. /** defines the third component (0 by default) */
  3660. z?: number,
  3661. /** defines the fourth component (1.0 by default) */
  3662. w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * 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)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * 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
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. 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;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. 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;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * 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"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * 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".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * 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"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * 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".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * 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.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * 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)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @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
  5102. * @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
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. 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);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. 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;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. 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;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. 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;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. 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);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * 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;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * 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).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * 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).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * 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.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * 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.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * 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.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * 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.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * 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).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * 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).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * 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.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * 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.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * 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.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * 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.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * 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).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * 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).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * 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.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * 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.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * 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.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * 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.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * 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).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * 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).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * 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.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * 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.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * 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.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * 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.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. subMeshFaceId: number;
  10488. /** Id of the the submesh that was picked */
  10489. subMeshId: number;
  10490. /** If a sprite was picked, this will be the sprite the pick collided with */
  10491. pickedSprite: Nullable<Sprite>;
  10492. /**
  10493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10494. */
  10495. originMesh: Nullable<AbstractMesh>;
  10496. /**
  10497. * The ray that was used to perform the picking.
  10498. */
  10499. ray: Nullable<Ray>;
  10500. /**
  10501. * Gets the normal correspodning to the face the pick collided with
  10502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10504. * @returns The normal correspodning to the face the pick collided with
  10505. */
  10506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10507. /**
  10508. * Gets the texture coordinates of where the pick occured
  10509. * @returns the vector containing the coordnates of the texture
  10510. */
  10511. getTextureCoordinates(): Nullable<Vector2>;
  10512. }
  10513. }
  10514. declare module "babylonjs/Culling/ray" {
  10515. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10516. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10518. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10519. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10520. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10521. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10522. import { Plane } from "babylonjs/Maths/math.plane";
  10523. /**
  10524. * Class representing a ray with position and direction
  10525. */
  10526. export class Ray {
  10527. /** origin point */
  10528. origin: Vector3;
  10529. /** direction */
  10530. direction: Vector3;
  10531. /** length of the ray */
  10532. length: number;
  10533. private static readonly TmpVector3;
  10534. private _tmpRay;
  10535. /**
  10536. * Creates a new ray
  10537. * @param origin origin point
  10538. * @param direction direction
  10539. * @param length length of the ray
  10540. */
  10541. constructor(
  10542. /** origin point */
  10543. origin: Vector3,
  10544. /** direction */
  10545. direction: Vector3,
  10546. /** length of the ray */
  10547. length?: number);
  10548. /**
  10549. * Checks if the ray intersects a box
  10550. * This does not account for the ray lenght by design to improve perfs.
  10551. * @param minimum bound of the box
  10552. * @param maximum bound of the box
  10553. * @param intersectionTreshold extra extend to be added to the box in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * Checks if the ray intersects a box
  10559. * This does not account for the ray lenght by design to improve perfs.
  10560. * @param box the bounding box to check
  10561. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10562. * @returns if the box was hit
  10563. */
  10564. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10565. /**
  10566. * If the ray hits a sphere
  10567. * @param sphere the bounding sphere to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10569. * @returns true if it hits the sphere
  10570. */
  10571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a triange
  10574. * @param vertex0 triangle vertex
  10575. * @param vertex1 triangle vertex
  10576. * @param vertex2 triangle vertex
  10577. * @returns intersection information if hit
  10578. */
  10579. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10580. /**
  10581. * Checks if ray intersects a plane
  10582. * @param plane the plane to check
  10583. * @returns the distance away it was hit
  10584. */
  10585. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10586. /**
  10587. * Calculate the intercept of a ray on a given axis
  10588. * @param axis to check 'x' | 'y' | 'z'
  10589. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10590. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10591. */
  10592. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10593. /**
  10594. * Checks if ray intersects a mesh
  10595. * @param mesh the mesh to check
  10596. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10597. * @returns picking info of the intersecton
  10598. */
  10599. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param meshes the meshes to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @param results array to store result in
  10605. * @returns Array of picking infos
  10606. */
  10607. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10608. private _comparePickingInfo;
  10609. private static smallnum;
  10610. private static rayl;
  10611. /**
  10612. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10613. * @param sega the first point of the segment to test the intersection against
  10614. * @param segb the second point of the segment to test the intersection against
  10615. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10616. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10617. */
  10618. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10619. /**
  10620. * Update the ray from viewport position
  10621. * @param x position
  10622. * @param y y position
  10623. * @param viewportWidth viewport width
  10624. * @param viewportHeight viewport height
  10625. * @param world world matrix
  10626. * @param view view matrix
  10627. * @param projection projection matrix
  10628. * @returns this ray updated
  10629. */
  10630. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10631. /**
  10632. * Creates a ray with origin and direction of 0,0,0
  10633. * @returns the new ray
  10634. */
  10635. static Zero(): Ray;
  10636. /**
  10637. * Creates a new ray from screen space and viewport
  10638. * @param x position
  10639. * @param y y position
  10640. * @param viewportWidth viewport width
  10641. * @param viewportHeight viewport height
  10642. * @param world world matrix
  10643. * @param view view matrix
  10644. * @param projection projection matrix
  10645. * @returns new ray
  10646. */
  10647. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10648. /**
  10649. * 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
  10650. * transformed to the given world matrix.
  10651. * @param origin The origin point
  10652. * @param end The end point
  10653. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10654. * @returns the new ray
  10655. */
  10656. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10657. /**
  10658. * Transforms a ray by a matrix
  10659. * @param ray ray to transform
  10660. * @param matrix matrix to apply
  10661. * @returns the resulting new ray
  10662. */
  10663. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @param result ray to store result in
  10669. */
  10670. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10671. /**
  10672. * Unproject a ray from screen space to object space
  10673. * @param sourceX defines the screen space x coordinate to use
  10674. * @param sourceY defines the screen space y coordinate to use
  10675. * @param viewportWidth defines the current width of the viewport
  10676. * @param viewportHeight defines the current height of the viewport
  10677. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10678. * @param view defines the view matrix to use
  10679. * @param projection defines the projection matrix to use
  10680. */
  10681. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10682. }
  10683. /**
  10684. * Type used to define predicate used to select faces when a mesh intersection is detected
  10685. */
  10686. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10687. module "babylonjs/scene" {
  10688. interface Scene {
  10689. /** @hidden */
  10690. _tempPickingRay: Nullable<Ray>;
  10691. /** @hidden */
  10692. _cachedRayForTransform: Ray;
  10693. /** @hidden */
  10694. _pickWithRayInverseMatrix: Matrix;
  10695. /** @hidden */
  10696. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10697. /** @hidden */
  10698. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10699. }
  10700. }
  10701. }
  10702. declare module "babylonjs/sceneComponent" {
  10703. import { Scene } from "babylonjs/scene";
  10704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10705. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10706. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10707. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10708. import { Nullable } from "babylonjs/types";
  10709. import { Camera } from "babylonjs/Cameras/camera";
  10710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10712. import { AbstractScene } from "babylonjs/abstractScene";
  10713. import { Mesh } from "babylonjs/Meshes/mesh";
  10714. /**
  10715. * Groups all the scene component constants in one place to ease maintenance.
  10716. * @hidden
  10717. */
  10718. export class SceneComponentConstants {
  10719. static readonly NAME_EFFECTLAYER: string;
  10720. static readonly NAME_LAYER: string;
  10721. static readonly NAME_LENSFLARESYSTEM: string;
  10722. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10723. static readonly NAME_PARTICLESYSTEM: string;
  10724. static readonly NAME_GAMEPAD: string;
  10725. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10726. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10727. static readonly NAME_DEPTHRENDERER: string;
  10728. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10729. static readonly NAME_SPRITE: string;
  10730. static readonly NAME_OUTLINERENDERER: string;
  10731. static readonly NAME_PROCEDURALTEXTURE: string;
  10732. static readonly NAME_SHADOWGENERATOR: string;
  10733. static readonly NAME_OCTREE: string;
  10734. static readonly NAME_PHYSICSENGINE: string;
  10735. static readonly NAME_AUDIO: string;
  10736. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10737. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10739. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10740. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10742. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10744. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10747. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10749. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10750. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10751. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10754. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10755. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_POINTERMOVE_SPRITE: number;
  10763. static readonly STEP_POINTERDOWN_SPRITE: number;
  10764. static readonly STEP_POINTERUP_SPRITE: number;
  10765. }
  10766. /**
  10767. * This represents a scene component.
  10768. *
  10769. * This is used to decouple the dependency the scene is having on the different workloads like
  10770. * layers, post processes...
  10771. */
  10772. export interface ISceneComponent {
  10773. /**
  10774. * The name of the component. Each component must have a unique name.
  10775. */
  10776. name: string;
  10777. /**
  10778. * The scene the component belongs to.
  10779. */
  10780. scene: Scene;
  10781. /**
  10782. * Register the component to one instance of a scene.
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. }
  10795. /**
  10796. * This represents a SERIALIZABLE scene component.
  10797. *
  10798. * This extends Scene Component to add Serialization methods on top.
  10799. */
  10800. export interface ISceneSerializableComponent extends ISceneComponent {
  10801. /**
  10802. * Adds all the elements from the container to the scene
  10803. * @param container the container holding the elements
  10804. */
  10805. addFromContainer(container: AbstractScene): void;
  10806. /**
  10807. * Removes all the elements in the container from the scene
  10808. * @param container contains the elements to remove
  10809. * @param dispose if the removed element should be disposed (default: false)
  10810. */
  10811. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10812. /**
  10813. * Serializes the component data to the specified json object
  10814. * @param serializationObject The object to serialize to
  10815. */
  10816. serialize(serializationObject: any): void;
  10817. }
  10818. /**
  10819. * Strong typing of a Mesh related stage step action
  10820. */
  10821. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10822. /**
  10823. * Strong typing of a Evaluate Sub Mesh related stage step action
  10824. */
  10825. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10826. /**
  10827. * Strong typing of a Active Mesh related stage step action
  10828. */
  10829. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10830. /**
  10831. * Strong typing of a Camera related stage step action
  10832. */
  10833. export type CameraStageAction = (camera: Camera) => void;
  10834. /**
  10835. * Strong typing of a Camera Frame buffer related stage step action
  10836. */
  10837. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10838. /**
  10839. * Strong typing of a Render Target related stage step action
  10840. */
  10841. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10842. /**
  10843. * Strong typing of a RenderingGroup related stage step action
  10844. */
  10845. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10846. /**
  10847. * Strong typing of a Mesh Render related stage step action
  10848. */
  10849. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10850. /**
  10851. * Strong typing of a simple stage step action
  10852. */
  10853. export type SimpleStageAction = () => void;
  10854. /**
  10855. * Strong typing of a render target action.
  10856. */
  10857. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10858. /**
  10859. * Strong typing of a pointer move action.
  10860. */
  10861. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10862. /**
  10863. * Strong typing of a pointer up/down action.
  10864. */
  10865. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10866. /**
  10867. * Representation of a stage in the scene (Basically a list of ordered steps)
  10868. * @hidden
  10869. */
  10870. export class Stage<T extends Function> extends Array<{
  10871. index: number;
  10872. component: ISceneComponent;
  10873. action: T;
  10874. }> {
  10875. /**
  10876. * Hide ctor from the rest of the world.
  10877. * @param items The items to add.
  10878. */
  10879. private constructor();
  10880. /**
  10881. * Creates a new Stage.
  10882. * @returns A new instance of a Stage
  10883. */
  10884. static Create<T extends Function>(): Stage<T>;
  10885. /**
  10886. * Registers a step in an ordered way in the targeted stage.
  10887. * @param index Defines the position to register the step in
  10888. * @param component Defines the component attached to the step
  10889. * @param action Defines the action to launch during the step
  10890. */
  10891. registerStep(index: number, component: ISceneComponent, action: T): void;
  10892. /**
  10893. * Clears all the steps from the stage.
  10894. */
  10895. clear(): void;
  10896. }
  10897. }
  10898. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10899. import { Nullable } from "babylonjs/types";
  10900. import { Observable } from "babylonjs/Misc/observable";
  10901. import { Scene } from "babylonjs/scene";
  10902. import { Sprite } from "babylonjs/Sprites/sprite";
  10903. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10904. import { Ray } from "babylonjs/Culling/ray";
  10905. import { Camera } from "babylonjs/Cameras/camera";
  10906. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10907. import { ISceneComponent } from "babylonjs/sceneComponent";
  10908. module "babylonjs/scene" {
  10909. interface Scene {
  10910. /** @hidden */
  10911. _pointerOverSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _pickedDownSprite: Nullable<Sprite>;
  10914. /** @hidden */
  10915. _tempSpritePickingRay: Nullable<Ray>;
  10916. /**
  10917. * All of the sprite managers added to this scene
  10918. * @see http://doc.babylonjs.com/babylon101/sprites
  10919. */
  10920. spriteManagers: Array<ISpriteManager>;
  10921. /**
  10922. * An event triggered when sprites rendering is about to start
  10923. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10924. */
  10925. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10926. /**
  10927. * An event triggered when sprites rendering is done
  10928. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10929. */
  10930. onAfterSpritesRenderingObservable: Observable<Scene>;
  10931. /** @hidden */
  10932. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Launch a ray to try to pick a sprite in the scene
  10934. * @param x position on screen
  10935. * @param y position on screen
  10936. * @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
  10937. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10938. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10939. * @returns a PickingInfo
  10940. */
  10941. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10942. /** Use the given ray to pick a sprite in the scene
  10943. * @param ray The ray (in world space) to use to pick meshes
  10944. * @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
  10945. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10946. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10947. * @returns a PickingInfo
  10948. */
  10949. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10950. /** @hidden */
  10951. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10952. /** Launch a ray to try to pick sprites in the scene
  10953. * @param x position on screen
  10954. * @param y position on screen
  10955. * @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
  10956. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10957. * @returns a PickingInfo array
  10958. */
  10959. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10960. /** Use the given ray to pick sprites in the scene
  10961. * @param ray The ray (in world space) to use to pick meshes
  10962. * @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
  10963. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10964. * @returns a PickingInfo array
  10965. */
  10966. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10967. /**
  10968. * Force the sprite under the pointer
  10969. * @param sprite defines the sprite to use
  10970. */
  10971. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10972. /**
  10973. * Gets the sprite under the pointer
  10974. * @returns a Sprite or null if no sprite is under the pointer
  10975. */
  10976. getPointerOverSprite(): Nullable<Sprite>;
  10977. }
  10978. }
  10979. /**
  10980. * Defines the sprite scene component responsible to manage sprites
  10981. * in a given scene.
  10982. */
  10983. export class SpriteSceneComponent implements ISceneComponent {
  10984. /**
  10985. * The component name helpfull to identify the component in the list of scene components.
  10986. */
  10987. readonly name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /** @hidden */
  10993. private _spritePredicate;
  10994. /**
  10995. * Creates a new instance of the component for the given scene
  10996. * @param scene Defines the scene to register the component in
  10997. */
  10998. constructor(scene: Scene);
  10999. /**
  11000. * Registers the component in a given scene
  11001. */
  11002. register(): void;
  11003. /**
  11004. * Rebuilds the elements related to this component in case of
  11005. * context lost for instance.
  11006. */
  11007. rebuild(): void;
  11008. /**
  11009. * Disposes the component and the associated ressources.
  11010. */
  11011. dispose(): void;
  11012. private _pickSpriteButKeepRay;
  11013. private _pointerMove;
  11014. private _pointerDown;
  11015. private _pointerUp;
  11016. }
  11017. }
  11018. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11019. /** @hidden */
  11020. export var fogFragmentDeclaration: {
  11021. name: string;
  11022. shader: string;
  11023. };
  11024. }
  11025. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11026. /** @hidden */
  11027. export var fogFragment: {
  11028. name: string;
  11029. shader: string;
  11030. };
  11031. }
  11032. declare module "babylonjs/Shaders/sprites.fragment" {
  11033. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11034. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11035. /** @hidden */
  11036. export var spritesPixelShader: {
  11037. name: string;
  11038. shader: string;
  11039. };
  11040. }
  11041. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11042. /** @hidden */
  11043. export var fogVertexDeclaration: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module "babylonjs/Shaders/sprites.vertex" {
  11049. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11050. /** @hidden */
  11051. export var spritesVertexShader: {
  11052. name: string;
  11053. shader: string;
  11054. };
  11055. }
  11056. declare module "babylonjs/Sprites/spriteManager" {
  11057. import { IDisposable, Scene } from "babylonjs/scene";
  11058. import { Nullable } from "babylonjs/types";
  11059. import { Observable } from "babylonjs/Misc/observable";
  11060. import { Sprite } from "babylonjs/Sprites/sprite";
  11061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11062. import { Camera } from "babylonjs/Cameras/camera";
  11063. import { Texture } from "babylonjs/Materials/Textures/texture";
  11064. import "babylonjs/Shaders/sprites.fragment";
  11065. import "babylonjs/Shaders/sprites.vertex";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. /**
  11068. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11069. */
  11070. export interface ISpriteManager extends IDisposable {
  11071. /**
  11072. * Gets manager's name
  11073. */
  11074. name: string;
  11075. /**
  11076. * Restricts the camera to viewing objects with the same layerMask.
  11077. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11078. */
  11079. layerMask: number;
  11080. /**
  11081. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11082. */
  11083. isPickable: boolean;
  11084. /**
  11085. * Gets the hosting scene
  11086. */
  11087. scene: Scene;
  11088. /**
  11089. * Specifies the rendering group id for this mesh (0 by default)
  11090. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11091. */
  11092. renderingGroupId: number;
  11093. /**
  11094. * Defines the list of sprites managed by the manager.
  11095. */
  11096. sprites: Array<Sprite>;
  11097. /**
  11098. * Gets or sets the spritesheet texture
  11099. */
  11100. texture: Texture;
  11101. /** Defines the default width of a cell in the spritesheet */
  11102. cellWidth: number;
  11103. /** Defines the default height of a cell in the spritesheet */
  11104. cellHeight: number;
  11105. /**
  11106. * Tests the intersection of a sprite with a specific ray.
  11107. * @param ray The ray we are sending to test the collision
  11108. * @param camera The camera space we are sending rays in
  11109. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11110. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11111. * @returns picking info or null.
  11112. */
  11113. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11114. /**
  11115. * Intersects the sprites with a ray
  11116. * @param ray defines the ray to intersect with
  11117. * @param camera defines the current active camera
  11118. * @param predicate defines a predicate used to select candidate sprites
  11119. * @returns null if no hit or a PickingInfo array
  11120. */
  11121. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11122. /**
  11123. * Renders the list of sprites on screen.
  11124. */
  11125. render(): void;
  11126. }
  11127. /**
  11128. * Class used to manage multiple sprites on the same spritesheet
  11129. * @see http://doc.babylonjs.com/babylon101/sprites
  11130. */
  11131. export class SpriteManager implements ISpriteManager {
  11132. /** defines the manager's name */
  11133. name: string;
  11134. /** Define the Url to load snippets */
  11135. static SnippetUrl: string;
  11136. /** Snippet ID if the manager was created from the snippet server */
  11137. snippetId: string;
  11138. /** Gets the list of sprites */
  11139. sprites: Sprite[];
  11140. /** Gets or sets the rendering group id (0 by default) */
  11141. renderingGroupId: number;
  11142. /** Gets or sets camera layer mask */
  11143. layerMask: number;
  11144. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11145. fogEnabled: boolean;
  11146. /** Gets or sets a boolean indicating if the sprites are pickable */
  11147. isPickable: boolean;
  11148. /** Defines the default width of a cell in the spritesheet */
  11149. cellWidth: number;
  11150. /** Defines the default height of a cell in the spritesheet */
  11151. cellHeight: number;
  11152. /** Associative array from JSON sprite data file */
  11153. private _cellData;
  11154. /** Array of sprite names from JSON sprite data file */
  11155. private _spriteMap;
  11156. /** True when packed cell data from JSON file is ready*/
  11157. private _packedAndReady;
  11158. private _textureContent;
  11159. /**
  11160. * An event triggered when the manager is disposed.
  11161. */
  11162. onDisposeObservable: Observable<SpriteManager>;
  11163. private _onDisposeObserver;
  11164. /**
  11165. * Callback called when the manager is disposed
  11166. */
  11167. set onDispose(callback: () => void);
  11168. private _capacity;
  11169. private _fromPacked;
  11170. private _spriteTexture;
  11171. private _epsilon;
  11172. private _scene;
  11173. private _vertexData;
  11174. private _buffer;
  11175. private _vertexBuffers;
  11176. private _indexBuffer;
  11177. private _effectBase;
  11178. private _effectFog;
  11179. /**
  11180. * Gets or sets the unique id of the sprite
  11181. */
  11182. uniqueId: number;
  11183. /**
  11184. * Gets the array of sprites
  11185. */
  11186. get children(): Sprite[];
  11187. /**
  11188. * Gets the hosting scene
  11189. */
  11190. get scene(): Scene;
  11191. /**
  11192. * Gets the capacity of the manager
  11193. */
  11194. get capacity(): number;
  11195. /**
  11196. * Gets or sets the spritesheet texture
  11197. */
  11198. get texture(): Texture;
  11199. set texture(value: Texture);
  11200. private _blendMode;
  11201. /**
  11202. * Blend mode use to render the particle, it can be any of
  11203. * the static Constants.ALPHA_x properties provided in this class.
  11204. * Default value is Constants.ALPHA_COMBINE
  11205. */
  11206. get blendMode(): number;
  11207. set blendMode(blendMode: number);
  11208. /** Disables writing to the depth buffer when rendering the sprites.
  11209. * It can be handy to disable depth writing when using textures without alpha channel
  11210. * and setting some specific blend modes.
  11211. */
  11212. disableDepthWrite: boolean;
  11213. /**
  11214. * Creates a new sprite manager
  11215. * @param name defines the manager's name
  11216. * @param imgUrl defines the sprite sheet url
  11217. * @param capacity defines the maximum allowed number of sprites
  11218. * @param cellSize defines the size of a sprite cell
  11219. * @param scene defines the hosting scene
  11220. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11221. * @param samplingMode defines the smapling mode to use with spritesheet
  11222. * @param fromPacked set to false; do not alter
  11223. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11224. */
  11225. constructor(
  11226. /** defines the manager's name */
  11227. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11228. /**
  11229. * Returns the string "SpriteManager"
  11230. * @returns "SpriteManager"
  11231. */
  11232. getClassName(): string;
  11233. private _makePacked;
  11234. private _appendSpriteVertex;
  11235. private _checkTextureAlpha;
  11236. /**
  11237. * Intersects the sprites with a ray
  11238. * @param ray defines the ray to intersect with
  11239. * @param camera defines the current active camera
  11240. * @param predicate defines a predicate used to select candidate sprites
  11241. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11242. * @returns null if no hit or a PickingInfo
  11243. */
  11244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11245. /**
  11246. * Intersects the sprites with a ray
  11247. * @param ray defines the ray to intersect with
  11248. * @param camera defines the current active camera
  11249. * @param predicate defines a predicate used to select candidate sprites
  11250. * @returns null if no hit or a PickingInfo array
  11251. */
  11252. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11253. /**
  11254. * Render all child sprites
  11255. */
  11256. render(): void;
  11257. /**
  11258. * Release associated resources
  11259. */
  11260. dispose(): void;
  11261. /**
  11262. * Serializes the sprite manager to a JSON object
  11263. * @param serializeTexture defines if the texture must be serialized as well
  11264. * @returns the JSON object
  11265. */
  11266. serialize(serializeTexture?: boolean): any;
  11267. /**
  11268. * Parses a JSON object to create a new sprite manager.
  11269. * @param parsedManager The JSON object to parse
  11270. * @param scene The scene to create the sprite managerin
  11271. * @param rootUrl The root url to use to load external dependencies like texture
  11272. * @returns the new sprite manager
  11273. */
  11274. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11275. /**
  11276. * Creates a sprite manager from a snippet saved in a remote file
  11277. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11278. * @param url defines the url to load from
  11279. * @param scene defines the hosting scene
  11280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11281. * @returns a promise that will resolve to the new sprite manager
  11282. */
  11283. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11284. /**
  11285. * Creates a sprite manager from a snippet saved by the sprite editor
  11286. * @param snippetId defines the snippet to load
  11287. * @param scene defines the hosting scene
  11288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11289. * @returns a promise that will resolve to the new sprite manager
  11290. */
  11291. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11292. }
  11293. }
  11294. declare module "babylonjs/Misc/gradients" {
  11295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11296. /** Interface used by value gradients (color, factor, ...) */
  11297. export interface IValueGradient {
  11298. /**
  11299. * Gets or sets the gradient value (between 0 and 1)
  11300. */
  11301. gradient: number;
  11302. }
  11303. /** Class used to store color4 gradient */
  11304. export class ColorGradient implements IValueGradient {
  11305. /**
  11306. * Gets or sets the gradient value (between 0 and 1)
  11307. */
  11308. gradient: number;
  11309. /**
  11310. * Gets or sets first associated color
  11311. */
  11312. color1: Color4;
  11313. /**
  11314. * Gets or sets second associated color
  11315. */
  11316. color2?: Color4 | undefined;
  11317. /**
  11318. * Creates a new color4 gradient
  11319. * @param gradient gets or sets the gradient value (between 0 and 1)
  11320. * @param color1 gets or sets first associated color
  11321. * @param color2 gets or sets first second color
  11322. */
  11323. constructor(
  11324. /**
  11325. * Gets or sets the gradient value (between 0 and 1)
  11326. */
  11327. gradient: number,
  11328. /**
  11329. * Gets or sets first associated color
  11330. */
  11331. color1: Color4,
  11332. /**
  11333. * Gets or sets second associated color
  11334. */
  11335. color2?: Color4 | undefined);
  11336. /**
  11337. * Will get a color picked randomly between color1 and color2.
  11338. * If color2 is undefined then color1 will be used
  11339. * @param result defines the target Color4 to store the result in
  11340. */
  11341. getColorToRef(result: Color4): void;
  11342. }
  11343. /** Class used to store color 3 gradient */
  11344. export class Color3Gradient implements IValueGradient {
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number;
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3;
  11353. /**
  11354. * Creates a new color3 gradient
  11355. * @param gradient gets or sets the gradient value (between 0 and 1)
  11356. * @param color gets or sets associated color
  11357. */
  11358. constructor(
  11359. /**
  11360. * Gets or sets the gradient value (between 0 and 1)
  11361. */
  11362. gradient: number,
  11363. /**
  11364. * Gets or sets the associated color
  11365. */
  11366. color: Color3);
  11367. }
  11368. /** Class used to store factor gradient */
  11369. export class FactorGradient implements IValueGradient {
  11370. /**
  11371. * Gets or sets the gradient value (between 0 and 1)
  11372. */
  11373. gradient: number;
  11374. /**
  11375. * Gets or sets first associated factor
  11376. */
  11377. factor1: number;
  11378. /**
  11379. * Gets or sets second associated factor
  11380. */
  11381. factor2?: number | undefined;
  11382. /**
  11383. * Creates a new factor gradient
  11384. * @param gradient gets or sets the gradient value (between 0 and 1)
  11385. * @param factor1 gets or sets first associated factor
  11386. * @param factor2 gets or sets second associated factor
  11387. */
  11388. constructor(
  11389. /**
  11390. * Gets or sets the gradient value (between 0 and 1)
  11391. */
  11392. gradient: number,
  11393. /**
  11394. * Gets or sets first associated factor
  11395. */
  11396. factor1: number,
  11397. /**
  11398. * Gets or sets second associated factor
  11399. */
  11400. factor2?: number | undefined);
  11401. /**
  11402. * Will get a number picked randomly between factor1 and factor2.
  11403. * If factor2 is undefined then factor1 will be used
  11404. * @returns the picked number
  11405. */
  11406. getFactor(): number;
  11407. }
  11408. /**
  11409. * Helper used to simplify some generic gradient tasks
  11410. */
  11411. export class GradientHelper {
  11412. /**
  11413. * Gets the current gradient from an array of IValueGradient
  11414. * @param ratio defines the current ratio to get
  11415. * @param gradients defines the array of IValueGradient
  11416. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11417. */
  11418. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11419. }
  11420. }
  11421. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11423. import { Nullable } from "babylonjs/types";
  11424. module "babylonjs/Engines/thinEngine" {
  11425. interface ThinEngine {
  11426. /**
  11427. * Creates a dynamic texture
  11428. * @param width defines the width of the texture
  11429. * @param height defines the height of the texture
  11430. * @param generateMipMaps defines if the engine should generate the mip levels
  11431. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11432. * @returns the dynamic texture inside an InternalTexture
  11433. */
  11434. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11435. /**
  11436. * Update the content of a dynamic texture
  11437. * @param texture defines the texture to update
  11438. * @param canvas defines the canvas containing the source
  11439. * @param invertY defines if data must be stored with Y axis inverted
  11440. * @param premulAlpha defines if alpha is stored as premultiplied
  11441. * @param format defines the format of the data
  11442. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11443. */
  11444. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11445. }
  11446. }
  11447. }
  11448. declare module "babylonjs/Misc/canvasGenerator" {
  11449. /**
  11450. * Helper class used to generate a canvas to manipulate images
  11451. */
  11452. export class CanvasGenerator {
  11453. /**
  11454. * Create a new canvas (or offscreen canvas depending on the context)
  11455. * @param width defines the expected width
  11456. * @param height defines the expected height
  11457. * @return a new canvas or offscreen canvas
  11458. */
  11459. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11460. }
  11461. }
  11462. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11463. import { Scene } from "babylonjs/scene";
  11464. import { Texture } from "babylonjs/Materials/Textures/texture";
  11465. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11466. /**
  11467. * A class extending Texture allowing drawing on a texture
  11468. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11469. */
  11470. export class DynamicTexture extends Texture {
  11471. private _generateMipMaps;
  11472. private _canvas;
  11473. private _context;
  11474. /**
  11475. * Creates a DynamicTexture
  11476. * @param name defines the name of the texture
  11477. * @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
  11478. * @param scene defines the scene where you want the texture
  11479. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11480. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11481. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11482. */
  11483. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11484. /**
  11485. * Get the current class name of the texture useful for serialization or dynamic coding.
  11486. * @returns "DynamicTexture"
  11487. */
  11488. getClassName(): string;
  11489. /**
  11490. * Gets the current state of canRescale
  11491. */
  11492. get canRescale(): boolean;
  11493. private _recreate;
  11494. /**
  11495. * Scales the texture
  11496. * @param ratio the scale factor to apply to both width and height
  11497. */
  11498. scale(ratio: number): void;
  11499. /**
  11500. * Resizes the texture
  11501. * @param width the new width
  11502. * @param height the new height
  11503. */
  11504. scaleTo(width: number, height: number): void;
  11505. /**
  11506. * Gets the context of the canvas used by the texture
  11507. * @returns the canvas context of the dynamic texture
  11508. */
  11509. getContext(): CanvasRenderingContext2D;
  11510. /**
  11511. * Clears the texture
  11512. */
  11513. clear(): void;
  11514. /**
  11515. * Updates the texture
  11516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11517. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11518. */
  11519. update(invertY?: boolean, premulAlpha?: boolean): void;
  11520. /**
  11521. * Draws text onto the texture
  11522. * @param text defines the text to be drawn
  11523. * @param x defines the placement of the text from the left
  11524. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11525. * @param font defines the font to be used with font-style, font-size, font-name
  11526. * @param color defines the color used for the text
  11527. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11528. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11529. * @param update defines whether texture is immediately update (default is true)
  11530. */
  11531. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11532. /**
  11533. * Clones the texture
  11534. * @returns the clone of the texture.
  11535. */
  11536. clone(): DynamicTexture;
  11537. /**
  11538. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11539. * @returns a serialized dynamic texture object
  11540. */
  11541. serialize(): any;
  11542. /** @hidden */
  11543. _rebuild(): void;
  11544. }
  11545. }
  11546. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11547. import { Nullable } from "babylonjs/types";
  11548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11549. import { Scene } from "babylonjs/scene";
  11550. module "babylonjs/Engines/thinEngine" {
  11551. interface ThinEngine {
  11552. /**
  11553. * Creates a raw texture
  11554. * @param data defines the data to store in the texture
  11555. * @param width defines the width of the texture
  11556. * @param height defines the height of the texture
  11557. * @param format defines the format of the data
  11558. * @param generateMipMaps defines if the engine should generate the mip levels
  11559. * @param invertY defines if data must be stored with Y axis inverted
  11560. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11561. * @param compression defines the compression used (null by default)
  11562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11563. * @returns the raw texture inside an InternalTexture
  11564. */
  11565. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11566. /**
  11567. * Update a raw texture
  11568. * @param texture defines the texture to update
  11569. * @param data defines the data to store in the texture
  11570. * @param format defines the format of the data
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. */
  11573. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11574. /**
  11575. * Update a raw texture
  11576. * @param texture defines the texture to update
  11577. * @param data defines the data to store in the texture
  11578. * @param format defines the format of the data
  11579. * @param invertY defines if data must be stored with Y axis inverted
  11580. * @param compression defines the compression used (null by default)
  11581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11582. */
  11583. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11584. /**
  11585. * Creates a new raw cube texture
  11586. * @param data defines the array of data to use to create each face
  11587. * @param size defines the size of the textures
  11588. * @param format defines the format of the data
  11589. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11590. * @param generateMipMaps defines if the engine should generate the mip levels
  11591. * @param invertY defines if data must be stored with Y axis inverted
  11592. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11593. * @param compression defines the compression used (null by default)
  11594. * @returns the cube texture as an InternalTexture
  11595. */
  11596. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11597. /**
  11598. * Update a raw cube texture
  11599. * @param texture defines the texture to udpdate
  11600. * @param data defines the data to store
  11601. * @param format defines the data format
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @param invertY defines if data must be stored with Y axis inverted
  11604. */
  11605. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11606. /**
  11607. * Update a raw cube texture
  11608. * @param texture defines the texture to udpdate
  11609. * @param data defines the data to store
  11610. * @param format defines the data format
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. * @param invertY defines if data must be stored with Y axis inverted
  11613. * @param compression defines the compression used (null by default)
  11614. */
  11615. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11616. /**
  11617. * Update a raw cube texture
  11618. * @param texture defines the texture to udpdate
  11619. * @param data defines the data to store
  11620. * @param format defines the data format
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param compression defines the compression used (null by default)
  11624. * @param level defines which level of the texture to update
  11625. */
  11626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11627. /**
  11628. * Creates a new raw cube texture from a specified url
  11629. * @param url defines the url where the data is located
  11630. * @param scene defines the current scene
  11631. * @param size defines the size of the textures
  11632. * @param format defines the format of the data
  11633. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11634. * @param noMipmap defines if the engine should avoid generating the mip levels
  11635. * @param callback defines a callback used to extract texture data from loaded data
  11636. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11637. * @param onLoad defines a callback called when texture is loaded
  11638. * @param onError defines a callback called if there is an error
  11639. * @returns the cube texture as an InternalTexture
  11640. */
  11641. 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;
  11642. /**
  11643. * Creates a new raw cube texture from a specified url
  11644. * @param url defines the url where the data is located
  11645. * @param scene defines the current scene
  11646. * @param size defines the size of the textures
  11647. * @param format defines the format of the data
  11648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11649. * @param noMipmap defines if the engine should avoid generating the mip levels
  11650. * @param callback defines a callback used to extract texture data from loaded data
  11651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11652. * @param onLoad defines a callback called when texture is loaded
  11653. * @param onError defines a callback called if there is an error
  11654. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11655. * @param invertY defines if data must be stored with Y axis inverted
  11656. * @returns the cube texture as an InternalTexture
  11657. */
  11658. 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;
  11659. /**
  11660. * Creates a new raw 3D texture
  11661. * @param data defines the data used to create the texture
  11662. * @param width defines the width of the texture
  11663. * @param height defines the height of the texture
  11664. * @param depth defines the depth of the texture
  11665. * @param format defines the format of the texture
  11666. * @param generateMipMaps defines if the engine must generate mip levels
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11669. * @param compression defines the compressed used (can be null)
  11670. * @param textureType defines the compressed used (can be null)
  11671. * @returns a new raw 3D texture (stored in an InternalTexture)
  11672. */
  11673. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11674. /**
  11675. * Update a raw 3D texture
  11676. * @param texture defines the texture to update
  11677. * @param data defines the data to store
  11678. * @param format defines the data format
  11679. * @param invertY defines if data must be stored with Y axis inverted
  11680. */
  11681. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11682. /**
  11683. * Update a raw 3D texture
  11684. * @param texture defines the texture to update
  11685. * @param data defines the data to store
  11686. * @param format defines the data format
  11687. * @param invertY defines if data must be stored with Y axis inverted
  11688. * @param compression defines the used compression (can be null)
  11689. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11690. */
  11691. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11692. /**
  11693. * Creates a new raw 2D array texture
  11694. * @param data defines the data used to create the texture
  11695. * @param width defines the width of the texture
  11696. * @param height defines the height of the texture
  11697. * @param depth defines the number of layers of the texture
  11698. * @param format defines the format of the texture
  11699. * @param generateMipMaps defines if the engine must generate mip levels
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11702. * @param compression defines the compressed used (can be null)
  11703. * @param textureType defines the compressed used (can be null)
  11704. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11705. */
  11706. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11707. /**
  11708. * Update a raw 2D array texture
  11709. * @param texture defines the texture to update
  11710. * @param data defines the data to store
  11711. * @param format defines the data format
  11712. * @param invertY defines if data must be stored with Y axis inverted
  11713. */
  11714. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11715. /**
  11716. * Update a raw 2D array texture
  11717. * @param texture defines the texture to update
  11718. * @param data defines the data to store
  11719. * @param format defines the data format
  11720. * @param invertY defines if data must be stored with Y axis inverted
  11721. * @param compression defines the used compression (can be null)
  11722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11723. */
  11724. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11725. }
  11726. }
  11727. }
  11728. declare module "babylonjs/Materials/Textures/rawTexture" {
  11729. import { Scene } from "babylonjs/scene";
  11730. import { Texture } from "babylonjs/Materials/Textures/texture";
  11731. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11732. /**
  11733. * Raw texture can help creating a texture directly from an array of data.
  11734. * This can be super useful if you either get the data from an uncompressed source or
  11735. * if you wish to create your texture pixel by pixel.
  11736. */
  11737. export class RawTexture extends Texture {
  11738. /**
  11739. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11740. */
  11741. format: number;
  11742. /**
  11743. * Instantiates a new RawTexture.
  11744. * Raw texture can help creating a texture directly from an array of data.
  11745. * This can be super useful if you either get the data from an uncompressed source or
  11746. * if you wish to create your texture pixel by pixel.
  11747. * @param data define the array of data to use to create the texture
  11748. * @param width define the width of the texture
  11749. * @param height define the height of the texture
  11750. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11751. * @param scene define the scene the texture belongs to
  11752. * @param generateMipMaps define whether mip maps should be generated or not
  11753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11755. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11756. */
  11757. constructor(data: ArrayBufferView, width: number, height: number,
  11758. /**
  11759. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11760. */
  11761. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11762. /**
  11763. * Updates the texture underlying data.
  11764. * @param data Define the new data of the texture
  11765. */
  11766. update(data: ArrayBufferView): void;
  11767. /**
  11768. * Creates a luminance texture from some data.
  11769. * @param data Define the texture data
  11770. * @param width Define the width of the texture
  11771. * @param height Define the height of the texture
  11772. * @param scene Define the scene the texture belongs to
  11773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11776. * @returns the luminance texture
  11777. */
  11778. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11779. /**
  11780. * Creates a luminance alpha texture from some data.
  11781. * @param data Define the texture data
  11782. * @param width Define the width of the texture
  11783. * @param height Define the height of the texture
  11784. * @param scene Define the scene the texture belongs to
  11785. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11788. * @returns the luminance alpha texture
  11789. */
  11790. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11791. /**
  11792. * Creates an alpha texture from some data.
  11793. * @param data Define the texture data
  11794. * @param width Define the width of the texture
  11795. * @param height Define the height of the texture
  11796. * @param scene Define the scene the texture belongs to
  11797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11800. * @returns the alpha texture
  11801. */
  11802. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11803. /**
  11804. * Creates a RGB texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param scene Define the scene the texture belongs to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the RGB alpha texture
  11814. */
  11815. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. /**
  11817. * Creates a RGBA texture from some data.
  11818. * @param data Define the texture data
  11819. * @param width Define the width of the texture
  11820. * @param height Define the height of the texture
  11821. * @param scene Define the scene the texture belongs to
  11822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11826. * @returns the RGBA texture
  11827. */
  11828. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11829. /**
  11830. * Creates a R texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param scene Define the scene the texture belongs to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11839. * @returns the R texture
  11840. */
  11841. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11842. }
  11843. }
  11844. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11845. import { Scene } from "babylonjs/scene";
  11846. import { ISceneComponent } from "babylonjs/sceneComponent";
  11847. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11848. module "babylonjs/abstractScene" {
  11849. interface AbstractScene {
  11850. /**
  11851. * The list of procedural textures added to the scene
  11852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11853. */
  11854. proceduralTextures: Array<ProceduralTexture>;
  11855. }
  11856. }
  11857. /**
  11858. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11859. * in a given scene.
  11860. */
  11861. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11862. /**
  11863. * The component name helpfull to identify the component in the list of scene components.
  11864. */
  11865. readonly name: string;
  11866. /**
  11867. * The scene the component belongs to.
  11868. */
  11869. scene: Scene;
  11870. /**
  11871. * Creates a new instance of the component for the given scene
  11872. * @param scene Defines the scene to register the component in
  11873. */
  11874. constructor(scene: Scene);
  11875. /**
  11876. * Registers the component in a given scene
  11877. */
  11878. register(): void;
  11879. /**
  11880. * Rebuilds the elements related to this component in case of
  11881. * context lost for instance.
  11882. */
  11883. rebuild(): void;
  11884. /**
  11885. * Disposes the component and the associated ressources.
  11886. */
  11887. dispose(): void;
  11888. private _beforeClear;
  11889. }
  11890. }
  11891. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11893. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11894. module "babylonjs/Engines/thinEngine" {
  11895. interface ThinEngine {
  11896. /**
  11897. * Creates a new render target cube texture
  11898. * @param size defines the size of the texture
  11899. * @param options defines the options used to create the texture
  11900. * @returns a new render target cube texture stored in an InternalTexture
  11901. */
  11902. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11903. }
  11904. }
  11905. }
  11906. declare module "babylonjs/Shaders/procedural.vertex" {
  11907. /** @hidden */
  11908. export var proceduralVertexShader: {
  11909. name: string;
  11910. shader: string;
  11911. };
  11912. }
  11913. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11914. import { Observable } from "babylonjs/Misc/observable";
  11915. import { Nullable } from "babylonjs/types";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11918. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11919. import { Effect } from "babylonjs/Materials/effect";
  11920. import { Texture } from "babylonjs/Materials/Textures/texture";
  11921. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11922. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11923. import "babylonjs/Shaders/procedural.vertex";
  11924. /**
  11925. * 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.
  11926. * This is the base class of any Procedural texture and contains most of the shareable code.
  11927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11928. */
  11929. export class ProceduralTexture extends Texture {
  11930. isCube: boolean;
  11931. /**
  11932. * Define if the texture is enabled or not (disabled texture will not render)
  11933. */
  11934. isEnabled: boolean;
  11935. /**
  11936. * Define if the texture must be cleared before rendering (default is true)
  11937. */
  11938. autoClear: boolean;
  11939. /**
  11940. * Callback called when the texture is generated
  11941. */
  11942. onGenerated: () => void;
  11943. /**
  11944. * Event raised when the texture is generated
  11945. */
  11946. onGeneratedObservable: Observable<ProceduralTexture>;
  11947. /** @hidden */
  11948. _generateMipMaps: boolean;
  11949. /** @hidden **/
  11950. _effect: Effect;
  11951. /** @hidden */
  11952. _textures: {
  11953. [key: string]: Texture;
  11954. };
  11955. /** @hidden */
  11956. protected _fallbackTexture: Nullable<Texture>;
  11957. private _size;
  11958. private _currentRefreshId;
  11959. private _frameId;
  11960. private _refreshRate;
  11961. private _vertexBuffers;
  11962. private _indexBuffer;
  11963. private _uniforms;
  11964. private _samplers;
  11965. private _fragment;
  11966. private _floats;
  11967. private _ints;
  11968. private _floatsArrays;
  11969. private _colors3;
  11970. private _colors4;
  11971. private _vectors2;
  11972. private _vectors3;
  11973. private _matrices;
  11974. private _fallbackTextureUsed;
  11975. private _fullEngine;
  11976. private _cachedDefines;
  11977. private _contentUpdateId;
  11978. private _contentData;
  11979. /**
  11980. * Instantiates a new procedural texture.
  11981. * 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.
  11982. * This is the base class of any Procedural texture and contains most of the shareable code.
  11983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11984. * @param name Define the name of the texture
  11985. * @param size Define the size of the texture to create
  11986. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11987. * @param scene Define the scene the texture belongs to
  11988. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11989. * @param generateMipMaps Define if the texture should creates mip maps or not
  11990. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11991. */
  11992. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11993. /**
  11994. * The effect that is created when initializing the post process.
  11995. * @returns The created effect corresponding the the postprocess.
  11996. */
  11997. getEffect(): Effect;
  11998. /**
  11999. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12000. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12001. */
  12002. getContent(): Nullable<ArrayBufferView>;
  12003. private _createIndexBuffer;
  12004. /** @hidden */
  12005. _rebuild(): void;
  12006. /**
  12007. * Resets the texture in order to recreate its associated resources.
  12008. * This can be called in case of context loss
  12009. */
  12010. reset(): void;
  12011. protected _getDefines(): string;
  12012. /**
  12013. * Is the texture ready to be used ? (rendered at least once)
  12014. * @returns true if ready, otherwise, false.
  12015. */
  12016. isReady(): boolean;
  12017. /**
  12018. * Resets the refresh counter of the texture and start bak from scratch.
  12019. * Could be useful to regenerate the texture if it is setup to render only once.
  12020. */
  12021. resetRefreshCounter(): void;
  12022. /**
  12023. * Set the fragment shader to use in order to render the texture.
  12024. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12025. */
  12026. setFragment(fragment: any): void;
  12027. /**
  12028. * Define the refresh rate of the texture or the rendering frequency.
  12029. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12030. */
  12031. get refreshRate(): number;
  12032. set refreshRate(value: number);
  12033. /** @hidden */
  12034. _shouldRender(): boolean;
  12035. /**
  12036. * Get the size the texture is rendering at.
  12037. * @returns the size (texture is always squared)
  12038. */
  12039. getRenderSize(): number;
  12040. /**
  12041. * Resize the texture to new value.
  12042. * @param size Define the new size the texture should have
  12043. * @param generateMipMaps Define whether the new texture should create mip maps
  12044. */
  12045. resize(size: number, generateMipMaps: boolean): void;
  12046. private _checkUniform;
  12047. /**
  12048. * Set a texture in the shader program used to render.
  12049. * @param name Define the name of the uniform samplers as defined in the shader
  12050. * @param texture Define the texture to bind to this sampler
  12051. * @return the texture itself allowing "fluent" like uniform updates
  12052. */
  12053. setTexture(name: string, texture: Texture): ProceduralTexture;
  12054. /**
  12055. * Set a float in the shader.
  12056. * @param name Define the name of the uniform as defined in the shader
  12057. * @param value Define the value to give to the uniform
  12058. * @return the texture itself allowing "fluent" like uniform updates
  12059. */
  12060. setFloat(name: string, value: number): ProceduralTexture;
  12061. /**
  12062. * Set a int in the shader.
  12063. * @param name Define the name of the uniform as defined in the shader
  12064. * @param value Define the value to give to the uniform
  12065. * @return the texture itself allowing "fluent" like uniform updates
  12066. */
  12067. setInt(name: string, value: number): ProceduralTexture;
  12068. /**
  12069. * Set an array of floats in the shader.
  12070. * @param name Define the name of the uniform as defined in the shader
  12071. * @param value Define the value to give to the uniform
  12072. * @return the texture itself allowing "fluent" like uniform updates
  12073. */
  12074. setFloats(name: string, value: number[]): ProceduralTexture;
  12075. /**
  12076. * Set a vec3 in the shader from a Color3.
  12077. * @param name Define the name of the uniform as defined in the shader
  12078. * @param value Define the value to give to the uniform
  12079. * @return the texture itself allowing "fluent" like uniform updates
  12080. */
  12081. setColor3(name: string, value: Color3): ProceduralTexture;
  12082. /**
  12083. * Set a vec4 in the shader from a Color4.
  12084. * @param name Define the name of the uniform as defined in the shader
  12085. * @param value Define the value to give to the uniform
  12086. * @return the texture itself allowing "fluent" like uniform updates
  12087. */
  12088. setColor4(name: string, value: Color4): ProceduralTexture;
  12089. /**
  12090. * Set a vec2 in the shader from a Vector2.
  12091. * @param name Define the name of the uniform as defined in the shader
  12092. * @param value Define the value to give to the uniform
  12093. * @return the texture itself allowing "fluent" like uniform updates
  12094. */
  12095. setVector2(name: string, value: Vector2): ProceduralTexture;
  12096. /**
  12097. * Set a vec3 in the shader from a Vector3.
  12098. * @param name Define the name of the uniform as defined in the shader
  12099. * @param value Define the value to give to the uniform
  12100. * @return the texture itself allowing "fluent" like uniform updates
  12101. */
  12102. setVector3(name: string, value: Vector3): ProceduralTexture;
  12103. /**
  12104. * Set a mat4 in the shader from a MAtrix.
  12105. * @param name Define the name of the uniform as defined in the shader
  12106. * @param value Define the value to give to the uniform
  12107. * @return the texture itself allowing "fluent" like uniform updates
  12108. */
  12109. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12110. /**
  12111. * Render the texture to its associated render target.
  12112. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12113. */
  12114. render(useCameraPostProcess?: boolean): void;
  12115. /**
  12116. * Clone the texture.
  12117. * @returns the cloned texture
  12118. */
  12119. clone(): ProceduralTexture;
  12120. /**
  12121. * Dispose the texture and release its asoociated resources.
  12122. */
  12123. dispose(): void;
  12124. }
  12125. }
  12126. declare module "babylonjs/Particles/baseParticleSystem" {
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12130. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12131. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12133. import { Scene } from "babylonjs/scene";
  12134. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12135. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12136. import { Texture } from "babylonjs/Materials/Textures/texture";
  12137. import { Color4 } from "babylonjs/Maths/math.color";
  12138. import { Animation } from "babylonjs/Animations/animation";
  12139. /**
  12140. * This represents the base class for particle system in Babylon.
  12141. * 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.
  12142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12143. * @example https://doc.babylonjs.com/babylon101/particles
  12144. */
  12145. export class BaseParticleSystem {
  12146. /**
  12147. * Source color is added to the destination color without alpha affecting the result
  12148. */
  12149. static BLENDMODE_ONEONE: number;
  12150. /**
  12151. * Blend current color and particle color using particle’s alpha
  12152. */
  12153. static BLENDMODE_STANDARD: number;
  12154. /**
  12155. * Add current color and particle color multiplied by particle’s alpha
  12156. */
  12157. static BLENDMODE_ADD: number;
  12158. /**
  12159. * Multiply current color with particle color
  12160. */
  12161. static BLENDMODE_MULTIPLY: number;
  12162. /**
  12163. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12164. */
  12165. static BLENDMODE_MULTIPLYADD: number;
  12166. /**
  12167. * List of animations used by the particle system.
  12168. */
  12169. animations: Animation[];
  12170. /**
  12171. * Gets or sets the unique id of the particle system
  12172. */
  12173. uniqueId: number;
  12174. /**
  12175. * The id of the Particle system.
  12176. */
  12177. id: string;
  12178. /**
  12179. * The friendly name of the Particle system.
  12180. */
  12181. name: string;
  12182. /**
  12183. * Snippet ID if the particle system was created from the snippet server
  12184. */
  12185. snippetId: string;
  12186. /**
  12187. * The rendering group used by the Particle system to chose when to render.
  12188. */
  12189. renderingGroupId: number;
  12190. /**
  12191. * The emitter represents the Mesh or position we are attaching the particle system to.
  12192. */
  12193. emitter: Nullable<AbstractMesh | Vector3>;
  12194. /**
  12195. * The maximum number of particles to emit per frame
  12196. */
  12197. emitRate: number;
  12198. /**
  12199. * If you want to launch only a few particles at once, that can be done, as well.
  12200. */
  12201. manualEmitCount: number;
  12202. /**
  12203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12204. */
  12205. updateSpeed: number;
  12206. /**
  12207. * The amount of time the particle system is running (depends of the overall update speed).
  12208. */
  12209. targetStopDuration: number;
  12210. /**
  12211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12212. */
  12213. disposeOnStop: boolean;
  12214. /**
  12215. * Minimum power of emitting particles.
  12216. */
  12217. minEmitPower: number;
  12218. /**
  12219. * Maximum power of emitting particles.
  12220. */
  12221. maxEmitPower: number;
  12222. /**
  12223. * Minimum life time of emitting particles.
  12224. */
  12225. minLifeTime: number;
  12226. /**
  12227. * Maximum life time of emitting particles.
  12228. */
  12229. maxLifeTime: number;
  12230. /**
  12231. * Minimum Size of emitting particles.
  12232. */
  12233. minSize: number;
  12234. /**
  12235. * Maximum Size of emitting particles.
  12236. */
  12237. maxSize: number;
  12238. /**
  12239. * Minimum scale of emitting particles on X axis.
  12240. */
  12241. minScaleX: number;
  12242. /**
  12243. * Maximum scale of emitting particles on X axis.
  12244. */
  12245. maxScaleX: number;
  12246. /**
  12247. * Minimum scale of emitting particles on Y axis.
  12248. */
  12249. minScaleY: number;
  12250. /**
  12251. * Maximum scale of emitting particles on Y axis.
  12252. */
  12253. maxScaleY: number;
  12254. /**
  12255. * Gets or sets the minimal initial rotation in radians.
  12256. */
  12257. minInitialRotation: number;
  12258. /**
  12259. * Gets or sets the maximal initial rotation in radians.
  12260. */
  12261. maxInitialRotation: number;
  12262. /**
  12263. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12264. */
  12265. minAngularSpeed: number;
  12266. /**
  12267. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12268. */
  12269. maxAngularSpeed: number;
  12270. /**
  12271. * The texture used to render each particle. (this can be a spritesheet)
  12272. */
  12273. particleTexture: Nullable<Texture>;
  12274. /**
  12275. * The layer mask we are rendering the particles through.
  12276. */
  12277. layerMask: number;
  12278. /**
  12279. * This can help using your own shader to render the particle system.
  12280. * The according effect will be created
  12281. */
  12282. customShader: any;
  12283. /**
  12284. * By default particle system starts as soon as they are created. This prevents the
  12285. * automatic start to happen and let you decide when to start emitting particles.
  12286. */
  12287. preventAutoStart: boolean;
  12288. private _noiseTexture;
  12289. /**
  12290. * Gets or sets a texture used to add random noise to particle positions
  12291. */
  12292. get noiseTexture(): Nullable<ProceduralTexture>;
  12293. set noiseTexture(value: Nullable<ProceduralTexture>);
  12294. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12295. noiseStrength: Vector3;
  12296. /**
  12297. * Callback triggered when the particle animation is ending.
  12298. */
  12299. onAnimationEnd: Nullable<() => void>;
  12300. /**
  12301. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12302. */
  12303. blendMode: number;
  12304. /**
  12305. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12306. * to override the particles.
  12307. */
  12308. forceDepthWrite: boolean;
  12309. /** 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 */
  12310. preWarmCycles: number;
  12311. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12312. preWarmStepOffset: number;
  12313. /**
  12314. * 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)
  12315. */
  12316. spriteCellChangeSpeed: number;
  12317. /**
  12318. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12319. */
  12320. startSpriteCellID: number;
  12321. /**
  12322. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12323. */
  12324. endSpriteCellID: number;
  12325. /**
  12326. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12327. */
  12328. spriteCellWidth: number;
  12329. /**
  12330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12331. */
  12332. spriteCellHeight: number;
  12333. /**
  12334. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12335. */
  12336. spriteRandomStartCell: boolean;
  12337. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12338. translationPivot: Vector2;
  12339. /** @hidden */
  12340. protected _isAnimationSheetEnabled: boolean;
  12341. /**
  12342. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12343. */
  12344. beginAnimationOnStart: boolean;
  12345. /**
  12346. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12347. */
  12348. beginAnimationFrom: number;
  12349. /**
  12350. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12351. */
  12352. beginAnimationTo: number;
  12353. /**
  12354. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12355. */
  12356. beginAnimationLoop: boolean;
  12357. /**
  12358. * Gets or sets a world offset applied to all particles
  12359. */
  12360. worldOffset: Vector3;
  12361. /**
  12362. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12363. */
  12364. get isAnimationSheetEnabled(): boolean;
  12365. set isAnimationSheetEnabled(value: boolean);
  12366. /**
  12367. * Get hosting scene
  12368. * @returns the scene
  12369. */
  12370. getScene(): Scene;
  12371. /**
  12372. * You can use gravity if you want to give an orientation to your particles.
  12373. */
  12374. gravity: Vector3;
  12375. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12376. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12378. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12379. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12381. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12382. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12383. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12384. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12385. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12387. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12388. /**
  12389. * Defines the delay in milliseconds before starting the system (0 by default)
  12390. */
  12391. startDelay: number;
  12392. /**
  12393. * Gets the current list of drag gradients.
  12394. * You must use addDragGradient and removeDragGradient to udpate this list
  12395. * @returns the list of drag gradients
  12396. */
  12397. getDragGradients(): Nullable<Array<FactorGradient>>;
  12398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12399. limitVelocityDamping: number;
  12400. /**
  12401. * Gets the current list of limit velocity gradients.
  12402. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12403. * @returns the list of limit velocity gradients
  12404. */
  12405. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12406. /**
  12407. * Gets the current list of color gradients.
  12408. * You must use addColorGradient and removeColorGradient to udpate this list
  12409. * @returns the list of color gradients
  12410. */
  12411. getColorGradients(): Nullable<Array<ColorGradient>>;
  12412. /**
  12413. * Gets the current list of size gradients.
  12414. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12415. * @returns the list of size gradients
  12416. */
  12417. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12418. /**
  12419. * Gets the current list of color remap gradients.
  12420. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12421. * @returns the list of color remap gradients
  12422. */
  12423. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12424. /**
  12425. * Gets the current list of alpha remap gradients.
  12426. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12427. * @returns the list of alpha remap gradients
  12428. */
  12429. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12430. /**
  12431. * Gets the current list of life time gradients.
  12432. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12433. * @returns the list of life time gradients
  12434. */
  12435. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12436. /**
  12437. * Gets the current list of angular speed gradients.
  12438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12439. * @returns the list of angular speed gradients
  12440. */
  12441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12442. /**
  12443. * Gets the current list of velocity gradients.
  12444. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12445. * @returns the list of velocity gradients
  12446. */
  12447. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12448. /**
  12449. * Gets the current list of start size gradients.
  12450. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12451. * @returns the list of start size gradients
  12452. */
  12453. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12454. /**
  12455. * Gets the current list of emit rate gradients.
  12456. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12457. * @returns the list of emit rate gradients
  12458. */
  12459. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12460. /**
  12461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12462. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12463. */
  12464. get direction1(): Vector3;
  12465. set direction1(value: Vector3);
  12466. /**
  12467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12468. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12469. */
  12470. get direction2(): Vector3;
  12471. set direction2(value: Vector3);
  12472. /**
  12473. * 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.
  12474. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12475. */
  12476. get minEmitBox(): Vector3;
  12477. set minEmitBox(value: Vector3);
  12478. /**
  12479. * 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.
  12480. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12481. */
  12482. get maxEmitBox(): Vector3;
  12483. set maxEmitBox(value: Vector3);
  12484. /**
  12485. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12486. */
  12487. color1: Color4;
  12488. /**
  12489. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12490. */
  12491. color2: Color4;
  12492. /**
  12493. * Color the particle will have at the end of its lifetime
  12494. */
  12495. colorDead: Color4;
  12496. /**
  12497. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12498. */
  12499. textureMask: Color4;
  12500. /**
  12501. * The particle emitter type defines the emitter used by the particle system.
  12502. * It can be for example box, sphere, or cone...
  12503. */
  12504. particleEmitterType: IParticleEmitterType;
  12505. /** @hidden */
  12506. _isSubEmitter: boolean;
  12507. /**
  12508. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12509. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12510. */
  12511. billboardMode: number;
  12512. protected _isBillboardBased: boolean;
  12513. /**
  12514. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12515. */
  12516. get isBillboardBased(): boolean;
  12517. set isBillboardBased(value: boolean);
  12518. /**
  12519. * The scene the particle system belongs to.
  12520. */
  12521. protected _scene: Scene;
  12522. /**
  12523. * Local cache of defines for image processing.
  12524. */
  12525. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12526. /**
  12527. * Default configuration related to image processing available in the standard Material.
  12528. */
  12529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12530. /**
  12531. * Gets the image processing configuration used either in this material.
  12532. */
  12533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12534. /**
  12535. * Sets the Default image processing configuration used either in the this material.
  12536. *
  12537. * If sets to null, the scene one is in use.
  12538. */
  12539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12540. /**
  12541. * Attaches a new image processing configuration to the Standard Material.
  12542. * @param configuration
  12543. */
  12544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12545. /** @hidden */
  12546. protected _reset(): void;
  12547. /** @hidden */
  12548. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12549. /**
  12550. * Instantiates a particle system.
  12551. * 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.
  12552. * @param name The name of the particle system
  12553. */
  12554. constructor(name: string);
  12555. /**
  12556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12559. * @returns the emitter
  12560. */
  12561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12562. /**
  12563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12564. * @param radius The radius of the hemisphere to emit from
  12565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12566. * @returns the emitter
  12567. */
  12568. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12569. /**
  12570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12571. * @param radius The radius of the sphere to emit from
  12572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12573. * @returns the emitter
  12574. */
  12575. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12576. /**
  12577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12578. * @param radius The radius of the sphere to emit from
  12579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12581. * @returns the emitter
  12582. */
  12583. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12584. /**
  12585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12586. * @param radius The radius of the emission cylinder
  12587. * @param height The height of the emission cylinder
  12588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12590. * @returns the emitter
  12591. */
  12592. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12593. /**
  12594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12595. * @param radius The radius of the cylinder to emit from
  12596. * @param height The height of the emission cylinder
  12597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12600. * @returns the emitter
  12601. */
  12602. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12603. /**
  12604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12605. * @param radius The radius of the cone to emit from
  12606. * @param angle The base angle of the cone
  12607. * @returns the emitter
  12608. */
  12609. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12610. /**
  12611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12616. * @returns the emitter
  12617. */
  12618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12619. }
  12620. }
  12621. declare module "babylonjs/Particles/subEmitter" {
  12622. import { Scene } from "babylonjs/scene";
  12623. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12624. /**
  12625. * Type of sub emitter
  12626. */
  12627. export enum SubEmitterType {
  12628. /**
  12629. * Attached to the particle over it's lifetime
  12630. */
  12631. ATTACHED = 0,
  12632. /**
  12633. * Created when the particle dies
  12634. */
  12635. END = 1
  12636. }
  12637. /**
  12638. * Sub emitter class used to emit particles from an existing particle
  12639. */
  12640. export class SubEmitter {
  12641. /**
  12642. * the particle system to be used by the sub emitter
  12643. */
  12644. particleSystem: ParticleSystem;
  12645. /**
  12646. * Type of the submitter (Default: END)
  12647. */
  12648. type: SubEmitterType;
  12649. /**
  12650. * 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)
  12651. * Note: This only is supported when using an emitter of type Mesh
  12652. */
  12653. inheritDirection: boolean;
  12654. /**
  12655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12656. */
  12657. inheritedVelocityAmount: number;
  12658. /**
  12659. * Creates a sub emitter
  12660. * @param particleSystem the particle system to be used by the sub emitter
  12661. */
  12662. constructor(
  12663. /**
  12664. * the particle system to be used by the sub emitter
  12665. */
  12666. particleSystem: ParticleSystem);
  12667. /**
  12668. * Clones the sub emitter
  12669. * @returns the cloned sub emitter
  12670. */
  12671. clone(): SubEmitter;
  12672. /**
  12673. * Serialize current object to a JSON object
  12674. * @returns the serialized object
  12675. */
  12676. serialize(): any;
  12677. /** @hidden */
  12678. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12679. /**
  12680. * Creates a new SubEmitter from a serialized JSON version
  12681. * @param serializationObject defines the JSON object to read from
  12682. * @param scene defines the hosting scene
  12683. * @param rootUrl defines the rootUrl for data loading
  12684. * @returns a new SubEmitter
  12685. */
  12686. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12687. /** Release associated resources */
  12688. dispose(): void;
  12689. }
  12690. }
  12691. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12692. /** @hidden */
  12693. export var imageProcessingDeclaration: {
  12694. name: string;
  12695. shader: string;
  12696. };
  12697. }
  12698. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12699. /** @hidden */
  12700. export var imageProcessingFunctions: {
  12701. name: string;
  12702. shader: string;
  12703. };
  12704. }
  12705. declare module "babylonjs/Shaders/particles.fragment" {
  12706. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12708. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12709. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12711. /** @hidden */
  12712. export var particlesPixelShader: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module "babylonjs/Shaders/particles.vertex" {
  12718. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12719. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12720. /** @hidden */
  12721. export var particlesVertexShader: {
  12722. name: string;
  12723. shader: string;
  12724. };
  12725. }
  12726. declare module "babylonjs/Particles/particleSystem" {
  12727. import { Nullable } from "babylonjs/types";
  12728. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12729. import { Observable } from "babylonjs/Misc/observable";
  12730. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12731. import { Effect } from "babylonjs/Materials/effect";
  12732. import { Scene, IDisposable } from "babylonjs/scene";
  12733. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12734. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12735. import { Particle } from "babylonjs/Particles/particle";
  12736. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12738. import "babylonjs/Shaders/particles.fragment";
  12739. import "babylonjs/Shaders/particles.vertex";
  12740. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12741. /**
  12742. * This represents a particle system in Babylon.
  12743. * 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.
  12744. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12745. * @example https://doc.babylonjs.com/babylon101/particles
  12746. */
  12747. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12748. /**
  12749. * Billboard mode will only apply to Y axis
  12750. */
  12751. static readonly BILLBOARDMODE_Y: number;
  12752. /**
  12753. * Billboard mode will apply to all axes
  12754. */
  12755. static readonly BILLBOARDMODE_ALL: number;
  12756. /**
  12757. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12758. */
  12759. static readonly BILLBOARDMODE_STRETCHED: number;
  12760. /**
  12761. * This function can be defined to provide custom update for active particles.
  12762. * This function will be called instead of regular update (age, position, color, etc.).
  12763. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12764. */
  12765. updateFunction: (particles: Particle[]) => void;
  12766. private _emitterWorldMatrix;
  12767. /**
  12768. * This function can be defined to specify initial direction for every new particle.
  12769. * It by default use the emitterType defined function
  12770. */
  12771. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12772. /**
  12773. * This function can be defined to specify initial position for every new particle.
  12774. * It by default use the emitterType defined function
  12775. */
  12776. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12777. /**
  12778. * @hidden
  12779. */
  12780. _inheritedVelocityOffset: Vector3;
  12781. /**
  12782. * An event triggered when the system is disposed
  12783. */
  12784. onDisposeObservable: Observable<IParticleSystem>;
  12785. private _onDisposeObserver;
  12786. /**
  12787. * Sets a callback that will be triggered when the system is disposed
  12788. */
  12789. set onDispose(callback: () => void);
  12790. private _particles;
  12791. private _epsilon;
  12792. private _capacity;
  12793. private _stockParticles;
  12794. private _newPartsExcess;
  12795. private _vertexData;
  12796. private _vertexBuffer;
  12797. private _vertexBuffers;
  12798. private _spriteBuffer;
  12799. private _indexBuffer;
  12800. private _effect;
  12801. private _customEffect;
  12802. private _cachedDefines;
  12803. private _scaledColorStep;
  12804. private _colorDiff;
  12805. private _scaledDirection;
  12806. private _scaledGravity;
  12807. private _currentRenderId;
  12808. private _alive;
  12809. private _useInstancing;
  12810. private _started;
  12811. private _stopped;
  12812. private _actualFrame;
  12813. private _scaledUpdateSpeed;
  12814. private _vertexBufferSize;
  12815. /** @hidden */
  12816. _currentEmitRateGradient: Nullable<FactorGradient>;
  12817. /** @hidden */
  12818. _currentEmitRate1: number;
  12819. /** @hidden */
  12820. _currentEmitRate2: number;
  12821. /** @hidden */
  12822. _currentStartSizeGradient: Nullable<FactorGradient>;
  12823. /** @hidden */
  12824. _currentStartSize1: number;
  12825. /** @hidden */
  12826. _currentStartSize2: number;
  12827. private readonly _rawTextureWidth;
  12828. private _rampGradientsTexture;
  12829. private _useRampGradients;
  12830. /** Gets or sets a boolean indicating that ramp gradients must be used
  12831. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12832. */
  12833. get useRampGradients(): boolean;
  12834. set useRampGradients(value: boolean);
  12835. /**
  12836. * 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.
  12837. * 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: [])
  12838. */
  12839. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12840. private _subEmitters;
  12841. /**
  12842. * @hidden
  12843. * If the particle systems emitter should be disposed when the particle system is disposed
  12844. */
  12845. _disposeEmitterOnDispose: boolean;
  12846. /**
  12847. * The current active Sub-systems, this property is used by the root particle system only.
  12848. */
  12849. activeSubSystems: Array<ParticleSystem>;
  12850. /**
  12851. * Specifies if the particles are updated in emitter local space or world space
  12852. */
  12853. isLocal: boolean;
  12854. private _rootParticleSystem;
  12855. /**
  12856. * Gets the current list of active particles
  12857. */
  12858. get particles(): Particle[];
  12859. /**
  12860. * Gets the number of particles active at the same time.
  12861. * @returns The number of active particles.
  12862. */
  12863. getActiveCount(): number;
  12864. /**
  12865. * Returns the string "ParticleSystem"
  12866. * @returns a string containing the class name
  12867. */
  12868. getClassName(): string;
  12869. /**
  12870. * Gets a boolean indicating that the system is stopping
  12871. * @returns true if the system is currently stopping
  12872. */
  12873. isStopping(): boolean;
  12874. /**
  12875. * Gets the custom effect used to render the particles
  12876. * @param blendMode Blend mode for which the effect should be retrieved
  12877. * @returns The effect
  12878. */
  12879. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12880. /**
  12881. * Sets the custom effect used to render the particles
  12882. * @param effect The effect to set
  12883. * @param blendMode Blend mode for which the effect should be set
  12884. */
  12885. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12886. /** @hidden */
  12887. private _onBeforeDrawParticlesObservable;
  12888. /**
  12889. * Observable that will be called just before the particles are drawn
  12890. */
  12891. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12892. /**
  12893. * Gets the name of the particle vertex shader
  12894. */
  12895. get vertexShaderName(): string;
  12896. /**
  12897. * Instantiates a particle system.
  12898. * 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.
  12899. * @param name The name of the particle system
  12900. * @param capacity The max number of particles alive at the same time
  12901. * @param scene The scene the particle system belongs to
  12902. * @param customEffect a custom effect used to change the way particles are rendered by default
  12903. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12904. * @param epsilon Offset used to render the particles
  12905. */
  12906. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12907. private _addFactorGradient;
  12908. private _removeFactorGradient;
  12909. /**
  12910. * Adds a new life time gradient
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the life time factor to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific life time gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12923. /**
  12924. * Adds a new size gradient
  12925. * @param gradient defines the gradient to use (between 0 and 1)
  12926. * @param factor defines the size factor to affect to the specified gradient
  12927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12928. * @returns the current particle system
  12929. */
  12930. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12931. /**
  12932. * Remove a specific size gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeSizeGradient(gradient: number): IParticleSystem;
  12937. /**
  12938. * Adds a new color remap gradient
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param min defines the color remap minimal range
  12941. * @param max defines the color remap maximal range
  12942. * @returns the current particle system
  12943. */
  12944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12945. /**
  12946. * Remove a specific color remap gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns the current particle system
  12949. */
  12950. removeColorRemapGradient(gradient: number): IParticleSystem;
  12951. /**
  12952. * Adds a new alpha remap gradient
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param min defines the alpha remap minimal range
  12955. * @param max defines the alpha remap maximal range
  12956. * @returns the current particle system
  12957. */
  12958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12959. /**
  12960. * Remove a specific alpha remap gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12965. /**
  12966. * Adds a new angular speed gradient
  12967. * @param gradient defines the gradient to use (between 0 and 1)
  12968. * @param factor defines the angular speed to affect to the specified gradient
  12969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12970. * @returns the current particle system
  12971. */
  12972. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12973. /**
  12974. * Remove a specific angular speed gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns the current particle system
  12977. */
  12978. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12979. /**
  12980. * Adds a new velocity gradient
  12981. * @param gradient defines the gradient to use (between 0 and 1)
  12982. * @param factor defines the velocity to affect to the specified gradient
  12983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12984. * @returns the current particle system
  12985. */
  12986. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12987. /**
  12988. * Remove a specific velocity gradient
  12989. * @param gradient defines the gradient to remove
  12990. * @returns the current particle system
  12991. */
  12992. removeVelocityGradient(gradient: number): IParticleSystem;
  12993. /**
  12994. * Adds a new limit velocity gradient
  12995. * @param gradient defines the gradient to use (between 0 and 1)
  12996. * @param factor defines the limit velocity value to affect to the specified gradient
  12997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12998. * @returns the current particle system
  12999. */
  13000. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13001. /**
  13002. * Remove a specific limit velocity gradient
  13003. * @param gradient defines the gradient to remove
  13004. * @returns the current particle system
  13005. */
  13006. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13007. /**
  13008. * Adds a new drag gradient
  13009. * @param gradient defines the gradient to use (between 0 and 1)
  13010. * @param factor defines the drag value to affect to the specified gradient
  13011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13012. * @returns the current particle system
  13013. */
  13014. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13015. /**
  13016. * Remove a specific drag gradient
  13017. * @param gradient defines the gradient to remove
  13018. * @returns the current particle system
  13019. */
  13020. removeDragGradient(gradient: number): IParticleSystem;
  13021. /**
  13022. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13023. * @param gradient defines the gradient to use (between 0 and 1)
  13024. * @param factor defines the emit rate value to affect to the specified gradient
  13025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13026. * @returns the current particle system
  13027. */
  13028. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13029. /**
  13030. * Remove a specific emit rate gradient
  13031. * @param gradient defines the gradient to remove
  13032. * @returns the current particle system
  13033. */
  13034. removeEmitRateGradient(gradient: number): IParticleSystem;
  13035. /**
  13036. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13037. * @param gradient defines the gradient to use (between 0 and 1)
  13038. * @param factor defines the start size value to affect to the specified gradient
  13039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13040. * @returns the current particle system
  13041. */
  13042. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13043. /**
  13044. * Remove a specific start size gradient
  13045. * @param gradient defines the gradient to remove
  13046. * @returns the current particle system
  13047. */
  13048. removeStartSizeGradient(gradient: number): IParticleSystem;
  13049. private _createRampGradientTexture;
  13050. /**
  13051. * Gets the current list of ramp gradients.
  13052. * You must use addRampGradient and removeRampGradient to udpate this list
  13053. * @returns the list of ramp gradients
  13054. */
  13055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13056. /** Force the system to rebuild all gradients that need to be resync */
  13057. forceRefreshGradients(): void;
  13058. private _syncRampGradientTexture;
  13059. /**
  13060. * Adds a new ramp gradient used to remap particle colors
  13061. * @param gradient defines the gradient to use (between 0 and 1)
  13062. * @param color defines the color to affect to the specified gradient
  13063. * @returns the current particle system
  13064. */
  13065. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13066. /**
  13067. * Remove a specific ramp gradient
  13068. * @param gradient defines the gradient to remove
  13069. * @returns the current particle system
  13070. */
  13071. removeRampGradient(gradient: number): ParticleSystem;
  13072. /**
  13073. * Adds a new color gradient
  13074. * @param gradient defines the gradient to use (between 0 and 1)
  13075. * @param color1 defines the color to affect to the specified gradient
  13076. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13077. * @returns this particle system
  13078. */
  13079. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13080. /**
  13081. * Remove a specific color gradient
  13082. * @param gradient defines the gradient to remove
  13083. * @returns this particle system
  13084. */
  13085. removeColorGradient(gradient: number): IParticleSystem;
  13086. private _fetchR;
  13087. protected _reset(): void;
  13088. private _resetEffect;
  13089. private _createVertexBuffers;
  13090. private _createIndexBuffer;
  13091. /**
  13092. * Gets the maximum number of particles active at the same time.
  13093. * @returns The max number of active particles.
  13094. */
  13095. getCapacity(): number;
  13096. /**
  13097. * Gets whether there are still active particles in the system.
  13098. * @returns True if it is alive, otherwise false.
  13099. */
  13100. isAlive(): boolean;
  13101. /**
  13102. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13103. * @returns True if it has been started, otherwise false.
  13104. */
  13105. isStarted(): boolean;
  13106. private _prepareSubEmitterInternalArray;
  13107. /**
  13108. * Starts the particle system and begins to emit
  13109. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13110. */
  13111. start(delay?: number): void;
  13112. /**
  13113. * Stops the particle system.
  13114. * @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.
  13115. */
  13116. stop(stopSubEmitters?: boolean): void;
  13117. /**
  13118. * Remove all active particles
  13119. */
  13120. reset(): void;
  13121. /**
  13122. * @hidden (for internal use only)
  13123. */
  13124. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13125. /**
  13126. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13127. * Its lifetime will start back at 0.
  13128. */
  13129. recycleParticle: (particle: Particle) => void;
  13130. private _stopSubEmitters;
  13131. private _createParticle;
  13132. private _removeFromRoot;
  13133. private _emitFromParticle;
  13134. private _update;
  13135. /** @hidden */
  13136. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13137. /** @hidden */
  13138. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13139. /**
  13140. * Fill the defines array according to the current settings of the particle system
  13141. * @param defines Array to be updated
  13142. * @param blendMode blend mode to take into account when updating the array
  13143. */
  13144. fillDefines(defines: Array<string>, blendMode: number): void;
  13145. /**
  13146. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13147. * @param uniforms Uniforms array to fill
  13148. * @param attributes Attributes array to fill
  13149. * @param samplers Samplers array to fill
  13150. */
  13151. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13152. /** @hidden */
  13153. private _getEffect;
  13154. /**
  13155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13156. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13157. */
  13158. animate(preWarmOnly?: boolean): void;
  13159. private _appendParticleVertices;
  13160. /**
  13161. * Rebuilds the particle system.
  13162. */
  13163. rebuild(): void;
  13164. /**
  13165. * Is this system ready to be used/rendered
  13166. * @return true if the system is ready
  13167. */
  13168. isReady(): boolean;
  13169. private _render;
  13170. /**
  13171. * Renders the particle system in its current state.
  13172. * @returns the current number of particles
  13173. */
  13174. render(): number;
  13175. /**
  13176. * Disposes the particle system and free the associated resources
  13177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13178. */
  13179. dispose(disposeTexture?: boolean): void;
  13180. /**
  13181. * Clones the particle system.
  13182. * @param name The name of the cloned object
  13183. * @param newEmitter The new emitter to use
  13184. * @returns the cloned particle system
  13185. */
  13186. clone(name: string, newEmitter: any): ParticleSystem;
  13187. /**
  13188. * Serializes the particle system to a JSON object
  13189. * @param serializeTexture defines if the texture must be serialized as well
  13190. * @returns the JSON object
  13191. */
  13192. serialize(serializeTexture?: boolean): any;
  13193. /** @hidden */
  13194. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13195. /** @hidden */
  13196. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13197. /**
  13198. * Parses a JSON object to create a particle system.
  13199. * @param parsedParticleSystem The JSON object to parse
  13200. * @param scene The scene to create the particle system in
  13201. * @param rootUrl The root url to use to load external dependencies like texture
  13202. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13203. * @returns the Parsed particle system
  13204. */
  13205. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13206. }
  13207. }
  13208. declare module "babylonjs/Particles/particle" {
  13209. import { Nullable } from "babylonjs/types";
  13210. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13211. import { Color4 } from "babylonjs/Maths/math.color";
  13212. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13213. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13214. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13215. /**
  13216. * A particle represents one of the element emitted by a particle system.
  13217. * This is mainly define by its coordinates, direction, velocity and age.
  13218. */
  13219. export class Particle {
  13220. /**
  13221. * The particle system the particle belongs to.
  13222. */
  13223. particleSystem: ParticleSystem;
  13224. private static _Count;
  13225. /**
  13226. * Unique ID of the particle
  13227. */
  13228. id: number;
  13229. /**
  13230. * The world position of the particle in the scene.
  13231. */
  13232. position: Vector3;
  13233. /**
  13234. * The world direction of the particle in the scene.
  13235. */
  13236. direction: Vector3;
  13237. /**
  13238. * The color of the particle.
  13239. */
  13240. color: Color4;
  13241. /**
  13242. * The color change of the particle per step.
  13243. */
  13244. colorStep: Color4;
  13245. /**
  13246. * Defines how long will the life of the particle be.
  13247. */
  13248. lifeTime: number;
  13249. /**
  13250. * The current age of the particle.
  13251. */
  13252. age: number;
  13253. /**
  13254. * The current size of the particle.
  13255. */
  13256. size: number;
  13257. /**
  13258. * The current scale of the particle.
  13259. */
  13260. scale: Vector2;
  13261. /**
  13262. * The current angle of the particle.
  13263. */
  13264. angle: number;
  13265. /**
  13266. * Defines how fast is the angle changing.
  13267. */
  13268. angularSpeed: number;
  13269. /**
  13270. * Defines the cell index used by the particle to be rendered from a sprite.
  13271. */
  13272. cellIndex: number;
  13273. /**
  13274. * The information required to support color remapping
  13275. */
  13276. remapData: Vector4;
  13277. /** @hidden */
  13278. _randomCellOffset?: number;
  13279. /** @hidden */
  13280. _initialDirection: Nullable<Vector3>;
  13281. /** @hidden */
  13282. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13283. /** @hidden */
  13284. _initialStartSpriteCellID: number;
  13285. /** @hidden */
  13286. _initialEndSpriteCellID: number;
  13287. /** @hidden */
  13288. _currentColorGradient: Nullable<ColorGradient>;
  13289. /** @hidden */
  13290. _currentColor1: Color4;
  13291. /** @hidden */
  13292. _currentColor2: Color4;
  13293. /** @hidden */
  13294. _currentSizeGradient: Nullable<FactorGradient>;
  13295. /** @hidden */
  13296. _currentSize1: number;
  13297. /** @hidden */
  13298. _currentSize2: number;
  13299. /** @hidden */
  13300. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13301. /** @hidden */
  13302. _currentAngularSpeed1: number;
  13303. /** @hidden */
  13304. _currentAngularSpeed2: number;
  13305. /** @hidden */
  13306. _currentVelocityGradient: Nullable<FactorGradient>;
  13307. /** @hidden */
  13308. _currentVelocity1: number;
  13309. /** @hidden */
  13310. _currentVelocity2: number;
  13311. /** @hidden */
  13312. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13313. /** @hidden */
  13314. _currentLimitVelocity1: number;
  13315. /** @hidden */
  13316. _currentLimitVelocity2: number;
  13317. /** @hidden */
  13318. _currentDragGradient: Nullable<FactorGradient>;
  13319. /** @hidden */
  13320. _currentDrag1: number;
  13321. /** @hidden */
  13322. _currentDrag2: number;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates1: Vector3;
  13325. /** @hidden */
  13326. _randomNoiseCoordinates2: Vector3;
  13327. /** @hidden */
  13328. _localPosition?: Vector3;
  13329. /**
  13330. * Creates a new instance Particle
  13331. * @param particleSystem the particle system the particle belongs to
  13332. */
  13333. constructor(
  13334. /**
  13335. * The particle system the particle belongs to.
  13336. */
  13337. particleSystem: ParticleSystem);
  13338. private updateCellInfoFromSystem;
  13339. /**
  13340. * Defines how the sprite cell index is updated for the particle
  13341. */
  13342. updateCellIndex(): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13345. /** @hidden */
  13346. _inheritParticleInfoToSubEmitters(): void;
  13347. /** @hidden */
  13348. _reset(): void;
  13349. /**
  13350. * Copy the properties of particle to another one.
  13351. * @param other the particle to copy the information to.
  13352. */
  13353. copyTo(other: Particle): void;
  13354. }
  13355. }
  13356. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13358. import { Effect } from "babylonjs/Materials/effect";
  13359. import { Particle } from "babylonjs/Particles/particle";
  13360. import { Scene } from "babylonjs/scene";
  13361. /**
  13362. * Particle emitter represents a volume emitting particles.
  13363. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13364. */
  13365. export interface IParticleEmitterType {
  13366. /**
  13367. * Called by the particle System when the direction is computed for the created particle.
  13368. * @param worldMatrix is the world matrix of the particle system
  13369. * @param directionToUpdate is the direction vector to update with the result
  13370. * @param particle is the particle we are computed the direction for
  13371. * @param isLocal defines if the direction should be set in local space
  13372. */
  13373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13374. /**
  13375. * Called by the particle System when the position is computed for the created particle.
  13376. * @param worldMatrix is the world matrix of the particle system
  13377. * @param positionToUpdate is the position vector to update with the result
  13378. * @param particle is the particle we are computed the position for
  13379. * @param isLocal defines if the position should be set in local space
  13380. */
  13381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13382. /**
  13383. * Clones the current emitter and returns a copy of it
  13384. * @returns the new emitter
  13385. */
  13386. clone(): IParticleEmitterType;
  13387. /**
  13388. * Called by the GPUParticleSystem to setup the update shader
  13389. * @param effect defines the update shader
  13390. */
  13391. applyToShader(effect: Effect): void;
  13392. /**
  13393. * Returns a string to use to update the GPU particles update shader
  13394. * @returns the effect defines string
  13395. */
  13396. getEffectDefines(): string;
  13397. /**
  13398. * Returns a string representing the class name
  13399. * @returns a string containing the class name
  13400. */
  13401. getClassName(): string;
  13402. /**
  13403. * Serializes the particle system to a JSON object.
  13404. * @returns the JSON object
  13405. */
  13406. serialize(): any;
  13407. /**
  13408. * Parse properties from a JSON object
  13409. * @param serializationObject defines the JSON object
  13410. * @param scene defines the hosting scene
  13411. */
  13412. parse(serializationObject: any, scene: Scene): void;
  13413. }
  13414. }
  13415. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13416. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13417. import { Effect } from "babylonjs/Materials/effect";
  13418. import { Particle } from "babylonjs/Particles/particle";
  13419. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13420. /**
  13421. * Particle emitter emitting particles from the inside of a box.
  13422. * It emits the particles randomly between 2 given directions.
  13423. */
  13424. export class BoxParticleEmitter implements IParticleEmitterType {
  13425. /**
  13426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13427. */
  13428. direction1: Vector3;
  13429. /**
  13430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13431. */
  13432. direction2: Vector3;
  13433. /**
  13434. * 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.
  13435. */
  13436. minEmitBox: Vector3;
  13437. /**
  13438. * 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.
  13439. */
  13440. maxEmitBox: Vector3;
  13441. /**
  13442. * Creates a new instance BoxParticleEmitter
  13443. */
  13444. constructor();
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): BoxParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "BoxParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13494. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13495. import { Effect } from "babylonjs/Materials/effect";
  13496. import { Particle } from "babylonjs/Particles/particle";
  13497. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13498. /**
  13499. * Particle emitter emitting particles from the inside of a cone.
  13500. * It emits the particles alongside the cone volume from the base to the particle.
  13501. * The emission direction might be randomized.
  13502. */
  13503. export class ConeParticleEmitter implements IParticleEmitterType {
  13504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13505. directionRandomizer: number;
  13506. private _radius;
  13507. private _angle;
  13508. private _height;
  13509. /**
  13510. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13511. */
  13512. radiusRange: number;
  13513. /**
  13514. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13515. */
  13516. heightRange: number;
  13517. /**
  13518. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13519. */
  13520. emitFromSpawnPointOnly: boolean;
  13521. /**
  13522. * Gets or sets the radius of the emission cone
  13523. */
  13524. get radius(): number;
  13525. set radius(value: number);
  13526. /**
  13527. * Gets or sets the angle of the emission cone
  13528. */
  13529. get angle(): number;
  13530. set angle(value: number);
  13531. private _buildHeight;
  13532. /**
  13533. * Creates a new instance ConeParticleEmitter
  13534. * @param radius the radius of the emission cone (1 by default)
  13535. * @param angle the cone base angle (PI by default)
  13536. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13537. */
  13538. constructor(radius?: number, angle?: number,
  13539. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13540. directionRandomizer?: number);
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): ConeParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "ConeParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13590. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13591. import { Effect } from "babylonjs/Materials/effect";
  13592. import { Particle } from "babylonjs/Particles/particle";
  13593. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13594. /**
  13595. * Particle emitter emitting particles from the inside of a cylinder.
  13596. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13597. */
  13598. export class CylinderParticleEmitter implements IParticleEmitterType {
  13599. /**
  13600. * The radius of the emission cylinder.
  13601. */
  13602. radius: number;
  13603. /**
  13604. * The height of the emission cylinder.
  13605. */
  13606. height: number;
  13607. /**
  13608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13609. */
  13610. radiusRange: number;
  13611. /**
  13612. * How much to randomize the particle direction [0-1].
  13613. */
  13614. directionRandomizer: number;
  13615. /**
  13616. * Creates a new instance CylinderParticleEmitter
  13617. * @param radius the radius of the emission cylinder (1 by default)
  13618. * @param height the height of the emission cylinder (1 by default)
  13619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13621. */
  13622. constructor(
  13623. /**
  13624. * The radius of the emission cylinder.
  13625. */
  13626. radius?: number,
  13627. /**
  13628. * The height of the emission cylinder.
  13629. */
  13630. height?: number,
  13631. /**
  13632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13633. */
  13634. radiusRange?: number,
  13635. /**
  13636. * How much to randomize the particle direction [0-1].
  13637. */
  13638. directionRandomizer?: number);
  13639. /**
  13640. * Called by the particle System when the direction is computed for the created particle.
  13641. * @param worldMatrix is the world matrix of the particle system
  13642. * @param directionToUpdate is the direction vector to update with the result
  13643. * @param particle is the particle we are computed the direction for
  13644. * @param isLocal defines if the direction should be set in local space
  13645. */
  13646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13647. /**
  13648. * Called by the particle System when the position is computed for the created particle.
  13649. * @param worldMatrix is the world matrix of the particle system
  13650. * @param positionToUpdate is the position vector to update with the result
  13651. * @param particle is the particle we are computed the position for
  13652. * @param isLocal defines if the position should be set in local space
  13653. */
  13654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13655. /**
  13656. * Clones the current emitter and returns a copy of it
  13657. * @returns the new emitter
  13658. */
  13659. clone(): CylinderParticleEmitter;
  13660. /**
  13661. * Called by the GPUParticleSystem to setup the update shader
  13662. * @param effect defines the update shader
  13663. */
  13664. applyToShader(effect: Effect): void;
  13665. /**
  13666. * Returns a string to use to update the GPU particles update shader
  13667. * @returns a string containng the defines string
  13668. */
  13669. getEffectDefines(): string;
  13670. /**
  13671. * Returns the string "CylinderParticleEmitter"
  13672. * @returns a string containing the class name
  13673. */
  13674. getClassName(): string;
  13675. /**
  13676. * Serializes the particle system to a JSON object.
  13677. * @returns the JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Parse properties from a JSON object
  13682. * @param serializationObject defines the JSON object
  13683. */
  13684. parse(serializationObject: any): void;
  13685. }
  13686. /**
  13687. * Particle emitter emitting particles from the inside of a cylinder.
  13688. * It emits the particles randomly between two vectors.
  13689. */
  13690. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1: Vector3;
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2: Vector3;
  13699. /**
  13700. * Creates a new instance CylinderDirectedParticleEmitter
  13701. * @param radius the radius of the emission cylinder (1 by default)
  13702. * @param height the height of the emission cylinder (1 by default)
  13703. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13704. * @param direction1 the min limit of the emission direction (up vector by default)
  13705. * @param direction2 the max limit of the emission direction (up vector by default)
  13706. */
  13707. constructor(radius?: number, height?: number, radiusRange?: number,
  13708. /**
  13709. * The min limit of the emission direction.
  13710. */
  13711. direction1?: Vector3,
  13712. /**
  13713. * The max limit of the emission direction.
  13714. */
  13715. direction2?: Vector3);
  13716. /**
  13717. * Called by the particle System when the direction is computed for the created particle.
  13718. * @param worldMatrix is the world matrix of the particle system
  13719. * @param directionToUpdate is the direction vector to update with the result
  13720. * @param particle is the particle we are computed the direction for
  13721. */
  13722. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13723. /**
  13724. * Clones the current emitter and returns a copy of it
  13725. * @returns the new emitter
  13726. */
  13727. clone(): CylinderDirectedParticleEmitter;
  13728. /**
  13729. * Called by the GPUParticleSystem to setup the update shader
  13730. * @param effect defines the update shader
  13731. */
  13732. applyToShader(effect: Effect): void;
  13733. /**
  13734. * Returns a string to use to update the GPU particles update shader
  13735. * @returns a string containng the defines string
  13736. */
  13737. getEffectDefines(): string;
  13738. /**
  13739. * Returns the string "CylinderDirectedParticleEmitter"
  13740. * @returns a string containing the class name
  13741. */
  13742. getClassName(): string;
  13743. /**
  13744. * Serializes the particle system to a JSON object.
  13745. * @returns the JSON object
  13746. */
  13747. serialize(): any;
  13748. /**
  13749. * Parse properties from a JSON object
  13750. * @param serializationObject defines the JSON object
  13751. */
  13752. parse(serializationObject: any): void;
  13753. }
  13754. }
  13755. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13756. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13757. import { Effect } from "babylonjs/Materials/effect";
  13758. import { Particle } from "babylonjs/Particles/particle";
  13759. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13760. /**
  13761. * Particle emitter emitting particles from the inside of a hemisphere.
  13762. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13763. */
  13764. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13765. /**
  13766. * The radius of the emission hemisphere.
  13767. */
  13768. radius: number;
  13769. /**
  13770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13771. */
  13772. radiusRange: number;
  13773. /**
  13774. * How much to randomize the particle direction [0-1].
  13775. */
  13776. directionRandomizer: number;
  13777. /**
  13778. * Creates a new instance HemisphericParticleEmitter
  13779. * @param radius the radius of the emission hemisphere (1 by default)
  13780. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13781. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13782. */
  13783. constructor(
  13784. /**
  13785. * The radius of the emission hemisphere.
  13786. */
  13787. radius?: number,
  13788. /**
  13789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13790. */
  13791. radiusRange?: number,
  13792. /**
  13793. * How much to randomize the particle direction [0-1].
  13794. */
  13795. directionRandomizer?: number);
  13796. /**
  13797. * Called by the particle System when the direction is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param directionToUpdate is the direction vector to update with the result
  13800. * @param particle is the particle we are computed the direction for
  13801. * @param isLocal defines if the direction should be set in local space
  13802. */
  13803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Called by the particle System when the position is computed for the created particle.
  13806. * @param worldMatrix is the world matrix of the particle system
  13807. * @param positionToUpdate is the position vector to update with the result
  13808. * @param particle is the particle we are computed the position for
  13809. * @param isLocal defines if the position should be set in local space
  13810. */
  13811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13812. /**
  13813. * Clones the current emitter and returns a copy of it
  13814. * @returns the new emitter
  13815. */
  13816. clone(): HemisphericParticleEmitter;
  13817. /**
  13818. * Called by the GPUParticleSystem to setup the update shader
  13819. * @param effect defines the update shader
  13820. */
  13821. applyToShader(effect: Effect): void;
  13822. /**
  13823. * Returns a string to use to update the GPU particles update shader
  13824. * @returns a string containng the defines string
  13825. */
  13826. getEffectDefines(): string;
  13827. /**
  13828. * Returns the string "HemisphericParticleEmitter"
  13829. * @returns a string containing the class name
  13830. */
  13831. getClassName(): string;
  13832. /**
  13833. * Serializes the particle system to a JSON object.
  13834. * @returns the JSON object
  13835. */
  13836. serialize(): any;
  13837. /**
  13838. * Parse properties from a JSON object
  13839. * @param serializationObject defines the JSON object
  13840. */
  13841. parse(serializationObject: any): void;
  13842. }
  13843. }
  13844. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13845. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13846. import { Effect } from "babylonjs/Materials/effect";
  13847. import { Particle } from "babylonjs/Particles/particle";
  13848. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13849. /**
  13850. * Particle emitter emitting particles from a point.
  13851. * It emits the particles randomly between 2 given directions.
  13852. */
  13853. export class PointParticleEmitter implements IParticleEmitterType {
  13854. /**
  13855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13856. */
  13857. direction1: Vector3;
  13858. /**
  13859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13860. */
  13861. direction2: Vector3;
  13862. /**
  13863. * Creates a new instance PointParticleEmitter
  13864. */
  13865. constructor();
  13866. /**
  13867. * Called by the particle System when the direction is computed for the created particle.
  13868. * @param worldMatrix is the world matrix of the particle system
  13869. * @param directionToUpdate is the direction vector to update with the result
  13870. * @param particle is the particle we are computed the direction for
  13871. * @param isLocal defines if the direction should be set in local space
  13872. */
  13873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13874. /**
  13875. * Called by the particle System when the position is computed for the created particle.
  13876. * @param worldMatrix is the world matrix of the particle system
  13877. * @param positionToUpdate is the position vector to update with the result
  13878. * @param particle is the particle we are computed the position for
  13879. * @param isLocal defines if the position should be set in local space
  13880. */
  13881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13882. /**
  13883. * Clones the current emitter and returns a copy of it
  13884. * @returns the new emitter
  13885. */
  13886. clone(): PointParticleEmitter;
  13887. /**
  13888. * Called by the GPUParticleSystem to setup the update shader
  13889. * @param effect defines the update shader
  13890. */
  13891. applyToShader(effect: Effect): void;
  13892. /**
  13893. * Returns a string to use to update the GPU particles update shader
  13894. * @returns a string containng the defines string
  13895. */
  13896. getEffectDefines(): string;
  13897. /**
  13898. * Returns the string "PointParticleEmitter"
  13899. * @returns a string containing the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Serializes the particle system to a JSON object.
  13904. * @returns the JSON object
  13905. */
  13906. serialize(): any;
  13907. /**
  13908. * Parse properties from a JSON object
  13909. * @param serializationObject defines the JSON object
  13910. */
  13911. parse(serializationObject: any): void;
  13912. }
  13913. }
  13914. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13916. import { Effect } from "babylonjs/Materials/effect";
  13917. import { Particle } from "babylonjs/Particles/particle";
  13918. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13919. /**
  13920. * Particle emitter emitting particles from the inside of a sphere.
  13921. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13922. */
  13923. export class SphereParticleEmitter implements IParticleEmitterType {
  13924. /**
  13925. * The radius of the emission sphere.
  13926. */
  13927. radius: number;
  13928. /**
  13929. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13930. */
  13931. radiusRange: number;
  13932. /**
  13933. * How much to randomize the particle direction [0-1].
  13934. */
  13935. directionRandomizer: number;
  13936. /**
  13937. * Creates a new instance SphereParticleEmitter
  13938. * @param radius the radius of the emission sphere (1 by default)
  13939. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13941. */
  13942. constructor(
  13943. /**
  13944. * The radius of the emission sphere.
  13945. */
  13946. radius?: number,
  13947. /**
  13948. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13949. */
  13950. radiusRange?: number,
  13951. /**
  13952. * How much to randomize the particle direction [0-1].
  13953. */
  13954. directionRandomizer?: number);
  13955. /**
  13956. * Called by the particle System when the direction is computed for the created particle.
  13957. * @param worldMatrix is the world matrix of the particle system
  13958. * @param directionToUpdate is the direction vector to update with the result
  13959. * @param particle is the particle we are computed the direction for
  13960. * @param isLocal defines if the direction should be set in local space
  13961. */
  13962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13963. /**
  13964. * Called by the particle System when the position is computed for the created particle.
  13965. * @param worldMatrix is the world matrix of the particle system
  13966. * @param positionToUpdate is the position vector to update with the result
  13967. * @param particle is the particle we are computed the position for
  13968. * @param isLocal defines if the position should be set in local space
  13969. */
  13970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13971. /**
  13972. * Clones the current emitter and returns a copy of it
  13973. * @returns the new emitter
  13974. */
  13975. clone(): SphereParticleEmitter;
  13976. /**
  13977. * Called by the GPUParticleSystem to setup the update shader
  13978. * @param effect defines the update shader
  13979. */
  13980. applyToShader(effect: Effect): void;
  13981. /**
  13982. * Returns a string to use to update the GPU particles update shader
  13983. * @returns a string containng the defines string
  13984. */
  13985. getEffectDefines(): string;
  13986. /**
  13987. * Returns the string "SphereParticleEmitter"
  13988. * @returns a string containing the class name
  13989. */
  13990. getClassName(): string;
  13991. /**
  13992. * Serializes the particle system to a JSON object.
  13993. * @returns the JSON object
  13994. */
  13995. serialize(): any;
  13996. /**
  13997. * Parse properties from a JSON object
  13998. * @param serializationObject defines the JSON object
  13999. */
  14000. parse(serializationObject: any): void;
  14001. }
  14002. /**
  14003. * Particle emitter emitting particles from the inside of a sphere.
  14004. * It emits the particles randomly between two vectors.
  14005. */
  14006. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14007. /**
  14008. * The min limit of the emission direction.
  14009. */
  14010. direction1: Vector3;
  14011. /**
  14012. * The max limit of the emission direction.
  14013. */
  14014. direction2: Vector3;
  14015. /**
  14016. * Creates a new instance SphereDirectedParticleEmitter
  14017. * @param radius the radius of the emission sphere (1 by default)
  14018. * @param direction1 the min limit of the emission direction (up vector by default)
  14019. * @param direction2 the max limit of the emission direction (up vector by default)
  14020. */
  14021. constructor(radius?: number,
  14022. /**
  14023. * The min limit of the emission direction.
  14024. */
  14025. direction1?: Vector3,
  14026. /**
  14027. * The max limit of the emission direction.
  14028. */
  14029. direction2?: Vector3);
  14030. /**
  14031. * Called by the particle System when the direction is computed for the created particle.
  14032. * @param worldMatrix is the world matrix of the particle system
  14033. * @param directionToUpdate is the direction vector to update with the result
  14034. * @param particle is the particle we are computed the direction for
  14035. */
  14036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14037. /**
  14038. * Clones the current emitter and returns a copy of it
  14039. * @returns the new emitter
  14040. */
  14041. clone(): SphereDirectedParticleEmitter;
  14042. /**
  14043. * Called by the GPUParticleSystem to setup the update shader
  14044. * @param effect defines the update shader
  14045. */
  14046. applyToShader(effect: Effect): void;
  14047. /**
  14048. * Returns a string to use to update the GPU particles update shader
  14049. * @returns a string containng the defines string
  14050. */
  14051. getEffectDefines(): string;
  14052. /**
  14053. * Returns the string "SphereDirectedParticleEmitter"
  14054. * @returns a string containing the class name
  14055. */
  14056. getClassName(): string;
  14057. /**
  14058. * Serializes the particle system to a JSON object.
  14059. * @returns the JSON object
  14060. */
  14061. serialize(): any;
  14062. /**
  14063. * Parse properties from a JSON object
  14064. * @param serializationObject defines the JSON object
  14065. */
  14066. parse(serializationObject: any): void;
  14067. }
  14068. }
  14069. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14070. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14071. import { Effect } from "babylonjs/Materials/effect";
  14072. import { Particle } from "babylonjs/Particles/particle";
  14073. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14074. import { Nullable } from "babylonjs/types";
  14075. /**
  14076. * Particle emitter emitting particles from a custom list of positions.
  14077. */
  14078. export class CustomParticleEmitter implements IParticleEmitterType {
  14079. /**
  14080. * Gets or sets the position generator that will create the inital position of each particle.
  14081. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14082. */
  14083. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14084. /**
  14085. * Gets or sets the destination generator that will create the final destination of each particle.
  14086. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14087. */
  14088. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14089. /**
  14090. * Creates a new instance CustomParticleEmitter
  14091. */
  14092. constructor();
  14093. /**
  14094. * Called by the particle System when the direction is computed for the created particle.
  14095. * @param worldMatrix is the world matrix of the particle system
  14096. * @param directionToUpdate is the direction vector to update with the result
  14097. * @param particle is the particle we are computed the direction for
  14098. * @param isLocal defines if the direction should be set in local space
  14099. */
  14100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14101. /**
  14102. * Called by the particle System when the position is computed for the created particle.
  14103. * @param worldMatrix is the world matrix of the particle system
  14104. * @param positionToUpdate is the position vector to update with the result
  14105. * @param particle is the particle we are computed the position for
  14106. * @param isLocal defines if the position should be set in local space
  14107. */
  14108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14109. /**
  14110. * Clones the current emitter and returns a copy of it
  14111. * @returns the new emitter
  14112. */
  14113. clone(): CustomParticleEmitter;
  14114. /**
  14115. * Called by the GPUParticleSystem to setup the update shader
  14116. * @param effect defines the update shader
  14117. */
  14118. applyToShader(effect: Effect): void;
  14119. /**
  14120. * Returns a string to use to update the GPU particles update shader
  14121. * @returns a string containng the defines string
  14122. */
  14123. getEffectDefines(): string;
  14124. /**
  14125. * Returns the string "PointParticleEmitter"
  14126. * @returns a string containing the class name
  14127. */
  14128. getClassName(): string;
  14129. /**
  14130. * Serializes the particle system to a JSON object.
  14131. * @returns the JSON object
  14132. */
  14133. serialize(): any;
  14134. /**
  14135. * Parse properties from a JSON object
  14136. * @param serializationObject defines the JSON object
  14137. */
  14138. parse(serializationObject: any): void;
  14139. }
  14140. }
  14141. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14142. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14143. import { Effect } from "babylonjs/Materials/effect";
  14144. import { Particle } from "babylonjs/Particles/particle";
  14145. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14146. import { Nullable } from "babylonjs/types";
  14147. import { Scene } from "babylonjs/scene";
  14148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14149. /**
  14150. * Particle emitter emitting particles from the inside of a box.
  14151. * It emits the particles randomly between 2 given directions.
  14152. */
  14153. export class MeshParticleEmitter implements IParticleEmitterType {
  14154. private _indices;
  14155. private _positions;
  14156. private _normals;
  14157. private _storedNormal;
  14158. private _mesh;
  14159. /**
  14160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14161. */
  14162. direction1: Vector3;
  14163. /**
  14164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14165. */
  14166. direction2: Vector3;
  14167. /**
  14168. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14169. */
  14170. useMeshNormalsForDirection: boolean;
  14171. /** Defines the mesh to use as source */
  14172. get mesh(): Nullable<AbstractMesh>;
  14173. set mesh(value: Nullable<AbstractMesh>);
  14174. /**
  14175. * Creates a new instance MeshParticleEmitter
  14176. * @param mesh defines the mesh to use as source
  14177. */
  14178. constructor(mesh?: Nullable<AbstractMesh>);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. * @param isLocal defines if the direction should be set in local space
  14185. */
  14186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14187. /**
  14188. * Called by the particle System when the position is computed for the created particle.
  14189. * @param worldMatrix is the world matrix of the particle system
  14190. * @param positionToUpdate is the position vector to update with the result
  14191. * @param particle is the particle we are computed the position for
  14192. * @param isLocal defines if the position should be set in local space
  14193. */
  14194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14195. /**
  14196. * Clones the current emitter and returns a copy of it
  14197. * @returns the new emitter
  14198. */
  14199. clone(): MeshParticleEmitter;
  14200. /**
  14201. * Called by the GPUParticleSystem to setup the update shader
  14202. * @param effect defines the update shader
  14203. */
  14204. applyToShader(effect: Effect): void;
  14205. /**
  14206. * Returns a string to use to update the GPU particles update shader
  14207. * @returns a string containng the defines string
  14208. */
  14209. getEffectDefines(): string;
  14210. /**
  14211. * Returns the string "BoxParticleEmitter"
  14212. * @returns a string containing the class name
  14213. */
  14214. getClassName(): string;
  14215. /**
  14216. * Serializes the particle system to a JSON object.
  14217. * @returns the JSON object
  14218. */
  14219. serialize(): any;
  14220. /**
  14221. * Parse properties from a JSON object
  14222. * @param serializationObject defines the JSON object
  14223. * @param scene defines the hosting scene
  14224. */
  14225. parse(serializationObject: any, scene: Scene): void;
  14226. }
  14227. }
  14228. declare module "babylonjs/Particles/EmitterTypes/index" {
  14229. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14232. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14234. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14236. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14237. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14238. }
  14239. declare module "babylonjs/Particles/IParticleSystem" {
  14240. import { Nullable } from "babylonjs/types";
  14241. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14242. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14245. import { Texture } from "babylonjs/Materials/Textures/texture";
  14246. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14247. import { Scene } from "babylonjs/scene";
  14248. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14249. import { Effect } from "babylonjs/Materials/effect";
  14250. import { Observable } from "babylonjs/Misc/observable";
  14251. import { Animation } from "babylonjs/Animations/animation";
  14252. /**
  14253. * Interface representing a particle system in Babylon.js.
  14254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14256. */
  14257. export interface IParticleSystem {
  14258. /**
  14259. * List of animations used by the particle system.
  14260. */
  14261. animations: Animation[];
  14262. /**
  14263. * The id of the Particle system.
  14264. */
  14265. id: string;
  14266. /**
  14267. * The name of the Particle system.
  14268. */
  14269. name: string;
  14270. /**
  14271. * The emitter represents the Mesh or position we are attaching the particle system to.
  14272. */
  14273. emitter: Nullable<AbstractMesh | Vector3>;
  14274. /**
  14275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14276. */
  14277. isBillboardBased: boolean;
  14278. /**
  14279. * The rendering group used by the Particle system to chose when to render.
  14280. */
  14281. renderingGroupId: number;
  14282. /**
  14283. * The layer mask we are rendering the particles through.
  14284. */
  14285. layerMask: number;
  14286. /**
  14287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14288. */
  14289. updateSpeed: number;
  14290. /**
  14291. * The amount of time the particle system is running (depends of the overall update speed).
  14292. */
  14293. targetStopDuration: number;
  14294. /**
  14295. * The texture used to render each particle. (this can be a spritesheet)
  14296. */
  14297. particleTexture: Nullable<Texture>;
  14298. /**
  14299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14300. */
  14301. blendMode: number;
  14302. /**
  14303. * Minimum life time of emitting particles.
  14304. */
  14305. minLifeTime: number;
  14306. /**
  14307. * Maximum life time of emitting particles.
  14308. */
  14309. maxLifeTime: number;
  14310. /**
  14311. * Minimum Size of emitting particles.
  14312. */
  14313. minSize: number;
  14314. /**
  14315. * Maximum Size of emitting particles.
  14316. */
  14317. maxSize: number;
  14318. /**
  14319. * Minimum scale of emitting particles on X axis.
  14320. */
  14321. minScaleX: number;
  14322. /**
  14323. * Maximum scale of emitting particles on X axis.
  14324. */
  14325. maxScaleX: number;
  14326. /**
  14327. * Minimum scale of emitting particles on Y axis.
  14328. */
  14329. minScaleY: number;
  14330. /**
  14331. * Maximum scale of emitting particles on Y axis.
  14332. */
  14333. maxScaleY: number;
  14334. /**
  14335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14336. */
  14337. color1: Color4;
  14338. /**
  14339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14340. */
  14341. color2: Color4;
  14342. /**
  14343. * Color the particle will have at the end of its lifetime.
  14344. */
  14345. colorDead: Color4;
  14346. /**
  14347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14348. */
  14349. emitRate: number;
  14350. /**
  14351. * You can use gravity if you want to give an orientation to your particles.
  14352. */
  14353. gravity: Vector3;
  14354. /**
  14355. * Minimum power of emitting particles.
  14356. */
  14357. minEmitPower: number;
  14358. /**
  14359. * Maximum power of emitting particles.
  14360. */
  14361. maxEmitPower: number;
  14362. /**
  14363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14364. */
  14365. minAngularSpeed: number;
  14366. /**
  14367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14368. */
  14369. maxAngularSpeed: number;
  14370. /**
  14371. * Gets or sets the minimal initial rotation in radians.
  14372. */
  14373. minInitialRotation: number;
  14374. /**
  14375. * Gets or sets the maximal initial rotation in radians.
  14376. */
  14377. maxInitialRotation: number;
  14378. /**
  14379. * The particle emitter type defines the emitter used by the particle system.
  14380. * It can be for example box, sphere, or cone...
  14381. */
  14382. particleEmitterType: Nullable<IParticleEmitterType>;
  14383. /**
  14384. * Defines the delay in milliseconds before starting the system (0 by default)
  14385. */
  14386. startDelay: number;
  14387. /**
  14388. * 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
  14389. */
  14390. preWarmCycles: number;
  14391. /**
  14392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14393. */
  14394. preWarmStepOffset: number;
  14395. /**
  14396. * 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)
  14397. */
  14398. spriteCellChangeSpeed: number;
  14399. /**
  14400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14401. */
  14402. startSpriteCellID: number;
  14403. /**
  14404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14405. */
  14406. endSpriteCellID: number;
  14407. /**
  14408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14409. */
  14410. spriteCellWidth: number;
  14411. /**
  14412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14413. */
  14414. spriteCellHeight: number;
  14415. /**
  14416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14417. */
  14418. spriteRandomStartCell: boolean;
  14419. /**
  14420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14421. */
  14422. isAnimationSheetEnabled: boolean;
  14423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14424. translationPivot: Vector2;
  14425. /**
  14426. * Gets or sets a texture used to add random noise to particle positions
  14427. */
  14428. noiseTexture: Nullable<BaseTexture>;
  14429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14430. noiseStrength: Vector3;
  14431. /**
  14432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14434. */
  14435. billboardMode: number;
  14436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14437. limitVelocityDamping: number;
  14438. /**
  14439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14440. */
  14441. beginAnimationOnStart: boolean;
  14442. /**
  14443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14444. */
  14445. beginAnimationFrom: number;
  14446. /**
  14447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14448. */
  14449. beginAnimationTo: number;
  14450. /**
  14451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14452. */
  14453. beginAnimationLoop: boolean;
  14454. /**
  14455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14456. */
  14457. disposeOnStop: boolean;
  14458. /**
  14459. * Specifies if the particles are updated in emitter local space or world space
  14460. */
  14461. isLocal: boolean;
  14462. /** Snippet ID if the particle system was created from the snippet server */
  14463. snippetId: string;
  14464. /**
  14465. * Gets the maximum number of particles active at the same time.
  14466. * @returns The max number of active particles.
  14467. */
  14468. getCapacity(): number;
  14469. /**
  14470. * Gets the number of particles active at the same time.
  14471. * @returns The number of active particles.
  14472. */
  14473. getActiveCount(): number;
  14474. /**
  14475. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14476. * @returns True if it has been started, otherwise false.
  14477. */
  14478. isStarted(): boolean;
  14479. /**
  14480. * Animates the particle system for this frame.
  14481. */
  14482. animate(): void;
  14483. /**
  14484. * Renders the particle system in its current state.
  14485. * @returns the current number of particles
  14486. */
  14487. render(): number;
  14488. /**
  14489. * Dispose the particle system and frees its associated resources.
  14490. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14491. */
  14492. dispose(disposeTexture?: boolean): void;
  14493. /**
  14494. * An event triggered when the system is disposed
  14495. */
  14496. onDisposeObservable: Observable<IParticleSystem>;
  14497. /**
  14498. * Clones the particle system.
  14499. * @param name The name of the cloned object
  14500. * @param newEmitter The new emitter to use
  14501. * @returns the cloned particle system
  14502. */
  14503. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14504. /**
  14505. * Serializes the particle system to a JSON object
  14506. * @param serializeTexture defines if the texture must be serialized as well
  14507. * @returns the JSON object
  14508. */
  14509. serialize(serializeTexture: boolean): any;
  14510. /**
  14511. * Rebuild the particle system
  14512. */
  14513. rebuild(): void;
  14514. /** Force the system to rebuild all gradients that need to be resync */
  14515. forceRefreshGradients(): void;
  14516. /**
  14517. * Starts the particle system and begins to emit
  14518. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14519. */
  14520. start(delay?: number): void;
  14521. /**
  14522. * Stops the particle system.
  14523. */
  14524. stop(): void;
  14525. /**
  14526. * Remove all active particles
  14527. */
  14528. reset(): void;
  14529. /**
  14530. * Gets a boolean indicating that the system is stopping
  14531. * @returns true if the system is currently stopping
  14532. */
  14533. isStopping(): boolean;
  14534. /**
  14535. * Is this system ready to be used/rendered
  14536. * @return true if the system is ready
  14537. */
  14538. isReady(): boolean;
  14539. /**
  14540. * Returns the string "ParticleSystem"
  14541. * @returns a string containing the class name
  14542. */
  14543. getClassName(): string;
  14544. /**
  14545. * Gets the custom effect used to render the particles
  14546. * @param blendMode Blend mode for which the effect should be retrieved
  14547. * @returns The effect
  14548. */
  14549. getCustomEffect(blendMode: number): Nullable<Effect>;
  14550. /**
  14551. * Sets the custom effect used to render the particles
  14552. * @param effect The effect to set
  14553. * @param blendMode Blend mode for which the effect should be set
  14554. */
  14555. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14556. /**
  14557. * Fill the defines array according to the current settings of the particle system
  14558. * @param defines Array to be updated
  14559. * @param blendMode blend mode to take into account when updating the array
  14560. */
  14561. fillDefines(defines: Array<string>, blendMode: number): void;
  14562. /**
  14563. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14564. * @param uniforms Uniforms array to fill
  14565. * @param attributes Attributes array to fill
  14566. * @param samplers Samplers array to fill
  14567. */
  14568. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14569. /**
  14570. * Observable that will be called just before the particles are drawn
  14571. */
  14572. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14573. /**
  14574. * Gets the name of the particle vertex shader
  14575. */
  14576. vertexShaderName: string;
  14577. /**
  14578. * Adds a new color gradient
  14579. * @param gradient defines the gradient to use (between 0 and 1)
  14580. * @param color1 defines the color to affect to the specified gradient
  14581. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14582. * @returns the current particle system
  14583. */
  14584. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14585. /**
  14586. * Remove a specific color gradient
  14587. * @param gradient defines the gradient to remove
  14588. * @returns the current particle system
  14589. */
  14590. removeColorGradient(gradient: number): IParticleSystem;
  14591. /**
  14592. * Adds a new size gradient
  14593. * @param gradient defines the gradient to use (between 0 and 1)
  14594. * @param factor defines the size factor to affect to the specified gradient
  14595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14596. * @returns the current particle system
  14597. */
  14598. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14599. /**
  14600. * Remove a specific size gradient
  14601. * @param gradient defines the gradient to remove
  14602. * @returns the current particle system
  14603. */
  14604. removeSizeGradient(gradient: number): IParticleSystem;
  14605. /**
  14606. * Gets the current list of color gradients.
  14607. * You must use addColorGradient and removeColorGradient to udpate this list
  14608. * @returns the list of color gradients
  14609. */
  14610. getColorGradients(): Nullable<Array<ColorGradient>>;
  14611. /**
  14612. * Gets the current list of size gradients.
  14613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14614. * @returns the list of size gradients
  14615. */
  14616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14617. /**
  14618. * Gets the current list of angular speed gradients.
  14619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14620. * @returns the list of angular speed gradients
  14621. */
  14622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14623. /**
  14624. * Adds a new angular speed gradient
  14625. * @param gradient defines the gradient to use (between 0 and 1)
  14626. * @param factor defines the angular speed to affect to the specified gradient
  14627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14628. * @returns the current particle system
  14629. */
  14630. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14631. /**
  14632. * Remove a specific angular speed gradient
  14633. * @param gradient defines the gradient to remove
  14634. * @returns the current particle system
  14635. */
  14636. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14637. /**
  14638. * Gets the current list of velocity gradients.
  14639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14640. * @returns the list of velocity gradients
  14641. */
  14642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Adds a new velocity gradient
  14645. * @param gradient defines the gradient to use (between 0 and 1)
  14646. * @param factor defines the velocity to affect to the specified gradient
  14647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14648. * @returns the current particle system
  14649. */
  14650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14651. /**
  14652. * Remove a specific velocity gradient
  14653. * @param gradient defines the gradient to remove
  14654. * @returns the current particle system
  14655. */
  14656. removeVelocityGradient(gradient: number): IParticleSystem;
  14657. /**
  14658. * Gets the current list of limit velocity gradients.
  14659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14660. * @returns the list of limit velocity gradients
  14661. */
  14662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Adds a new limit velocity gradient
  14665. * @param gradient defines the gradient to use (between 0 and 1)
  14666. * @param factor defines the limit velocity to affect to the specified gradient
  14667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14668. * @returns the current particle system
  14669. */
  14670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14671. /**
  14672. * Remove a specific limit velocity gradient
  14673. * @param gradient defines the gradient to remove
  14674. * @returns the current particle system
  14675. */
  14676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14677. /**
  14678. * Adds a new drag gradient
  14679. * @param gradient defines the gradient to use (between 0 and 1)
  14680. * @param factor defines the drag to affect to the specified gradient
  14681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14682. * @returns the current particle system
  14683. */
  14684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14685. /**
  14686. * Remove a specific drag gradient
  14687. * @param gradient defines the gradient to remove
  14688. * @returns the current particle system
  14689. */
  14690. removeDragGradient(gradient: number): IParticleSystem;
  14691. /**
  14692. * Gets the current list of drag gradients.
  14693. * You must use addDragGradient and removeDragGradient to udpate this list
  14694. * @returns the list of drag gradients
  14695. */
  14696. getDragGradients(): Nullable<Array<FactorGradient>>;
  14697. /**
  14698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14699. * @param gradient defines the gradient to use (between 0 and 1)
  14700. * @param factor defines the emit rate to affect to the specified gradient
  14701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14702. * @returns the current particle system
  14703. */
  14704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14705. /**
  14706. * Remove a specific emit rate gradient
  14707. * @param gradient defines the gradient to remove
  14708. * @returns the current particle system
  14709. */
  14710. removeEmitRateGradient(gradient: number): IParticleSystem;
  14711. /**
  14712. * Gets the current list of emit rate gradients.
  14713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14714. * @returns the list of emit rate gradients
  14715. */
  14716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14719. * @param gradient defines the gradient to use (between 0 and 1)
  14720. * @param factor defines the start size to affect to the specified gradient
  14721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14722. * @returns the current particle system
  14723. */
  14724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14725. /**
  14726. * Remove a specific start size gradient
  14727. * @param gradient defines the gradient to remove
  14728. * @returns the current particle system
  14729. */
  14730. removeStartSizeGradient(gradient: number): IParticleSystem;
  14731. /**
  14732. * Gets the current list of start size gradients.
  14733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14734. * @returns the list of start size gradients
  14735. */
  14736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14737. /**
  14738. * Adds a new life time gradient
  14739. * @param gradient defines the gradient to use (between 0 and 1)
  14740. * @param factor defines the life time factor to affect to the specified gradient
  14741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14742. * @returns the current particle system
  14743. */
  14744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14745. /**
  14746. * Remove a specific life time gradient
  14747. * @param gradient defines the gradient to remove
  14748. * @returns the current particle system
  14749. */
  14750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14751. /**
  14752. * Gets the current list of life time gradients.
  14753. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14754. * @returns the list of life time gradients
  14755. */
  14756. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14757. /**
  14758. * Gets the current list of color gradients.
  14759. * You must use addColorGradient and removeColorGradient to udpate this list
  14760. * @returns the list of color gradients
  14761. */
  14762. getColorGradients(): Nullable<Array<ColorGradient>>;
  14763. /**
  14764. * Adds a new ramp gradient used to remap particle colors
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param color defines the color to affect to the specified gradient
  14767. * @returns the current particle system
  14768. */
  14769. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14770. /**
  14771. * Gets the current list of ramp gradients.
  14772. * You must use addRampGradient and removeRampGradient to udpate this list
  14773. * @returns the list of ramp gradients
  14774. */
  14775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14776. /** Gets or sets a boolean indicating that ramp gradients must be used
  14777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14778. */
  14779. useRampGradients: boolean;
  14780. /**
  14781. * Adds a new color remap gradient
  14782. * @param gradient defines the gradient to use (between 0 and 1)
  14783. * @param min defines the color remap minimal range
  14784. * @param max defines the color remap maximal range
  14785. * @returns the current particle system
  14786. */
  14787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14788. /**
  14789. * Gets the current list of color remap gradients.
  14790. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14791. * @returns the list of color remap gradients
  14792. */
  14793. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14794. /**
  14795. * Adds a new alpha remap gradient
  14796. * @param gradient defines the gradient to use (between 0 and 1)
  14797. * @param min defines the alpha remap minimal range
  14798. * @param max defines the alpha remap maximal range
  14799. * @returns the current particle system
  14800. */
  14801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14802. /**
  14803. * Gets the current list of alpha remap gradients.
  14804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14805. * @returns the list of alpha remap gradients
  14806. */
  14807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14808. /**
  14809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14812. * @returns the emitter
  14813. */
  14814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14815. /**
  14816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14817. * @param radius The radius of the hemisphere to emit from
  14818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14819. * @returns the emitter
  14820. */
  14821. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14822. /**
  14823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14824. * @param radius The radius of the sphere to emit from
  14825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14826. * @returns the emitter
  14827. */
  14828. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14829. /**
  14830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14831. * @param radius The radius of the sphere to emit from
  14832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14834. * @returns the emitter
  14835. */
  14836. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14837. /**
  14838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14839. * @param radius The radius of the emission cylinder
  14840. * @param height The height of the emission cylinder
  14841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14843. * @returns the emitter
  14844. */
  14845. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14846. /**
  14847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14848. * @param radius The radius of the cylinder to emit from
  14849. * @param height The height of the emission cylinder
  14850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14853. * @returns the emitter
  14854. */
  14855. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14856. /**
  14857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14858. * @param radius The radius of the cone to emit from
  14859. * @param angle The base angle of the cone
  14860. * @returns the emitter
  14861. */
  14862. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14863. /**
  14864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14869. * @returns the emitter
  14870. */
  14871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14872. /**
  14873. * Get hosting scene
  14874. * @returns the scene
  14875. */
  14876. getScene(): Scene;
  14877. }
  14878. }
  14879. declare module "babylonjs/Meshes/transformNode" {
  14880. import { DeepImmutable } from "babylonjs/types";
  14881. import { Observable } from "babylonjs/Misc/observable";
  14882. import { Nullable } from "babylonjs/types";
  14883. import { Camera } from "babylonjs/Cameras/camera";
  14884. import { Scene } from "babylonjs/scene";
  14885. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14886. import { Node } from "babylonjs/node";
  14887. import { Bone } from "babylonjs/Bones/bone";
  14888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14889. import { Space } from "babylonjs/Maths/math.axis";
  14890. /**
  14891. * 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.
  14892. * @see https://doc.babylonjs.com/how_to/transformnode
  14893. */
  14894. export class TransformNode extends Node {
  14895. /**
  14896. * Object will not rotate to face the camera
  14897. */
  14898. static BILLBOARDMODE_NONE: number;
  14899. /**
  14900. * Object will rotate to face the camera but only on the x axis
  14901. */
  14902. static BILLBOARDMODE_X: number;
  14903. /**
  14904. * Object will rotate to face the camera but only on the y axis
  14905. */
  14906. static BILLBOARDMODE_Y: number;
  14907. /**
  14908. * Object will rotate to face the camera but only on the z axis
  14909. */
  14910. static BILLBOARDMODE_Z: number;
  14911. /**
  14912. * Object will rotate to face the camera
  14913. */
  14914. static BILLBOARDMODE_ALL: number;
  14915. /**
  14916. * Object will rotate to face the camera's position instead of orientation
  14917. */
  14918. static BILLBOARDMODE_USE_POSITION: number;
  14919. private _forward;
  14920. private _forwardInverted;
  14921. private _up;
  14922. private _right;
  14923. private _rightInverted;
  14924. private _position;
  14925. private _rotation;
  14926. private _rotationQuaternion;
  14927. protected _scaling: Vector3;
  14928. protected _isDirty: boolean;
  14929. private _transformToBoneReferal;
  14930. private _isAbsoluteSynced;
  14931. private _billboardMode;
  14932. /**
  14933. * Gets or sets the billboard mode. Default is 0.
  14934. *
  14935. * | Value | Type | Description |
  14936. * | --- | --- | --- |
  14937. * | 0 | BILLBOARDMODE_NONE | |
  14938. * | 1 | BILLBOARDMODE_X | |
  14939. * | 2 | BILLBOARDMODE_Y | |
  14940. * | 4 | BILLBOARDMODE_Z | |
  14941. * | 7 | BILLBOARDMODE_ALL | |
  14942. *
  14943. */
  14944. get billboardMode(): number;
  14945. set billboardMode(value: number);
  14946. private _preserveParentRotationForBillboard;
  14947. /**
  14948. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14949. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14950. */
  14951. get preserveParentRotationForBillboard(): boolean;
  14952. set preserveParentRotationForBillboard(value: boolean);
  14953. /**
  14954. * 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
  14955. */
  14956. scalingDeterminant: number;
  14957. private _infiniteDistance;
  14958. /**
  14959. * Gets or sets the distance of the object to max, often used by skybox
  14960. */
  14961. get infiniteDistance(): boolean;
  14962. set infiniteDistance(value: boolean);
  14963. /**
  14964. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14965. * By default the system will update normals to compensate
  14966. */
  14967. ignoreNonUniformScaling: boolean;
  14968. /**
  14969. * 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
  14970. */
  14971. reIntegrateRotationIntoRotationQuaternion: boolean;
  14972. /** @hidden */
  14973. _poseMatrix: Nullable<Matrix>;
  14974. /** @hidden */
  14975. _localMatrix: Matrix;
  14976. private _usePivotMatrix;
  14977. private _absolutePosition;
  14978. private _absoluteScaling;
  14979. private _absoluteRotationQuaternion;
  14980. private _pivotMatrix;
  14981. private _pivotMatrixInverse;
  14982. protected _postMultiplyPivotMatrix: boolean;
  14983. protected _isWorldMatrixFrozen: boolean;
  14984. /** @hidden */
  14985. _indexInSceneTransformNodesArray: number;
  14986. /**
  14987. * An event triggered after the world matrix is updated
  14988. */
  14989. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14990. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14991. /**
  14992. * Gets a string identifying the name of the class
  14993. * @returns "TransformNode" string
  14994. */
  14995. getClassName(): string;
  14996. /**
  14997. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14998. */
  14999. get position(): Vector3;
  15000. set position(newPosition: Vector3);
  15001. /**
  15002. * 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)).
  15003. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15004. */
  15005. get rotation(): Vector3;
  15006. set rotation(newRotation: Vector3);
  15007. /**
  15008. * 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)).
  15009. */
  15010. get scaling(): Vector3;
  15011. set scaling(newScaling: Vector3);
  15012. /**
  15013. * 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).
  15014. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15015. */
  15016. get rotationQuaternion(): Nullable<Quaternion>;
  15017. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15018. /**
  15019. * The forward direction of that transform in world space.
  15020. */
  15021. get forward(): Vector3;
  15022. /**
  15023. * The up direction of that transform in world space.
  15024. */
  15025. get up(): Vector3;
  15026. /**
  15027. * The right direction of that transform in world space.
  15028. */
  15029. get right(): Vector3;
  15030. /**
  15031. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15032. * @param matrix the matrix to copy the pose from
  15033. * @returns this TransformNode.
  15034. */
  15035. updatePoseMatrix(matrix: Matrix): TransformNode;
  15036. /**
  15037. * Returns the mesh Pose matrix.
  15038. * @returns the pose matrix
  15039. */
  15040. getPoseMatrix(): Matrix;
  15041. /** @hidden */
  15042. _isSynchronized(): boolean;
  15043. /** @hidden */
  15044. _initCache(): void;
  15045. /**
  15046. * Flag the transform node as dirty (Forcing it to update everything)
  15047. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15048. * @returns this transform node
  15049. */
  15050. markAsDirty(property: string): TransformNode;
  15051. /**
  15052. * Returns the current mesh absolute position.
  15053. * Returns a Vector3.
  15054. */
  15055. get absolutePosition(): Vector3;
  15056. /**
  15057. * Returns the current mesh absolute scaling.
  15058. * Returns a Vector3.
  15059. */
  15060. get absoluteScaling(): Vector3;
  15061. /**
  15062. * Returns the current mesh absolute rotation.
  15063. * Returns a Quaternion.
  15064. */
  15065. get absoluteRotationQuaternion(): Quaternion;
  15066. /**
  15067. * Sets a new matrix to apply before all other transformation
  15068. * @param matrix defines the transform matrix
  15069. * @returns the current TransformNode
  15070. */
  15071. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15072. /**
  15073. * Sets a new pivot matrix to the current node
  15074. * @param matrix defines the new pivot matrix to use
  15075. * @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
  15076. * @returns the current TransformNode
  15077. */
  15078. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15079. /**
  15080. * Returns the mesh pivot matrix.
  15081. * Default : Identity.
  15082. * @returns the matrix
  15083. */
  15084. getPivotMatrix(): Matrix;
  15085. /**
  15086. * Instantiate (when possible) or clone that node with its hierarchy
  15087. * @param newParent defines the new parent to use for the instance (or clone)
  15088. * @param options defines options to configure how copy is done
  15089. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15090. * @returns an instance (or a clone) of the current node with its hiearchy
  15091. */
  15092. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15093. doNotInstantiate: boolean;
  15094. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15095. /**
  15096. * Prevents the World matrix to be computed any longer
  15097. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15098. * @returns the TransformNode.
  15099. */
  15100. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15101. /**
  15102. * Allows back the World matrix computation.
  15103. * @returns the TransformNode.
  15104. */
  15105. unfreezeWorldMatrix(): this;
  15106. /**
  15107. * True if the World matrix has been frozen.
  15108. */
  15109. get isWorldMatrixFrozen(): boolean;
  15110. /**
  15111. * Retuns the mesh absolute position in the World.
  15112. * @returns a Vector3.
  15113. */
  15114. getAbsolutePosition(): Vector3;
  15115. /**
  15116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15117. * @param absolutePosition the absolute position to set
  15118. * @returns the TransformNode.
  15119. */
  15120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15121. /**
  15122. * Sets the mesh position in its local space.
  15123. * @param vector3 the position to set in localspace
  15124. * @returns the TransformNode.
  15125. */
  15126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15127. /**
  15128. * Returns the mesh position in the local space from the current World matrix values.
  15129. * @returns a new Vector3.
  15130. */
  15131. getPositionExpressedInLocalSpace(): Vector3;
  15132. /**
  15133. * Translates the mesh along the passed Vector3 in its local space.
  15134. * @param vector3 the distance to translate in localspace
  15135. * @returns the TransformNode.
  15136. */
  15137. locallyTranslate(vector3: Vector3): TransformNode;
  15138. private static _lookAtVectorCache;
  15139. /**
  15140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15141. * @param targetPoint the position (must be in same space as current mesh) to look at
  15142. * @param yawCor optional yaw (y-axis) correction in radians
  15143. * @param pitchCor optional pitch (x-axis) correction in radians
  15144. * @param rollCor optional roll (z-axis) correction in radians
  15145. * @param space the choosen space of the target
  15146. * @returns the TransformNode.
  15147. */
  15148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15149. /**
  15150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15151. * This Vector3 is expressed in the World space.
  15152. * @param localAxis axis to rotate
  15153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15154. */
  15155. getDirection(localAxis: Vector3): Vector3;
  15156. /**
  15157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15158. * localAxis is expressed in the mesh local space.
  15159. * result is computed in the Wordl space from the mesh World matrix.
  15160. * @param localAxis axis to rotate
  15161. * @param result the resulting transformnode
  15162. * @returns this TransformNode.
  15163. */
  15164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15165. /**
  15166. * Sets this transform node rotation to the given local axis.
  15167. * @param localAxis the axis in local space
  15168. * @param yawCor optional yaw (y-axis) correction in radians
  15169. * @param pitchCor optional pitch (x-axis) correction in radians
  15170. * @param rollCor optional roll (z-axis) correction in radians
  15171. * @returns this TransformNode
  15172. */
  15173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15174. /**
  15175. * Sets a new pivot point to the current node
  15176. * @param point defines the new pivot point to use
  15177. * @param space defines if the point is in world or local space (local by default)
  15178. * @returns the current TransformNode
  15179. */
  15180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15181. /**
  15182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15183. * @returns the pivot point
  15184. */
  15185. getPivotPoint(): Vector3;
  15186. /**
  15187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15188. * @param result the vector3 to store the result
  15189. * @returns this TransformNode.
  15190. */
  15191. getPivotPointToRef(result: Vector3): TransformNode;
  15192. /**
  15193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15195. */
  15196. getAbsolutePivotPoint(): Vector3;
  15197. /**
  15198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15199. * @param result vector3 to store the result
  15200. * @returns this TransformNode.
  15201. */
  15202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15203. /**
  15204. * Defines the passed node as the parent of the current node.
  15205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15206. * @see https://doc.babylonjs.com/how_to/parenting
  15207. * @param node the node ot set as the parent
  15208. * @returns this TransformNode.
  15209. */
  15210. setParent(node: Nullable<Node>): TransformNode;
  15211. private _nonUniformScaling;
  15212. /**
  15213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15214. */
  15215. get nonUniformScaling(): boolean;
  15216. /** @hidden */
  15217. _updateNonUniformScalingState(value: boolean): boolean;
  15218. /**
  15219. * Attach the current TransformNode to another TransformNode associated with a bone
  15220. * @param bone Bone affecting the TransformNode
  15221. * @param affectedTransformNode TransformNode associated with the bone
  15222. * @returns this object
  15223. */
  15224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15225. /**
  15226. * Detach the transform node if its associated with a bone
  15227. * @returns this object
  15228. */
  15229. detachFromBone(): TransformNode;
  15230. private static _rotationAxisCache;
  15231. /**
  15232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15235. * The passed axis is also normalized.
  15236. * @param axis the axis to rotate around
  15237. * @param amount the amount to rotate in radians
  15238. * @param space Space to rotate in (Default: local)
  15239. * @returns the TransformNode.
  15240. */
  15241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15242. /**
  15243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15245. * The passed axis is also normalized. .
  15246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15247. * @param point the point to rotate around
  15248. * @param axis the axis to rotate around
  15249. * @param amount the amount to rotate in radians
  15250. * @returns the TransformNode
  15251. */
  15252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15253. /**
  15254. * Translates the mesh along the axis vector for the passed distance in the given space.
  15255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15256. * @param axis the axis to translate in
  15257. * @param distance the distance to translate
  15258. * @param space Space to rotate in (Default: local)
  15259. * @returns the TransformNode.
  15260. */
  15261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15262. /**
  15263. * Adds a rotation step to the mesh current rotation.
  15264. * x, y, z are Euler angles expressed in radians.
  15265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15266. * This means this rotation is made in the mesh local space only.
  15267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15269. * ```javascript
  15270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15271. * ```
  15272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15273. * 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.
  15274. * @param x Rotation to add
  15275. * @param y Rotation to add
  15276. * @param z Rotation to add
  15277. * @returns the TransformNode.
  15278. */
  15279. addRotation(x: number, y: number, z: number): TransformNode;
  15280. /**
  15281. * @hidden
  15282. */
  15283. protected _getEffectiveParent(): Nullable<Node>;
  15284. /**
  15285. * Computes the world matrix of the node
  15286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15287. * @returns the world matrix
  15288. */
  15289. computeWorldMatrix(force?: boolean): Matrix;
  15290. /**
  15291. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15292. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15293. */
  15294. resetLocalMatrix(independentOfChildren?: boolean): void;
  15295. protected _afterComputeWorldMatrix(): void;
  15296. /**
  15297. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15298. * @param func callback function to add
  15299. *
  15300. * @returns the TransformNode.
  15301. */
  15302. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15303. /**
  15304. * Removes a registered callback function.
  15305. * @param func callback function to remove
  15306. * @returns the TransformNode.
  15307. */
  15308. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15309. /**
  15310. * Gets the position of the current mesh in camera space
  15311. * @param camera defines the camera to use
  15312. * @returns a position
  15313. */
  15314. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15315. /**
  15316. * Returns the distance from the mesh to the active camera
  15317. * @param camera defines the camera to use
  15318. * @returns the distance
  15319. */
  15320. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15321. /**
  15322. * Clone the current transform node
  15323. * @param name Name of the new clone
  15324. * @param newParent New parent for the clone
  15325. * @param doNotCloneChildren Do not clone children hierarchy
  15326. * @returns the new transform node
  15327. */
  15328. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15329. /**
  15330. * Serializes the objects information.
  15331. * @param currentSerializationObject defines the object to serialize in
  15332. * @returns the serialized object
  15333. */
  15334. serialize(currentSerializationObject?: any): any;
  15335. /**
  15336. * Returns a new TransformNode object parsed from the source provided.
  15337. * @param parsedTransformNode is the source.
  15338. * @param scene the scne the object belongs to
  15339. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15340. * @returns a new TransformNode object parsed from the source provided.
  15341. */
  15342. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15343. /**
  15344. * Get all child-transformNodes of this node
  15345. * @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
  15346. * @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
  15347. * @returns an array of TransformNode
  15348. */
  15349. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15350. /**
  15351. * Releases resources associated with this transform node.
  15352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15354. */
  15355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15356. /**
  15357. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15358. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15359. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15360. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15361. * @returns the current mesh
  15362. */
  15363. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15364. private _syncAbsoluteScalingAndRotation;
  15365. }
  15366. }
  15367. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15368. /**
  15369. * Class used to override all child animations of a given target
  15370. */
  15371. export class AnimationPropertiesOverride {
  15372. /**
  15373. * Gets or sets a value indicating if animation blending must be used
  15374. */
  15375. enableBlending: boolean;
  15376. /**
  15377. * Gets or sets the blending speed to use when enableBlending is true
  15378. */
  15379. blendingSpeed: number;
  15380. /**
  15381. * Gets or sets the default loop mode to use
  15382. */
  15383. loopMode: number;
  15384. }
  15385. }
  15386. declare module "babylonjs/Bones/bone" {
  15387. import { Skeleton } from "babylonjs/Bones/skeleton";
  15388. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15389. import { Nullable } from "babylonjs/types";
  15390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15392. import { Node } from "babylonjs/node";
  15393. import { Space } from "babylonjs/Maths/math.axis";
  15394. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15395. /**
  15396. * Class used to store bone information
  15397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15398. */
  15399. export class Bone extends Node {
  15400. /**
  15401. * defines the bone name
  15402. */
  15403. name: string;
  15404. private static _tmpVecs;
  15405. private static _tmpQuat;
  15406. private static _tmpMats;
  15407. /**
  15408. * Gets the list of child bones
  15409. */
  15410. children: Bone[];
  15411. /** Gets the animations associated with this bone */
  15412. animations: import("babylonjs/Animations/animation").Animation[];
  15413. /**
  15414. * Gets or sets bone length
  15415. */
  15416. length: number;
  15417. /**
  15418. * @hidden Internal only
  15419. * Set this value to map this bone to a different index in the transform matrices
  15420. * Set this value to -1 to exclude the bone from the transform matrices
  15421. */
  15422. _index: Nullable<number>;
  15423. private _skeleton;
  15424. private _localMatrix;
  15425. private _restPose;
  15426. private _baseMatrix;
  15427. private _absoluteTransform;
  15428. private _invertedAbsoluteTransform;
  15429. private _parent;
  15430. private _scalingDeterminant;
  15431. private _worldTransform;
  15432. private _localScaling;
  15433. private _localRotation;
  15434. private _localPosition;
  15435. private _needToDecompose;
  15436. private _needToCompose;
  15437. /** @hidden */
  15438. _linkedTransformNode: Nullable<TransformNode>;
  15439. /** @hidden */
  15440. _waitingTransformNodeId: Nullable<string>;
  15441. /** @hidden */
  15442. get _matrix(): Matrix;
  15443. /** @hidden */
  15444. set _matrix(value: Matrix);
  15445. /**
  15446. * Create a new bone
  15447. * @param name defines the bone name
  15448. * @param skeleton defines the parent skeleton
  15449. * @param parentBone defines the parent (can be null if the bone is the root)
  15450. * @param localMatrix defines the local matrix
  15451. * @param restPose defines the rest pose matrix
  15452. * @param baseMatrix defines the base matrix
  15453. * @param index defines index of the bone in the hiearchy
  15454. */
  15455. constructor(
  15456. /**
  15457. * defines the bone name
  15458. */
  15459. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15460. /**
  15461. * Gets the current object class name.
  15462. * @return the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Gets the parent skeleton
  15467. * @returns a skeleton
  15468. */
  15469. getSkeleton(): Skeleton;
  15470. /**
  15471. * Gets parent bone
  15472. * @returns a bone or null if the bone is the root of the bone hierarchy
  15473. */
  15474. getParent(): Nullable<Bone>;
  15475. /**
  15476. * Returns an array containing the root bones
  15477. * @returns an array containing the root bones
  15478. */
  15479. getChildren(): Array<Bone>;
  15480. /**
  15481. * Gets the node index in matrix array generated for rendering
  15482. * @returns the node index
  15483. */
  15484. getIndex(): number;
  15485. /**
  15486. * Sets the parent bone
  15487. * @param parent defines the parent (can be null if the bone is the root)
  15488. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15489. */
  15490. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15491. /**
  15492. * Gets the local matrix
  15493. * @returns a matrix
  15494. */
  15495. getLocalMatrix(): Matrix;
  15496. /**
  15497. * Gets the base matrix (initial matrix which remains unchanged)
  15498. * @returns a matrix
  15499. */
  15500. getBaseMatrix(): Matrix;
  15501. /**
  15502. * Gets the rest pose matrix
  15503. * @returns a matrix
  15504. */
  15505. getRestPose(): Matrix;
  15506. /**
  15507. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15508. */
  15509. getWorldMatrix(): Matrix;
  15510. /**
  15511. * Sets the local matrix to rest pose matrix
  15512. */
  15513. returnToRest(): void;
  15514. /**
  15515. * Gets the inverse of the absolute transform matrix.
  15516. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15517. * @returns a matrix
  15518. */
  15519. getInvertedAbsoluteTransform(): Matrix;
  15520. /**
  15521. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15522. * @returns a matrix
  15523. */
  15524. getAbsoluteTransform(): Matrix;
  15525. /**
  15526. * Links with the given transform node.
  15527. * The local matrix of this bone is copied from the transform node every frame.
  15528. * @param transformNode defines the transform node to link to
  15529. */
  15530. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15531. /**
  15532. * Gets the node used to drive the bone's transformation
  15533. * @returns a transform node or null
  15534. */
  15535. getTransformNode(): Nullable<TransformNode>;
  15536. /** Gets or sets current position (in local space) */
  15537. get position(): Vector3;
  15538. set position(newPosition: Vector3);
  15539. /** Gets or sets current rotation (in local space) */
  15540. get rotation(): Vector3;
  15541. set rotation(newRotation: Vector3);
  15542. /** Gets or sets current rotation quaternion (in local space) */
  15543. get rotationQuaternion(): Quaternion;
  15544. set rotationQuaternion(newRotation: Quaternion);
  15545. /** Gets or sets current scaling (in local space) */
  15546. get scaling(): Vector3;
  15547. set scaling(newScaling: Vector3);
  15548. /**
  15549. * Gets the animation properties override
  15550. */
  15551. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15552. private _decompose;
  15553. private _compose;
  15554. /**
  15555. * Update the base and local matrices
  15556. * @param matrix defines the new base or local matrix
  15557. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15558. * @param updateLocalMatrix defines if the local matrix should be updated
  15559. */
  15560. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15561. /** @hidden */
  15562. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15563. /**
  15564. * Flag the bone as dirty (Forcing it to update everything)
  15565. */
  15566. markAsDirty(): void;
  15567. /** @hidden */
  15568. _markAsDirtyAndCompose(): void;
  15569. private _markAsDirtyAndDecompose;
  15570. /**
  15571. * Translate the bone in local or world space
  15572. * @param vec The amount to translate the bone
  15573. * @param space The space that the translation is in
  15574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15575. */
  15576. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15577. /**
  15578. * Set the postion of the bone in local or world space
  15579. * @param position The position to set the bone
  15580. * @param space The space that the position is in
  15581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15582. */
  15583. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15584. /**
  15585. * Set the absolute position of the bone (world space)
  15586. * @param position The position to set the bone
  15587. * @param mesh The mesh that this bone is attached to
  15588. */
  15589. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15590. /**
  15591. * Scale the bone on the x, y and z axes (in local space)
  15592. * @param x The amount to scale the bone on the x axis
  15593. * @param y The amount to scale the bone on the y axis
  15594. * @param z The amount to scale the bone on the z axis
  15595. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15596. */
  15597. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15598. /**
  15599. * Set the bone scaling in local space
  15600. * @param scale defines the scaling vector
  15601. */
  15602. setScale(scale: Vector3): void;
  15603. /**
  15604. * Gets the current scaling in local space
  15605. * @returns the current scaling vector
  15606. */
  15607. getScale(): Vector3;
  15608. /**
  15609. * Gets the current scaling in local space and stores it in a target vector
  15610. * @param result defines the target vector
  15611. */
  15612. getScaleToRef(result: Vector3): void;
  15613. /**
  15614. * Set the yaw, pitch, and roll of the bone in local or world space
  15615. * @param yaw The rotation of the bone on the y axis
  15616. * @param pitch The rotation of the bone on the x axis
  15617. * @param roll The rotation of the bone on the z axis
  15618. * @param space The space that the axes of rotation are in
  15619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15620. */
  15621. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15622. /**
  15623. * Add a rotation to the bone on an axis in local or world space
  15624. * @param axis The axis to rotate the bone on
  15625. * @param amount The amount to rotate the bone
  15626. * @param space The space that the axis is in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. */
  15629. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15630. /**
  15631. * Set the rotation of the bone to a particular axis angle in local or world space
  15632. * @param axis The axis to rotate the bone on
  15633. * @param angle The angle that the bone should be rotated to
  15634. * @param space The space that the axis is in
  15635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15636. */
  15637. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15638. /**
  15639. * Set the euler rotation of the bone in local of world space
  15640. * @param rotation The euler rotation that the bone should be set to
  15641. * @param space The space that the rotation is in
  15642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15643. */
  15644. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15645. /**
  15646. * Set the quaternion rotation of the bone in local of world space
  15647. * @param quat The quaternion rotation that the bone should be set to
  15648. * @param space The space that the rotation is in
  15649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15650. */
  15651. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15652. /**
  15653. * Set the rotation matrix of the bone in local of world space
  15654. * @param rotMat The rotation matrix that the bone should be set to
  15655. * @param space The space that the rotation is in
  15656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15657. */
  15658. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15659. private _rotateWithMatrix;
  15660. private _getNegativeRotationToRef;
  15661. /**
  15662. * Get the position of the bone in local or world space
  15663. * @param space The space that the returned position is in
  15664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15665. * @returns The position of the bone
  15666. */
  15667. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15668. /**
  15669. * Copy the position of the bone to a vector3 in local or world space
  15670. * @param space The space that the returned position is in
  15671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15672. * @param result The vector3 to copy the position to
  15673. */
  15674. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15675. /**
  15676. * Get the absolute position of the bone (world space)
  15677. * @param mesh The mesh that this bone is attached to
  15678. * @returns The absolute position of the bone
  15679. */
  15680. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15681. /**
  15682. * Copy the absolute position of the bone (world space) to the result param
  15683. * @param mesh The mesh that this bone is attached to
  15684. * @param result The vector3 to copy the absolute position to
  15685. */
  15686. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15687. /**
  15688. * Compute the absolute transforms of this bone and its children
  15689. */
  15690. computeAbsoluteTransforms(): void;
  15691. /**
  15692. * Get the world direction from an axis that is in the local space of the bone
  15693. * @param localAxis The local direction that is used to compute the world direction
  15694. * @param mesh The mesh that this bone is attached to
  15695. * @returns The world direction
  15696. */
  15697. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15698. /**
  15699. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15700. * @param localAxis The local direction that is used to compute the world direction
  15701. * @param mesh The mesh that this bone is attached to
  15702. * @param result The vector3 that the world direction will be copied to
  15703. */
  15704. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15705. /**
  15706. * Get the euler rotation of the bone in local or world space
  15707. * @param space The space that the rotation should be in
  15708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15709. * @returns The euler rotation
  15710. */
  15711. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15712. /**
  15713. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15714. * @param space The space that the rotation should be in
  15715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15716. * @param result The vector3 that the rotation should be copied to
  15717. */
  15718. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15719. /**
  15720. * Get the quaternion rotation of the bone in either local or world space
  15721. * @param space The space that the rotation should be in
  15722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15723. * @returns The quaternion rotation
  15724. */
  15725. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15726. /**
  15727. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15728. * @param space The space that the rotation should be in
  15729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15730. * @param result The quaternion that the rotation should be copied to
  15731. */
  15732. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15733. /**
  15734. * Get the rotation matrix of the bone in local or world space
  15735. * @param space The space that the rotation should be in
  15736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15737. * @returns The rotation matrix
  15738. */
  15739. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15740. /**
  15741. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15742. * @param space The space that the rotation should be in
  15743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15744. * @param result The quaternion that the rotation should be copied to
  15745. */
  15746. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15747. /**
  15748. * Get the world position of a point that is in the local space of the bone
  15749. * @param position The local position
  15750. * @param mesh The mesh that this bone is attached to
  15751. * @returns The world position
  15752. */
  15753. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15754. /**
  15755. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15756. * @param position The local position
  15757. * @param mesh The mesh that this bone is attached to
  15758. * @param result The vector3 that the world position should be copied to
  15759. */
  15760. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15761. /**
  15762. * Get the local position of a point that is in world space
  15763. * @param position The world position
  15764. * @param mesh The mesh that this bone is attached to
  15765. * @returns The local position
  15766. */
  15767. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15768. /**
  15769. * Get the local position of a point that is in world space and copy it to the result param
  15770. * @param position The world position
  15771. * @param mesh The mesh that this bone is attached to
  15772. * @param result The vector3 that the local position should be copied to
  15773. */
  15774. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15775. }
  15776. }
  15777. declare module "babylonjs/Animations/runtimeAnimation" {
  15778. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15779. import { Animatable } from "babylonjs/Animations/animatable";
  15780. import { Scene } from "babylonjs/scene";
  15781. /**
  15782. * Defines a runtime animation
  15783. */
  15784. export class RuntimeAnimation {
  15785. private _events;
  15786. /**
  15787. * The current frame of the runtime animation
  15788. */
  15789. private _currentFrame;
  15790. /**
  15791. * The animation used by the runtime animation
  15792. */
  15793. private _animation;
  15794. /**
  15795. * The target of the runtime animation
  15796. */
  15797. private _target;
  15798. /**
  15799. * The initiating animatable
  15800. */
  15801. private _host;
  15802. /**
  15803. * The original value of the runtime animation
  15804. */
  15805. private _originalValue;
  15806. /**
  15807. * The original blend value of the runtime animation
  15808. */
  15809. private _originalBlendValue;
  15810. /**
  15811. * The offsets cache of the runtime animation
  15812. */
  15813. private _offsetsCache;
  15814. /**
  15815. * The high limits cache of the runtime animation
  15816. */
  15817. private _highLimitsCache;
  15818. /**
  15819. * Specifies if the runtime animation has been stopped
  15820. */
  15821. private _stopped;
  15822. /**
  15823. * The blending factor of the runtime animation
  15824. */
  15825. private _blendingFactor;
  15826. /**
  15827. * The BabylonJS scene
  15828. */
  15829. private _scene;
  15830. /**
  15831. * The current value of the runtime animation
  15832. */
  15833. private _currentValue;
  15834. /** @hidden */
  15835. _animationState: _IAnimationState;
  15836. /**
  15837. * The active target of the runtime animation
  15838. */
  15839. private _activeTargets;
  15840. private _currentActiveTarget;
  15841. private _directTarget;
  15842. /**
  15843. * The target path of the runtime animation
  15844. */
  15845. private _targetPath;
  15846. /**
  15847. * The weight of the runtime animation
  15848. */
  15849. private _weight;
  15850. /**
  15851. * The ratio offset of the runtime animation
  15852. */
  15853. private _ratioOffset;
  15854. /**
  15855. * The previous delay of the runtime animation
  15856. */
  15857. private _previousDelay;
  15858. /**
  15859. * The previous ratio of the runtime animation
  15860. */
  15861. private _previousRatio;
  15862. private _enableBlending;
  15863. private _keys;
  15864. private _minFrame;
  15865. private _maxFrame;
  15866. private _minValue;
  15867. private _maxValue;
  15868. private _targetIsArray;
  15869. /**
  15870. * Gets the current frame of the runtime animation
  15871. */
  15872. get currentFrame(): number;
  15873. /**
  15874. * Gets the weight of the runtime animation
  15875. */
  15876. get weight(): number;
  15877. /**
  15878. * Gets the current value of the runtime animation
  15879. */
  15880. get currentValue(): any;
  15881. /**
  15882. * Gets the target path of the runtime animation
  15883. */
  15884. get targetPath(): string;
  15885. /**
  15886. * Gets the actual target of the runtime animation
  15887. */
  15888. get target(): any;
  15889. /**
  15890. * Gets the additive state of the runtime animation
  15891. */
  15892. get isAdditive(): boolean;
  15893. /** @hidden */
  15894. _onLoop: () => void;
  15895. /**
  15896. * Create a new RuntimeAnimation object
  15897. * @param target defines the target of the animation
  15898. * @param animation defines the source animation object
  15899. * @param scene defines the hosting scene
  15900. * @param host defines the initiating Animatable
  15901. */
  15902. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15903. private _preparePath;
  15904. /**
  15905. * Gets the animation from the runtime animation
  15906. */
  15907. get animation(): Animation;
  15908. /**
  15909. * Resets the runtime animation to the beginning
  15910. * @param restoreOriginal defines whether to restore the target property to the original value
  15911. */
  15912. reset(restoreOriginal?: boolean): void;
  15913. /**
  15914. * Specifies if the runtime animation is stopped
  15915. * @returns Boolean specifying if the runtime animation is stopped
  15916. */
  15917. isStopped(): boolean;
  15918. /**
  15919. * Disposes of the runtime animation
  15920. */
  15921. dispose(): void;
  15922. /**
  15923. * Apply the interpolated value to the target
  15924. * @param currentValue defines the value computed by the animation
  15925. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15926. */
  15927. setValue(currentValue: any, weight: number): void;
  15928. private _getOriginalValues;
  15929. private _setValue;
  15930. /**
  15931. * Gets the loop pmode of the runtime animation
  15932. * @returns Loop Mode
  15933. */
  15934. private _getCorrectLoopMode;
  15935. /**
  15936. * Move the current animation to a given frame
  15937. * @param frame defines the frame to move to
  15938. */
  15939. goToFrame(frame: number): void;
  15940. /**
  15941. * @hidden Internal use only
  15942. */
  15943. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15944. /**
  15945. * Execute the current animation
  15946. * @param delay defines the delay to add to the current frame
  15947. * @param from defines the lower bound of the animation range
  15948. * @param to defines the upper bound of the animation range
  15949. * @param loop defines if the current animation must loop
  15950. * @param speedRatio defines the current speed ratio
  15951. * @param weight defines the weight of the animation (default is -1 so no weight)
  15952. * @param onLoop optional callback called when animation loops
  15953. * @returns a boolean indicating if the animation is running
  15954. */
  15955. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15956. }
  15957. }
  15958. declare module "babylonjs/Animations/animatable" {
  15959. import { Animation } from "babylonjs/Animations/animation";
  15960. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15961. import { Nullable } from "babylonjs/types";
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Scene } from "babylonjs/scene";
  15964. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15965. import { Node } from "babylonjs/node";
  15966. /**
  15967. * Class used to store an actual running animation
  15968. */
  15969. export class Animatable {
  15970. /** defines the target object */
  15971. target: any;
  15972. /** defines the starting frame number (default is 0) */
  15973. fromFrame: number;
  15974. /** defines the ending frame number (default is 100) */
  15975. toFrame: number;
  15976. /** defines if the animation must loop (default is false) */
  15977. loopAnimation: boolean;
  15978. /** defines a callback to call when animation ends if it is not looping */
  15979. onAnimationEnd?: (() => void) | null | undefined;
  15980. /** defines a callback to call when animation loops */
  15981. onAnimationLoop?: (() => void) | null | undefined;
  15982. /** defines whether the animation should be evaluated additively */
  15983. isAdditive: boolean;
  15984. private _localDelayOffset;
  15985. private _pausedDelay;
  15986. private _runtimeAnimations;
  15987. private _paused;
  15988. private _scene;
  15989. private _speedRatio;
  15990. private _weight;
  15991. private _syncRoot;
  15992. /**
  15993. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15994. * This will only apply for non looping animation (default is true)
  15995. */
  15996. disposeOnEnd: boolean;
  15997. /**
  15998. * Gets a boolean indicating if the animation has started
  15999. */
  16000. animationStarted: boolean;
  16001. /**
  16002. * Observer raised when the animation ends
  16003. */
  16004. onAnimationEndObservable: Observable<Animatable>;
  16005. /**
  16006. * Observer raised when the animation loops
  16007. */
  16008. onAnimationLoopObservable: Observable<Animatable>;
  16009. /**
  16010. * Gets the root Animatable used to synchronize and normalize animations
  16011. */
  16012. get syncRoot(): Nullable<Animatable>;
  16013. /**
  16014. * Gets the current frame of the first RuntimeAnimation
  16015. * Used to synchronize Animatables
  16016. */
  16017. get masterFrame(): number;
  16018. /**
  16019. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16020. */
  16021. get weight(): number;
  16022. set weight(value: number);
  16023. /**
  16024. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16025. */
  16026. get speedRatio(): number;
  16027. set speedRatio(value: number);
  16028. /**
  16029. * Creates a new Animatable
  16030. * @param scene defines the hosting scene
  16031. * @param target defines the target object
  16032. * @param fromFrame defines the starting frame number (default is 0)
  16033. * @param toFrame defines the ending frame number (default is 100)
  16034. * @param loopAnimation defines if the animation must loop (default is false)
  16035. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16036. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16037. * @param animations defines a group of animation to add to the new Animatable
  16038. * @param onAnimationLoop defines a callback to call when animation loops
  16039. * @param isAdditive defines whether the animation should be evaluated additively
  16040. */
  16041. constructor(scene: Scene,
  16042. /** defines the target object */
  16043. target: any,
  16044. /** defines the starting frame number (default is 0) */
  16045. fromFrame?: number,
  16046. /** defines the ending frame number (default is 100) */
  16047. toFrame?: number,
  16048. /** defines if the animation must loop (default is false) */
  16049. loopAnimation?: boolean, speedRatio?: number,
  16050. /** defines a callback to call when animation ends if it is not looping */
  16051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16052. /** defines a callback to call when animation loops */
  16053. onAnimationLoop?: (() => void) | null | undefined,
  16054. /** defines whether the animation should be evaluated additively */
  16055. isAdditive?: boolean);
  16056. /**
  16057. * Synchronize and normalize current Animatable with a source Animatable
  16058. * This is useful when using animation weights and when animations are not of the same length
  16059. * @param root defines the root Animatable to synchronize with
  16060. * @returns the current Animatable
  16061. */
  16062. syncWith(root: Animatable): Animatable;
  16063. /**
  16064. * Gets the list of runtime animations
  16065. * @returns an array of RuntimeAnimation
  16066. */
  16067. getAnimations(): RuntimeAnimation[];
  16068. /**
  16069. * Adds more animations to the current animatable
  16070. * @param target defines the target of the animations
  16071. * @param animations defines the new animations to add
  16072. */
  16073. appendAnimations(target: any, animations: Animation[]): void;
  16074. /**
  16075. * Gets the source animation for a specific property
  16076. * @param property defines the propertyu to look for
  16077. * @returns null or the source animation for the given property
  16078. */
  16079. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16080. /**
  16081. * Gets the runtime animation for a specific property
  16082. * @param property defines the propertyu to look for
  16083. * @returns null or the runtime animation for the given property
  16084. */
  16085. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16086. /**
  16087. * Resets the animatable to its original state
  16088. */
  16089. reset(): void;
  16090. /**
  16091. * Allows the animatable to blend with current running animations
  16092. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16093. * @param blendingSpeed defines the blending speed to use
  16094. */
  16095. enableBlending(blendingSpeed: number): void;
  16096. /**
  16097. * Disable animation blending
  16098. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16099. */
  16100. disableBlending(): void;
  16101. /**
  16102. * Jump directly to a given frame
  16103. * @param frame defines the frame to jump to
  16104. */
  16105. goToFrame(frame: number): void;
  16106. /**
  16107. * Pause the animation
  16108. */
  16109. pause(): void;
  16110. /**
  16111. * Restart the animation
  16112. */
  16113. restart(): void;
  16114. private _raiseOnAnimationEnd;
  16115. /**
  16116. * Stop and delete the current animation
  16117. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16118. * @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)
  16119. */
  16120. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16121. /**
  16122. * Wait asynchronously for the animation to end
  16123. * @returns a promise which will be fullfilled when the animation ends
  16124. */
  16125. waitAsync(): Promise<Animatable>;
  16126. /** @hidden */
  16127. _animate(delay: number): boolean;
  16128. }
  16129. module "babylonjs/scene" {
  16130. interface Scene {
  16131. /** @hidden */
  16132. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16133. /** @hidden */
  16134. _processLateAnimationBindingsForMatrices(holder: {
  16135. totalWeight: number;
  16136. totalAdditiveWeight: number;
  16137. animations: RuntimeAnimation[];
  16138. additiveAnimations: RuntimeAnimation[];
  16139. originalValue: Matrix;
  16140. }): any;
  16141. /** @hidden */
  16142. _processLateAnimationBindingsForQuaternions(holder: {
  16143. totalWeight: number;
  16144. totalAdditiveWeight: number;
  16145. animations: RuntimeAnimation[];
  16146. additiveAnimations: RuntimeAnimation[];
  16147. originalValue: Quaternion;
  16148. }, refQuaternion: Quaternion): Quaternion;
  16149. /** @hidden */
  16150. _processLateAnimationBindings(): void;
  16151. /**
  16152. * Will start the animation sequence of a given target
  16153. * @param target defines the target
  16154. * @param from defines from which frame should animation start
  16155. * @param to defines until which frame should animation run.
  16156. * @param weight defines the weight to apply to the animation (1.0 by default)
  16157. * @param loop defines if the animation loops
  16158. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16159. * @param onAnimationEnd defines the function to be executed when the animation ends
  16160. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16161. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16162. * @param onAnimationLoop defines the callback to call when an animation loops
  16163. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16164. * @returns the animatable object created for this animation
  16165. */
  16166. 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;
  16167. /**
  16168. * Will start the animation sequence of a given target
  16169. * @param target defines the target
  16170. * @param from defines from which frame should animation start
  16171. * @param to defines until which frame should animation run.
  16172. * @param loop defines if the animation loops
  16173. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16174. * @param onAnimationEnd defines the function to be executed when the animation ends
  16175. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16176. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16177. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16178. * @param onAnimationLoop defines the callback to call when an animation loops
  16179. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16180. * @returns the animatable object created for this animation
  16181. */
  16182. 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;
  16183. /**
  16184. * Will start the animation sequence of a given target and its hierarchy
  16185. * @param target defines the target
  16186. * @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.
  16187. * @param from defines from which frame should animation start
  16188. * @param to defines until which frame should animation run.
  16189. * @param loop defines if the animation loops
  16190. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16191. * @param onAnimationEnd defines the function to be executed when the animation ends
  16192. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16193. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16194. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16195. * @param onAnimationLoop defines the callback to call when an animation loops
  16196. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16197. * @returns the list of created animatables
  16198. */
  16199. 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[];
  16200. /**
  16201. * Begin a new animation on a given node
  16202. * @param target defines the target where the animation will take place
  16203. * @param animations defines the list of animations to start
  16204. * @param from defines the initial value
  16205. * @param to defines the final value
  16206. * @param loop defines if you want animation to loop (off by default)
  16207. * @param speedRatio defines the speed ratio to apply to all animations
  16208. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16209. * @param onAnimationLoop defines the callback to call when an animation loops
  16210. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16211. * @returns the list of created animatables
  16212. */
  16213. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16214. /**
  16215. * Begin a new animation on a given node and its hierarchy
  16216. * @param target defines the root node where the animation will take place
  16217. * @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.
  16218. * @param animations defines the list of animations to start
  16219. * @param from defines the initial value
  16220. * @param to defines the final value
  16221. * @param loop defines if you want animation to loop (off by default)
  16222. * @param speedRatio defines the speed ratio to apply to all animations
  16223. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16224. * @param onAnimationLoop defines the callback to call when an animation loops
  16225. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16226. * @returns the list of animatables created for all nodes
  16227. */
  16228. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16229. /**
  16230. * Gets the animatable associated with a specific target
  16231. * @param target defines the target of the animatable
  16232. * @returns the required animatable if found
  16233. */
  16234. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16235. /**
  16236. * Gets all animatables associated with a given target
  16237. * @param target defines the target to look animatables for
  16238. * @returns an array of Animatables
  16239. */
  16240. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16241. /**
  16242. * Stops and removes all animations that have been applied to the scene
  16243. */
  16244. stopAllAnimations(): void;
  16245. /**
  16246. * Gets the current delta time used by animation engine
  16247. */
  16248. deltaTime: number;
  16249. }
  16250. }
  16251. module "babylonjs/Bones/bone" {
  16252. interface Bone {
  16253. /**
  16254. * Copy an animation range from another bone
  16255. * @param source defines the source bone
  16256. * @param rangeName defines the range name to copy
  16257. * @param frameOffset defines the frame offset
  16258. * @param rescaleAsRequired defines if rescaling must be applied if required
  16259. * @param skelDimensionsRatio defines the scaling ratio
  16260. * @returns true if operation was successful
  16261. */
  16262. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16263. }
  16264. }
  16265. }
  16266. declare module "babylonjs/Bones/skeleton" {
  16267. import { Bone } from "babylonjs/Bones/bone";
  16268. import { Observable } from "babylonjs/Misc/observable";
  16269. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16270. import { Scene } from "babylonjs/scene";
  16271. import { Nullable } from "babylonjs/types";
  16272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16273. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16274. import { Animatable } from "babylonjs/Animations/animatable";
  16275. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16276. import { Animation } from "babylonjs/Animations/animation";
  16277. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16278. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16280. /**
  16281. * Class used to handle skinning animations
  16282. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16283. */
  16284. export class Skeleton implements IAnimatable {
  16285. /** defines the skeleton name */
  16286. name: string;
  16287. /** defines the skeleton Id */
  16288. id: string;
  16289. /**
  16290. * Defines the list of child bones
  16291. */
  16292. bones: Bone[];
  16293. /**
  16294. * Defines an estimate of the dimension of the skeleton at rest
  16295. */
  16296. dimensionsAtRest: Vector3;
  16297. /**
  16298. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16299. */
  16300. needInitialSkinMatrix: boolean;
  16301. /**
  16302. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16303. */
  16304. overrideMesh: Nullable<AbstractMesh>;
  16305. /**
  16306. * Gets the list of animations attached to this skeleton
  16307. */
  16308. animations: Array<Animation>;
  16309. private _scene;
  16310. private _isDirty;
  16311. private _transformMatrices;
  16312. private _transformMatrixTexture;
  16313. private _meshesWithPoseMatrix;
  16314. private _animatables;
  16315. private _identity;
  16316. private _synchronizedWithMesh;
  16317. private _ranges;
  16318. private _lastAbsoluteTransformsUpdateId;
  16319. private _canUseTextureForBones;
  16320. private _uniqueId;
  16321. /** @hidden */
  16322. _numBonesWithLinkedTransformNode: number;
  16323. /** @hidden */
  16324. _hasWaitingData: Nullable<boolean>;
  16325. /**
  16326. * Specifies if the skeleton should be serialized
  16327. */
  16328. doNotSerialize: boolean;
  16329. private _useTextureToStoreBoneMatrices;
  16330. /**
  16331. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16332. * Please note that this option is not available if the hardware does not support it
  16333. */
  16334. get useTextureToStoreBoneMatrices(): boolean;
  16335. set useTextureToStoreBoneMatrices(value: boolean);
  16336. private _animationPropertiesOverride;
  16337. /**
  16338. * Gets or sets the animation properties override
  16339. */
  16340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16341. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16342. /**
  16343. * List of inspectable custom properties (used by the Inspector)
  16344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16345. */
  16346. inspectableCustomProperties: IInspectable[];
  16347. /**
  16348. * An observable triggered before computing the skeleton's matrices
  16349. */
  16350. onBeforeComputeObservable: Observable<Skeleton>;
  16351. /**
  16352. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16353. */
  16354. get isUsingTextureForMatrices(): boolean;
  16355. /**
  16356. * Gets the unique ID of this skeleton
  16357. */
  16358. get uniqueId(): number;
  16359. /**
  16360. * Creates a new skeleton
  16361. * @param name defines the skeleton name
  16362. * @param id defines the skeleton Id
  16363. * @param scene defines the hosting scene
  16364. */
  16365. constructor(
  16366. /** defines the skeleton name */
  16367. name: string,
  16368. /** defines the skeleton Id */
  16369. id: string, scene: Scene);
  16370. /**
  16371. * Gets the current object class name.
  16372. * @return the class name
  16373. */
  16374. getClassName(): string;
  16375. /**
  16376. * Returns an array containing the root bones
  16377. * @returns an array containing the root bones
  16378. */
  16379. getChildren(): Array<Bone>;
  16380. /**
  16381. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16382. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16383. * @returns a Float32Array containing matrices data
  16384. */
  16385. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16386. /**
  16387. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16389. * @returns a raw texture containing the data
  16390. */
  16391. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16392. /**
  16393. * Gets the current hosting scene
  16394. * @returns a scene object
  16395. */
  16396. getScene(): Scene;
  16397. /**
  16398. * Gets a string representing the current skeleton data
  16399. * @param fullDetails defines a boolean indicating if we want a verbose version
  16400. * @returns a string representing the current skeleton data
  16401. */
  16402. toString(fullDetails?: boolean): string;
  16403. /**
  16404. * Get bone's index searching by name
  16405. * @param name defines bone's name to search for
  16406. * @return the indice of the bone. Returns -1 if not found
  16407. */
  16408. getBoneIndexByName(name: string): number;
  16409. /**
  16410. * Creater a new animation range
  16411. * @param name defines the name of the range
  16412. * @param from defines the start key
  16413. * @param to defines the end key
  16414. */
  16415. createAnimationRange(name: string, from: number, to: number): void;
  16416. /**
  16417. * Delete a specific animation range
  16418. * @param name defines the name of the range
  16419. * @param deleteFrames defines if frames must be removed as well
  16420. */
  16421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16422. /**
  16423. * Gets a specific animation range
  16424. * @param name defines the name of the range to look for
  16425. * @returns the requested animation range or null if not found
  16426. */
  16427. getAnimationRange(name: string): Nullable<AnimationRange>;
  16428. /**
  16429. * Gets the list of all animation ranges defined on this skeleton
  16430. * @returns an array
  16431. */
  16432. getAnimationRanges(): Nullable<AnimationRange>[];
  16433. /**
  16434. * Copy animation range from a source skeleton.
  16435. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16436. * @param source defines the source skeleton
  16437. * @param name defines the name of the range to copy
  16438. * @param rescaleAsRequired defines if rescaling must be applied if required
  16439. * @returns true if operation was successful
  16440. */
  16441. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16442. /**
  16443. * Forces the skeleton to go to rest pose
  16444. */
  16445. returnToRest(): void;
  16446. private _getHighestAnimationFrame;
  16447. /**
  16448. * Begin a specific animation range
  16449. * @param name defines the name of the range to start
  16450. * @param loop defines if looping must be turned on (false by default)
  16451. * @param speedRatio defines the speed ratio to apply (1 by default)
  16452. * @param onAnimationEnd defines a callback which will be called when animation will end
  16453. * @returns a new animatable
  16454. */
  16455. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16456. /**
  16457. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16458. * @param skeleton defines the Skeleton containing the animation range to convert
  16459. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16460. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16461. * @returns the original skeleton
  16462. */
  16463. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16464. /** @hidden */
  16465. _markAsDirty(): void;
  16466. /** @hidden */
  16467. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. /** @hidden */
  16469. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16470. private _computeTransformMatrices;
  16471. /**
  16472. * Build all resources required to render a skeleton
  16473. */
  16474. prepare(): void;
  16475. /**
  16476. * Gets the list of animatables currently running for this skeleton
  16477. * @returns an array of animatables
  16478. */
  16479. getAnimatables(): IAnimatable[];
  16480. /**
  16481. * Clone the current skeleton
  16482. * @param name defines the name of the new skeleton
  16483. * @param id defines the id of the new skeleton
  16484. * @returns the new skeleton
  16485. */
  16486. clone(name: string, id?: string): Skeleton;
  16487. /**
  16488. * Enable animation blending for this skeleton
  16489. * @param blendingSpeed defines the blending speed to apply
  16490. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16491. */
  16492. enableBlending(blendingSpeed?: number): void;
  16493. /**
  16494. * Releases all resources associated with the current skeleton
  16495. */
  16496. dispose(): void;
  16497. /**
  16498. * Serialize the skeleton in a JSON object
  16499. * @returns a JSON object
  16500. */
  16501. serialize(): any;
  16502. /**
  16503. * Creates a new skeleton from serialized data
  16504. * @param parsedSkeleton defines the serialized data
  16505. * @param scene defines the hosting scene
  16506. * @returns a new skeleton
  16507. */
  16508. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16509. /**
  16510. * Compute all node absolute transforms
  16511. * @param forceUpdate defines if computation must be done even if cache is up to date
  16512. */
  16513. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16514. /**
  16515. * Gets the root pose matrix
  16516. * @returns a matrix
  16517. */
  16518. getPoseMatrix(): Nullable<Matrix>;
  16519. /**
  16520. * Sorts bones per internal index
  16521. */
  16522. sortBones(): void;
  16523. private _sortBones;
  16524. }
  16525. }
  16526. declare module "babylonjs/Meshes/instancedMesh" {
  16527. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16528. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16529. import { Camera } from "babylonjs/Cameras/camera";
  16530. import { Node } from "babylonjs/node";
  16531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16532. import { Mesh } from "babylonjs/Meshes/mesh";
  16533. import { Material } from "babylonjs/Materials/material";
  16534. import { Skeleton } from "babylonjs/Bones/skeleton";
  16535. import { Light } from "babylonjs/Lights/light";
  16536. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16537. /**
  16538. * Creates an instance based on a source mesh.
  16539. */
  16540. export class InstancedMesh extends AbstractMesh {
  16541. private _sourceMesh;
  16542. private _currentLOD;
  16543. /** @hidden */
  16544. _indexInSourceMeshInstanceArray: number;
  16545. constructor(name: string, source: Mesh);
  16546. /**
  16547. * Returns the string "InstancedMesh".
  16548. */
  16549. getClassName(): string;
  16550. /** Gets the list of lights affecting that mesh */
  16551. get lightSources(): Light[];
  16552. _resyncLightSources(): void;
  16553. _resyncLightSource(light: Light): void;
  16554. _removeLightSource(light: Light, dispose: boolean): void;
  16555. /**
  16556. * If the source mesh receives shadows
  16557. */
  16558. get receiveShadows(): boolean;
  16559. /**
  16560. * The material of the source mesh
  16561. */
  16562. get material(): Nullable<Material>;
  16563. /**
  16564. * Visibility of the source mesh
  16565. */
  16566. get visibility(): number;
  16567. /**
  16568. * Skeleton of the source mesh
  16569. */
  16570. get skeleton(): Nullable<Skeleton>;
  16571. /**
  16572. * Rendering ground id of the source mesh
  16573. */
  16574. get renderingGroupId(): number;
  16575. set renderingGroupId(value: number);
  16576. /**
  16577. * Returns the total number of vertices (integer).
  16578. */
  16579. getTotalVertices(): number;
  16580. /**
  16581. * Returns a positive integer : the total number of indices in this mesh geometry.
  16582. * @returns the numner of indices or zero if the mesh has no geometry.
  16583. */
  16584. getTotalIndices(): number;
  16585. /**
  16586. * The source mesh of the instance
  16587. */
  16588. get sourceMesh(): Mesh;
  16589. /**
  16590. * Creates a new InstancedMesh object from the mesh model.
  16591. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16592. * @param name defines the name of the new instance
  16593. * @returns a new InstancedMesh
  16594. */
  16595. createInstance(name: string): InstancedMesh;
  16596. /**
  16597. * Is this node ready to be used/rendered
  16598. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16599. * @return {boolean} is it ready
  16600. */
  16601. isReady(completeCheck?: boolean): boolean;
  16602. /**
  16603. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16604. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16605. * @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.
  16606. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16607. */
  16608. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16609. /**
  16610. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16611. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16612. * The `data` are either a numeric array either a Float32Array.
  16613. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16614. * 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).
  16615. * Note that a new underlying VertexBuffer object is created each call.
  16616. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16617. *
  16618. * Possible `kind` values :
  16619. * - VertexBuffer.PositionKind
  16620. * - VertexBuffer.UVKind
  16621. * - VertexBuffer.UV2Kind
  16622. * - VertexBuffer.UV3Kind
  16623. * - VertexBuffer.UV4Kind
  16624. * - VertexBuffer.UV5Kind
  16625. * - VertexBuffer.UV6Kind
  16626. * - VertexBuffer.ColorKind
  16627. * - VertexBuffer.MatricesIndicesKind
  16628. * - VertexBuffer.MatricesIndicesExtraKind
  16629. * - VertexBuffer.MatricesWeightsKind
  16630. * - VertexBuffer.MatricesWeightsExtraKind
  16631. *
  16632. * Returns the Mesh.
  16633. */
  16634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16635. /**
  16636. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16637. * If the mesh has no geometry, it is simply returned as it is.
  16638. * The `data` are either a numeric array either a Float32Array.
  16639. * No new underlying VertexBuffer object is created.
  16640. * 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.
  16641. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16642. *
  16643. * Possible `kind` values :
  16644. * - VertexBuffer.PositionKind
  16645. * - VertexBuffer.UVKind
  16646. * - VertexBuffer.UV2Kind
  16647. * - VertexBuffer.UV3Kind
  16648. * - VertexBuffer.UV4Kind
  16649. * - VertexBuffer.UV5Kind
  16650. * - VertexBuffer.UV6Kind
  16651. * - VertexBuffer.ColorKind
  16652. * - VertexBuffer.MatricesIndicesKind
  16653. * - VertexBuffer.MatricesIndicesExtraKind
  16654. * - VertexBuffer.MatricesWeightsKind
  16655. * - VertexBuffer.MatricesWeightsExtraKind
  16656. *
  16657. * Returns the Mesh.
  16658. */
  16659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16660. /**
  16661. * Sets the mesh indices.
  16662. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16663. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16664. * This method creates a new index buffer each call.
  16665. * Returns the Mesh.
  16666. */
  16667. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16668. /**
  16669. * Boolean : True if the mesh owns the requested kind of data.
  16670. */
  16671. isVerticesDataPresent(kind: string): boolean;
  16672. /**
  16673. * Returns an array of indices (IndicesArray).
  16674. */
  16675. getIndices(): Nullable<IndicesArray>;
  16676. get _positions(): Nullable<Vector3[]>;
  16677. /**
  16678. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16679. * This means the mesh underlying bounding box and sphere are recomputed.
  16680. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16681. * @returns the current mesh
  16682. */
  16683. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16684. /** @hidden */
  16685. _preActivate(): InstancedMesh;
  16686. /** @hidden */
  16687. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16688. /** @hidden */
  16689. _postActivate(): void;
  16690. getWorldMatrix(): Matrix;
  16691. get isAnInstance(): boolean;
  16692. /**
  16693. * Returns the current associated LOD AbstractMesh.
  16694. */
  16695. getLOD(camera: Camera): AbstractMesh;
  16696. /** @hidden */
  16697. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16698. /** @hidden */
  16699. _syncSubMeshes(): InstancedMesh;
  16700. /** @hidden */
  16701. _generatePointsArray(): boolean;
  16702. /**
  16703. * Creates a new InstancedMesh from the current mesh.
  16704. * - name (string) : the cloned mesh name
  16705. * - newParent (optional Node) : the optional Node to parent the clone to.
  16706. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16707. *
  16708. * Returns the clone.
  16709. */
  16710. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16711. /**
  16712. * Disposes the InstancedMesh.
  16713. * Returns nothing.
  16714. */
  16715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16716. }
  16717. module "babylonjs/Meshes/mesh" {
  16718. interface Mesh {
  16719. /**
  16720. * Register a custom buffer that will be instanced
  16721. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16722. * @param kind defines the buffer kind
  16723. * @param stride defines the stride in floats
  16724. */
  16725. registerInstancedBuffer(kind: string, stride: number): void;
  16726. /**
  16727. * true to use the edge renderer for all instances of this mesh
  16728. */
  16729. edgesShareWithInstances: boolean;
  16730. /** @hidden */
  16731. _userInstancedBuffersStorage: {
  16732. data: {
  16733. [key: string]: Float32Array;
  16734. };
  16735. sizes: {
  16736. [key: string]: number;
  16737. };
  16738. vertexBuffers: {
  16739. [key: string]: Nullable<VertexBuffer>;
  16740. };
  16741. strides: {
  16742. [key: string]: number;
  16743. };
  16744. };
  16745. }
  16746. }
  16747. module "babylonjs/Meshes/abstractMesh" {
  16748. interface AbstractMesh {
  16749. /**
  16750. * Object used to store instanced buffers defined by user
  16751. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16752. */
  16753. instancedBuffers: {
  16754. [key: string]: any;
  16755. };
  16756. }
  16757. }
  16758. }
  16759. declare module "babylonjs/Materials/shaderMaterial" {
  16760. import { Nullable } from "babylonjs/types";
  16761. import { Scene } from "babylonjs/scene";
  16762. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16764. import { Mesh } from "babylonjs/Meshes/mesh";
  16765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16767. import { Effect } from "babylonjs/Materials/effect";
  16768. import { Material } from "babylonjs/Materials/material";
  16769. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16770. /**
  16771. * Defines the options associated with the creation of a shader material.
  16772. */
  16773. export interface IShaderMaterialOptions {
  16774. /**
  16775. * Does the material work in alpha blend mode
  16776. */
  16777. needAlphaBlending: boolean;
  16778. /**
  16779. * Does the material work in alpha test mode
  16780. */
  16781. needAlphaTesting: boolean;
  16782. /**
  16783. * The list of attribute names used in the shader
  16784. */
  16785. attributes: string[];
  16786. /**
  16787. * The list of unifrom names used in the shader
  16788. */
  16789. uniforms: string[];
  16790. /**
  16791. * The list of UBO names used in the shader
  16792. */
  16793. uniformBuffers: string[];
  16794. /**
  16795. * The list of sampler names used in the shader
  16796. */
  16797. samplers: string[];
  16798. /**
  16799. * The list of defines used in the shader
  16800. */
  16801. defines: string[];
  16802. }
  16803. /**
  16804. * 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.
  16805. *
  16806. * This returned material effects how the mesh will look based on the code in the shaders.
  16807. *
  16808. * @see http://doc.babylonjs.com/how_to/shader_material
  16809. */
  16810. export class ShaderMaterial extends Material {
  16811. private _shaderPath;
  16812. private _options;
  16813. private _textures;
  16814. private _textureArrays;
  16815. private _floats;
  16816. private _ints;
  16817. private _floatsArrays;
  16818. private _colors3;
  16819. private _colors3Arrays;
  16820. private _colors4;
  16821. private _colors4Arrays;
  16822. private _vectors2;
  16823. private _vectors3;
  16824. private _vectors4;
  16825. private _matrices;
  16826. private _matrixArrays;
  16827. private _matrices3x3;
  16828. private _matrices2x2;
  16829. private _vectors2Arrays;
  16830. private _vectors3Arrays;
  16831. private _vectors4Arrays;
  16832. private _cachedWorldViewMatrix;
  16833. private _cachedWorldViewProjectionMatrix;
  16834. private _renderId;
  16835. private _multiview;
  16836. private _cachedDefines;
  16837. /** Define the Url to load snippets */
  16838. static SnippetUrl: string;
  16839. /** Snippet ID if the material was created from the snippet server */
  16840. snippetId: string;
  16841. /**
  16842. * Instantiate a new shader material.
  16843. * 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.
  16844. * This returned material effects how the mesh will look based on the code in the shaders.
  16845. * @see http://doc.babylonjs.com/how_to/shader_material
  16846. * @param name Define the name of the material in the scene
  16847. * @param scene Define the scene the material belongs to
  16848. * @param shaderPath Defines the route to the shader code in one of three ways:
  16849. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16850. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16851. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16852. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16853. * @param options Define the options used to create the shader
  16854. */
  16855. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16856. /**
  16857. * Gets the shader path used to define the shader code
  16858. * It can be modified to trigger a new compilation
  16859. */
  16860. get shaderPath(): any;
  16861. /**
  16862. * Sets the shader path used to define the shader code
  16863. * It can be modified to trigger a new compilation
  16864. */
  16865. set shaderPath(shaderPath: any);
  16866. /**
  16867. * Gets the options used to compile the shader.
  16868. * They can be modified to trigger a new compilation
  16869. */
  16870. get options(): IShaderMaterialOptions;
  16871. /**
  16872. * Gets the current class name of the material e.g. "ShaderMaterial"
  16873. * Mainly use in serialization.
  16874. * @returns the class name
  16875. */
  16876. getClassName(): string;
  16877. /**
  16878. * Specifies if the material will require alpha blending
  16879. * @returns a boolean specifying if alpha blending is needed
  16880. */
  16881. needAlphaBlending(): boolean;
  16882. /**
  16883. * Specifies if this material should be rendered in alpha test mode
  16884. * @returns a boolean specifying if an alpha test is needed.
  16885. */
  16886. needAlphaTesting(): boolean;
  16887. private _checkUniform;
  16888. /**
  16889. * Set a texture in the shader.
  16890. * @param name Define the name of the uniform samplers as defined in the shader
  16891. * @param texture Define the texture to bind to this sampler
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16895. /**
  16896. * Set a texture array in the shader.
  16897. * @param name Define the name of the uniform sampler array as defined in the shader
  16898. * @param textures Define the list of textures to bind to this sampler
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16902. /**
  16903. * Set a float in the shader.
  16904. * @param name Define the name of the uniform as defined in the shader
  16905. * @param value Define the value to give to the uniform
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setFloat(name: string, value: number): ShaderMaterial;
  16909. /**
  16910. * Set a int in the shader.
  16911. * @param name Define the name of the uniform as defined in the shader
  16912. * @param value Define the value to give to the uniform
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setInt(name: string, value: number): ShaderMaterial;
  16916. /**
  16917. * Set an array of floats in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloats(name: string, value: number[]): ShaderMaterial;
  16923. /**
  16924. * Set a vec3 in the shader from a Color3.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setColor3(name: string, value: Color3): ShaderMaterial;
  16930. /**
  16931. * Set a vec3 array in the shader from a Color3 array.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec4 in the shader from a Color4.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor4(name: string, value: Color4): ShaderMaterial;
  16944. /**
  16945. * Set a vec4 array in the shader from a Color4 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec2 in the shader from a Vector2.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setVector2(name: string, value: Vector2): ShaderMaterial;
  16958. /**
  16959. * Set a vec3 in the shader from a Vector3.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector3(name: string, value: Vector3): ShaderMaterial;
  16965. /**
  16966. * Set a vec4 in the shader from a Vector4.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector4(name: string, value: Vector4): ShaderMaterial;
  16972. /**
  16973. * Set a mat4 in the shader from a Matrix.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16979. /**
  16980. * Set a float32Array in the shader from a matrix array.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. /**
  17015. * Set a vec4 array in the shader from a number array.
  17016. * @param name Define the name of the uniform as defined in the shader
  17017. * @param value Define the value to give to the uniform
  17018. * @return the material itself allowing "fluent" like uniform updates
  17019. */
  17020. setArray4(name: string, value: number[]): ShaderMaterial;
  17021. private _checkCache;
  17022. /**
  17023. * Specifies that the submesh is ready to be used
  17024. * @param mesh defines the mesh to check
  17025. * @param subMesh defines which submesh to check
  17026. * @param useInstances specifies that instances should be used
  17027. * @returns a boolean indicating that the submesh is ready or not
  17028. */
  17029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17030. /**
  17031. * Checks if the material is ready to render the requested mesh
  17032. * @param mesh Define the mesh to render
  17033. * @param useInstances Define whether or not the material is used with instances
  17034. * @returns true if ready, otherwise false
  17035. */
  17036. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17037. /**
  17038. * Binds the world matrix to the material
  17039. * @param world defines the world transformation matrix
  17040. * @param effectOverride - If provided, use this effect instead of internal effect
  17041. */
  17042. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17043. /**
  17044. * Binds the submesh to this material by preparing the effect and shader to draw
  17045. * @param world defines the world transformation matrix
  17046. * @param mesh defines the mesh containing the submesh
  17047. * @param subMesh defines the submesh to bind the material to
  17048. */
  17049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17050. /**
  17051. * Binds the material to the mesh
  17052. * @param world defines the world transformation matrix
  17053. * @param mesh defines the mesh to bind the material to
  17054. * @param effectOverride - If provided, use this effect instead of internal effect
  17055. */
  17056. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17057. protected _afterBind(mesh?: Mesh): void;
  17058. /**
  17059. * Gets the active textures from the material
  17060. * @returns an array of textures
  17061. */
  17062. getActiveTextures(): BaseTexture[];
  17063. /**
  17064. * Specifies if the material uses a texture
  17065. * @param texture defines the texture to check against the material
  17066. * @returns a boolean specifying if the material uses the texture
  17067. */
  17068. hasTexture(texture: BaseTexture): boolean;
  17069. /**
  17070. * Makes a duplicate of the material, and gives it a new name
  17071. * @param name defines the new name for the duplicated material
  17072. * @returns the cloned material
  17073. */
  17074. clone(name: string): ShaderMaterial;
  17075. /**
  17076. * Disposes the material
  17077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17080. */
  17081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17082. /**
  17083. * Serializes this material in a JSON representation
  17084. * @returns the serialized material object
  17085. */
  17086. serialize(): any;
  17087. /**
  17088. * Creates a shader material from parsed shader material data
  17089. * @param source defines the JSON represnetation of the material
  17090. * @param scene defines the hosting scene
  17091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17092. * @returns a new material
  17093. */
  17094. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17095. /**
  17096. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17097. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17098. * @param url defines the url to load from
  17099. * @param scene defines the hosting scene
  17100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17101. * @returns a promise that will resolve to the new ShaderMaterial
  17102. */
  17103. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17104. /**
  17105. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17106. * @param snippetId defines the snippet to load
  17107. * @param scene defines the hosting scene
  17108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17109. * @returns a promise that will resolve to the new ShaderMaterial
  17110. */
  17111. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17112. }
  17113. }
  17114. declare module "babylonjs/Shaders/color.fragment" {
  17115. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17116. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17117. /** @hidden */
  17118. export var colorPixelShader: {
  17119. name: string;
  17120. shader: string;
  17121. };
  17122. }
  17123. declare module "babylonjs/Shaders/color.vertex" {
  17124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17125. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17126. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17127. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17128. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17129. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17130. /** @hidden */
  17131. export var colorVertexShader: {
  17132. name: string;
  17133. shader: string;
  17134. };
  17135. }
  17136. declare module "babylonjs/Meshes/linesMesh" {
  17137. import { Nullable } from "babylonjs/types";
  17138. import { Scene } from "babylonjs/scene";
  17139. import { Color3 } from "babylonjs/Maths/math.color";
  17140. import { Node } from "babylonjs/node";
  17141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17142. import { Mesh } from "babylonjs/Meshes/mesh";
  17143. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17144. import { Effect } from "babylonjs/Materials/effect";
  17145. import { Material } from "babylonjs/Materials/material";
  17146. import "babylonjs/Shaders/color.fragment";
  17147. import "babylonjs/Shaders/color.vertex";
  17148. /**
  17149. * Line mesh
  17150. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17151. */
  17152. export class LinesMesh extends Mesh {
  17153. /**
  17154. * If vertex color should be applied to the mesh
  17155. */
  17156. readonly useVertexColor?: boolean | undefined;
  17157. /**
  17158. * If vertex alpha should be applied to the mesh
  17159. */
  17160. readonly useVertexAlpha?: boolean | undefined;
  17161. /**
  17162. * Color of the line (Default: White)
  17163. */
  17164. color: Color3;
  17165. /**
  17166. * Alpha of the line (Default: 1)
  17167. */
  17168. alpha: number;
  17169. /**
  17170. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17171. * This margin is expressed in world space coordinates, so its value may vary.
  17172. * Default value is 0.1
  17173. */
  17174. intersectionThreshold: number;
  17175. private _colorShader;
  17176. private color4;
  17177. /**
  17178. * Creates a new LinesMesh
  17179. * @param name defines the name
  17180. * @param scene defines the hosting scene
  17181. * @param parent defines the parent mesh if any
  17182. * @param source defines the optional source LinesMesh used to clone data from
  17183. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17184. * When false, achieved by calling a clone(), also passing False.
  17185. * This will make creation of children, recursive.
  17186. * @param useVertexColor defines if this LinesMesh supports vertex color
  17187. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17188. */
  17189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17190. /**
  17191. * If vertex color should be applied to the mesh
  17192. */
  17193. useVertexColor?: boolean | undefined,
  17194. /**
  17195. * If vertex alpha should be applied to the mesh
  17196. */
  17197. useVertexAlpha?: boolean | undefined);
  17198. private _addClipPlaneDefine;
  17199. private _removeClipPlaneDefine;
  17200. isReady(): boolean;
  17201. /**
  17202. * Returns the string "LineMesh"
  17203. */
  17204. getClassName(): string;
  17205. /**
  17206. * @hidden
  17207. */
  17208. get material(): Material;
  17209. /**
  17210. * @hidden
  17211. */
  17212. set material(value: Material);
  17213. /**
  17214. * @hidden
  17215. */
  17216. get checkCollisions(): boolean;
  17217. /** @hidden */
  17218. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17219. /** @hidden */
  17220. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17221. /**
  17222. * Disposes of the line mesh
  17223. * @param doNotRecurse If children should be disposed
  17224. */
  17225. dispose(doNotRecurse?: boolean): void;
  17226. /**
  17227. * Returns a new LineMesh object cloned from the current one.
  17228. */
  17229. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17230. /**
  17231. * Creates a new InstancedLinesMesh object from the mesh model.
  17232. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17233. * @param name defines the name of the new instance
  17234. * @returns a new InstancedLinesMesh
  17235. */
  17236. createInstance(name: string): InstancedLinesMesh;
  17237. }
  17238. /**
  17239. * Creates an instance based on a source LinesMesh
  17240. */
  17241. export class InstancedLinesMesh extends InstancedMesh {
  17242. /**
  17243. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17244. * This margin is expressed in world space coordinates, so its value may vary.
  17245. * Initilized with the intersectionThreshold value of the source LinesMesh
  17246. */
  17247. intersectionThreshold: number;
  17248. constructor(name: string, source: LinesMesh);
  17249. /**
  17250. * Returns the string "InstancedLinesMesh".
  17251. */
  17252. getClassName(): string;
  17253. }
  17254. }
  17255. declare module "babylonjs/Shaders/line.fragment" {
  17256. /** @hidden */
  17257. export var linePixelShader: {
  17258. name: string;
  17259. shader: string;
  17260. };
  17261. }
  17262. declare module "babylonjs/Shaders/line.vertex" {
  17263. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17264. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17265. /** @hidden */
  17266. export var lineVertexShader: {
  17267. name: string;
  17268. shader: string;
  17269. };
  17270. }
  17271. declare module "babylonjs/Rendering/edgesRenderer" {
  17272. import { Nullable } from "babylonjs/types";
  17273. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17275. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17276. import { IDisposable } from "babylonjs/scene";
  17277. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17278. import "babylonjs/Shaders/line.fragment";
  17279. import "babylonjs/Shaders/line.vertex";
  17280. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17281. import { SmartArray } from "babylonjs/Misc/smartArray";
  17282. module "babylonjs/scene" {
  17283. interface Scene {
  17284. /** @hidden */
  17285. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17286. }
  17287. }
  17288. module "babylonjs/Meshes/abstractMesh" {
  17289. interface AbstractMesh {
  17290. /**
  17291. * Gets the edgesRenderer associated with the mesh
  17292. */
  17293. edgesRenderer: Nullable<EdgesRenderer>;
  17294. }
  17295. }
  17296. module "babylonjs/Meshes/linesMesh" {
  17297. interface LinesMesh {
  17298. /**
  17299. * Enables the edge rendering mode on the mesh.
  17300. * This mode makes the mesh edges visible
  17301. * @param epsilon defines the maximal distance between two angles to detect a face
  17302. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17303. * @returns the currentAbstractMesh
  17304. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17305. */
  17306. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17307. }
  17308. }
  17309. module "babylonjs/Meshes/linesMesh" {
  17310. interface InstancedLinesMesh {
  17311. /**
  17312. * Enables the edge rendering mode on the mesh.
  17313. * This mode makes the mesh edges visible
  17314. * @param epsilon defines the maximal distance between two angles to detect a face
  17315. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17316. * @returns the current InstancedLinesMesh
  17317. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17318. */
  17319. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17320. }
  17321. }
  17322. /**
  17323. * Defines the minimum contract an Edges renderer should follow.
  17324. */
  17325. export interface IEdgesRenderer extends IDisposable {
  17326. /**
  17327. * Gets or sets a boolean indicating if the edgesRenderer is active
  17328. */
  17329. isEnabled: boolean;
  17330. /**
  17331. * Renders the edges of the attached mesh,
  17332. */
  17333. render(): void;
  17334. /**
  17335. * Checks wether or not the edges renderer is ready to render.
  17336. * @return true if ready, otherwise false.
  17337. */
  17338. isReady(): boolean;
  17339. /**
  17340. * List of instances to render in case the source mesh has instances
  17341. */
  17342. customInstances: SmartArray<Matrix>;
  17343. }
  17344. /**
  17345. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17346. */
  17347. export class EdgesRenderer implements IEdgesRenderer {
  17348. /**
  17349. * Define the size of the edges with an orthographic camera
  17350. */
  17351. edgesWidthScalerForOrthographic: number;
  17352. /**
  17353. * Define the size of the edges with a perspective camera
  17354. */
  17355. edgesWidthScalerForPerspective: number;
  17356. protected _source: AbstractMesh;
  17357. protected _linesPositions: number[];
  17358. protected _linesNormals: number[];
  17359. protected _linesIndices: number[];
  17360. protected _epsilon: number;
  17361. protected _indicesCount: number;
  17362. protected _lineShader: ShaderMaterial;
  17363. protected _ib: DataBuffer;
  17364. protected _buffers: {
  17365. [key: string]: Nullable<VertexBuffer>;
  17366. };
  17367. protected _buffersForInstances: {
  17368. [key: string]: Nullable<VertexBuffer>;
  17369. };
  17370. protected _checkVerticesInsteadOfIndices: boolean;
  17371. private _meshRebuildObserver;
  17372. private _meshDisposeObserver;
  17373. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17374. isEnabled: boolean;
  17375. /**
  17376. * List of instances to render in case the source mesh has instances
  17377. */
  17378. customInstances: SmartArray<Matrix>;
  17379. private static GetShader;
  17380. /**
  17381. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17382. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17383. * @param source Mesh used to create edges
  17384. * @param epsilon sum of angles in adjacency to check for edge
  17385. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17386. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17387. */
  17388. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17389. protected _prepareRessources(): void;
  17390. /** @hidden */
  17391. _rebuild(): void;
  17392. /**
  17393. * Releases the required resources for the edges renderer
  17394. */
  17395. dispose(): void;
  17396. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17397. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17398. /**
  17399. * Checks if the pair of p0 and p1 is en edge
  17400. * @param faceIndex
  17401. * @param edge
  17402. * @param faceNormals
  17403. * @param p0
  17404. * @param p1
  17405. * @private
  17406. */
  17407. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17408. /**
  17409. * push line into the position, normal and index buffer
  17410. * @protected
  17411. */
  17412. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17413. /**
  17414. * Generates lines edges from adjacencjes
  17415. * @private
  17416. */
  17417. _generateEdgesLines(): void;
  17418. /**
  17419. * Checks wether or not the edges renderer is ready to render.
  17420. * @return true if ready, otherwise false.
  17421. */
  17422. isReady(): boolean;
  17423. /**
  17424. * Renders the edges of the attached mesh,
  17425. */
  17426. render(): void;
  17427. }
  17428. /**
  17429. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17430. */
  17431. export class LineEdgesRenderer extends EdgesRenderer {
  17432. /**
  17433. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17434. * @param source LineMesh used to generate edges
  17435. * @param epsilon not important (specified angle for edge detection)
  17436. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17437. */
  17438. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17439. /**
  17440. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17441. */
  17442. _generateEdgesLines(): void;
  17443. }
  17444. }
  17445. declare module "babylonjs/Rendering/renderingGroup" {
  17446. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17449. import { Nullable } from "babylonjs/types";
  17450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17451. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17452. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17453. import { Material } from "babylonjs/Materials/material";
  17454. import { Scene } from "babylonjs/scene";
  17455. /**
  17456. * This represents the object necessary to create a rendering group.
  17457. * This is exclusively used and created by the rendering manager.
  17458. * To modify the behavior, you use the available helpers in your scene or meshes.
  17459. * @hidden
  17460. */
  17461. export class RenderingGroup {
  17462. index: number;
  17463. private static _zeroVector;
  17464. private _scene;
  17465. private _opaqueSubMeshes;
  17466. private _transparentSubMeshes;
  17467. private _alphaTestSubMeshes;
  17468. private _depthOnlySubMeshes;
  17469. private _particleSystems;
  17470. private _spriteManagers;
  17471. private _opaqueSortCompareFn;
  17472. private _alphaTestSortCompareFn;
  17473. private _transparentSortCompareFn;
  17474. private _renderOpaque;
  17475. private _renderAlphaTest;
  17476. private _renderTransparent;
  17477. /** @hidden */
  17478. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17479. onBeforeTransparentRendering: () => void;
  17480. /**
  17481. * Set the opaque sort comparison function.
  17482. * If null the sub meshes will be render in the order they were created
  17483. */
  17484. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17485. /**
  17486. * Set the alpha test sort comparison function.
  17487. * If null the sub meshes will be render in the order they were created
  17488. */
  17489. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17490. /**
  17491. * Set the transparent sort comparison function.
  17492. * If null the sub meshes will be render in the order they were created
  17493. */
  17494. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17495. /**
  17496. * Creates a new rendering group.
  17497. * @param index The rendering group index
  17498. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17499. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17500. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17501. */
  17502. 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>);
  17503. /**
  17504. * Render all the sub meshes contained in the group.
  17505. * @param customRenderFunction Used to override the default render behaviour of the group.
  17506. * @returns true if rendered some submeshes.
  17507. */
  17508. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17509. /**
  17510. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17511. * @param subMeshes The submeshes to render
  17512. */
  17513. private renderOpaqueSorted;
  17514. /**
  17515. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17516. * @param subMeshes The submeshes to render
  17517. */
  17518. private renderAlphaTestSorted;
  17519. /**
  17520. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17521. * @param subMeshes The submeshes to render
  17522. */
  17523. private renderTransparentSorted;
  17524. /**
  17525. * Renders the submeshes in a specified order.
  17526. * @param subMeshes The submeshes to sort before render
  17527. * @param sortCompareFn The comparison function use to sort
  17528. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17529. * @param transparent Specifies to activate blending if true
  17530. */
  17531. private static renderSorted;
  17532. /**
  17533. * Renders the submeshes in the order they were dispatched (no sort applied).
  17534. * @param subMeshes The submeshes to render
  17535. */
  17536. private static renderUnsorted;
  17537. /**
  17538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17539. * are rendered back to front if in the same alpha index.
  17540. *
  17541. * @param a The first submesh
  17542. * @param b The second submesh
  17543. * @returns The result of the comparison
  17544. */
  17545. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17546. /**
  17547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17548. * are rendered back to front.
  17549. *
  17550. * @param a The first submesh
  17551. * @param b The second submesh
  17552. * @returns The result of the comparison
  17553. */
  17554. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17555. /**
  17556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17557. * are rendered front to back (prevent overdraw).
  17558. *
  17559. * @param a The first submesh
  17560. * @param b The second submesh
  17561. * @returns The result of the comparison
  17562. */
  17563. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17564. /**
  17565. * Resets the different lists of submeshes to prepare a new frame.
  17566. */
  17567. prepare(): void;
  17568. dispose(): void;
  17569. /**
  17570. * Inserts the submesh in its correct queue depending on its material.
  17571. * @param subMesh The submesh to dispatch
  17572. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17573. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17574. */
  17575. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17576. dispatchSprites(spriteManager: ISpriteManager): void;
  17577. dispatchParticles(particleSystem: IParticleSystem): void;
  17578. private _renderParticles;
  17579. private _renderSprites;
  17580. }
  17581. }
  17582. declare module "babylonjs/Rendering/renderingManager" {
  17583. import { Nullable } from "babylonjs/types";
  17584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17586. import { SmartArray } from "babylonjs/Misc/smartArray";
  17587. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17589. import { Material } from "babylonjs/Materials/material";
  17590. import { Scene } from "babylonjs/scene";
  17591. import { Camera } from "babylonjs/Cameras/camera";
  17592. /**
  17593. * Interface describing the different options available in the rendering manager
  17594. * regarding Auto Clear between groups.
  17595. */
  17596. export interface IRenderingManagerAutoClearSetup {
  17597. /**
  17598. * Defines whether or not autoclear is enable.
  17599. */
  17600. autoClear: boolean;
  17601. /**
  17602. * Defines whether or not to autoclear the depth buffer.
  17603. */
  17604. depth: boolean;
  17605. /**
  17606. * Defines whether or not to autoclear the stencil buffer.
  17607. */
  17608. stencil: boolean;
  17609. }
  17610. /**
  17611. * This class is used by the onRenderingGroupObservable
  17612. */
  17613. export class RenderingGroupInfo {
  17614. /**
  17615. * The Scene that being rendered
  17616. */
  17617. scene: Scene;
  17618. /**
  17619. * The camera currently used for the rendering pass
  17620. */
  17621. camera: Nullable<Camera>;
  17622. /**
  17623. * The ID of the renderingGroup being processed
  17624. */
  17625. renderingGroupId: number;
  17626. }
  17627. /**
  17628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17629. * It is enable to manage the different groups as well as the different necessary sort functions.
  17630. * This should not be used directly aside of the few static configurations
  17631. */
  17632. export class RenderingManager {
  17633. /**
  17634. * The max id used for rendering groups (not included)
  17635. */
  17636. static MAX_RENDERINGGROUPS: number;
  17637. /**
  17638. * The min id used for rendering groups (included)
  17639. */
  17640. static MIN_RENDERINGGROUPS: number;
  17641. /**
  17642. * Used to globally prevent autoclearing scenes.
  17643. */
  17644. static AUTOCLEAR: boolean;
  17645. /**
  17646. * @hidden
  17647. */
  17648. _useSceneAutoClearSetup: boolean;
  17649. private _scene;
  17650. private _renderingGroups;
  17651. private _depthStencilBufferAlreadyCleaned;
  17652. private _autoClearDepthStencil;
  17653. private _customOpaqueSortCompareFn;
  17654. private _customAlphaTestSortCompareFn;
  17655. private _customTransparentSortCompareFn;
  17656. private _renderingGroupInfo;
  17657. /**
  17658. * Instantiates a new rendering group for a particular scene
  17659. * @param scene Defines the scene the groups belongs to
  17660. */
  17661. constructor(scene: Scene);
  17662. private _clearDepthStencilBuffer;
  17663. /**
  17664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17665. * @hidden
  17666. */
  17667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17668. /**
  17669. * Resets the different information of the group to prepare a new frame
  17670. * @hidden
  17671. */
  17672. reset(): void;
  17673. /**
  17674. * Dispose and release the group and its associated resources.
  17675. * @hidden
  17676. */
  17677. dispose(): void;
  17678. /**
  17679. * Clear the info related to rendering groups preventing retention points during dispose.
  17680. */
  17681. freeRenderingGroups(): void;
  17682. private _prepareRenderingGroup;
  17683. /**
  17684. * Add a sprite manager to the rendering manager in order to render it this frame.
  17685. * @param spriteManager Define the sprite manager to render
  17686. */
  17687. dispatchSprites(spriteManager: ISpriteManager): void;
  17688. /**
  17689. * Add a particle system to the rendering manager in order to render it this frame.
  17690. * @param particleSystem Define the particle system to render
  17691. */
  17692. dispatchParticles(particleSystem: IParticleSystem): void;
  17693. /**
  17694. * Add a submesh to the manager in order to render it this frame
  17695. * @param subMesh The submesh to dispatch
  17696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17698. */
  17699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17700. /**
  17701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17702. * This allowed control for front to back rendering or reversly depending of the special needs.
  17703. *
  17704. * @param renderingGroupId The rendering group id corresponding to its index
  17705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17708. */
  17709. 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;
  17710. /**
  17711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17712. *
  17713. * @param renderingGroupId The rendering group id corresponding to its index
  17714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17717. */
  17718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17719. /**
  17720. * Gets the current auto clear configuration for one rendering group of the rendering
  17721. * manager.
  17722. * @param index the rendering group index to get the information for
  17723. * @returns The auto clear setup for the requested rendering group
  17724. */
  17725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17726. }
  17727. }
  17728. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17729. import { SmartArray } from "babylonjs/Misc/smartArray";
  17730. import { Nullable } from "babylonjs/types";
  17731. import { Scene } from "babylonjs/scene";
  17732. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17735. import { Mesh } from "babylonjs/Meshes/mesh";
  17736. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17737. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17738. import { Effect } from "babylonjs/Materials/effect";
  17739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17740. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17741. import "babylonjs/Shaders/shadowMap.fragment";
  17742. import "babylonjs/Shaders/shadowMap.vertex";
  17743. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17744. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17745. import { Observable } from "babylonjs/Misc/observable";
  17746. /**
  17747. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17748. */
  17749. export interface ICustomShaderOptions {
  17750. /**
  17751. * Gets or sets the custom shader name to use
  17752. */
  17753. shaderName: string;
  17754. /**
  17755. * The list of attribute names used in the shader
  17756. */
  17757. attributes?: string[];
  17758. /**
  17759. * The list of unifrom names used in the shader
  17760. */
  17761. uniforms?: string[];
  17762. /**
  17763. * The list of sampler names used in the shader
  17764. */
  17765. samplers?: string[];
  17766. /**
  17767. * The list of defines used in the shader
  17768. */
  17769. defines?: string[];
  17770. }
  17771. /**
  17772. * Interface to implement to create a shadow generator compatible with BJS.
  17773. */
  17774. export interface IShadowGenerator {
  17775. /**
  17776. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17777. * @returns The render target texture if present otherwise, null
  17778. */
  17779. getShadowMap(): Nullable<RenderTargetTexture>;
  17780. /**
  17781. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17782. * @param subMesh The submesh we want to render in the shadow map
  17783. * @param useInstances Defines wether will draw in the map using instances
  17784. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17785. * @returns true if ready otherwise, false
  17786. */
  17787. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17788. /**
  17789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17790. * @param defines Defines of the material we want to update
  17791. * @param lightIndex Index of the light in the enabled light list of the material
  17792. */
  17793. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17794. /**
  17795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17796. * defined in the generator but impacting the effect).
  17797. * It implies the unifroms available on the materials are the standard BJS ones.
  17798. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17799. * @param effect The effect we are binfing the information for
  17800. */
  17801. bindShadowLight(lightIndex: string, effect: Effect): void;
  17802. /**
  17803. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17804. * (eq to shadow prjection matrix * light transform matrix)
  17805. * @returns The transform matrix used to create the shadow map
  17806. */
  17807. getTransformMatrix(): Matrix;
  17808. /**
  17809. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17810. * Cube and 2D textures for instance.
  17811. */
  17812. recreateShadowMap(): void;
  17813. /**
  17814. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17815. * @param onCompiled Callback triggered at the and of the effects compilation
  17816. * @param options Sets of optional options forcing the compilation with different modes
  17817. */
  17818. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17819. useInstances: boolean;
  17820. }>): void;
  17821. /**
  17822. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17823. * @param options Sets of optional options forcing the compilation with different modes
  17824. * @returns A promise that resolves when the compilation completes
  17825. */
  17826. forceCompilationAsync(options?: Partial<{
  17827. useInstances: boolean;
  17828. }>): Promise<void>;
  17829. /**
  17830. * Serializes the shadow generator setup to a json object.
  17831. * @returns The serialized JSON object
  17832. */
  17833. serialize(): any;
  17834. /**
  17835. * Disposes the Shadow map and related Textures and effects.
  17836. */
  17837. dispose(): void;
  17838. }
  17839. /**
  17840. * Default implementation IShadowGenerator.
  17841. * This is the main object responsible of generating shadows in the framework.
  17842. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17843. */
  17844. export class ShadowGenerator implements IShadowGenerator {
  17845. /**
  17846. * Name of the shadow generator class
  17847. */
  17848. static CLASSNAME: string;
  17849. /**
  17850. * Shadow generator mode None: no filtering applied.
  17851. */
  17852. static readonly FILTER_NONE: number;
  17853. /**
  17854. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17855. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17856. */
  17857. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17858. /**
  17859. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17860. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17861. */
  17862. static readonly FILTER_POISSONSAMPLING: number;
  17863. /**
  17864. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17865. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17866. */
  17867. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17868. /**
  17869. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17870. * edge artifacts on steep falloff.
  17871. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17872. */
  17873. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17874. /**
  17875. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17876. * edge artifacts on steep falloff.
  17877. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17878. */
  17879. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17880. /**
  17881. * Shadow generator mode PCF: Percentage Closer Filtering
  17882. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17883. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17884. */
  17885. static readonly FILTER_PCF: number;
  17886. /**
  17887. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17888. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17889. * Contact Hardening
  17890. */
  17891. static readonly FILTER_PCSS: number;
  17892. /**
  17893. * Reserved for PCF and PCSS
  17894. * Highest Quality.
  17895. *
  17896. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17897. *
  17898. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17899. */
  17900. static readonly QUALITY_HIGH: number;
  17901. /**
  17902. * Reserved for PCF and PCSS
  17903. * Good tradeoff for quality/perf cross devices
  17904. *
  17905. * Execute PCF on a 3*3 kernel.
  17906. *
  17907. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17908. */
  17909. static readonly QUALITY_MEDIUM: number;
  17910. /**
  17911. * Reserved for PCF and PCSS
  17912. * The lowest quality but the fastest.
  17913. *
  17914. * Execute PCF on a 1*1 kernel.
  17915. *
  17916. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17917. */
  17918. static readonly QUALITY_LOW: number;
  17919. /** Gets or sets the custom shader name to use */
  17920. customShaderOptions: ICustomShaderOptions;
  17921. /**
  17922. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17923. */
  17924. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17925. /**
  17926. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17927. */
  17928. onAfterShadowMapRenderObservable: Observable<Effect>;
  17929. /**
  17930. * Observable triggered before a mesh is rendered in the shadow map.
  17931. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17932. */
  17933. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17934. /**
  17935. * Observable triggered after a mesh is rendered in the shadow map.
  17936. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17937. */
  17938. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17939. protected _bias: number;
  17940. /**
  17941. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17942. */
  17943. get bias(): number;
  17944. /**
  17945. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17946. */
  17947. set bias(bias: number);
  17948. protected _normalBias: number;
  17949. /**
  17950. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17951. */
  17952. get normalBias(): number;
  17953. /**
  17954. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17955. */
  17956. set normalBias(normalBias: number);
  17957. protected _blurBoxOffset: number;
  17958. /**
  17959. * Gets the blur box offset: offset applied during the blur pass.
  17960. * Only useful if useKernelBlur = false
  17961. */
  17962. get blurBoxOffset(): number;
  17963. /**
  17964. * Sets the blur box offset: offset applied during the blur pass.
  17965. * Only useful if useKernelBlur = false
  17966. */
  17967. set blurBoxOffset(value: number);
  17968. protected _blurScale: number;
  17969. /**
  17970. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17971. * 2 means half of the size.
  17972. */
  17973. get blurScale(): number;
  17974. /**
  17975. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17976. * 2 means half of the size.
  17977. */
  17978. set blurScale(value: number);
  17979. protected _blurKernel: number;
  17980. /**
  17981. * Gets the blur kernel: kernel size of the blur pass.
  17982. * Only useful if useKernelBlur = true
  17983. */
  17984. get blurKernel(): number;
  17985. /**
  17986. * Sets the blur kernel: kernel size of the blur pass.
  17987. * Only useful if useKernelBlur = true
  17988. */
  17989. set blurKernel(value: number);
  17990. protected _useKernelBlur: boolean;
  17991. /**
  17992. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17993. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17994. */
  17995. get useKernelBlur(): boolean;
  17996. /**
  17997. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17998. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17999. */
  18000. set useKernelBlur(value: boolean);
  18001. protected _depthScale: number;
  18002. /**
  18003. * Gets the depth scale used in ESM mode.
  18004. */
  18005. get depthScale(): number;
  18006. /**
  18007. * Sets the depth scale used in ESM mode.
  18008. * This can override the scale stored on the light.
  18009. */
  18010. set depthScale(value: number);
  18011. protected _validateFilter(filter: number): number;
  18012. protected _filter: number;
  18013. /**
  18014. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18015. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18016. */
  18017. get filter(): number;
  18018. /**
  18019. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18020. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18021. */
  18022. set filter(value: number);
  18023. /**
  18024. * Gets if the current filter is set to Poisson Sampling.
  18025. */
  18026. get usePoissonSampling(): boolean;
  18027. /**
  18028. * Sets the current filter to Poisson Sampling.
  18029. */
  18030. set usePoissonSampling(value: boolean);
  18031. /**
  18032. * Gets if the current filter is set to ESM.
  18033. */
  18034. get useExponentialShadowMap(): boolean;
  18035. /**
  18036. * Sets the current filter is to ESM.
  18037. */
  18038. set useExponentialShadowMap(value: boolean);
  18039. /**
  18040. * Gets if the current filter is set to filtered ESM.
  18041. */
  18042. get useBlurExponentialShadowMap(): boolean;
  18043. /**
  18044. * Gets if the current filter is set to filtered ESM.
  18045. */
  18046. set useBlurExponentialShadowMap(value: boolean);
  18047. /**
  18048. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18049. * exponential to prevent steep falloff artifacts).
  18050. */
  18051. get useCloseExponentialShadowMap(): boolean;
  18052. /**
  18053. * Sets the current filter to "close ESM" (using the inverse of the
  18054. * exponential to prevent steep falloff artifacts).
  18055. */
  18056. set useCloseExponentialShadowMap(value: boolean);
  18057. /**
  18058. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18059. * exponential to prevent steep falloff artifacts).
  18060. */
  18061. get useBlurCloseExponentialShadowMap(): boolean;
  18062. /**
  18063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18064. * exponential to prevent steep falloff artifacts).
  18065. */
  18066. set useBlurCloseExponentialShadowMap(value: boolean);
  18067. /**
  18068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18069. */
  18070. get usePercentageCloserFiltering(): boolean;
  18071. /**
  18072. * Sets the current filter to "PCF" (percentage closer filtering).
  18073. */
  18074. set usePercentageCloserFiltering(value: boolean);
  18075. protected _filteringQuality: number;
  18076. /**
  18077. * Gets the PCF or PCSS Quality.
  18078. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18079. */
  18080. get filteringQuality(): number;
  18081. /**
  18082. * Sets the PCF or PCSS Quality.
  18083. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18084. */
  18085. set filteringQuality(filteringQuality: number);
  18086. /**
  18087. * Gets if the current filter is set to "PCSS" (contact hardening).
  18088. */
  18089. get useContactHardeningShadow(): boolean;
  18090. /**
  18091. * Sets the current filter to "PCSS" (contact hardening).
  18092. */
  18093. set useContactHardeningShadow(value: boolean);
  18094. protected _contactHardeningLightSizeUVRatio: number;
  18095. /**
  18096. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18097. * Using a ratio helps keeping shape stability independently of the map size.
  18098. *
  18099. * It does not account for the light projection as it was having too much
  18100. * instability during the light setup or during light position changes.
  18101. *
  18102. * Only valid if useContactHardeningShadow is true.
  18103. */
  18104. get contactHardeningLightSizeUVRatio(): number;
  18105. /**
  18106. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18107. * Using a ratio helps keeping shape stability independently of the map size.
  18108. *
  18109. * It does not account for the light projection as it was having too much
  18110. * instability during the light setup or during light position changes.
  18111. *
  18112. * Only valid if useContactHardeningShadow is true.
  18113. */
  18114. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18115. protected _darkness: number;
  18116. /** Gets or sets the actual darkness of a shadow */
  18117. get darkness(): number;
  18118. set darkness(value: number);
  18119. /**
  18120. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18121. * 0 means strongest and 1 would means no shadow.
  18122. * @returns the darkness.
  18123. */
  18124. getDarkness(): number;
  18125. /**
  18126. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18127. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18128. * @returns the shadow generator allowing fluent coding.
  18129. */
  18130. setDarkness(darkness: number): ShadowGenerator;
  18131. protected _transparencyShadow: boolean;
  18132. /** Gets or sets the ability to have transparent shadow */
  18133. get transparencyShadow(): boolean;
  18134. set transparencyShadow(value: boolean);
  18135. /**
  18136. * Sets the ability to have transparent shadow (boolean).
  18137. * @param transparent True if transparent else False
  18138. * @returns the shadow generator allowing fluent coding
  18139. */
  18140. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18141. /**
  18142. * Enables or disables shadows with varying strength based on the transparency
  18143. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18144. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18145. * mesh.visibility * alphaTexture.a
  18146. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18147. */
  18148. enableSoftTransparentShadow: boolean;
  18149. protected _shadowMap: Nullable<RenderTargetTexture>;
  18150. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18151. /**
  18152. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18153. * @returns The render target texture if present otherwise, null
  18154. */
  18155. getShadowMap(): Nullable<RenderTargetTexture>;
  18156. /**
  18157. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18158. * @returns The render target texture if the shadow map is present otherwise, null
  18159. */
  18160. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18161. /**
  18162. * Gets the class name of that object
  18163. * @returns "ShadowGenerator"
  18164. */
  18165. getClassName(): string;
  18166. /**
  18167. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18168. * @param mesh Mesh to add
  18169. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18170. * @returns the Shadow Generator itself
  18171. */
  18172. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18173. /**
  18174. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18175. * @param mesh Mesh to remove
  18176. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18177. * @returns the Shadow Generator itself
  18178. */
  18179. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18180. /**
  18181. * Controls the extent to which the shadows fade out at the edge of the frustum
  18182. */
  18183. frustumEdgeFalloff: number;
  18184. protected _light: IShadowLight;
  18185. /**
  18186. * Returns the associated light object.
  18187. * @returns the light generating the shadow
  18188. */
  18189. getLight(): IShadowLight;
  18190. /**
  18191. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18192. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18193. * It might on the other hand introduce peter panning.
  18194. */
  18195. forceBackFacesOnly: boolean;
  18196. protected _scene: Scene;
  18197. protected _lightDirection: Vector3;
  18198. protected _effect: Effect;
  18199. protected _viewMatrix: Matrix;
  18200. protected _projectionMatrix: Matrix;
  18201. protected _transformMatrix: Matrix;
  18202. protected _cachedPosition: Vector3;
  18203. protected _cachedDirection: Vector3;
  18204. protected _cachedDefines: string;
  18205. protected _currentRenderID: number;
  18206. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18207. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18208. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18209. protected _blurPostProcesses: PostProcess[];
  18210. protected _mapSize: number;
  18211. protected _currentFaceIndex: number;
  18212. protected _currentFaceIndexCache: number;
  18213. protected _textureType: number;
  18214. protected _defaultTextureMatrix: Matrix;
  18215. protected _storedUniqueId: Nullable<number>;
  18216. /** @hidden */
  18217. static _SceneComponentInitialization: (scene: Scene) => void;
  18218. /**
  18219. * Creates a ShadowGenerator object.
  18220. * A ShadowGenerator is the required tool to use the shadows.
  18221. * Each light casting shadows needs to use its own ShadowGenerator.
  18222. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18223. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18224. * @param light The light object generating the shadows.
  18225. * @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.
  18226. */
  18227. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18228. protected _initializeGenerator(): void;
  18229. protected _createTargetRenderTexture(): void;
  18230. protected _initializeShadowMap(): void;
  18231. protected _initializeBlurRTTAndPostProcesses(): void;
  18232. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18233. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18234. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18235. protected _applyFilterValues(): void;
  18236. /**
  18237. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18238. * @param onCompiled Callback triggered at the and of the effects compilation
  18239. * @param options Sets of optional options forcing the compilation with different modes
  18240. */
  18241. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18242. useInstances: boolean;
  18243. }>): void;
  18244. /**
  18245. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18246. * @param options Sets of optional options forcing the compilation with different modes
  18247. * @returns A promise that resolves when the compilation completes
  18248. */
  18249. forceCompilationAsync(options?: Partial<{
  18250. useInstances: boolean;
  18251. }>): Promise<void>;
  18252. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18253. private _prepareShadowDefines;
  18254. /**
  18255. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18256. * @param subMesh The submesh we want to render in the shadow map
  18257. * @param useInstances Defines wether will draw in the map using instances
  18258. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18259. * @returns true if ready otherwise, false
  18260. */
  18261. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18262. /**
  18263. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18264. * @param defines Defines of the material we want to update
  18265. * @param lightIndex Index of the light in the enabled light list of the material
  18266. */
  18267. prepareDefines(defines: any, lightIndex: number): void;
  18268. /**
  18269. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18270. * defined in the generator but impacting the effect).
  18271. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18272. * @param effect The effect we are binfing the information for
  18273. */
  18274. bindShadowLight(lightIndex: string, effect: Effect): void;
  18275. /**
  18276. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18277. * (eq to shadow prjection matrix * light transform matrix)
  18278. * @returns The transform matrix used to create the shadow map
  18279. */
  18280. getTransformMatrix(): Matrix;
  18281. /**
  18282. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18283. * Cube and 2D textures for instance.
  18284. */
  18285. recreateShadowMap(): void;
  18286. protected _disposeBlurPostProcesses(): void;
  18287. protected _disposeRTTandPostProcesses(): void;
  18288. /**
  18289. * Disposes the ShadowGenerator.
  18290. * Returns nothing.
  18291. */
  18292. dispose(): void;
  18293. /**
  18294. * Serializes the shadow generator setup to a json object.
  18295. * @returns The serialized JSON object
  18296. */
  18297. serialize(): any;
  18298. /**
  18299. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18300. * @param parsedShadowGenerator The JSON object to parse
  18301. * @param scene The scene to create the shadow map for
  18302. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18303. * @returns The parsed shadow generator
  18304. */
  18305. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18306. }
  18307. }
  18308. declare module "babylonjs/Lights/light" {
  18309. import { Nullable } from "babylonjs/types";
  18310. import { Scene } from "babylonjs/scene";
  18311. import { Vector3 } from "babylonjs/Maths/math.vector";
  18312. import { Color3 } from "babylonjs/Maths/math.color";
  18313. import { Node } from "babylonjs/node";
  18314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18315. import { Effect } from "babylonjs/Materials/effect";
  18316. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18317. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18318. /**
  18319. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18320. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18321. * 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.
  18322. */
  18323. export abstract class Light extends Node {
  18324. /**
  18325. * Falloff Default: light is falling off following the material specification:
  18326. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18327. */
  18328. static readonly FALLOFF_DEFAULT: number;
  18329. /**
  18330. * Falloff Physical: light is falling off following the inverse squared distance law.
  18331. */
  18332. static readonly FALLOFF_PHYSICAL: number;
  18333. /**
  18334. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18335. * to enhance interoperability with other engines.
  18336. */
  18337. static readonly FALLOFF_GLTF: number;
  18338. /**
  18339. * Falloff Standard: light is falling off like in the standard material
  18340. * to enhance interoperability with other materials.
  18341. */
  18342. static readonly FALLOFF_STANDARD: number;
  18343. /**
  18344. * If every light affecting the material is in this lightmapMode,
  18345. * material.lightmapTexture adds or multiplies
  18346. * (depends on material.useLightmapAsShadowmap)
  18347. * after every other light calculations.
  18348. */
  18349. static readonly LIGHTMAP_DEFAULT: number;
  18350. /**
  18351. * material.lightmapTexture as only diffuse lighting from this light
  18352. * adds only specular lighting from this light
  18353. * adds dynamic shadows
  18354. */
  18355. static readonly LIGHTMAP_SPECULAR: number;
  18356. /**
  18357. * material.lightmapTexture as only lighting
  18358. * no light calculation from this light
  18359. * only adds dynamic shadows from this light
  18360. */
  18361. static readonly LIGHTMAP_SHADOWSONLY: number;
  18362. /**
  18363. * Each light type uses the default quantity according to its type:
  18364. * point/spot lights use luminous intensity
  18365. * directional lights use illuminance
  18366. */
  18367. static readonly INTENSITYMODE_AUTOMATIC: number;
  18368. /**
  18369. * lumen (lm)
  18370. */
  18371. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18372. /**
  18373. * candela (lm/sr)
  18374. */
  18375. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18376. /**
  18377. * lux (lm/m^2)
  18378. */
  18379. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18380. /**
  18381. * nit (cd/m^2)
  18382. */
  18383. static readonly INTENSITYMODE_LUMINANCE: number;
  18384. /**
  18385. * Light type const id of the point light.
  18386. */
  18387. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18388. /**
  18389. * Light type const id of the directional light.
  18390. */
  18391. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18392. /**
  18393. * Light type const id of the spot light.
  18394. */
  18395. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18396. /**
  18397. * Light type const id of the hemispheric light.
  18398. */
  18399. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18400. /**
  18401. * Diffuse gives the basic color to an object.
  18402. */
  18403. diffuse: Color3;
  18404. /**
  18405. * Specular produces a highlight color on an object.
  18406. * Note: This is note affecting PBR materials.
  18407. */
  18408. specular: Color3;
  18409. /**
  18410. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18411. * falling off base on range or angle.
  18412. * This can be set to any values in Light.FALLOFF_x.
  18413. *
  18414. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18415. * other types of materials.
  18416. */
  18417. falloffType: number;
  18418. /**
  18419. * Strength of the light.
  18420. * Note: By default it is define in the framework own unit.
  18421. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18422. */
  18423. intensity: number;
  18424. private _range;
  18425. protected _inverseSquaredRange: number;
  18426. /**
  18427. * Defines how far from the source the light is impacting in scene units.
  18428. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18429. */
  18430. get range(): number;
  18431. /**
  18432. * Defines how far from the source the light is impacting in scene units.
  18433. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18434. */
  18435. set range(value: number);
  18436. /**
  18437. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18438. * of light.
  18439. */
  18440. private _photometricScale;
  18441. private _intensityMode;
  18442. /**
  18443. * Gets the photometric scale used to interpret the intensity.
  18444. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18445. */
  18446. get intensityMode(): number;
  18447. /**
  18448. * Sets the photometric scale used to interpret the intensity.
  18449. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18450. */
  18451. set intensityMode(value: number);
  18452. private _radius;
  18453. /**
  18454. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18455. */
  18456. get radius(): number;
  18457. /**
  18458. * sets the light radius used by PBR Materials to simulate soft area lights.
  18459. */
  18460. set radius(value: number);
  18461. private _renderPriority;
  18462. /**
  18463. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18464. * exceeding the number allowed of the materials.
  18465. */
  18466. renderPriority: number;
  18467. private _shadowEnabled;
  18468. /**
  18469. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18470. * the current shadow generator.
  18471. */
  18472. get shadowEnabled(): boolean;
  18473. /**
  18474. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18475. * the current shadow generator.
  18476. */
  18477. set shadowEnabled(value: boolean);
  18478. private _includedOnlyMeshes;
  18479. /**
  18480. * Gets the only meshes impacted by this light.
  18481. */
  18482. get includedOnlyMeshes(): AbstractMesh[];
  18483. /**
  18484. * Sets the only meshes impacted by this light.
  18485. */
  18486. set includedOnlyMeshes(value: AbstractMesh[]);
  18487. private _excludedMeshes;
  18488. /**
  18489. * Gets the meshes not impacted by this light.
  18490. */
  18491. get excludedMeshes(): AbstractMesh[];
  18492. /**
  18493. * Sets the meshes not impacted by this light.
  18494. */
  18495. set excludedMeshes(value: AbstractMesh[]);
  18496. private _excludeWithLayerMask;
  18497. /**
  18498. * Gets the layer id use to find what meshes are not impacted by the light.
  18499. * Inactive if 0
  18500. */
  18501. get excludeWithLayerMask(): number;
  18502. /**
  18503. * Sets the layer id use to find what meshes are not impacted by the light.
  18504. * Inactive if 0
  18505. */
  18506. set excludeWithLayerMask(value: number);
  18507. private _includeOnlyWithLayerMask;
  18508. /**
  18509. * Gets the layer id use to find what meshes are impacted by the light.
  18510. * Inactive if 0
  18511. */
  18512. get includeOnlyWithLayerMask(): number;
  18513. /**
  18514. * Sets the layer id use to find what meshes are impacted by the light.
  18515. * Inactive if 0
  18516. */
  18517. set includeOnlyWithLayerMask(value: number);
  18518. private _lightmapMode;
  18519. /**
  18520. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18521. */
  18522. get lightmapMode(): number;
  18523. /**
  18524. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18525. */
  18526. set lightmapMode(value: number);
  18527. /**
  18528. * Shadow generator associted to the light.
  18529. * @hidden Internal use only.
  18530. */
  18531. _shadowGenerator: Nullable<IShadowGenerator>;
  18532. /**
  18533. * @hidden Internal use only.
  18534. */
  18535. _excludedMeshesIds: string[];
  18536. /**
  18537. * @hidden Internal use only.
  18538. */
  18539. _includedOnlyMeshesIds: string[];
  18540. /**
  18541. * The current light unifom buffer.
  18542. * @hidden Internal use only.
  18543. */
  18544. _uniformBuffer: UniformBuffer;
  18545. /** @hidden */
  18546. _renderId: number;
  18547. /**
  18548. * Creates a Light object in the scene.
  18549. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18550. * @param name The firendly name of the light
  18551. * @param scene The scene the light belongs too
  18552. */
  18553. constructor(name: string, scene: Scene);
  18554. protected abstract _buildUniformLayout(): void;
  18555. /**
  18556. * Sets the passed Effect "effect" with the Light information.
  18557. * @param effect The effect to update
  18558. * @param lightIndex The index of the light in the effect to update
  18559. * @returns The light
  18560. */
  18561. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18562. /**
  18563. * Sets the passed Effect "effect" with the Light textures.
  18564. * @param effect The effect to update
  18565. * @param lightIndex The index of the light in the effect to update
  18566. * @returns The light
  18567. */
  18568. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18569. /**
  18570. * Binds the lights information from the scene to the effect for the given mesh.
  18571. * @param lightIndex Light index
  18572. * @param scene The scene where the light belongs to
  18573. * @param effect The effect we are binding the data to
  18574. * @param useSpecular Defines if specular is supported
  18575. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18576. */
  18577. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18578. /**
  18579. * Sets the passed Effect "effect" with the Light information.
  18580. * @param effect The effect to update
  18581. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18582. * @returns The light
  18583. */
  18584. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18585. /**
  18586. * Returns the string "Light".
  18587. * @returns the class name
  18588. */
  18589. getClassName(): string;
  18590. /** @hidden */
  18591. readonly _isLight: boolean;
  18592. /**
  18593. * Converts the light information to a readable string for debug purpose.
  18594. * @param fullDetails Supports for multiple levels of logging within scene loading
  18595. * @returns the human readable light info
  18596. */
  18597. toString(fullDetails?: boolean): string;
  18598. /** @hidden */
  18599. protected _syncParentEnabledState(): void;
  18600. /**
  18601. * Set the enabled state of this node.
  18602. * @param value - the new enabled state
  18603. */
  18604. setEnabled(value: boolean): void;
  18605. /**
  18606. * Returns the Light associated shadow generator if any.
  18607. * @return the associated shadow generator.
  18608. */
  18609. getShadowGenerator(): Nullable<IShadowGenerator>;
  18610. /**
  18611. * Returns a Vector3, the absolute light position in the World.
  18612. * @returns the world space position of the light
  18613. */
  18614. getAbsolutePosition(): Vector3;
  18615. /**
  18616. * Specifies if the light will affect the passed mesh.
  18617. * @param mesh The mesh to test against the light
  18618. * @return true the mesh is affected otherwise, false.
  18619. */
  18620. canAffectMesh(mesh: AbstractMesh): boolean;
  18621. /**
  18622. * Sort function to order lights for rendering.
  18623. * @param a First Light object to compare to second.
  18624. * @param b Second Light object to compare first.
  18625. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18626. */
  18627. static CompareLightsPriority(a: Light, b: Light): number;
  18628. /**
  18629. * Releases resources associated with this node.
  18630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18632. */
  18633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18634. /**
  18635. * Returns the light type ID (integer).
  18636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18637. */
  18638. getTypeID(): number;
  18639. /**
  18640. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18641. * @returns the scaled intensity in intensity mode unit
  18642. */
  18643. getScaledIntensity(): number;
  18644. /**
  18645. * Returns a new Light object, named "name", from the current one.
  18646. * @param name The name of the cloned light
  18647. * @param newParent The parent of this light, if it has one
  18648. * @returns the new created light
  18649. */
  18650. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18651. /**
  18652. * Serializes the current light into a Serialization object.
  18653. * @returns the serialized object.
  18654. */
  18655. serialize(): any;
  18656. /**
  18657. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18658. * This new light is named "name" and added to the passed scene.
  18659. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18660. * @param name The friendly name of the light
  18661. * @param scene The scene the new light will belong to
  18662. * @returns the constructor function
  18663. */
  18664. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18665. /**
  18666. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18667. * @param parsedLight The JSON representation of the light
  18668. * @param scene The scene to create the parsed light in
  18669. * @returns the created light after parsing
  18670. */
  18671. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18672. private _hookArrayForExcluded;
  18673. private _hookArrayForIncludedOnly;
  18674. private _resyncMeshes;
  18675. /**
  18676. * Forces the meshes to update their light related information in their rendering used effects
  18677. * @hidden Internal Use Only
  18678. */
  18679. _markMeshesAsLightDirty(): void;
  18680. /**
  18681. * Recomputes the cached photometric scale if needed.
  18682. */
  18683. private _computePhotometricScale;
  18684. /**
  18685. * Returns the Photometric Scale according to the light type and intensity mode.
  18686. */
  18687. private _getPhotometricScale;
  18688. /**
  18689. * Reorder the light in the scene according to their defined priority.
  18690. * @hidden Internal Use Only
  18691. */
  18692. _reorderLightsInScene(): void;
  18693. /**
  18694. * Prepares the list of defines specific to the light type.
  18695. * @param defines the list of defines
  18696. * @param lightIndex defines the index of the light for the effect
  18697. */
  18698. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18699. }
  18700. }
  18701. declare module "babylonjs/Cameras/targetCamera" {
  18702. import { Nullable } from "babylonjs/types";
  18703. import { Camera } from "babylonjs/Cameras/camera";
  18704. import { Scene } from "babylonjs/scene";
  18705. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18706. /**
  18707. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18708. * This is the base of the follow, arc rotate cameras and Free camera
  18709. * @see http://doc.babylonjs.com/features/cameras
  18710. */
  18711. export class TargetCamera extends Camera {
  18712. private static _RigCamTransformMatrix;
  18713. private static _TargetTransformMatrix;
  18714. private static _TargetFocalPoint;
  18715. /**
  18716. * Define the current direction the camera is moving to
  18717. */
  18718. cameraDirection: Vector3;
  18719. /**
  18720. * Define the current rotation the camera is rotating to
  18721. */
  18722. cameraRotation: Vector2;
  18723. /**
  18724. * When set, the up vector of the camera will be updated by the rotation of the camera
  18725. */
  18726. updateUpVectorFromRotation: boolean;
  18727. private _tmpQuaternion;
  18728. /**
  18729. * Define the current rotation of the camera
  18730. */
  18731. rotation: Vector3;
  18732. /**
  18733. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18734. */
  18735. rotationQuaternion: Quaternion;
  18736. /**
  18737. * Define the current speed of the camera
  18738. */
  18739. speed: number;
  18740. /**
  18741. * Add constraint to the camera to prevent it to move freely in all directions and
  18742. * around all axis.
  18743. */
  18744. noRotationConstraint: boolean;
  18745. /**
  18746. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18747. * panning
  18748. */
  18749. invertRotation: boolean;
  18750. /**
  18751. * Speed multiplier for inverse camera panning
  18752. */
  18753. inverseRotationSpeed: number;
  18754. /**
  18755. * Define the current target of the camera as an object or a position.
  18756. */
  18757. lockedTarget: any;
  18758. /** @hidden */
  18759. _currentTarget: Vector3;
  18760. /** @hidden */
  18761. _initialFocalDistance: number;
  18762. /** @hidden */
  18763. _viewMatrix: Matrix;
  18764. /** @hidden */
  18765. _camMatrix: Matrix;
  18766. /** @hidden */
  18767. _cameraTransformMatrix: Matrix;
  18768. /** @hidden */
  18769. _cameraRotationMatrix: Matrix;
  18770. /** @hidden */
  18771. _referencePoint: Vector3;
  18772. /** @hidden */
  18773. _transformedReferencePoint: Vector3;
  18774. /** @hidden */
  18775. _reset: () => void;
  18776. private _defaultUp;
  18777. /**
  18778. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18779. * This is the base of the follow, arc rotate cameras and Free camera
  18780. * @see http://doc.babylonjs.com/features/cameras
  18781. * @param name Defines the name of the camera in the scene
  18782. * @param position Defines the start position of the camera in the scene
  18783. * @param scene Defines the scene the camera belongs to
  18784. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18785. */
  18786. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18787. /**
  18788. * Gets the position in front of the camera at a given distance.
  18789. * @param distance The distance from the camera we want the position to be
  18790. * @returns the position
  18791. */
  18792. getFrontPosition(distance: number): Vector3;
  18793. /** @hidden */
  18794. _getLockedTargetPosition(): Nullable<Vector3>;
  18795. private _storedPosition;
  18796. private _storedRotation;
  18797. private _storedRotationQuaternion;
  18798. /**
  18799. * Store current camera state of the camera (fov, position, rotation, etc..)
  18800. * @returns the camera
  18801. */
  18802. storeState(): Camera;
  18803. /**
  18804. * Restored camera state. You must call storeState() first
  18805. * @returns whether it was successful or not
  18806. * @hidden
  18807. */
  18808. _restoreStateValues(): boolean;
  18809. /** @hidden */
  18810. _initCache(): void;
  18811. /** @hidden */
  18812. _updateCache(ignoreParentClass?: boolean): void;
  18813. /** @hidden */
  18814. _isSynchronizedViewMatrix(): boolean;
  18815. /** @hidden */
  18816. _computeLocalCameraSpeed(): number;
  18817. /**
  18818. * Defines the target the camera should look at.
  18819. * @param target Defines the new target as a Vector or a mesh
  18820. */
  18821. setTarget(target: Vector3): void;
  18822. /**
  18823. * Return the current target position of the camera. This value is expressed in local space.
  18824. * @returns the target position
  18825. */
  18826. getTarget(): Vector3;
  18827. /** @hidden */
  18828. _decideIfNeedsToMove(): boolean;
  18829. /** @hidden */
  18830. _updatePosition(): void;
  18831. /** @hidden */
  18832. _checkInputs(): void;
  18833. protected _updateCameraRotationMatrix(): void;
  18834. /**
  18835. * 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)
  18836. * @returns the current camera
  18837. */
  18838. private _rotateUpVectorWithCameraRotationMatrix;
  18839. private _cachedRotationZ;
  18840. private _cachedQuaternionRotationZ;
  18841. /** @hidden */
  18842. _getViewMatrix(): Matrix;
  18843. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18844. /**
  18845. * @hidden
  18846. */
  18847. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18848. /**
  18849. * @hidden
  18850. */
  18851. _updateRigCameras(): void;
  18852. private _getRigCamPositionAndTarget;
  18853. /**
  18854. * Gets the current object class name.
  18855. * @return the class name
  18856. */
  18857. getClassName(): string;
  18858. }
  18859. }
  18860. declare module "babylonjs/Events/keyboardEvents" {
  18861. /**
  18862. * Gather the list of keyboard event types as constants.
  18863. */
  18864. export class KeyboardEventTypes {
  18865. /**
  18866. * The keydown event is fired when a key becomes active (pressed).
  18867. */
  18868. static readonly KEYDOWN: number;
  18869. /**
  18870. * The keyup event is fired when a key has been released.
  18871. */
  18872. static readonly KEYUP: number;
  18873. }
  18874. /**
  18875. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18876. */
  18877. export class KeyboardInfo {
  18878. /**
  18879. * Defines the type of event (KeyboardEventTypes)
  18880. */
  18881. type: number;
  18882. /**
  18883. * Defines the related dom event
  18884. */
  18885. event: KeyboardEvent;
  18886. /**
  18887. * Instantiates a new keyboard info.
  18888. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18889. * @param type Defines the type of event (KeyboardEventTypes)
  18890. * @param event Defines the related dom event
  18891. */
  18892. constructor(
  18893. /**
  18894. * Defines the type of event (KeyboardEventTypes)
  18895. */
  18896. type: number,
  18897. /**
  18898. * Defines the related dom event
  18899. */
  18900. event: KeyboardEvent);
  18901. }
  18902. /**
  18903. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18904. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18905. */
  18906. export class KeyboardInfoPre extends KeyboardInfo {
  18907. /**
  18908. * Defines the type of event (KeyboardEventTypes)
  18909. */
  18910. type: number;
  18911. /**
  18912. * Defines the related dom event
  18913. */
  18914. event: KeyboardEvent;
  18915. /**
  18916. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18917. */
  18918. skipOnPointerObservable: boolean;
  18919. /**
  18920. * Instantiates a new keyboard pre info.
  18921. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18922. * @param type Defines the type of event (KeyboardEventTypes)
  18923. * @param event Defines the related dom event
  18924. */
  18925. constructor(
  18926. /**
  18927. * Defines the type of event (KeyboardEventTypes)
  18928. */
  18929. type: number,
  18930. /**
  18931. * Defines the related dom event
  18932. */
  18933. event: KeyboardEvent);
  18934. }
  18935. }
  18936. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18937. import { Nullable } from "babylonjs/types";
  18938. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18939. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18940. /**
  18941. * Manage the keyboard inputs to control the movement of a free camera.
  18942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18943. */
  18944. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18945. /**
  18946. * Defines the camera the input is attached to.
  18947. */
  18948. camera: FreeCamera;
  18949. /**
  18950. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18951. */
  18952. keysUp: number[];
  18953. /**
  18954. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18955. */
  18956. keysUpward: number[];
  18957. /**
  18958. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18959. */
  18960. keysDown: number[];
  18961. /**
  18962. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18963. */
  18964. keysDownward: number[];
  18965. /**
  18966. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18967. */
  18968. keysLeft: number[];
  18969. /**
  18970. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18971. */
  18972. keysRight: number[];
  18973. private _keys;
  18974. private _onCanvasBlurObserver;
  18975. private _onKeyboardObserver;
  18976. private _engine;
  18977. private _scene;
  18978. /**
  18979. * Attach the input controls to a specific dom element to get the input from.
  18980. * @param element Defines the element the controls should be listened from
  18981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18982. */
  18983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18984. /**
  18985. * Detach the current controls from the specified dom element.
  18986. * @param element Defines the element to stop listening the inputs from
  18987. */
  18988. detachControl(element: Nullable<HTMLElement>): void;
  18989. /**
  18990. * Update the current camera state depending on the inputs that have been used this frame.
  18991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18992. */
  18993. checkInputs(): void;
  18994. /**
  18995. * Gets the class name of the current intput.
  18996. * @returns the class name
  18997. */
  18998. getClassName(): string;
  18999. /** @hidden */
  19000. _onLostFocus(): void;
  19001. /**
  19002. * Get the friendly name associated with the input class.
  19003. * @returns the input friendly name
  19004. */
  19005. getSimpleName(): string;
  19006. }
  19007. }
  19008. declare module "babylonjs/Events/pointerEvents" {
  19009. import { Nullable } from "babylonjs/types";
  19010. import { Vector2 } from "babylonjs/Maths/math.vector";
  19011. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19012. import { Ray } from "babylonjs/Culling/ray";
  19013. /**
  19014. * Gather the list of pointer event types as constants.
  19015. */
  19016. export class PointerEventTypes {
  19017. /**
  19018. * 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.
  19019. */
  19020. static readonly POINTERDOWN: number;
  19021. /**
  19022. * The pointerup event is fired when a pointer is no longer active.
  19023. */
  19024. static readonly POINTERUP: number;
  19025. /**
  19026. * The pointermove event is fired when a pointer changes coordinates.
  19027. */
  19028. static readonly POINTERMOVE: number;
  19029. /**
  19030. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19031. */
  19032. static readonly POINTERWHEEL: number;
  19033. /**
  19034. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19035. */
  19036. static readonly POINTERPICK: number;
  19037. /**
  19038. * The pointertap event is fired when a the object has been touched and released without drag.
  19039. */
  19040. static readonly POINTERTAP: number;
  19041. /**
  19042. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19043. */
  19044. static readonly POINTERDOUBLETAP: number;
  19045. }
  19046. /**
  19047. * Base class of pointer info types.
  19048. */
  19049. export class PointerInfoBase {
  19050. /**
  19051. * Defines the type of event (PointerEventTypes)
  19052. */
  19053. type: number;
  19054. /**
  19055. * Defines the related dom event
  19056. */
  19057. event: PointerEvent | MouseWheelEvent;
  19058. /**
  19059. * Instantiates the base class of pointers info.
  19060. * @param type Defines the type of event (PointerEventTypes)
  19061. * @param event Defines the related dom event
  19062. */
  19063. constructor(
  19064. /**
  19065. * Defines the type of event (PointerEventTypes)
  19066. */
  19067. type: number,
  19068. /**
  19069. * Defines the related dom event
  19070. */
  19071. event: PointerEvent | MouseWheelEvent);
  19072. }
  19073. /**
  19074. * This class is used to store pointer related info for the onPrePointerObservable event.
  19075. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19076. */
  19077. export class PointerInfoPre extends PointerInfoBase {
  19078. /**
  19079. * Ray from a pointer if availible (eg. 6dof controller)
  19080. */
  19081. ray: Nullable<Ray>;
  19082. /**
  19083. * Defines the local position of the pointer on the canvas.
  19084. */
  19085. localPosition: Vector2;
  19086. /**
  19087. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19088. */
  19089. skipOnPointerObservable: boolean;
  19090. /**
  19091. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19092. * @param type Defines the type of event (PointerEventTypes)
  19093. * @param event Defines the related dom event
  19094. * @param localX Defines the local x coordinates of the pointer when the event occured
  19095. * @param localY Defines the local y coordinates of the pointer when the event occured
  19096. */
  19097. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19098. }
  19099. /**
  19100. * This type contains all the data related to a pointer event in Babylon.js.
  19101. * 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.
  19102. */
  19103. export class PointerInfo extends PointerInfoBase {
  19104. /**
  19105. * Defines the picking info associated to the info (if any)\
  19106. */
  19107. pickInfo: Nullable<PickingInfo>;
  19108. /**
  19109. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19110. * @param type Defines the type of event (PointerEventTypes)
  19111. * @param event Defines the related dom event
  19112. * @param pickInfo Defines the picking info associated to the info (if any)\
  19113. */
  19114. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19115. /**
  19116. * Defines the picking info associated to the info (if any)\
  19117. */
  19118. pickInfo: Nullable<PickingInfo>);
  19119. }
  19120. /**
  19121. * Data relating to a touch event on the screen.
  19122. */
  19123. export interface PointerTouch {
  19124. /**
  19125. * X coordinate of touch.
  19126. */
  19127. x: number;
  19128. /**
  19129. * Y coordinate of touch.
  19130. */
  19131. y: number;
  19132. /**
  19133. * Id of touch. Unique for each finger.
  19134. */
  19135. pointerId: number;
  19136. /**
  19137. * Event type passed from DOM.
  19138. */
  19139. type: any;
  19140. }
  19141. }
  19142. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19143. import { Observable } from "babylonjs/Misc/observable";
  19144. import { Nullable } from "babylonjs/types";
  19145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19147. /**
  19148. * Manage the mouse inputs to control the movement of a free camera.
  19149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19150. */
  19151. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19152. /**
  19153. * Define if touch is enabled in the mouse input
  19154. */
  19155. touchEnabled: boolean;
  19156. /**
  19157. * Defines the camera the input is attached to.
  19158. */
  19159. camera: FreeCamera;
  19160. /**
  19161. * Defines the buttons associated with the input to handle camera move.
  19162. */
  19163. buttons: number[];
  19164. /**
  19165. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19166. */
  19167. angularSensibility: number;
  19168. private _pointerInput;
  19169. private _onMouseMove;
  19170. private _observer;
  19171. private previousPosition;
  19172. /**
  19173. * Observable for when a pointer move event occurs containing the move offset
  19174. */
  19175. onPointerMovedObservable: Observable<{
  19176. offsetX: number;
  19177. offsetY: number;
  19178. }>;
  19179. /**
  19180. * @hidden
  19181. * If the camera should be rotated automatically based on pointer movement
  19182. */
  19183. _allowCameraRotation: boolean;
  19184. /**
  19185. * Manage the mouse inputs to control the movement of a free camera.
  19186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19187. * @param touchEnabled Defines if touch is enabled or not
  19188. */
  19189. constructor(
  19190. /**
  19191. * Define if touch is enabled in the mouse input
  19192. */
  19193. touchEnabled?: boolean);
  19194. /**
  19195. * Attach the input controls to a specific dom element to get the input from.
  19196. * @param element Defines the element the controls should be listened from
  19197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19198. */
  19199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19200. /**
  19201. * Called on JS contextmenu event.
  19202. * Override this method to provide functionality.
  19203. */
  19204. protected onContextMenu(evt: PointerEvent): void;
  19205. /**
  19206. * Detach the current controls from the specified dom element.
  19207. * @param element Defines the element to stop listening the inputs from
  19208. */
  19209. detachControl(element: Nullable<HTMLElement>): void;
  19210. /**
  19211. * Gets the class name of the current intput.
  19212. * @returns the class name
  19213. */
  19214. getClassName(): string;
  19215. /**
  19216. * Get the friendly name associated with the input class.
  19217. * @returns the input friendly name
  19218. */
  19219. getSimpleName(): string;
  19220. }
  19221. }
  19222. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19223. import { Nullable } from "babylonjs/types";
  19224. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19226. /**
  19227. * Manage the touch inputs to control the movement of a free camera.
  19228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19229. */
  19230. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19231. /**
  19232. * Defines the camera the input is attached to.
  19233. */
  19234. camera: FreeCamera;
  19235. /**
  19236. * Defines the touch sensibility for rotation.
  19237. * The higher the faster.
  19238. */
  19239. touchAngularSensibility: number;
  19240. /**
  19241. * Defines the touch sensibility for move.
  19242. * The higher the faster.
  19243. */
  19244. touchMoveSensibility: number;
  19245. private _offsetX;
  19246. private _offsetY;
  19247. private _pointerPressed;
  19248. private _pointerInput;
  19249. private _observer;
  19250. private _onLostFocus;
  19251. /**
  19252. * Attach the input controls to a specific dom element to get the input from.
  19253. * @param element Defines the element the controls should be listened from
  19254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19255. */
  19256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19257. /**
  19258. * Detach the current controls from the specified dom element.
  19259. * @param element Defines the element to stop listening the inputs from
  19260. */
  19261. detachControl(element: Nullable<HTMLElement>): void;
  19262. /**
  19263. * Update the current camera state depending on the inputs that have been used this frame.
  19264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19265. */
  19266. checkInputs(): void;
  19267. /**
  19268. * Gets the class name of the current intput.
  19269. * @returns the class name
  19270. */
  19271. getClassName(): string;
  19272. /**
  19273. * Get the friendly name associated with the input class.
  19274. * @returns the input friendly name
  19275. */
  19276. getSimpleName(): string;
  19277. }
  19278. }
  19279. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19280. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19281. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19282. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19283. import { Nullable } from "babylonjs/types";
  19284. /**
  19285. * Default Inputs manager for the FreeCamera.
  19286. * It groups all the default supported inputs for ease of use.
  19287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19288. */
  19289. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19290. /**
  19291. * @hidden
  19292. */
  19293. _mouseInput: Nullable<FreeCameraMouseInput>;
  19294. /**
  19295. * Instantiates a new FreeCameraInputsManager.
  19296. * @param camera Defines the camera the inputs belong to
  19297. */
  19298. constructor(camera: FreeCamera);
  19299. /**
  19300. * Add keyboard input support to the input manager.
  19301. * @returns the current input manager
  19302. */
  19303. addKeyboard(): FreeCameraInputsManager;
  19304. /**
  19305. * Add mouse input support to the input manager.
  19306. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19307. * @returns the current input manager
  19308. */
  19309. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19310. /**
  19311. * Removes the mouse input support from the manager
  19312. * @returns the current input manager
  19313. */
  19314. removeMouse(): FreeCameraInputsManager;
  19315. /**
  19316. * Add touch input support to the input manager.
  19317. * @returns the current input manager
  19318. */
  19319. addTouch(): FreeCameraInputsManager;
  19320. /**
  19321. * Remove all attached input methods from a camera
  19322. */
  19323. clear(): void;
  19324. }
  19325. }
  19326. declare module "babylonjs/Cameras/freeCamera" {
  19327. import { Vector3 } from "babylonjs/Maths/math.vector";
  19328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19329. import { Scene } from "babylonjs/scene";
  19330. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19331. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19332. /**
  19333. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19334. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19336. */
  19337. export class FreeCamera extends TargetCamera {
  19338. /**
  19339. * Define the collision ellipsoid of the camera.
  19340. * This is helpful to simulate a camera body like the player body around the camera
  19341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19342. */
  19343. ellipsoid: Vector3;
  19344. /**
  19345. * Define an offset for the position of the ellipsoid around the camera.
  19346. * This can be helpful to determine the center of the body near the gravity center of the body
  19347. * instead of its head.
  19348. */
  19349. ellipsoidOffset: Vector3;
  19350. /**
  19351. * Enable or disable collisions of the camera with the rest of the scene objects.
  19352. */
  19353. checkCollisions: boolean;
  19354. /**
  19355. * Enable or disable gravity on the camera.
  19356. */
  19357. applyGravity: boolean;
  19358. /**
  19359. * Define the input manager associated to the camera.
  19360. */
  19361. inputs: FreeCameraInputsManager;
  19362. /**
  19363. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19364. * Higher values reduce sensitivity.
  19365. */
  19366. get angularSensibility(): number;
  19367. /**
  19368. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19369. * Higher values reduce sensitivity.
  19370. */
  19371. set angularSensibility(value: number);
  19372. /**
  19373. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19374. */
  19375. get keysUp(): number[];
  19376. set keysUp(value: number[]);
  19377. /**
  19378. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19379. */
  19380. get keysUpward(): number[];
  19381. set keysUpward(value: number[]);
  19382. /**
  19383. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19384. */
  19385. get keysDown(): number[];
  19386. set keysDown(value: number[]);
  19387. /**
  19388. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19389. */
  19390. get keysDownward(): number[];
  19391. set keysDownward(value: number[]);
  19392. /**
  19393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19394. */
  19395. get keysLeft(): number[];
  19396. set keysLeft(value: number[]);
  19397. /**
  19398. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19399. */
  19400. get keysRight(): number[];
  19401. set keysRight(value: number[]);
  19402. /**
  19403. * Event raised when the camera collide with a mesh in the scene.
  19404. */
  19405. onCollide: (collidedMesh: AbstractMesh) => void;
  19406. private _collider;
  19407. private _needMoveForGravity;
  19408. private _oldPosition;
  19409. private _diffPosition;
  19410. private _newPosition;
  19411. /** @hidden */
  19412. _localDirection: Vector3;
  19413. /** @hidden */
  19414. _transformedDirection: Vector3;
  19415. /**
  19416. * Instantiates a Free Camera.
  19417. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19418. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19419. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19420. * @param name Define the name of the camera in the scene
  19421. * @param position Define the start position of the camera in the scene
  19422. * @param scene Define the scene the camera belongs to
  19423. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19424. */
  19425. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19426. /**
  19427. * Attached controls to the current camera.
  19428. * @param element Defines the element the controls should be listened from
  19429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19430. */
  19431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19432. /**
  19433. * Detach the current controls from the camera.
  19434. * The camera will stop reacting to inputs.
  19435. * @param element Defines the element to stop listening the inputs from
  19436. */
  19437. detachControl(element: HTMLElement): void;
  19438. private _collisionMask;
  19439. /**
  19440. * Define a collision mask to limit the list of object the camera can collide with
  19441. */
  19442. get collisionMask(): number;
  19443. set collisionMask(mask: number);
  19444. /** @hidden */
  19445. _collideWithWorld(displacement: Vector3): void;
  19446. private _onCollisionPositionChange;
  19447. /** @hidden */
  19448. _checkInputs(): void;
  19449. /** @hidden */
  19450. _decideIfNeedsToMove(): boolean;
  19451. /** @hidden */
  19452. _updatePosition(): void;
  19453. /**
  19454. * Destroy the camera and release the current resources hold by it.
  19455. */
  19456. dispose(): void;
  19457. /**
  19458. * Gets the current object class name.
  19459. * @return the class name
  19460. */
  19461. getClassName(): string;
  19462. }
  19463. }
  19464. declare module "babylonjs/Gamepads/gamepad" {
  19465. import { Observable } from "babylonjs/Misc/observable";
  19466. /**
  19467. * Represents a gamepad control stick position
  19468. */
  19469. export class StickValues {
  19470. /**
  19471. * The x component of the control stick
  19472. */
  19473. x: number;
  19474. /**
  19475. * The y component of the control stick
  19476. */
  19477. y: number;
  19478. /**
  19479. * Initializes the gamepad x and y control stick values
  19480. * @param x The x component of the gamepad control stick value
  19481. * @param y The y component of the gamepad control stick value
  19482. */
  19483. constructor(
  19484. /**
  19485. * The x component of the control stick
  19486. */
  19487. x: number,
  19488. /**
  19489. * The y component of the control stick
  19490. */
  19491. y: number);
  19492. }
  19493. /**
  19494. * An interface which manages callbacks for gamepad button changes
  19495. */
  19496. export interface GamepadButtonChanges {
  19497. /**
  19498. * Called when a gamepad has been changed
  19499. */
  19500. changed: boolean;
  19501. /**
  19502. * Called when a gamepad press event has been triggered
  19503. */
  19504. pressChanged: boolean;
  19505. /**
  19506. * Called when a touch event has been triggered
  19507. */
  19508. touchChanged: boolean;
  19509. /**
  19510. * Called when a value has changed
  19511. */
  19512. valueChanged: boolean;
  19513. }
  19514. /**
  19515. * Represents a gamepad
  19516. */
  19517. export class Gamepad {
  19518. /**
  19519. * The id of the gamepad
  19520. */
  19521. id: string;
  19522. /**
  19523. * The index of the gamepad
  19524. */
  19525. index: number;
  19526. /**
  19527. * The browser gamepad
  19528. */
  19529. browserGamepad: any;
  19530. /**
  19531. * Specifies what type of gamepad this represents
  19532. */
  19533. type: number;
  19534. private _leftStick;
  19535. private _rightStick;
  19536. /** @hidden */
  19537. _isConnected: boolean;
  19538. private _leftStickAxisX;
  19539. private _leftStickAxisY;
  19540. private _rightStickAxisX;
  19541. private _rightStickAxisY;
  19542. /**
  19543. * Triggered when the left control stick has been changed
  19544. */
  19545. private _onleftstickchanged;
  19546. /**
  19547. * Triggered when the right control stick has been changed
  19548. */
  19549. private _onrightstickchanged;
  19550. /**
  19551. * Represents a gamepad controller
  19552. */
  19553. static GAMEPAD: number;
  19554. /**
  19555. * Represents a generic controller
  19556. */
  19557. static GENERIC: number;
  19558. /**
  19559. * Represents an XBox controller
  19560. */
  19561. static XBOX: number;
  19562. /**
  19563. * Represents a pose-enabled controller
  19564. */
  19565. static POSE_ENABLED: number;
  19566. /**
  19567. * Represents an Dual Shock controller
  19568. */
  19569. static DUALSHOCK: number;
  19570. /**
  19571. * Specifies whether the left control stick should be Y-inverted
  19572. */
  19573. protected _invertLeftStickY: boolean;
  19574. /**
  19575. * Specifies if the gamepad has been connected
  19576. */
  19577. get isConnected(): boolean;
  19578. /**
  19579. * Initializes the gamepad
  19580. * @param id The id of the gamepad
  19581. * @param index The index of the gamepad
  19582. * @param browserGamepad The browser gamepad
  19583. * @param leftStickX The x component of the left joystick
  19584. * @param leftStickY The y component of the left joystick
  19585. * @param rightStickX The x component of the right joystick
  19586. * @param rightStickY The y component of the right joystick
  19587. */
  19588. constructor(
  19589. /**
  19590. * The id of the gamepad
  19591. */
  19592. id: string,
  19593. /**
  19594. * The index of the gamepad
  19595. */
  19596. index: number,
  19597. /**
  19598. * The browser gamepad
  19599. */
  19600. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19601. /**
  19602. * Callback triggered when the left joystick has changed
  19603. * @param callback
  19604. */
  19605. onleftstickchanged(callback: (values: StickValues) => void): void;
  19606. /**
  19607. * Callback triggered when the right joystick has changed
  19608. * @param callback
  19609. */
  19610. onrightstickchanged(callback: (values: StickValues) => void): void;
  19611. /**
  19612. * Gets the left joystick
  19613. */
  19614. get leftStick(): StickValues;
  19615. /**
  19616. * Sets the left joystick values
  19617. */
  19618. set leftStick(newValues: StickValues);
  19619. /**
  19620. * Gets the right joystick
  19621. */
  19622. get rightStick(): StickValues;
  19623. /**
  19624. * Sets the right joystick value
  19625. */
  19626. set rightStick(newValues: StickValues);
  19627. /**
  19628. * Updates the gamepad joystick positions
  19629. */
  19630. update(): void;
  19631. /**
  19632. * Disposes the gamepad
  19633. */
  19634. dispose(): void;
  19635. }
  19636. /**
  19637. * Represents a generic gamepad
  19638. */
  19639. export class GenericPad extends Gamepad {
  19640. private _buttons;
  19641. private _onbuttondown;
  19642. private _onbuttonup;
  19643. /**
  19644. * Observable triggered when a button has been pressed
  19645. */
  19646. onButtonDownObservable: Observable<number>;
  19647. /**
  19648. * Observable triggered when a button has been released
  19649. */
  19650. onButtonUpObservable: Observable<number>;
  19651. /**
  19652. * Callback triggered when a button has been pressed
  19653. * @param callback Called when a button has been pressed
  19654. */
  19655. onbuttondown(callback: (buttonPressed: number) => void): void;
  19656. /**
  19657. * Callback triggered when a button has been released
  19658. * @param callback Called when a button has been released
  19659. */
  19660. onbuttonup(callback: (buttonReleased: number) => void): void;
  19661. /**
  19662. * Initializes the generic gamepad
  19663. * @param id The id of the generic gamepad
  19664. * @param index The index of the generic gamepad
  19665. * @param browserGamepad The browser gamepad
  19666. */
  19667. constructor(id: string, index: number, browserGamepad: any);
  19668. private _setButtonValue;
  19669. /**
  19670. * Updates the generic gamepad
  19671. */
  19672. update(): void;
  19673. /**
  19674. * Disposes the generic gamepad
  19675. */
  19676. dispose(): void;
  19677. }
  19678. }
  19679. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19680. import { Observable } from "babylonjs/Misc/observable";
  19681. import { Nullable } from "babylonjs/types";
  19682. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19683. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19685. import { Ray } from "babylonjs/Culling/ray";
  19686. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19687. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19688. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19689. /**
  19690. * Defines the types of pose enabled controllers that are supported
  19691. */
  19692. export enum PoseEnabledControllerType {
  19693. /**
  19694. * HTC Vive
  19695. */
  19696. VIVE = 0,
  19697. /**
  19698. * Oculus Rift
  19699. */
  19700. OCULUS = 1,
  19701. /**
  19702. * Windows mixed reality
  19703. */
  19704. WINDOWS = 2,
  19705. /**
  19706. * Samsung gear VR
  19707. */
  19708. GEAR_VR = 3,
  19709. /**
  19710. * Google Daydream
  19711. */
  19712. DAYDREAM = 4,
  19713. /**
  19714. * Generic
  19715. */
  19716. GENERIC = 5
  19717. }
  19718. /**
  19719. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19720. */
  19721. export interface MutableGamepadButton {
  19722. /**
  19723. * Value of the button/trigger
  19724. */
  19725. value: number;
  19726. /**
  19727. * If the button/trigger is currently touched
  19728. */
  19729. touched: boolean;
  19730. /**
  19731. * If the button/trigger is currently pressed
  19732. */
  19733. pressed: boolean;
  19734. }
  19735. /**
  19736. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19737. * @hidden
  19738. */
  19739. export interface ExtendedGamepadButton extends GamepadButton {
  19740. /**
  19741. * If the button/trigger is currently pressed
  19742. */
  19743. readonly pressed: boolean;
  19744. /**
  19745. * If the button/trigger is currently touched
  19746. */
  19747. readonly touched: boolean;
  19748. /**
  19749. * Value of the button/trigger
  19750. */
  19751. readonly value: number;
  19752. }
  19753. /** @hidden */
  19754. export interface _GamePadFactory {
  19755. /**
  19756. * Returns whether or not the current gamepad can be created for this type of controller.
  19757. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19758. * @returns true if it can be created, otherwise false
  19759. */
  19760. canCreate(gamepadInfo: any): boolean;
  19761. /**
  19762. * Creates a new instance of the Gamepad.
  19763. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19764. * @returns the new gamepad instance
  19765. */
  19766. create(gamepadInfo: any): Gamepad;
  19767. }
  19768. /**
  19769. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19770. */
  19771. export class PoseEnabledControllerHelper {
  19772. /** @hidden */
  19773. static _ControllerFactories: _GamePadFactory[];
  19774. /** @hidden */
  19775. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19776. /**
  19777. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19778. * @param vrGamepad the gamepad to initialized
  19779. * @returns a vr controller of the type the gamepad identified as
  19780. */
  19781. static InitiateController(vrGamepad: any): Gamepad;
  19782. }
  19783. /**
  19784. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19785. */
  19786. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19787. /**
  19788. * If the controller is used in a webXR session
  19789. */
  19790. isXR: boolean;
  19791. private _deviceRoomPosition;
  19792. private _deviceRoomRotationQuaternion;
  19793. /**
  19794. * The device position in babylon space
  19795. */
  19796. devicePosition: Vector3;
  19797. /**
  19798. * The device rotation in babylon space
  19799. */
  19800. deviceRotationQuaternion: Quaternion;
  19801. /**
  19802. * The scale factor of the device in babylon space
  19803. */
  19804. deviceScaleFactor: number;
  19805. /**
  19806. * (Likely devicePosition should be used instead) The device position in its room space
  19807. */
  19808. position: Vector3;
  19809. /**
  19810. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19811. */
  19812. rotationQuaternion: Quaternion;
  19813. /**
  19814. * The type of controller (Eg. Windows mixed reality)
  19815. */
  19816. controllerType: PoseEnabledControllerType;
  19817. protected _calculatedPosition: Vector3;
  19818. private _calculatedRotation;
  19819. /**
  19820. * The raw pose from the device
  19821. */
  19822. rawPose: DevicePose;
  19823. private _trackPosition;
  19824. private _maxRotationDistFromHeadset;
  19825. private _draggedRoomRotation;
  19826. /**
  19827. * @hidden
  19828. */
  19829. _disableTrackPosition(fixedPosition: Vector3): void;
  19830. /**
  19831. * Internal, the mesh attached to the controller
  19832. * @hidden
  19833. */
  19834. _mesh: Nullable<AbstractMesh>;
  19835. private _poseControlledCamera;
  19836. private _leftHandSystemQuaternion;
  19837. /**
  19838. * Internal, matrix used to convert room space to babylon space
  19839. * @hidden
  19840. */
  19841. _deviceToWorld: Matrix;
  19842. /**
  19843. * Node to be used when casting a ray from the controller
  19844. * @hidden
  19845. */
  19846. _pointingPoseNode: Nullable<TransformNode>;
  19847. /**
  19848. * Name of the child mesh that can be used to cast a ray from the controller
  19849. */
  19850. static readonly POINTING_POSE: string;
  19851. /**
  19852. * Creates a new PoseEnabledController from a gamepad
  19853. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19854. */
  19855. constructor(browserGamepad: any);
  19856. private _workingMatrix;
  19857. /**
  19858. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19859. */
  19860. update(): void;
  19861. /**
  19862. * Updates only the pose device and mesh without doing any button event checking
  19863. */
  19864. protected _updatePoseAndMesh(): void;
  19865. /**
  19866. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19867. * @param poseData raw pose fromthe device
  19868. */
  19869. updateFromDevice(poseData: DevicePose): void;
  19870. /**
  19871. * @hidden
  19872. */
  19873. _meshAttachedObservable: Observable<AbstractMesh>;
  19874. /**
  19875. * Attaches a mesh to the controller
  19876. * @param mesh the mesh to be attached
  19877. */
  19878. attachToMesh(mesh: AbstractMesh): void;
  19879. /**
  19880. * Attaches the controllers mesh to a camera
  19881. * @param camera the camera the mesh should be attached to
  19882. */
  19883. attachToPoseControlledCamera(camera: TargetCamera): void;
  19884. /**
  19885. * Disposes of the controller
  19886. */
  19887. dispose(): void;
  19888. /**
  19889. * The mesh that is attached to the controller
  19890. */
  19891. get mesh(): Nullable<AbstractMesh>;
  19892. /**
  19893. * Gets the ray of the controller in the direction the controller is pointing
  19894. * @param length the length the resulting ray should be
  19895. * @returns a ray in the direction the controller is pointing
  19896. */
  19897. getForwardRay(length?: number): Ray;
  19898. }
  19899. }
  19900. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19901. import { Observable } from "babylonjs/Misc/observable";
  19902. import { Scene } from "babylonjs/scene";
  19903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19904. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19905. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19906. import { Nullable } from "babylonjs/types";
  19907. /**
  19908. * Defines the WebVRController object that represents controllers tracked in 3D space
  19909. */
  19910. export abstract class WebVRController extends PoseEnabledController {
  19911. /**
  19912. * Internal, the default controller model for the controller
  19913. */
  19914. protected _defaultModel: Nullable<AbstractMesh>;
  19915. /**
  19916. * Fired when the trigger state has changed
  19917. */
  19918. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19919. /**
  19920. * Fired when the main button state has changed
  19921. */
  19922. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19923. /**
  19924. * Fired when the secondary button state has changed
  19925. */
  19926. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19927. /**
  19928. * Fired when the pad state has changed
  19929. */
  19930. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19931. /**
  19932. * Fired when controllers stick values have changed
  19933. */
  19934. onPadValuesChangedObservable: Observable<StickValues>;
  19935. /**
  19936. * Array of button availible on the controller
  19937. */
  19938. protected _buttons: Array<MutableGamepadButton>;
  19939. private _onButtonStateChange;
  19940. /**
  19941. * Fired when a controller button's state has changed
  19942. * @param callback the callback containing the button that was modified
  19943. */
  19944. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19945. /**
  19946. * X and Y axis corresponding to the controllers joystick
  19947. */
  19948. pad: StickValues;
  19949. /**
  19950. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19951. */
  19952. hand: string;
  19953. /**
  19954. * The default controller model for the controller
  19955. */
  19956. get defaultModel(): Nullable<AbstractMesh>;
  19957. /**
  19958. * Creates a new WebVRController from a gamepad
  19959. * @param vrGamepad the gamepad that the WebVRController should be created from
  19960. */
  19961. constructor(vrGamepad: any);
  19962. /**
  19963. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19964. */
  19965. update(): void;
  19966. /**
  19967. * Function to be called when a button is modified
  19968. */
  19969. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19970. /**
  19971. * Loads a mesh and attaches it to the controller
  19972. * @param scene the scene the mesh should be added to
  19973. * @param meshLoaded callback for when the mesh has been loaded
  19974. */
  19975. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19976. private _setButtonValue;
  19977. private _changes;
  19978. private _checkChanges;
  19979. /**
  19980. * Disposes of th webVRCOntroller
  19981. */
  19982. dispose(): void;
  19983. }
  19984. }
  19985. declare module "babylonjs/Lights/hemisphericLight" {
  19986. import { Nullable } from "babylonjs/types";
  19987. import { Scene } from "babylonjs/scene";
  19988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19989. import { Color3 } from "babylonjs/Maths/math.color";
  19990. import { Effect } from "babylonjs/Materials/effect";
  19991. import { Light } from "babylonjs/Lights/light";
  19992. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19993. /**
  19994. * The HemisphericLight simulates the ambient environment light,
  19995. * so the passed direction is the light reflection direction, not the incoming direction.
  19996. */
  19997. export class HemisphericLight extends Light {
  19998. /**
  19999. * The groundColor is the light in the opposite direction to the one specified during creation.
  20000. * 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.
  20001. */
  20002. groundColor: Color3;
  20003. /**
  20004. * The light reflection direction, not the incoming direction.
  20005. */
  20006. direction: Vector3;
  20007. /**
  20008. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20009. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20010. * The HemisphericLight can't cast shadows.
  20011. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20012. * @param name The friendly name of the light
  20013. * @param direction The direction of the light reflection
  20014. * @param scene The scene the light belongs to
  20015. */
  20016. constructor(name: string, direction: Vector3, scene: Scene);
  20017. protected _buildUniformLayout(): void;
  20018. /**
  20019. * Returns the string "HemisphericLight".
  20020. * @return The class name
  20021. */
  20022. getClassName(): string;
  20023. /**
  20024. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20025. * Returns the updated direction.
  20026. * @param target The target the direction should point to
  20027. * @return The computed direction
  20028. */
  20029. setDirectionToTarget(target: Vector3): Vector3;
  20030. /**
  20031. * Returns the shadow generator associated to the light.
  20032. * @returns Always null for hemispheric lights because it does not support shadows.
  20033. */
  20034. getShadowGenerator(): Nullable<IShadowGenerator>;
  20035. /**
  20036. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20037. * @param effect The effect to update
  20038. * @param lightIndex The index of the light in the effect to update
  20039. * @returns The hemispheric light
  20040. */
  20041. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20042. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20043. /**
  20044. * Computes the world matrix of the node
  20045. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20046. * @param useWasUpdatedFlag defines a reserved property
  20047. * @returns the world matrix
  20048. */
  20049. computeWorldMatrix(): Matrix;
  20050. /**
  20051. * Returns the integer 3.
  20052. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20053. */
  20054. getTypeID(): number;
  20055. /**
  20056. * Prepares the list of defines specific to the light type.
  20057. * @param defines the list of defines
  20058. * @param lightIndex defines the index of the light for the effect
  20059. */
  20060. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20061. }
  20062. }
  20063. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20064. /** @hidden */
  20065. export var vrMultiviewToSingleviewPixelShader: {
  20066. name: string;
  20067. shader: string;
  20068. };
  20069. }
  20070. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20072. import { Scene } from "babylonjs/scene";
  20073. /**
  20074. * Renders to multiple views with a single draw call
  20075. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20076. */
  20077. export class MultiviewRenderTarget extends RenderTargetTexture {
  20078. /**
  20079. * Creates a multiview render target
  20080. * @param scene scene used with the render target
  20081. * @param size the size of the render target (used for each view)
  20082. */
  20083. constructor(scene: Scene, size?: number | {
  20084. width: number;
  20085. height: number;
  20086. } | {
  20087. ratio: number;
  20088. });
  20089. /**
  20090. * @hidden
  20091. * @param faceIndex the face index, if its a cube texture
  20092. */
  20093. _bindFrameBuffer(faceIndex?: number): void;
  20094. /**
  20095. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20096. * @returns the view count
  20097. */
  20098. getViewCount(): number;
  20099. }
  20100. }
  20101. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20102. import { Camera } from "babylonjs/Cameras/camera";
  20103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20104. import { Nullable } from "babylonjs/types";
  20105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20106. import { Matrix } from "babylonjs/Maths/math.vector";
  20107. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20108. module "babylonjs/Engines/engine" {
  20109. interface Engine {
  20110. /**
  20111. * Creates a new multiview render target
  20112. * @param width defines the width of the texture
  20113. * @param height defines the height of the texture
  20114. * @returns the created multiview texture
  20115. */
  20116. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20117. /**
  20118. * Binds a multiview framebuffer to be drawn to
  20119. * @param multiviewTexture texture to bind
  20120. */
  20121. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20122. }
  20123. }
  20124. module "babylonjs/Cameras/camera" {
  20125. interface Camera {
  20126. /**
  20127. * @hidden
  20128. * 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)
  20129. */
  20130. _useMultiviewToSingleView: boolean;
  20131. /**
  20132. * @hidden
  20133. * 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)
  20134. */
  20135. _multiviewTexture: Nullable<RenderTargetTexture>;
  20136. /**
  20137. * @hidden
  20138. * ensures the multiview texture of the camera exists and has the specified width/height
  20139. * @param width height to set on the multiview texture
  20140. * @param height width to set on the multiview texture
  20141. */
  20142. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20143. }
  20144. }
  20145. module "babylonjs/scene" {
  20146. interface Scene {
  20147. /** @hidden */
  20148. _transformMatrixR: Matrix;
  20149. /** @hidden */
  20150. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20151. /** @hidden */
  20152. _createMultiviewUbo(): void;
  20153. /** @hidden */
  20154. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20155. /** @hidden */
  20156. _renderMultiviewToSingleView(camera: Camera): void;
  20157. }
  20158. }
  20159. }
  20160. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20161. import { Camera } from "babylonjs/Cameras/camera";
  20162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20163. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20164. import "babylonjs/Engines/Extensions/engine.multiview";
  20165. /**
  20166. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20167. * This will not be used for webXR as it supports displaying texture arrays directly
  20168. */
  20169. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20170. /**
  20171. * Initializes a VRMultiviewToSingleview
  20172. * @param name name of the post process
  20173. * @param camera camera to be applied to
  20174. * @param scaleFactor scaling factor to the size of the output texture
  20175. */
  20176. constructor(name: string, camera: Camera, scaleFactor: number);
  20177. }
  20178. }
  20179. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20180. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20181. import { Nullable } from "babylonjs/types";
  20182. import { Size } from "babylonjs/Maths/math.size";
  20183. import { Observable } from "babylonjs/Misc/observable";
  20184. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20185. /**
  20186. * Interface used to define additional presentation attributes
  20187. */
  20188. export interface IVRPresentationAttributes {
  20189. /**
  20190. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20191. */
  20192. highRefreshRate: boolean;
  20193. /**
  20194. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20195. */
  20196. foveationLevel: number;
  20197. }
  20198. module "babylonjs/Engines/engine" {
  20199. interface Engine {
  20200. /** @hidden */
  20201. _vrDisplay: any;
  20202. /** @hidden */
  20203. _vrSupported: boolean;
  20204. /** @hidden */
  20205. _oldSize: Size;
  20206. /** @hidden */
  20207. _oldHardwareScaleFactor: number;
  20208. /** @hidden */
  20209. _vrExclusivePointerMode: boolean;
  20210. /** @hidden */
  20211. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20212. /** @hidden */
  20213. _onVRDisplayPointerRestricted: () => void;
  20214. /** @hidden */
  20215. _onVRDisplayPointerUnrestricted: () => void;
  20216. /** @hidden */
  20217. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20218. /** @hidden */
  20219. _onVrDisplayDisconnect: Nullable<() => void>;
  20220. /** @hidden */
  20221. _onVrDisplayPresentChange: Nullable<() => void>;
  20222. /**
  20223. * Observable signaled when VR display mode changes
  20224. */
  20225. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20226. /**
  20227. * Observable signaled when VR request present is complete
  20228. */
  20229. onVRRequestPresentComplete: Observable<boolean>;
  20230. /**
  20231. * Observable signaled when VR request present starts
  20232. */
  20233. onVRRequestPresentStart: Observable<Engine>;
  20234. /**
  20235. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20236. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20237. */
  20238. isInVRExclusivePointerMode: boolean;
  20239. /**
  20240. * Gets a boolean indicating if a webVR device was detected
  20241. * @returns true if a webVR device was detected
  20242. */
  20243. isVRDevicePresent(): boolean;
  20244. /**
  20245. * Gets the current webVR device
  20246. * @returns the current webVR device (or null)
  20247. */
  20248. getVRDevice(): any;
  20249. /**
  20250. * Initializes a webVR display and starts listening to display change events
  20251. * The onVRDisplayChangedObservable will be notified upon these changes
  20252. * @returns A promise containing a VRDisplay and if vr is supported
  20253. */
  20254. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20255. /** @hidden */
  20256. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20257. /**
  20258. * Gets or sets the presentation attributes used to configure VR rendering
  20259. */
  20260. vrPresentationAttributes?: IVRPresentationAttributes;
  20261. /**
  20262. * Call this function to switch to webVR mode
  20263. * Will do nothing if webVR is not supported or if there is no webVR device
  20264. * @param options the webvr options provided to the camera. mainly used for multiview
  20265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20266. */
  20267. enableVR(options: WebVROptions): void;
  20268. /** @hidden */
  20269. _onVRFullScreenTriggered(): void;
  20270. }
  20271. }
  20272. }
  20273. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20274. import { Nullable } from "babylonjs/types";
  20275. import { Observable } from "babylonjs/Misc/observable";
  20276. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20277. import { Scene } from "babylonjs/scene";
  20278. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20279. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20280. import { Node } from "babylonjs/node";
  20281. import { Ray } from "babylonjs/Culling/ray";
  20282. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20283. import "babylonjs/Engines/Extensions/engine.webVR";
  20284. /**
  20285. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20286. * IMPORTANT!! The data is right-hand data.
  20287. * @export
  20288. * @interface DevicePose
  20289. */
  20290. export interface DevicePose {
  20291. /**
  20292. * The position of the device, values in array are [x,y,z].
  20293. */
  20294. readonly position: Nullable<Float32Array>;
  20295. /**
  20296. * The linearVelocity of the device, values in array are [x,y,z].
  20297. */
  20298. readonly linearVelocity: Nullable<Float32Array>;
  20299. /**
  20300. * The linearAcceleration of the device, values in array are [x,y,z].
  20301. */
  20302. readonly linearAcceleration: Nullable<Float32Array>;
  20303. /**
  20304. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20305. */
  20306. readonly orientation: Nullable<Float32Array>;
  20307. /**
  20308. * The angularVelocity of the device, values in array are [x,y,z].
  20309. */
  20310. readonly angularVelocity: Nullable<Float32Array>;
  20311. /**
  20312. * The angularAcceleration of the device, values in array are [x,y,z].
  20313. */
  20314. readonly angularAcceleration: Nullable<Float32Array>;
  20315. }
  20316. /**
  20317. * Interface representing a pose controlled object in Babylon.
  20318. * A pose controlled object has both regular pose values as well as pose values
  20319. * from an external device such as a VR head mounted display
  20320. */
  20321. export interface PoseControlled {
  20322. /**
  20323. * The position of the object in babylon space.
  20324. */
  20325. position: Vector3;
  20326. /**
  20327. * The rotation quaternion of the object in babylon space.
  20328. */
  20329. rotationQuaternion: Quaternion;
  20330. /**
  20331. * The position of the device in babylon space.
  20332. */
  20333. devicePosition?: Vector3;
  20334. /**
  20335. * The rotation quaternion of the device in babylon space.
  20336. */
  20337. deviceRotationQuaternion: Quaternion;
  20338. /**
  20339. * The raw pose coming from the device.
  20340. */
  20341. rawPose: Nullable<DevicePose>;
  20342. /**
  20343. * The scale of the device to be used when translating from device space to babylon space.
  20344. */
  20345. deviceScaleFactor: number;
  20346. /**
  20347. * Updates the poseControlled values based on the input device pose.
  20348. * @param poseData the pose data to update the object with
  20349. */
  20350. updateFromDevice(poseData: DevicePose): void;
  20351. }
  20352. /**
  20353. * Set of options to customize the webVRCamera
  20354. */
  20355. export interface WebVROptions {
  20356. /**
  20357. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20358. */
  20359. trackPosition?: boolean;
  20360. /**
  20361. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20362. */
  20363. positionScale?: number;
  20364. /**
  20365. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20366. */
  20367. displayName?: string;
  20368. /**
  20369. * Should the native controller meshes be initialized. (default: true)
  20370. */
  20371. controllerMeshes?: boolean;
  20372. /**
  20373. * Creating a default HemiLight only on controllers. (default: true)
  20374. */
  20375. defaultLightingOnControllers?: boolean;
  20376. /**
  20377. * If you don't want to use the default VR button of the helper. (default: false)
  20378. */
  20379. useCustomVRButton?: boolean;
  20380. /**
  20381. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20382. */
  20383. customVRButton?: HTMLButtonElement;
  20384. /**
  20385. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20386. */
  20387. rayLength?: number;
  20388. /**
  20389. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20390. */
  20391. defaultHeight?: number;
  20392. /**
  20393. * If multiview should be used if availible (default: false)
  20394. */
  20395. useMultiview?: boolean;
  20396. }
  20397. /**
  20398. * This represents a WebVR camera.
  20399. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20400. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20401. */
  20402. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20403. private webVROptions;
  20404. /**
  20405. * @hidden
  20406. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20407. */
  20408. _vrDevice: any;
  20409. /**
  20410. * The rawPose of the vrDevice.
  20411. */
  20412. rawPose: Nullable<DevicePose>;
  20413. private _onVREnabled;
  20414. private _specsVersion;
  20415. private _attached;
  20416. private _frameData;
  20417. protected _descendants: Array<Node>;
  20418. private _deviceRoomPosition;
  20419. /** @hidden */
  20420. _deviceRoomRotationQuaternion: Quaternion;
  20421. private _standingMatrix;
  20422. /**
  20423. * Represents device position in babylon space.
  20424. */
  20425. devicePosition: Vector3;
  20426. /**
  20427. * Represents device rotation in babylon space.
  20428. */
  20429. deviceRotationQuaternion: Quaternion;
  20430. /**
  20431. * The scale of the device to be used when translating from device space to babylon space.
  20432. */
  20433. deviceScaleFactor: number;
  20434. private _deviceToWorld;
  20435. private _worldToDevice;
  20436. /**
  20437. * References to the webVR controllers for the vrDevice.
  20438. */
  20439. controllers: Array<WebVRController>;
  20440. /**
  20441. * Emits an event when a controller is attached.
  20442. */
  20443. onControllersAttachedObservable: Observable<WebVRController[]>;
  20444. /**
  20445. * Emits an event when a controller's mesh has been loaded;
  20446. */
  20447. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20448. /**
  20449. * Emits an event when the HMD's pose has been updated.
  20450. */
  20451. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20452. private _poseSet;
  20453. /**
  20454. * If the rig cameras be used as parent instead of this camera.
  20455. */
  20456. rigParenting: boolean;
  20457. private _lightOnControllers;
  20458. private _defaultHeight?;
  20459. /**
  20460. * Instantiates a WebVRFreeCamera.
  20461. * @param name The name of the WebVRFreeCamera
  20462. * @param position The starting anchor position for the camera
  20463. * @param scene The scene the camera belongs to
  20464. * @param webVROptions a set of customizable options for the webVRCamera
  20465. */
  20466. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20467. /**
  20468. * Gets the device distance from the ground in meters.
  20469. * @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.
  20470. */
  20471. deviceDistanceToRoomGround(): number;
  20472. /**
  20473. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20474. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20475. */
  20476. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20477. /**
  20478. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20479. * @returns A promise with a boolean set to if the standing matrix is supported.
  20480. */
  20481. useStandingMatrixAsync(): Promise<boolean>;
  20482. /**
  20483. * Disposes the camera
  20484. */
  20485. dispose(): void;
  20486. /**
  20487. * Gets a vrController by name.
  20488. * @param name The name of the controller to retreive
  20489. * @returns the controller matching the name specified or null if not found
  20490. */
  20491. getControllerByName(name: string): Nullable<WebVRController>;
  20492. private _leftController;
  20493. /**
  20494. * The controller corresponding to the users left hand.
  20495. */
  20496. get leftController(): Nullable<WebVRController>;
  20497. private _rightController;
  20498. /**
  20499. * The controller corresponding to the users right hand.
  20500. */
  20501. get rightController(): Nullable<WebVRController>;
  20502. /**
  20503. * Casts a ray forward from the vrCamera's gaze.
  20504. * @param length Length of the ray (default: 100)
  20505. * @returns the ray corresponding to the gaze
  20506. */
  20507. getForwardRay(length?: number): Ray;
  20508. /**
  20509. * @hidden
  20510. * Updates the camera based on device's frame data
  20511. */
  20512. _checkInputs(): void;
  20513. /**
  20514. * Updates the poseControlled values based on the input device pose.
  20515. * @param poseData Pose coming from the device
  20516. */
  20517. updateFromDevice(poseData: DevicePose): void;
  20518. private _htmlElementAttached;
  20519. private _detachIfAttached;
  20520. /**
  20521. * WebVR's attach control will start broadcasting frames to the device.
  20522. * Note that in certain browsers (chrome for example) this function must be called
  20523. * within a user-interaction callback. Example:
  20524. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20525. *
  20526. * @param element html element to attach the vrDevice to
  20527. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20528. */
  20529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20530. /**
  20531. * Detaches the camera from the html element and disables VR
  20532. *
  20533. * @param element html element to detach from
  20534. */
  20535. detachControl(element: HTMLElement): void;
  20536. /**
  20537. * @returns the name of this class
  20538. */
  20539. getClassName(): string;
  20540. /**
  20541. * Calls resetPose on the vrDisplay
  20542. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20543. */
  20544. resetToCurrentRotation(): void;
  20545. /**
  20546. * @hidden
  20547. * Updates the rig cameras (left and right eye)
  20548. */
  20549. _updateRigCameras(): void;
  20550. private _workingVector;
  20551. private _oneVector;
  20552. private _workingMatrix;
  20553. private updateCacheCalled;
  20554. private _correctPositionIfNotTrackPosition;
  20555. /**
  20556. * @hidden
  20557. * Updates the cached values of the camera
  20558. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20559. */
  20560. _updateCache(ignoreParentClass?: boolean): void;
  20561. /**
  20562. * @hidden
  20563. * Get current device position in babylon world
  20564. */
  20565. _computeDevicePosition(): void;
  20566. /**
  20567. * Updates the current device position and rotation in the babylon world
  20568. */
  20569. update(): void;
  20570. /**
  20571. * @hidden
  20572. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20573. * @returns an identity matrix
  20574. */
  20575. _getViewMatrix(): Matrix;
  20576. private _tmpMatrix;
  20577. /**
  20578. * This function is called by the two RIG cameras.
  20579. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20580. * @hidden
  20581. */
  20582. _getWebVRViewMatrix(): Matrix;
  20583. /** @hidden */
  20584. _getWebVRProjectionMatrix(): Matrix;
  20585. private _onGamepadConnectedObserver;
  20586. private _onGamepadDisconnectedObserver;
  20587. private _updateCacheWhenTrackingDisabledObserver;
  20588. /**
  20589. * Initializes the controllers and their meshes
  20590. */
  20591. initControllers(): void;
  20592. }
  20593. }
  20594. declare module "babylonjs/Materials/materialHelper" {
  20595. import { Nullable } from "babylonjs/types";
  20596. import { Scene } from "babylonjs/scene";
  20597. import { Engine } from "babylonjs/Engines/engine";
  20598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20599. import { Light } from "babylonjs/Lights/light";
  20600. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20601. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20603. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20604. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20605. /**
  20606. * "Static Class" containing the most commonly used helper while dealing with material for
  20607. * rendering purpose.
  20608. *
  20609. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20610. *
  20611. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20612. */
  20613. export class MaterialHelper {
  20614. /**
  20615. * Bind the current view position to an effect.
  20616. * @param effect The effect to be bound
  20617. * @param scene The scene the eyes position is used from
  20618. * @param variableName name of the shader variable that will hold the eye position
  20619. */
  20620. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20621. /**
  20622. * Helps preparing the defines values about the UVs in used in the effect.
  20623. * UVs are shared as much as we can accross channels in the shaders.
  20624. * @param texture The texture we are preparing the UVs for
  20625. * @param defines The defines to update
  20626. * @param key The channel key "diffuse", "specular"... used in the shader
  20627. */
  20628. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20629. /**
  20630. * Binds a texture matrix value to its corrsponding uniform
  20631. * @param texture The texture to bind the matrix for
  20632. * @param uniformBuffer The uniform buffer receivin the data
  20633. * @param key The channel key "diffuse", "specular"... used in the shader
  20634. */
  20635. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20636. /**
  20637. * Gets the current status of the fog (should it be enabled?)
  20638. * @param mesh defines the mesh to evaluate for fog support
  20639. * @param scene defines the hosting scene
  20640. * @returns true if fog must be enabled
  20641. */
  20642. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20643. /**
  20644. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20645. * @param mesh defines the current mesh
  20646. * @param scene defines the current scene
  20647. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20648. * @param pointsCloud defines if point cloud rendering has to be turned on
  20649. * @param fogEnabled defines if fog has to be turned on
  20650. * @param alphaTest defines if alpha testing has to be turned on
  20651. * @param defines defines the current list of defines
  20652. */
  20653. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20654. /**
  20655. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20656. * @param scene defines the current scene
  20657. * @param engine defines the current engine
  20658. * @param defines specifies the list of active defines
  20659. * @param useInstances defines if instances have to be turned on
  20660. * @param useClipPlane defines if clip plane have to be turned on
  20661. * @param useInstances defines if instances have to be turned on
  20662. * @param useThinInstances defines if thin instances have to be turned on
  20663. */
  20664. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20665. /**
  20666. * Prepares the defines for bones
  20667. * @param mesh The mesh containing the geometry data we will draw
  20668. * @param defines The defines to update
  20669. */
  20670. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20671. /**
  20672. * Prepares the defines for morph targets
  20673. * @param mesh The mesh containing the geometry data we will draw
  20674. * @param defines The defines to update
  20675. */
  20676. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20677. /**
  20678. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20679. * @param mesh The mesh containing the geometry data we will draw
  20680. * @param defines The defines to update
  20681. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20682. * @param useBones Precise whether bones should be used or not (override mesh info)
  20683. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20684. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20685. * @returns false if defines are considered not dirty and have not been checked
  20686. */
  20687. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20688. /**
  20689. * Prepares the defines related to multiview
  20690. * @param scene The scene we are intending to draw
  20691. * @param defines The defines to update
  20692. */
  20693. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20694. /**
  20695. * Prepares the defines related to the light information passed in parameter
  20696. * @param scene The scene we are intending to draw
  20697. * @param mesh The mesh the effect is compiling for
  20698. * @param light The light the effect is compiling for
  20699. * @param lightIndex The index of the light
  20700. * @param defines The defines to update
  20701. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20702. * @param state Defines the current state regarding what is needed (normals, etc...)
  20703. */
  20704. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20705. needNormals: boolean;
  20706. needRebuild: boolean;
  20707. shadowEnabled: boolean;
  20708. specularEnabled: boolean;
  20709. lightmapMode: boolean;
  20710. }): void;
  20711. /**
  20712. * Prepares the defines related to the light information passed in parameter
  20713. * @param scene The scene we are intending to draw
  20714. * @param mesh The mesh the effect is compiling for
  20715. * @param defines The defines to update
  20716. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20717. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20718. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20719. * @returns true if normals will be required for the rest of the effect
  20720. */
  20721. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20722. /**
  20723. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20724. * @param lightIndex defines the light index
  20725. * @param uniformsList The uniform list
  20726. * @param samplersList The sampler list
  20727. * @param projectedLightTexture defines if projected texture must be used
  20728. * @param uniformBuffersList defines an optional list of uniform buffers
  20729. */
  20730. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20731. /**
  20732. * Prepares the uniforms and samplers list to be used in the effect
  20733. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20734. * @param samplersList The sampler list
  20735. * @param defines The defines helping in the list generation
  20736. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20737. */
  20738. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20739. /**
  20740. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20741. * @param defines The defines to update while falling back
  20742. * @param fallbacks The authorized effect fallbacks
  20743. * @param maxSimultaneousLights The maximum number of lights allowed
  20744. * @param rank the current rank of the Effect
  20745. * @returns The newly affected rank
  20746. */
  20747. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20748. private static _TmpMorphInfluencers;
  20749. /**
  20750. * Prepares the list of attributes required for morph targets according to the effect defines.
  20751. * @param attribs The current list of supported attribs
  20752. * @param mesh The mesh to prepare the morph targets attributes for
  20753. * @param influencers The number of influencers
  20754. */
  20755. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20756. /**
  20757. * Prepares the list of attributes required for morph targets according to the effect defines.
  20758. * @param attribs The current list of supported attribs
  20759. * @param mesh The mesh to prepare the morph targets attributes for
  20760. * @param defines The current Defines of the effect
  20761. */
  20762. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20763. /**
  20764. * Prepares the list of attributes required for bones according to the effect defines.
  20765. * @param attribs The current list of supported attribs
  20766. * @param mesh The mesh to prepare the bones attributes for
  20767. * @param defines The current Defines of the effect
  20768. * @param fallbacks The current efffect fallback strategy
  20769. */
  20770. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20771. /**
  20772. * Check and prepare the list of attributes required for instances according to the effect defines.
  20773. * @param attribs The current list of supported attribs
  20774. * @param defines The current MaterialDefines of the effect
  20775. */
  20776. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20777. /**
  20778. * Add the list of attributes required for instances to the attribs array.
  20779. * @param attribs The current list of supported attribs
  20780. */
  20781. static PushAttributesForInstances(attribs: string[]): void;
  20782. /**
  20783. * Binds the light information to the effect.
  20784. * @param light The light containing the generator
  20785. * @param effect The effect we are binding the data to
  20786. * @param lightIndex The light index in the effect used to render
  20787. */
  20788. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20789. /**
  20790. * Binds the lights information from the scene to the effect for the given mesh.
  20791. * @param light Light to bind
  20792. * @param lightIndex Light index
  20793. * @param scene The scene where the light belongs to
  20794. * @param effect The effect we are binding the data to
  20795. * @param useSpecular Defines if specular is supported
  20796. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20797. */
  20798. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20799. /**
  20800. * Binds the lights information from the scene to the effect for the given mesh.
  20801. * @param scene The scene the lights belongs to
  20802. * @param mesh The mesh we are binding the information to render
  20803. * @param effect The effect we are binding the data to
  20804. * @param defines The generated defines for the effect
  20805. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20806. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20807. */
  20808. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20809. private static _tempFogColor;
  20810. /**
  20811. * Binds the fog information from the scene to the effect for the given mesh.
  20812. * @param scene The scene the lights belongs to
  20813. * @param mesh The mesh we are binding the information to render
  20814. * @param effect The effect we are binding the data to
  20815. * @param linearSpace Defines if the fog effect is applied in linear space
  20816. */
  20817. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20818. /**
  20819. * Binds the bones information from the mesh to the effect.
  20820. * @param mesh The mesh we are binding the information to render
  20821. * @param effect The effect we are binding the data to
  20822. */
  20823. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20824. /**
  20825. * Binds the morph targets information from the mesh to the effect.
  20826. * @param abstractMesh The mesh we are binding the information to render
  20827. * @param effect The effect we are binding the data to
  20828. */
  20829. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20830. /**
  20831. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20832. * @param defines The generated defines used in the effect
  20833. * @param effect The effect we are binding the data to
  20834. * @param scene The scene we are willing to render with logarithmic scale for
  20835. */
  20836. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20837. /**
  20838. * Binds the clip plane information from the scene to the effect.
  20839. * @param scene The scene the clip plane information are extracted from
  20840. * @param effect The effect we are binding the data to
  20841. */
  20842. static BindClipPlane(effect: Effect, scene: Scene): void;
  20843. }
  20844. }
  20845. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20847. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20848. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20849. import { Nullable } from "babylonjs/types";
  20850. import { Effect } from "babylonjs/Materials/effect";
  20851. import { Matrix } from "babylonjs/Maths/math.vector";
  20852. import { Scene } from "babylonjs/scene";
  20853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20855. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20856. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20857. import { Observable } from "babylonjs/Misc/observable";
  20858. /**
  20859. * Block used to expose an input value
  20860. */
  20861. export class InputBlock extends NodeMaterialBlock {
  20862. private _mode;
  20863. private _associatedVariableName;
  20864. private _storedValue;
  20865. private _valueCallback;
  20866. private _type;
  20867. private _animationType;
  20868. /** Gets or set a value used to limit the range of float values */
  20869. min: number;
  20870. /** Gets or set a value used to limit the range of float values */
  20871. max: number;
  20872. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20873. isBoolean: boolean;
  20874. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20875. matrixMode: number;
  20876. /** @hidden */
  20877. _systemValue: Nullable<NodeMaterialSystemValues>;
  20878. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20879. visibleInInspector: boolean;
  20880. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20881. isConstant: boolean;
  20882. /** Gets or sets the group to use to display this block in the Inspector */
  20883. groupInInspector: string;
  20884. /** Gets an observable raised when the value is changed */
  20885. onValueChangedObservable: Observable<InputBlock>;
  20886. /**
  20887. * Gets or sets the connection point type (default is float)
  20888. */
  20889. get type(): NodeMaterialBlockConnectionPointTypes;
  20890. /**
  20891. * Creates a new InputBlock
  20892. * @param name defines the block name
  20893. * @param target defines the target of that block (Vertex by default)
  20894. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20895. */
  20896. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20897. /**
  20898. * Gets the output component
  20899. */
  20900. get output(): NodeMaterialConnectionPoint;
  20901. /**
  20902. * Set the source of this connection point to a vertex attribute
  20903. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20904. * @returns the current connection point
  20905. */
  20906. setAsAttribute(attributeName?: string): InputBlock;
  20907. /**
  20908. * Set the source of this connection point to a system value
  20909. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20910. * @returns the current connection point
  20911. */
  20912. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20913. /**
  20914. * Gets or sets the value of that point.
  20915. * Please note that this value will be ignored if valueCallback is defined
  20916. */
  20917. get value(): any;
  20918. set value(value: any);
  20919. /**
  20920. * Gets or sets a callback used to get the value of that point.
  20921. * Please note that setting this value will force the connection point to ignore the value property
  20922. */
  20923. get valueCallback(): () => any;
  20924. set valueCallback(value: () => any);
  20925. /**
  20926. * Gets or sets the associated variable name in the shader
  20927. */
  20928. get associatedVariableName(): string;
  20929. set associatedVariableName(value: string);
  20930. /** Gets or sets the type of animation applied to the input */
  20931. get animationType(): AnimatedInputBlockTypes;
  20932. set animationType(value: AnimatedInputBlockTypes);
  20933. /**
  20934. * Gets a boolean indicating that this connection point not defined yet
  20935. */
  20936. get isUndefined(): boolean;
  20937. /**
  20938. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20939. * In this case the connection point name must be the name of the uniform to use.
  20940. * Can only be set on inputs
  20941. */
  20942. get isUniform(): boolean;
  20943. set isUniform(value: boolean);
  20944. /**
  20945. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20946. * In this case the connection point name must be the name of the attribute to use
  20947. * Can only be set on inputs
  20948. */
  20949. get isAttribute(): boolean;
  20950. set isAttribute(value: boolean);
  20951. /**
  20952. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20953. * Can only be set on exit points
  20954. */
  20955. get isVarying(): boolean;
  20956. set isVarying(value: boolean);
  20957. /**
  20958. * Gets a boolean indicating that the current connection point is a system value
  20959. */
  20960. get isSystemValue(): boolean;
  20961. /**
  20962. * Gets or sets the current well known value or null if not defined as a system value
  20963. */
  20964. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20965. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20966. /**
  20967. * Gets the current class name
  20968. * @returns the class name
  20969. */
  20970. getClassName(): string;
  20971. /**
  20972. * Animate the input if animationType !== None
  20973. * @param scene defines the rendering scene
  20974. */
  20975. animate(scene: Scene): void;
  20976. private _emitDefine;
  20977. initialize(state: NodeMaterialBuildState): void;
  20978. /**
  20979. * Set the input block to its default value (based on its type)
  20980. */
  20981. setDefaultValue(): void;
  20982. private _emitConstant;
  20983. /** @hidden */
  20984. get _noContextSwitch(): boolean;
  20985. private _emit;
  20986. /** @hidden */
  20987. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20988. /** @hidden */
  20989. _transmit(effect: Effect, scene: Scene): void;
  20990. protected _buildBlock(state: NodeMaterialBuildState): void;
  20991. protected _dumpPropertiesCode(): string;
  20992. dispose(): void;
  20993. serialize(): any;
  20994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20995. }
  20996. }
  20997. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20998. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20999. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21000. import { Nullable } from "babylonjs/types";
  21001. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21002. import { Observable } from "babylonjs/Misc/observable";
  21003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21004. /**
  21005. * Enum used to define the compatibility state between two connection points
  21006. */
  21007. export enum NodeMaterialConnectionPointCompatibilityStates {
  21008. /** Points are compatibles */
  21009. Compatible = 0,
  21010. /** Points are incompatible because of their types */
  21011. TypeIncompatible = 1,
  21012. /** Points are incompatible because of their targets (vertex vs fragment) */
  21013. TargetIncompatible = 2
  21014. }
  21015. /**
  21016. * Defines the direction of a connection point
  21017. */
  21018. export enum NodeMaterialConnectionPointDirection {
  21019. /** Input */
  21020. Input = 0,
  21021. /** Output */
  21022. Output = 1
  21023. }
  21024. /**
  21025. * Defines a connection point for a block
  21026. */
  21027. export class NodeMaterialConnectionPoint {
  21028. /** @hidden */
  21029. _ownerBlock: NodeMaterialBlock;
  21030. /** @hidden */
  21031. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21032. private _endpoints;
  21033. private _associatedVariableName;
  21034. private _direction;
  21035. /** @hidden */
  21036. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21037. /** @hidden */
  21038. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21039. private _type;
  21040. /** @hidden */
  21041. _enforceAssociatedVariableName: boolean;
  21042. /** Gets the direction of the point */
  21043. get direction(): NodeMaterialConnectionPointDirection;
  21044. /** Indicates that this connection point needs dual validation before being connected to another point */
  21045. needDualDirectionValidation: boolean;
  21046. /**
  21047. * Gets or sets the additional types supported by this connection point
  21048. */
  21049. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21050. /**
  21051. * Gets or sets the additional types excluded by this connection point
  21052. */
  21053. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21054. /**
  21055. * Observable triggered when this point is connected
  21056. */
  21057. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21058. /**
  21059. * Gets or sets the associated variable name in the shader
  21060. */
  21061. get associatedVariableName(): string;
  21062. set associatedVariableName(value: string);
  21063. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21064. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21065. /**
  21066. * Gets or sets the connection point type (default is float)
  21067. */
  21068. get type(): NodeMaterialBlockConnectionPointTypes;
  21069. set type(value: NodeMaterialBlockConnectionPointTypes);
  21070. /**
  21071. * Gets or sets the connection point name
  21072. */
  21073. name: string;
  21074. /**
  21075. * Gets or sets the connection point name
  21076. */
  21077. displayName: string;
  21078. /**
  21079. * Gets or sets a boolean indicating that this connection point can be omitted
  21080. */
  21081. isOptional: boolean;
  21082. /**
  21083. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21084. */
  21085. isExposedOnFrame: boolean;
  21086. /**
  21087. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21088. */
  21089. define: string;
  21090. /** @hidden */
  21091. _prioritizeVertex: boolean;
  21092. private _target;
  21093. /** Gets or sets the target of that connection point */
  21094. get target(): NodeMaterialBlockTargets;
  21095. set target(value: NodeMaterialBlockTargets);
  21096. /**
  21097. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21098. */
  21099. get isConnected(): boolean;
  21100. /**
  21101. * Gets a boolean indicating that the current point is connected to an input block
  21102. */
  21103. get isConnectedToInputBlock(): boolean;
  21104. /**
  21105. * Gets a the connected input block (if any)
  21106. */
  21107. get connectInputBlock(): Nullable<InputBlock>;
  21108. /** Get the other side of the connection (if any) */
  21109. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21110. /** Get the block that owns this connection point */
  21111. get ownerBlock(): NodeMaterialBlock;
  21112. /** Get the block connected on the other side of this connection (if any) */
  21113. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21114. /** Get the block connected on the endpoints of this connection (if any) */
  21115. get connectedBlocks(): Array<NodeMaterialBlock>;
  21116. /** Gets the list of connected endpoints */
  21117. get endpoints(): NodeMaterialConnectionPoint[];
  21118. /** Gets a boolean indicating if that output point is connected to at least one input */
  21119. get hasEndpoints(): boolean;
  21120. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21121. get isConnectedInVertexShader(): boolean;
  21122. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21123. get isConnectedInFragmentShader(): boolean;
  21124. /**
  21125. * Creates a block suitable to be used as an input for this input point.
  21126. * If null is returned, a block based on the point type will be created.
  21127. * @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
  21128. */
  21129. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21130. /**
  21131. * Creates a new connection point
  21132. * @param name defines the connection point name
  21133. * @param ownerBlock defines the block hosting this connection point
  21134. * @param direction defines the direction of the connection point
  21135. */
  21136. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21137. /**
  21138. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21139. * @returns the class name
  21140. */
  21141. getClassName(): string;
  21142. /**
  21143. * Gets a boolean indicating if the current point can be connected to another point
  21144. * @param connectionPoint defines the other connection point
  21145. * @returns a boolean
  21146. */
  21147. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21148. /**
  21149. * Gets a number indicating if the current point can be connected to another point
  21150. * @param connectionPoint defines the other connection point
  21151. * @returns a number defining the compatibility state
  21152. */
  21153. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21154. /**
  21155. * Connect this point to another connection point
  21156. * @param connectionPoint defines the other connection point
  21157. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21158. * @returns the current connection point
  21159. */
  21160. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21161. /**
  21162. * Disconnect this point from one of his endpoint
  21163. * @param endpoint defines the other connection point
  21164. * @returns the current connection point
  21165. */
  21166. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21167. /**
  21168. * Serializes this point in a JSON representation
  21169. * @param isInput defines if the connection point is an input (default is true)
  21170. * @returns the serialized point object
  21171. */
  21172. serialize(isInput?: boolean): any;
  21173. /**
  21174. * Release resources
  21175. */
  21176. dispose(): void;
  21177. }
  21178. }
  21179. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21180. /**
  21181. * Enum used to define the material modes
  21182. */
  21183. export enum NodeMaterialModes {
  21184. /** Regular material */
  21185. Material = 0,
  21186. /** For post process */
  21187. PostProcess = 1,
  21188. /** For particle system */
  21189. Particle = 2
  21190. }
  21191. }
  21192. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21195. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21198. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21199. import { Effect } from "babylonjs/Materials/effect";
  21200. import { Mesh } from "babylonjs/Meshes/mesh";
  21201. import { Nullable } from "babylonjs/types";
  21202. import { Texture } from "babylonjs/Materials/Textures/texture";
  21203. import { Scene } from "babylonjs/scene";
  21204. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21205. /**
  21206. * Block used to read a texture from a sampler
  21207. */
  21208. export class TextureBlock extends NodeMaterialBlock {
  21209. private _defineName;
  21210. private _linearDefineName;
  21211. private _gammaDefineName;
  21212. private _tempTextureRead;
  21213. private _samplerName;
  21214. private _transformedUVName;
  21215. private _textureTransformName;
  21216. private _textureInfoName;
  21217. private _mainUVName;
  21218. private _mainUVDefineName;
  21219. private _fragmentOnly;
  21220. /**
  21221. * Gets or sets the texture associated with the node
  21222. */
  21223. texture: Nullable<Texture>;
  21224. /**
  21225. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21226. */
  21227. convertToGammaSpace: boolean;
  21228. /**
  21229. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21230. */
  21231. convertToLinearSpace: boolean;
  21232. /**
  21233. * Create a new TextureBlock
  21234. * @param name defines the block name
  21235. */
  21236. constructor(name: string, fragmentOnly?: boolean);
  21237. /**
  21238. * Gets the current class name
  21239. * @returns the class name
  21240. */
  21241. getClassName(): string;
  21242. /**
  21243. * Gets the uv input component
  21244. */
  21245. get uv(): NodeMaterialConnectionPoint;
  21246. /**
  21247. * Gets the rgba output component
  21248. */
  21249. get rgba(): NodeMaterialConnectionPoint;
  21250. /**
  21251. * Gets the rgb output component
  21252. */
  21253. get rgb(): NodeMaterialConnectionPoint;
  21254. /**
  21255. * Gets the r output component
  21256. */
  21257. get r(): NodeMaterialConnectionPoint;
  21258. /**
  21259. * Gets the g output component
  21260. */
  21261. get g(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the b output component
  21264. */
  21265. get b(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the a output component
  21268. */
  21269. get a(): NodeMaterialConnectionPoint;
  21270. get target(): NodeMaterialBlockTargets;
  21271. autoConfigure(material: NodeMaterial): void;
  21272. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21274. isReady(): boolean;
  21275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21276. private get _isMixed();
  21277. private _injectVertexCode;
  21278. private _writeTextureRead;
  21279. private _writeOutput;
  21280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21281. protected _dumpPropertiesCode(): string;
  21282. serialize(): any;
  21283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21284. }
  21285. }
  21286. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21287. /** @hidden */
  21288. export var reflectionFunction: {
  21289. name: string;
  21290. shader: string;
  21291. };
  21292. }
  21293. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21299. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21300. import { Effect } from "babylonjs/Materials/effect";
  21301. import { Mesh } from "babylonjs/Meshes/mesh";
  21302. import { Nullable } from "babylonjs/types";
  21303. import { Scene } from "babylonjs/scene";
  21304. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21305. /**
  21306. * Base block used to read a reflection texture from a sampler
  21307. */
  21308. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21309. /** @hidden */
  21310. _define3DName: string;
  21311. /** @hidden */
  21312. _defineCubicName: string;
  21313. /** @hidden */
  21314. _defineExplicitName: string;
  21315. /** @hidden */
  21316. _defineProjectionName: string;
  21317. /** @hidden */
  21318. _defineLocalCubicName: string;
  21319. /** @hidden */
  21320. _defineSphericalName: string;
  21321. /** @hidden */
  21322. _definePlanarName: string;
  21323. /** @hidden */
  21324. _defineEquirectangularName: string;
  21325. /** @hidden */
  21326. _defineMirroredEquirectangularFixedName: string;
  21327. /** @hidden */
  21328. _defineEquirectangularFixedName: string;
  21329. /** @hidden */
  21330. _defineSkyboxName: string;
  21331. /** @hidden */
  21332. _defineOppositeZ: string;
  21333. /** @hidden */
  21334. _cubeSamplerName: string;
  21335. /** @hidden */
  21336. _2DSamplerName: string;
  21337. protected _positionUVWName: string;
  21338. protected _directionWName: string;
  21339. protected _reflectionVectorName: string;
  21340. /** @hidden */
  21341. _reflectionCoordsName: string;
  21342. /** @hidden */
  21343. _reflectionMatrixName: string;
  21344. protected _reflectionColorName: string;
  21345. /**
  21346. * Gets or sets the texture associated with the node
  21347. */
  21348. texture: Nullable<BaseTexture>;
  21349. /**
  21350. * Create a new ReflectionTextureBaseBlock
  21351. * @param name defines the block name
  21352. */
  21353. constructor(name: string);
  21354. /**
  21355. * Gets the current class name
  21356. * @returns the class name
  21357. */
  21358. getClassName(): string;
  21359. /**
  21360. * Gets the world position input component
  21361. */
  21362. abstract get position(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the world position input component
  21365. */
  21366. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the world normal input component
  21369. */
  21370. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Gets the world input component
  21373. */
  21374. abstract get world(): NodeMaterialConnectionPoint;
  21375. /**
  21376. * Gets the camera (or eye) position component
  21377. */
  21378. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21379. /**
  21380. * Gets the view input component
  21381. */
  21382. abstract get view(): NodeMaterialConnectionPoint;
  21383. protected _getTexture(): Nullable<BaseTexture>;
  21384. autoConfigure(material: NodeMaterial): void;
  21385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21386. isReady(): boolean;
  21387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21388. /**
  21389. * Gets the code to inject in the vertex shader
  21390. * @param state current state of the node material building
  21391. * @returns the shader code
  21392. */
  21393. handleVertexSide(state: NodeMaterialBuildState): string;
  21394. /**
  21395. * Handles the inits for the fragment code path
  21396. * @param state node material build state
  21397. */
  21398. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21399. /**
  21400. * Generates the reflection coords code for the fragment code path
  21401. * @param worldNormalVarName name of the world normal variable
  21402. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21403. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21404. * @returns the shader code
  21405. */
  21406. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21407. /**
  21408. * Generates the reflection color code for the fragment code path
  21409. * @param lodVarName name of the lod variable
  21410. * @param swizzleLookupTexture swizzle to use for the final color variable
  21411. * @returns the shader code
  21412. */
  21413. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21414. /**
  21415. * Generates the code corresponding to the connected output points
  21416. * @param state node material build state
  21417. * @param varName name of the variable to output
  21418. * @returns the shader code
  21419. */
  21420. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21421. protected _buildBlock(state: NodeMaterialBuildState): this;
  21422. protected _dumpPropertiesCode(): string;
  21423. serialize(): any;
  21424. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21425. }
  21426. }
  21427. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21429. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21430. import { Nullable } from "babylonjs/types";
  21431. /**
  21432. * Defines a connection point to be used for points with a custom object type
  21433. */
  21434. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21435. private _blockType;
  21436. private _blockName;
  21437. private _nameForCheking?;
  21438. /**
  21439. * Creates a new connection point
  21440. * @param name defines the connection point name
  21441. * @param ownerBlock defines the block hosting this connection point
  21442. * @param direction defines the direction of the connection point
  21443. */
  21444. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21445. /**
  21446. * Gets a number indicating if the current point can be connected to another point
  21447. * @param connectionPoint defines the other connection point
  21448. * @returns a number defining the compatibility state
  21449. */
  21450. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21451. /**
  21452. * Creates a block suitable to be used as an input for this input point.
  21453. * If null is returned, a block based on the point type will be created.
  21454. * @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
  21455. */
  21456. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21457. }
  21458. }
  21459. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21460. /**
  21461. * Enum defining the type of properties that can be edited in the property pages in the NME
  21462. */
  21463. export enum PropertyTypeForEdition {
  21464. /** property is a boolean */
  21465. Boolean = 0,
  21466. /** property is a float */
  21467. Float = 1,
  21468. /** property is a Vector2 */
  21469. Vector2 = 2,
  21470. /** property is a list of values */
  21471. List = 3
  21472. }
  21473. /**
  21474. * Interface that defines an option in a variable of type list
  21475. */
  21476. export interface IEditablePropertyListOption {
  21477. /** label of the option */
  21478. "label": string;
  21479. /** value of the option */
  21480. "value": number;
  21481. }
  21482. /**
  21483. * Interface that defines the options available for an editable property
  21484. */
  21485. export interface IEditablePropertyOption {
  21486. /** min value */
  21487. "min"?: number;
  21488. /** max value */
  21489. "max"?: number;
  21490. /** notifiers: indicates which actions to take when the property is changed */
  21491. "notifiers"?: {
  21492. /** the material should be rebuilt */
  21493. "rebuild"?: boolean;
  21494. /** the preview should be updated */
  21495. "update"?: boolean;
  21496. };
  21497. /** list of the options for a variable of type list */
  21498. "options"?: IEditablePropertyListOption[];
  21499. }
  21500. /**
  21501. * Interface that describes an editable property
  21502. */
  21503. export interface IPropertyDescriptionForEdition {
  21504. /** name of the property */
  21505. "propertyName": string;
  21506. /** display name of the property */
  21507. "displayName": string;
  21508. /** type of the property */
  21509. "type": PropertyTypeForEdition;
  21510. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21511. "groupName": string;
  21512. /** options for the property */
  21513. "options": IEditablePropertyOption;
  21514. }
  21515. /**
  21516. * Decorator that flags a property in a node material block as being editable
  21517. */
  21518. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21519. }
  21520. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21523. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21525. import { Nullable } from "babylonjs/types";
  21526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21527. import { Mesh } from "babylonjs/Meshes/mesh";
  21528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { Scene } from "babylonjs/scene";
  21531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21532. /**
  21533. * Block used to implement the refraction part of the sub surface module of the PBR material
  21534. */
  21535. export class RefractionBlock extends NodeMaterialBlock {
  21536. /** @hidden */
  21537. _define3DName: string;
  21538. /** @hidden */
  21539. _refractionMatrixName: string;
  21540. /** @hidden */
  21541. _defineLODRefractionAlpha: string;
  21542. /** @hidden */
  21543. _defineLinearSpecularRefraction: string;
  21544. /** @hidden */
  21545. _defineOppositeZ: string;
  21546. /** @hidden */
  21547. _cubeSamplerName: string;
  21548. /** @hidden */
  21549. _2DSamplerName: string;
  21550. /** @hidden */
  21551. _vRefractionMicrosurfaceInfosName: string;
  21552. /** @hidden */
  21553. _vRefractionInfosName: string;
  21554. private _scene;
  21555. /**
  21556. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21557. * Materials half opaque for instance using refraction could benefit from this control.
  21558. */
  21559. linkRefractionWithTransparency: boolean;
  21560. /**
  21561. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21562. */
  21563. invertRefractionY: boolean;
  21564. /**
  21565. * Gets or sets the texture associated with the node
  21566. */
  21567. texture: Nullable<BaseTexture>;
  21568. /**
  21569. * Create a new RefractionBlock
  21570. * @param name defines the block name
  21571. */
  21572. constructor(name: string);
  21573. /**
  21574. * Gets the current class name
  21575. * @returns the class name
  21576. */
  21577. getClassName(): string;
  21578. /**
  21579. * Gets the intensity input component
  21580. */
  21581. get intensity(): NodeMaterialConnectionPoint;
  21582. /**
  21583. * Gets the index of refraction input component
  21584. */
  21585. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21586. /**
  21587. * Gets the tint at distance input component
  21588. */
  21589. get tintAtDistance(): NodeMaterialConnectionPoint;
  21590. /**
  21591. * Gets the view input component
  21592. */
  21593. get view(): NodeMaterialConnectionPoint;
  21594. /**
  21595. * Gets the refraction object output component
  21596. */
  21597. get refraction(): NodeMaterialConnectionPoint;
  21598. /**
  21599. * Returns true if the block has a texture
  21600. */
  21601. get hasTexture(): boolean;
  21602. protected _getTexture(): Nullable<BaseTexture>;
  21603. autoConfigure(material: NodeMaterial): void;
  21604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21605. isReady(): boolean;
  21606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21607. /**
  21608. * Gets the main code of the block (fragment side)
  21609. * @param state current state of the node material building
  21610. * @returns the shader code
  21611. */
  21612. getCode(state: NodeMaterialBuildState): string;
  21613. protected _buildBlock(state: NodeMaterialBuildState): this;
  21614. protected _dumpPropertiesCode(): string;
  21615. serialize(): any;
  21616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21617. }
  21618. }
  21619. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21622. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21625. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21627. import { Nullable } from "babylonjs/types";
  21628. import { Scene } from "babylonjs/scene";
  21629. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21630. /**
  21631. * Base block used as input for post process
  21632. */
  21633. export class CurrentScreenBlock extends NodeMaterialBlock {
  21634. private _samplerName;
  21635. private _linearDefineName;
  21636. private _gammaDefineName;
  21637. private _mainUVName;
  21638. private _tempTextureRead;
  21639. /**
  21640. * Gets or sets the texture associated with the node
  21641. */
  21642. texture: Nullable<BaseTexture>;
  21643. /**
  21644. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21645. */
  21646. convertToGammaSpace: boolean;
  21647. /**
  21648. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21649. */
  21650. convertToLinearSpace: boolean;
  21651. /**
  21652. * Create a new CurrentScreenBlock
  21653. * @param name defines the block name
  21654. */
  21655. constructor(name: string);
  21656. /**
  21657. * Gets the current class name
  21658. * @returns the class name
  21659. */
  21660. getClassName(): string;
  21661. /**
  21662. * Gets the uv input component
  21663. */
  21664. get uv(): NodeMaterialConnectionPoint;
  21665. /**
  21666. * Gets the rgba output component
  21667. */
  21668. get rgba(): NodeMaterialConnectionPoint;
  21669. /**
  21670. * Gets the rgb output component
  21671. */
  21672. get rgb(): NodeMaterialConnectionPoint;
  21673. /**
  21674. * Gets the r output component
  21675. */
  21676. get r(): NodeMaterialConnectionPoint;
  21677. /**
  21678. * Gets the g output component
  21679. */
  21680. get g(): NodeMaterialConnectionPoint;
  21681. /**
  21682. * Gets the b output component
  21683. */
  21684. get b(): NodeMaterialConnectionPoint;
  21685. /**
  21686. * Gets the a output component
  21687. */
  21688. get a(): NodeMaterialConnectionPoint;
  21689. /**
  21690. * Initialize the block and prepare the context for build
  21691. * @param state defines the state that will be used for the build
  21692. */
  21693. initialize(state: NodeMaterialBuildState): void;
  21694. get target(): NodeMaterialBlockTargets;
  21695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21696. isReady(): boolean;
  21697. private _injectVertexCode;
  21698. private _writeTextureRead;
  21699. private _writeOutput;
  21700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21701. serialize(): any;
  21702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21703. }
  21704. }
  21705. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21710. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21712. import { Nullable } from "babylonjs/types";
  21713. import { Scene } from "babylonjs/scene";
  21714. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21715. /**
  21716. * Base block used for the particle texture
  21717. */
  21718. export class ParticleTextureBlock extends NodeMaterialBlock {
  21719. private _samplerName;
  21720. private _linearDefineName;
  21721. private _gammaDefineName;
  21722. private _tempTextureRead;
  21723. /**
  21724. * Gets or sets the texture associated with the node
  21725. */
  21726. texture: Nullable<BaseTexture>;
  21727. /**
  21728. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21729. */
  21730. convertToGammaSpace: boolean;
  21731. /**
  21732. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21733. */
  21734. convertToLinearSpace: boolean;
  21735. /**
  21736. * Create a new ParticleTextureBlock
  21737. * @param name defines the block name
  21738. */
  21739. constructor(name: string);
  21740. /**
  21741. * Gets the current class name
  21742. * @returns the class name
  21743. */
  21744. getClassName(): string;
  21745. /**
  21746. * Gets the uv input component
  21747. */
  21748. get uv(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the rgba output component
  21751. */
  21752. get rgba(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the rgb output component
  21755. */
  21756. get rgb(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the r output component
  21759. */
  21760. get r(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the g output component
  21763. */
  21764. get g(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the b output component
  21767. */
  21768. get b(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the a output component
  21771. */
  21772. get a(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Initialize the block and prepare the context for build
  21775. * @param state defines the state that will be used for the build
  21776. */
  21777. initialize(state: NodeMaterialBuildState): void;
  21778. autoConfigure(material: NodeMaterial): void;
  21779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21780. isReady(): boolean;
  21781. private _writeOutput;
  21782. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21783. serialize(): any;
  21784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21785. }
  21786. }
  21787. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21790. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21791. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21792. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21793. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21794. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21795. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21796. import { Scene } from "babylonjs/scene";
  21797. /**
  21798. * Class used to store shared data between 2 NodeMaterialBuildState
  21799. */
  21800. export class NodeMaterialBuildStateSharedData {
  21801. /**
  21802. * Gets the list of emitted varyings
  21803. */
  21804. temps: string[];
  21805. /**
  21806. * Gets the list of emitted varyings
  21807. */
  21808. varyings: string[];
  21809. /**
  21810. * Gets the varying declaration string
  21811. */
  21812. varyingDeclaration: string;
  21813. /**
  21814. * Input blocks
  21815. */
  21816. inputBlocks: InputBlock[];
  21817. /**
  21818. * Input blocks
  21819. */
  21820. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21821. /**
  21822. * Bindable blocks (Blocks that need to set data to the effect)
  21823. */
  21824. bindableBlocks: NodeMaterialBlock[];
  21825. /**
  21826. * List of blocks that can provide a compilation fallback
  21827. */
  21828. blocksWithFallbacks: NodeMaterialBlock[];
  21829. /**
  21830. * List of blocks that can provide a define update
  21831. */
  21832. blocksWithDefines: NodeMaterialBlock[];
  21833. /**
  21834. * List of blocks that can provide a repeatable content
  21835. */
  21836. repeatableContentBlocks: NodeMaterialBlock[];
  21837. /**
  21838. * List of blocks that can provide a dynamic list of uniforms
  21839. */
  21840. dynamicUniformBlocks: NodeMaterialBlock[];
  21841. /**
  21842. * List of blocks that can block the isReady function for the material
  21843. */
  21844. blockingBlocks: NodeMaterialBlock[];
  21845. /**
  21846. * Gets the list of animated inputs
  21847. */
  21848. animatedInputs: InputBlock[];
  21849. /**
  21850. * Build Id used to avoid multiple recompilations
  21851. */
  21852. buildId: number;
  21853. /** List of emitted variables */
  21854. variableNames: {
  21855. [key: string]: number;
  21856. };
  21857. /** List of emitted defines */
  21858. defineNames: {
  21859. [key: string]: number;
  21860. };
  21861. /** Should emit comments? */
  21862. emitComments: boolean;
  21863. /** Emit build activity */
  21864. verbose: boolean;
  21865. /** Gets or sets the hosting scene */
  21866. scene: Scene;
  21867. /**
  21868. * Gets the compilation hints emitted at compilation time
  21869. */
  21870. hints: {
  21871. needWorldViewMatrix: boolean;
  21872. needWorldViewProjectionMatrix: boolean;
  21873. needAlphaBlending: boolean;
  21874. needAlphaTesting: boolean;
  21875. };
  21876. /**
  21877. * List of compilation checks
  21878. */
  21879. checks: {
  21880. emitVertex: boolean;
  21881. emitFragment: boolean;
  21882. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21883. };
  21884. /**
  21885. * Is vertex program allowed to be empty?
  21886. */
  21887. allowEmptyVertexProgram: boolean;
  21888. /** Creates a new shared data */
  21889. constructor();
  21890. /**
  21891. * Emits console errors and exceptions if there is a failing check
  21892. */
  21893. emitErrors(): void;
  21894. }
  21895. }
  21896. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21897. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21898. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21899. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21900. /**
  21901. * Class used to store node based material build state
  21902. */
  21903. export class NodeMaterialBuildState {
  21904. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21905. supportUniformBuffers: boolean;
  21906. /**
  21907. * Gets the list of emitted attributes
  21908. */
  21909. attributes: string[];
  21910. /**
  21911. * Gets the list of emitted uniforms
  21912. */
  21913. uniforms: string[];
  21914. /**
  21915. * Gets the list of emitted constants
  21916. */
  21917. constants: string[];
  21918. /**
  21919. * Gets the list of emitted samplers
  21920. */
  21921. samplers: string[];
  21922. /**
  21923. * Gets the list of emitted functions
  21924. */
  21925. functions: {
  21926. [key: string]: string;
  21927. };
  21928. /**
  21929. * Gets the list of emitted extensions
  21930. */
  21931. extensions: {
  21932. [key: string]: string;
  21933. };
  21934. /**
  21935. * Gets the target of the compilation state
  21936. */
  21937. target: NodeMaterialBlockTargets;
  21938. /**
  21939. * Gets the list of emitted counters
  21940. */
  21941. counters: {
  21942. [key: string]: number;
  21943. };
  21944. /**
  21945. * Shared data between multiple NodeMaterialBuildState instances
  21946. */
  21947. sharedData: NodeMaterialBuildStateSharedData;
  21948. /** @hidden */
  21949. _vertexState: NodeMaterialBuildState;
  21950. /** @hidden */
  21951. _attributeDeclaration: string;
  21952. /** @hidden */
  21953. _uniformDeclaration: string;
  21954. /** @hidden */
  21955. _constantDeclaration: string;
  21956. /** @hidden */
  21957. _samplerDeclaration: string;
  21958. /** @hidden */
  21959. _varyingTransfer: string;
  21960. /** @hidden */
  21961. _injectAtEnd: string;
  21962. private _repeatableContentAnchorIndex;
  21963. /** @hidden */
  21964. _builtCompilationString: string;
  21965. /**
  21966. * Gets the emitted compilation strings
  21967. */
  21968. compilationString: string;
  21969. /**
  21970. * Finalize the compilation strings
  21971. * @param state defines the current compilation state
  21972. */
  21973. finalize(state: NodeMaterialBuildState): void;
  21974. /** @hidden */
  21975. get _repeatableContentAnchor(): string;
  21976. /** @hidden */
  21977. _getFreeVariableName(prefix: string): string;
  21978. /** @hidden */
  21979. _getFreeDefineName(prefix: string): string;
  21980. /** @hidden */
  21981. _excludeVariableName(name: string): void;
  21982. /** @hidden */
  21983. _emit2DSampler(name: string): void;
  21984. /** @hidden */
  21985. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21986. /** @hidden */
  21987. _emitExtension(name: string, extension: string, define?: string): void;
  21988. /** @hidden */
  21989. _emitFunction(name: string, code: string, comments: string): void;
  21990. /** @hidden */
  21991. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21992. replaceStrings?: {
  21993. search: RegExp;
  21994. replace: string;
  21995. }[];
  21996. repeatKey?: string;
  21997. }): string;
  21998. /** @hidden */
  21999. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22000. repeatKey?: string;
  22001. removeAttributes?: boolean;
  22002. removeUniforms?: boolean;
  22003. removeVaryings?: boolean;
  22004. removeIfDef?: boolean;
  22005. replaceStrings?: {
  22006. search: RegExp;
  22007. replace: string;
  22008. }[];
  22009. }, storeKey?: string): void;
  22010. /** @hidden */
  22011. _registerTempVariable(name: string): boolean;
  22012. /** @hidden */
  22013. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22014. /** @hidden */
  22015. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22016. /** @hidden */
  22017. _emitFloat(value: number): string;
  22018. }
  22019. }
  22020. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22021. /**
  22022. * Helper class used to generate session unique ID
  22023. */
  22024. export class UniqueIdGenerator {
  22025. private static _UniqueIdCounter;
  22026. /**
  22027. * Gets an unique (relatively to the current scene) Id
  22028. */
  22029. static get UniqueId(): number;
  22030. }
  22031. }
  22032. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22033. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22035. import { Nullable } from "babylonjs/types";
  22036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22037. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22038. import { Effect } from "babylonjs/Materials/effect";
  22039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22040. import { Mesh } from "babylonjs/Meshes/mesh";
  22041. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22042. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22043. import { Scene } from "babylonjs/scene";
  22044. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22045. /**
  22046. * Defines a block that can be used inside a node based material
  22047. */
  22048. export class NodeMaterialBlock {
  22049. private _buildId;
  22050. private _buildTarget;
  22051. private _target;
  22052. private _isFinalMerger;
  22053. private _isInput;
  22054. protected _isUnique: boolean;
  22055. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22056. inputsAreExclusive: boolean;
  22057. /** @hidden */
  22058. _codeVariableName: string;
  22059. /** @hidden */
  22060. _inputs: NodeMaterialConnectionPoint[];
  22061. /** @hidden */
  22062. _outputs: NodeMaterialConnectionPoint[];
  22063. /** @hidden */
  22064. _preparationId: number;
  22065. /**
  22066. * Gets or sets the name of the block
  22067. */
  22068. name: string;
  22069. /**
  22070. * Gets or sets the unique id of the node
  22071. */
  22072. uniqueId: number;
  22073. /**
  22074. * Gets or sets the comments associated with this block
  22075. */
  22076. comments: string;
  22077. /**
  22078. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22079. */
  22080. get isUnique(): boolean;
  22081. /**
  22082. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22083. */
  22084. get isFinalMerger(): boolean;
  22085. /**
  22086. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22087. */
  22088. get isInput(): boolean;
  22089. /**
  22090. * Gets or sets the build Id
  22091. */
  22092. get buildId(): number;
  22093. set buildId(value: number);
  22094. /**
  22095. * Gets or sets the target of the block
  22096. */
  22097. get target(): NodeMaterialBlockTargets;
  22098. set target(value: NodeMaterialBlockTargets);
  22099. /**
  22100. * Gets the list of input points
  22101. */
  22102. get inputs(): NodeMaterialConnectionPoint[];
  22103. /** Gets the list of output points */
  22104. get outputs(): NodeMaterialConnectionPoint[];
  22105. /**
  22106. * Find an input by its name
  22107. * @param name defines the name of the input to look for
  22108. * @returns the input or null if not found
  22109. */
  22110. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22111. /**
  22112. * Find an output by its name
  22113. * @param name defines the name of the outputto look for
  22114. * @returns the output or null if not found
  22115. */
  22116. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22117. /**
  22118. * Creates a new NodeMaterialBlock
  22119. * @param name defines the block name
  22120. * @param target defines the target of that block (Vertex by default)
  22121. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22122. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22123. */
  22124. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22125. /**
  22126. * Initialize the block and prepare the context for build
  22127. * @param state defines the state that will be used for the build
  22128. */
  22129. initialize(state: NodeMaterialBuildState): void;
  22130. /**
  22131. * Bind data to effect. Will only be called for blocks with isBindable === true
  22132. * @param effect defines the effect to bind data to
  22133. * @param nodeMaterial defines the hosting NodeMaterial
  22134. * @param mesh defines the mesh that will be rendered
  22135. * @param subMesh defines the submesh that will be rendered
  22136. */
  22137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22138. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22139. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22140. protected _writeFloat(value: number): string;
  22141. /**
  22142. * Gets the current class name e.g. "NodeMaterialBlock"
  22143. * @returns the class name
  22144. */
  22145. getClassName(): string;
  22146. /**
  22147. * Register a new input. Must be called inside a block constructor
  22148. * @param name defines the connection point name
  22149. * @param type defines the connection point type
  22150. * @param isOptional defines a boolean indicating that this input can be omitted
  22151. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22152. * @param point an already created connection point. If not provided, create a new one
  22153. * @returns the current block
  22154. */
  22155. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22156. /**
  22157. * Register a new output. Must be called inside a block constructor
  22158. * @param name defines the connection point name
  22159. * @param type defines the connection point type
  22160. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22161. * @param point an already created connection point. If not provided, create a new one
  22162. * @returns the current block
  22163. */
  22164. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22165. /**
  22166. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22167. * @param forOutput defines an optional connection point to check compatibility with
  22168. * @returns the first available input or null
  22169. */
  22170. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22171. /**
  22172. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22173. * @param forBlock defines an optional block to check compatibility with
  22174. * @returns the first available input or null
  22175. */
  22176. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22177. /**
  22178. * Gets the sibling of the given output
  22179. * @param current defines the current output
  22180. * @returns the next output in the list or null
  22181. */
  22182. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22183. /**
  22184. * Connect current block with another block
  22185. * @param other defines the block to connect with
  22186. * @param options define the various options to help pick the right connections
  22187. * @returns the current block
  22188. */
  22189. connectTo(other: NodeMaterialBlock, options?: {
  22190. input?: string;
  22191. output?: string;
  22192. outputSwizzle?: string;
  22193. }): this | undefined;
  22194. protected _buildBlock(state: NodeMaterialBuildState): void;
  22195. /**
  22196. * Add uniforms, samplers and uniform buffers at compilation time
  22197. * @param state defines the state to update
  22198. * @param nodeMaterial defines the node material requesting the update
  22199. * @param defines defines the material defines to update
  22200. * @param uniformBuffers defines the list of uniform buffer names
  22201. */
  22202. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22203. /**
  22204. * Add potential fallbacks if shader compilation fails
  22205. * @param mesh defines the mesh to be rendered
  22206. * @param fallbacks defines the current prioritized list of fallbacks
  22207. */
  22208. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22209. /**
  22210. * Initialize defines for shader compilation
  22211. * @param mesh defines the mesh to be rendered
  22212. * @param nodeMaterial defines the node material requesting the update
  22213. * @param defines defines the material defines to update
  22214. * @param useInstances specifies that instances should be used
  22215. */
  22216. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22217. /**
  22218. * Update defines for shader compilation
  22219. * @param mesh defines the mesh to be rendered
  22220. * @param nodeMaterial defines the node material requesting the update
  22221. * @param defines defines the material defines to update
  22222. * @param useInstances specifies that instances should be used
  22223. * @param subMesh defines which submesh to render
  22224. */
  22225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22226. /**
  22227. * Lets the block try to connect some inputs automatically
  22228. * @param material defines the hosting NodeMaterial
  22229. */
  22230. autoConfigure(material: NodeMaterial): void;
  22231. /**
  22232. * Function called when a block is declared as repeatable content generator
  22233. * @param vertexShaderState defines the current compilation state for the vertex shader
  22234. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22235. * @param mesh defines the mesh to be rendered
  22236. * @param defines defines the material defines to update
  22237. */
  22238. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22239. /**
  22240. * Checks if the block is ready
  22241. * @param mesh defines the mesh to be rendered
  22242. * @param nodeMaterial defines the node material requesting the update
  22243. * @param defines defines the material defines to update
  22244. * @param useInstances specifies that instances should be used
  22245. * @returns true if the block is ready
  22246. */
  22247. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22248. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22249. private _processBuild;
  22250. /**
  22251. * Compile the current node and generate the shader code
  22252. * @param state defines the current compilation state (uniforms, samplers, current string)
  22253. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22254. * @returns true if already built
  22255. */
  22256. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22257. protected _inputRename(name: string): string;
  22258. protected _outputRename(name: string): string;
  22259. protected _dumpPropertiesCode(): string;
  22260. /** @hidden */
  22261. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22262. /** @hidden */
  22263. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22264. /**
  22265. * Clone the current block to a new identical block
  22266. * @param scene defines the hosting scene
  22267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22268. * @returns a copy of the current block
  22269. */
  22270. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22271. /**
  22272. * Serializes this block in a JSON representation
  22273. * @returns the serialized block object
  22274. */
  22275. serialize(): any;
  22276. /** @hidden */
  22277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22278. private _deserializePortDisplayNamesAndExposedOnFrame;
  22279. /**
  22280. * Release resources
  22281. */
  22282. dispose(): void;
  22283. }
  22284. }
  22285. declare module "babylonjs/Materials/pushMaterial" {
  22286. import { Nullable } from "babylonjs/types";
  22287. import { Scene } from "babylonjs/scene";
  22288. import { Matrix } from "babylonjs/Maths/math.vector";
  22289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22290. import { Mesh } from "babylonjs/Meshes/mesh";
  22291. import { Material } from "babylonjs/Materials/material";
  22292. import { Effect } from "babylonjs/Materials/effect";
  22293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22294. /**
  22295. * Base class of materials working in push mode in babylon JS
  22296. * @hidden
  22297. */
  22298. export class PushMaterial extends Material {
  22299. protected _activeEffect: Effect;
  22300. protected _normalMatrix: Matrix;
  22301. constructor(name: string, scene: Scene);
  22302. getEffect(): Effect;
  22303. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22304. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22305. /**
  22306. * Binds the given world matrix to the active effect
  22307. *
  22308. * @param world the matrix to bind
  22309. */
  22310. bindOnlyWorldMatrix(world: Matrix): void;
  22311. /**
  22312. * Binds the given normal matrix to the active effect
  22313. *
  22314. * @param normalMatrix the matrix to bind
  22315. */
  22316. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22317. bind(world: Matrix, mesh?: Mesh): void;
  22318. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22319. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22320. }
  22321. }
  22322. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22324. /**
  22325. * Root class for all node material optimizers
  22326. */
  22327. export class NodeMaterialOptimizer {
  22328. /**
  22329. * Function used to optimize a NodeMaterial graph
  22330. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22331. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22332. */
  22333. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22334. }
  22335. }
  22336. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22340. import { Scene } from "babylonjs/scene";
  22341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22342. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22344. /**
  22345. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22346. */
  22347. export class TransformBlock extends NodeMaterialBlock {
  22348. /**
  22349. * Defines the value to use to complement W value to transform it to a Vector4
  22350. */
  22351. complementW: number;
  22352. /**
  22353. * Defines the value to use to complement z value to transform it to a Vector4
  22354. */
  22355. complementZ: number;
  22356. /**
  22357. * Creates a new TransformBlock
  22358. * @param name defines the block name
  22359. */
  22360. constructor(name: string);
  22361. /**
  22362. * Gets the current class name
  22363. * @returns the class name
  22364. */
  22365. getClassName(): string;
  22366. /**
  22367. * Gets the vector input
  22368. */
  22369. get vector(): NodeMaterialConnectionPoint;
  22370. /**
  22371. * Gets the output component
  22372. */
  22373. get output(): NodeMaterialConnectionPoint;
  22374. /**
  22375. * Gets the xyz output component
  22376. */
  22377. get xyz(): NodeMaterialConnectionPoint;
  22378. /**
  22379. * Gets the matrix transform input
  22380. */
  22381. get transform(): NodeMaterialConnectionPoint;
  22382. protected _buildBlock(state: NodeMaterialBuildState): this;
  22383. /**
  22384. * Update defines for shader compilation
  22385. * @param mesh defines the mesh to be rendered
  22386. * @param nodeMaterial defines the node material requesting the update
  22387. * @param defines defines the material defines to update
  22388. * @param useInstances specifies that instances should be used
  22389. * @param subMesh defines which submesh to render
  22390. */
  22391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22392. serialize(): any;
  22393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22394. protected _dumpPropertiesCode(): string;
  22395. }
  22396. }
  22397. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22398. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22399. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22400. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22401. /**
  22402. * Block used to output the vertex position
  22403. */
  22404. export class VertexOutputBlock extends NodeMaterialBlock {
  22405. /**
  22406. * Creates a new VertexOutputBlock
  22407. * @param name defines the block name
  22408. */
  22409. constructor(name: string);
  22410. /**
  22411. * Gets the current class name
  22412. * @returns the class name
  22413. */
  22414. getClassName(): string;
  22415. /**
  22416. * Gets the vector input component
  22417. */
  22418. get vector(): NodeMaterialConnectionPoint;
  22419. protected _buildBlock(state: NodeMaterialBuildState): this;
  22420. }
  22421. }
  22422. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22426. /**
  22427. * Block used to output the final color
  22428. */
  22429. export class FragmentOutputBlock extends NodeMaterialBlock {
  22430. /**
  22431. * Create a new FragmentOutputBlock
  22432. * @param name defines the block name
  22433. */
  22434. constructor(name: string);
  22435. /**
  22436. * Gets the current class name
  22437. * @returns the class name
  22438. */
  22439. getClassName(): string;
  22440. /**
  22441. * Gets the rgba input component
  22442. */
  22443. get rgba(): NodeMaterialConnectionPoint;
  22444. /**
  22445. * Gets the rgb input component
  22446. */
  22447. get rgb(): NodeMaterialConnectionPoint;
  22448. /**
  22449. * Gets the a input component
  22450. */
  22451. get a(): NodeMaterialConnectionPoint;
  22452. protected _buildBlock(state: NodeMaterialBuildState): this;
  22453. }
  22454. }
  22455. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22459. /**
  22460. * Block used for the particle ramp gradient section
  22461. */
  22462. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22463. /**
  22464. * Create a new ParticleRampGradientBlock
  22465. * @param name defines the block name
  22466. */
  22467. constructor(name: string);
  22468. /**
  22469. * Gets the current class name
  22470. * @returns the class name
  22471. */
  22472. getClassName(): string;
  22473. /**
  22474. * Gets the color input component
  22475. */
  22476. get color(): NodeMaterialConnectionPoint;
  22477. /**
  22478. * Gets the rampColor output component
  22479. */
  22480. get rampColor(): NodeMaterialConnectionPoint;
  22481. /**
  22482. * Initialize the block and prepare the context for build
  22483. * @param state defines the state that will be used for the build
  22484. */
  22485. initialize(state: NodeMaterialBuildState): void;
  22486. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22487. }
  22488. }
  22489. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22493. /**
  22494. * Block used for the particle blend multiply section
  22495. */
  22496. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22497. /**
  22498. * Create a new ParticleBlendMultiplyBlock
  22499. * @param name defines the block name
  22500. */
  22501. constructor(name: string);
  22502. /**
  22503. * Gets the current class name
  22504. * @returns the class name
  22505. */
  22506. getClassName(): string;
  22507. /**
  22508. * Gets the color input component
  22509. */
  22510. get color(): NodeMaterialConnectionPoint;
  22511. /**
  22512. * Gets the alphaTexture input component
  22513. */
  22514. get alphaTexture(): NodeMaterialConnectionPoint;
  22515. /**
  22516. * Gets the alphaColor input component
  22517. */
  22518. get alphaColor(): NodeMaterialConnectionPoint;
  22519. /**
  22520. * Gets the blendColor output component
  22521. */
  22522. get blendColor(): NodeMaterialConnectionPoint;
  22523. /**
  22524. * Initialize the block and prepare the context for build
  22525. * @param state defines the state that will be used for the build
  22526. */
  22527. initialize(state: NodeMaterialBuildState): void;
  22528. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22529. }
  22530. }
  22531. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22535. /**
  22536. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22537. */
  22538. export class VectorMergerBlock extends NodeMaterialBlock {
  22539. /**
  22540. * Create a new VectorMergerBlock
  22541. * @param name defines the block name
  22542. */
  22543. constructor(name: string);
  22544. /**
  22545. * Gets the current class name
  22546. * @returns the class name
  22547. */
  22548. getClassName(): string;
  22549. /**
  22550. * Gets the xyz component (input)
  22551. */
  22552. get xyzIn(): NodeMaterialConnectionPoint;
  22553. /**
  22554. * Gets the xy component (input)
  22555. */
  22556. get xyIn(): NodeMaterialConnectionPoint;
  22557. /**
  22558. * Gets the x component (input)
  22559. */
  22560. get x(): NodeMaterialConnectionPoint;
  22561. /**
  22562. * Gets the y component (input)
  22563. */
  22564. get y(): NodeMaterialConnectionPoint;
  22565. /**
  22566. * Gets the z component (input)
  22567. */
  22568. get z(): NodeMaterialConnectionPoint;
  22569. /**
  22570. * Gets the w component (input)
  22571. */
  22572. get w(): NodeMaterialConnectionPoint;
  22573. /**
  22574. * Gets the xyzw component (output)
  22575. */
  22576. get xyzw(): NodeMaterialConnectionPoint;
  22577. /**
  22578. * Gets the xyz component (output)
  22579. */
  22580. get xyzOut(): NodeMaterialConnectionPoint;
  22581. /**
  22582. * Gets the xy component (output)
  22583. */
  22584. get xyOut(): NodeMaterialConnectionPoint;
  22585. /**
  22586. * Gets the xy component (output)
  22587. * @deprecated Please use xyOut instead.
  22588. */
  22589. get xy(): NodeMaterialConnectionPoint;
  22590. /**
  22591. * Gets the xyz component (output)
  22592. * @deprecated Please use xyzOut instead.
  22593. */
  22594. get xyz(): NodeMaterialConnectionPoint;
  22595. protected _buildBlock(state: NodeMaterialBuildState): this;
  22596. }
  22597. }
  22598. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22602. import { Vector2 } from "babylonjs/Maths/math.vector";
  22603. import { Scene } from "babylonjs/scene";
  22604. /**
  22605. * Block used to remap a float from a range to a new one
  22606. */
  22607. export class RemapBlock extends NodeMaterialBlock {
  22608. /**
  22609. * Gets or sets the source range
  22610. */
  22611. sourceRange: Vector2;
  22612. /**
  22613. * Gets or sets the target range
  22614. */
  22615. targetRange: Vector2;
  22616. /**
  22617. * Creates a new RemapBlock
  22618. * @param name defines the block name
  22619. */
  22620. constructor(name: string);
  22621. /**
  22622. * Gets the current class name
  22623. * @returns the class name
  22624. */
  22625. getClassName(): string;
  22626. /**
  22627. * Gets the input component
  22628. */
  22629. get input(): NodeMaterialConnectionPoint;
  22630. /**
  22631. * Gets the source min input component
  22632. */
  22633. get sourceMin(): NodeMaterialConnectionPoint;
  22634. /**
  22635. * Gets the source max input component
  22636. */
  22637. get sourceMax(): NodeMaterialConnectionPoint;
  22638. /**
  22639. * Gets the target min input component
  22640. */
  22641. get targetMin(): NodeMaterialConnectionPoint;
  22642. /**
  22643. * Gets the target max input component
  22644. */
  22645. get targetMax(): NodeMaterialConnectionPoint;
  22646. /**
  22647. * Gets the output component
  22648. */
  22649. get output(): NodeMaterialConnectionPoint;
  22650. protected _buildBlock(state: NodeMaterialBuildState): this;
  22651. protected _dumpPropertiesCode(): string;
  22652. serialize(): any;
  22653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22654. }
  22655. }
  22656. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22660. /**
  22661. * Block used to multiply 2 values
  22662. */
  22663. export class MultiplyBlock extends NodeMaterialBlock {
  22664. /**
  22665. * Creates a new MultiplyBlock
  22666. * @param name defines the block name
  22667. */
  22668. constructor(name: string);
  22669. /**
  22670. * Gets the current class name
  22671. * @returns the class name
  22672. */
  22673. getClassName(): string;
  22674. /**
  22675. * Gets the left operand input component
  22676. */
  22677. get left(): NodeMaterialConnectionPoint;
  22678. /**
  22679. * Gets the right operand input component
  22680. */
  22681. get right(): NodeMaterialConnectionPoint;
  22682. /**
  22683. * Gets the output component
  22684. */
  22685. get output(): NodeMaterialConnectionPoint;
  22686. protected _buildBlock(state: NodeMaterialBuildState): this;
  22687. }
  22688. }
  22689. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22693. /**
  22694. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22695. */
  22696. export class ColorSplitterBlock extends NodeMaterialBlock {
  22697. /**
  22698. * Create a new ColorSplitterBlock
  22699. * @param name defines the block name
  22700. */
  22701. constructor(name: string);
  22702. /**
  22703. * Gets the current class name
  22704. * @returns the class name
  22705. */
  22706. getClassName(): string;
  22707. /**
  22708. * Gets the rgba component (input)
  22709. */
  22710. get rgba(): NodeMaterialConnectionPoint;
  22711. /**
  22712. * Gets the rgb component (input)
  22713. */
  22714. get rgbIn(): NodeMaterialConnectionPoint;
  22715. /**
  22716. * Gets the rgb component (output)
  22717. */
  22718. get rgbOut(): NodeMaterialConnectionPoint;
  22719. /**
  22720. * Gets the r component (output)
  22721. */
  22722. get r(): NodeMaterialConnectionPoint;
  22723. /**
  22724. * Gets the g component (output)
  22725. */
  22726. get g(): NodeMaterialConnectionPoint;
  22727. /**
  22728. * Gets the b component (output)
  22729. */
  22730. get b(): NodeMaterialConnectionPoint;
  22731. /**
  22732. * Gets the a component (output)
  22733. */
  22734. get a(): NodeMaterialConnectionPoint;
  22735. protected _inputRename(name: string): string;
  22736. protected _outputRename(name: string): string;
  22737. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22738. }
  22739. }
  22740. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22742. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22743. import { Scene } from "babylonjs/scene";
  22744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22745. import { Matrix } from "babylonjs/Maths/math.vector";
  22746. import { Mesh } from "babylonjs/Meshes/mesh";
  22747. import { Engine } from "babylonjs/Engines/engine";
  22748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22749. import { Observable } from "babylonjs/Misc/observable";
  22750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22751. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22752. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22753. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22754. import { Nullable } from "babylonjs/types";
  22755. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22756. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22757. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22758. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22759. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22760. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22761. import { Effect } from "babylonjs/Materials/effect";
  22762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22763. import { Camera } from "babylonjs/Cameras/camera";
  22764. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22765. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22766. /**
  22767. * Interface used to configure the node material editor
  22768. */
  22769. export interface INodeMaterialEditorOptions {
  22770. /** Define the URl to load node editor script */
  22771. editorURL?: string;
  22772. }
  22773. /** @hidden */
  22774. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22775. NORMAL: boolean;
  22776. TANGENT: boolean;
  22777. UV1: boolean;
  22778. /** BONES */
  22779. NUM_BONE_INFLUENCERS: number;
  22780. BonesPerMesh: number;
  22781. BONETEXTURE: boolean;
  22782. /** MORPH TARGETS */
  22783. MORPHTARGETS: boolean;
  22784. MORPHTARGETS_NORMAL: boolean;
  22785. MORPHTARGETS_TANGENT: boolean;
  22786. MORPHTARGETS_UV: boolean;
  22787. NUM_MORPH_INFLUENCERS: number;
  22788. /** IMAGE PROCESSING */
  22789. IMAGEPROCESSING: boolean;
  22790. VIGNETTE: boolean;
  22791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22792. VIGNETTEBLENDMODEOPAQUE: boolean;
  22793. TONEMAPPING: boolean;
  22794. TONEMAPPING_ACES: boolean;
  22795. CONTRAST: boolean;
  22796. EXPOSURE: boolean;
  22797. COLORCURVES: boolean;
  22798. COLORGRADING: boolean;
  22799. COLORGRADING3D: boolean;
  22800. SAMPLER3DGREENDEPTH: boolean;
  22801. SAMPLER3DBGRMAP: boolean;
  22802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22803. /** MISC. */
  22804. BUMPDIRECTUV: number;
  22805. constructor();
  22806. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22807. }
  22808. /**
  22809. * Class used to configure NodeMaterial
  22810. */
  22811. export interface INodeMaterialOptions {
  22812. /**
  22813. * Defines if blocks should emit comments
  22814. */
  22815. emitComments: boolean;
  22816. }
  22817. /**
  22818. * Class used to create a node based material built by assembling shader blocks
  22819. */
  22820. export class NodeMaterial extends PushMaterial {
  22821. private static _BuildIdGenerator;
  22822. private _options;
  22823. private _vertexCompilationState;
  22824. private _fragmentCompilationState;
  22825. private _sharedData;
  22826. private _buildId;
  22827. private _buildWasSuccessful;
  22828. private _cachedWorldViewMatrix;
  22829. private _cachedWorldViewProjectionMatrix;
  22830. private _optimizers;
  22831. private _animationFrame;
  22832. /** Define the Url to load node editor script */
  22833. static EditorURL: string;
  22834. /** Define the Url to load snippets */
  22835. static SnippetUrl: string;
  22836. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22837. static IgnoreTexturesAtLoadTime: boolean;
  22838. private BJSNODEMATERIALEDITOR;
  22839. /** Get the inspector from bundle or global */
  22840. private _getGlobalNodeMaterialEditor;
  22841. /**
  22842. * Snippet ID if the material was created from the snippet server
  22843. */
  22844. snippetId: string;
  22845. /**
  22846. * Gets or sets data used by visual editor
  22847. * @see https://nme.babylonjs.com
  22848. */
  22849. editorData: any;
  22850. /**
  22851. * 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)
  22852. */
  22853. ignoreAlpha: boolean;
  22854. /**
  22855. * Defines the maximum number of lights that can be used in the material
  22856. */
  22857. maxSimultaneousLights: number;
  22858. /**
  22859. * Observable raised when the material is built
  22860. */
  22861. onBuildObservable: Observable<NodeMaterial>;
  22862. /**
  22863. * Gets or sets the root nodes of the material vertex shader
  22864. */
  22865. _vertexOutputNodes: NodeMaterialBlock[];
  22866. /**
  22867. * Gets or sets the root nodes of the material fragment (pixel) shader
  22868. */
  22869. _fragmentOutputNodes: NodeMaterialBlock[];
  22870. /** Gets or sets options to control the node material overall behavior */
  22871. get options(): INodeMaterialOptions;
  22872. set options(options: INodeMaterialOptions);
  22873. /**
  22874. * Default configuration related to image processing available in the standard Material.
  22875. */
  22876. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22877. /**
  22878. * Gets the image processing configuration used either in this material.
  22879. */
  22880. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22881. /**
  22882. * Sets the Default image processing configuration used either in the this material.
  22883. *
  22884. * If sets to null, the scene one is in use.
  22885. */
  22886. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22887. /**
  22888. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22889. */
  22890. attachedBlocks: NodeMaterialBlock[];
  22891. /**
  22892. * Specifies the mode of the node material
  22893. * @hidden
  22894. */
  22895. _mode: NodeMaterialModes;
  22896. /**
  22897. * Gets the mode property
  22898. */
  22899. get mode(): NodeMaterialModes;
  22900. /**
  22901. * Create a new node based material
  22902. * @param name defines the material name
  22903. * @param scene defines the hosting scene
  22904. * @param options defines creation option
  22905. */
  22906. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22907. /**
  22908. * Gets the current class name of the material e.g. "NodeMaterial"
  22909. * @returns the class name
  22910. */
  22911. getClassName(): string;
  22912. /**
  22913. * Keep track of the image processing observer to allow dispose and replace.
  22914. */
  22915. private _imageProcessingObserver;
  22916. /**
  22917. * Attaches a new image processing configuration to the Standard Material.
  22918. * @param configuration
  22919. */
  22920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22921. /**
  22922. * Get a block by its name
  22923. * @param name defines the name of the block to retrieve
  22924. * @returns the required block or null if not found
  22925. */
  22926. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22927. /**
  22928. * Get a block by its name
  22929. * @param predicate defines the predicate used to find the good candidate
  22930. * @returns the required block or null if not found
  22931. */
  22932. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22933. /**
  22934. * Get an input block by its name
  22935. * @param predicate defines the predicate used to find the good candidate
  22936. * @returns the required input block or null if not found
  22937. */
  22938. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22939. /**
  22940. * Gets the list of input blocks attached to this material
  22941. * @returns an array of InputBlocks
  22942. */
  22943. getInputBlocks(): InputBlock[];
  22944. /**
  22945. * Adds a new optimizer to the list of optimizers
  22946. * @param optimizer defines the optimizers to add
  22947. * @returns the current material
  22948. */
  22949. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22950. /**
  22951. * Remove an optimizer from the list of optimizers
  22952. * @param optimizer defines the optimizers to remove
  22953. * @returns the current material
  22954. */
  22955. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22956. /**
  22957. * Add a new block to the list of output nodes
  22958. * @param node defines the node to add
  22959. * @returns the current material
  22960. */
  22961. addOutputNode(node: NodeMaterialBlock): this;
  22962. /**
  22963. * Remove a block from the list of root nodes
  22964. * @param node defines the node to remove
  22965. * @returns the current material
  22966. */
  22967. removeOutputNode(node: NodeMaterialBlock): this;
  22968. private _addVertexOutputNode;
  22969. private _removeVertexOutputNode;
  22970. private _addFragmentOutputNode;
  22971. private _removeFragmentOutputNode;
  22972. /**
  22973. * Specifies if the material will require alpha blending
  22974. * @returns a boolean specifying if alpha blending is needed
  22975. */
  22976. needAlphaBlending(): boolean;
  22977. /**
  22978. * Specifies if this material should be rendered in alpha test mode
  22979. * @returns a boolean specifying if an alpha test is needed.
  22980. */
  22981. needAlphaTesting(): boolean;
  22982. private _initializeBlock;
  22983. private _resetDualBlocks;
  22984. /**
  22985. * Remove a block from the current node material
  22986. * @param block defines the block to remove
  22987. */
  22988. removeBlock(block: NodeMaterialBlock): void;
  22989. /**
  22990. * Build the material and generates the inner effect
  22991. * @param verbose defines if the build should log activity
  22992. */
  22993. build(verbose?: boolean): void;
  22994. /**
  22995. * Runs an otpimization phase to try to improve the shader code
  22996. */
  22997. optimize(): void;
  22998. private _prepareDefinesForAttributes;
  22999. /**
  23000. * Create a post process from the material
  23001. * @param camera The camera to apply the render pass to.
  23002. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23004. * @param engine The engine which the post process will be applied. (default: current engine)
  23005. * @param reusable If the post process can be reused on the same frame. (default: false)
  23006. * @param textureType Type of textures used when performing the post process. (default: 0)
  23007. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23008. * @returns the post process created
  23009. */
  23010. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23011. /**
  23012. * Create the post process effect from the material
  23013. * @param postProcess The post process to create the effect for
  23014. */
  23015. createEffectForPostProcess(postProcess: PostProcess): void;
  23016. private _createEffectOrPostProcess;
  23017. private _createEffectForParticles;
  23018. /**
  23019. * Create the effect to be used as the custom effect for a particle system
  23020. * @param particleSystem Particle system to create the effect for
  23021. * @param onCompiled defines a function to call when the effect creation is successful
  23022. * @param onError defines a function to call when the effect creation has failed
  23023. */
  23024. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23025. private _processDefines;
  23026. /**
  23027. * Get if the submesh is ready to be used and all its information available.
  23028. * Child classes can use it to update shaders
  23029. * @param mesh defines the mesh to check
  23030. * @param subMesh defines which submesh to check
  23031. * @param useInstances specifies that instances should be used
  23032. * @returns a boolean indicating that the submesh is ready or not
  23033. */
  23034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23035. /**
  23036. * Get a string representing the shaders built by the current node graph
  23037. */
  23038. get compiledShaders(): string;
  23039. /**
  23040. * Binds the world matrix to the material
  23041. * @param world defines the world transformation matrix
  23042. */
  23043. bindOnlyWorldMatrix(world: Matrix): void;
  23044. /**
  23045. * Binds the submesh to this material by preparing the effect and shader to draw
  23046. * @param world defines the world transformation matrix
  23047. * @param mesh defines the mesh containing the submesh
  23048. * @param subMesh defines the submesh to bind the material to
  23049. */
  23050. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23051. /**
  23052. * Gets the active textures from the material
  23053. * @returns an array of textures
  23054. */
  23055. getActiveTextures(): BaseTexture[];
  23056. /**
  23057. * Gets the list of texture blocks
  23058. * @returns an array of texture blocks
  23059. */
  23060. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23061. /**
  23062. * Specifies if the material uses a texture
  23063. * @param texture defines the texture to check against the material
  23064. * @returns a boolean specifying if the material uses the texture
  23065. */
  23066. hasTexture(texture: BaseTexture): boolean;
  23067. /**
  23068. * Disposes the material
  23069. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23070. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23071. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23072. */
  23073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23074. /** Creates the node editor window. */
  23075. private _createNodeEditor;
  23076. /**
  23077. * Launch the node material editor
  23078. * @param config Define the configuration of the editor
  23079. * @return a promise fulfilled when the node editor is visible
  23080. */
  23081. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23082. /**
  23083. * Clear the current material
  23084. */
  23085. clear(): void;
  23086. /**
  23087. * Clear the current material and set it to a default state
  23088. */
  23089. setToDefault(): void;
  23090. /**
  23091. * Clear the current material and set it to a default state for post process
  23092. */
  23093. setToDefaultPostProcess(): void;
  23094. /**
  23095. * Clear the current material and set it to a default state for particle
  23096. */
  23097. setToDefaultParticle(): void;
  23098. /**
  23099. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23100. * @param url defines the url to load from
  23101. * @returns a promise that will fullfil when the material is fully loaded
  23102. */
  23103. loadAsync(url: string): Promise<void>;
  23104. private _gatherBlocks;
  23105. /**
  23106. * Generate a string containing the code declaration required to create an equivalent of this material
  23107. * @returns a string
  23108. */
  23109. generateCode(): string;
  23110. /**
  23111. * Serializes this material in a JSON representation
  23112. * @returns the serialized material object
  23113. */
  23114. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23115. private _restoreConnections;
  23116. /**
  23117. * Clear the current graph and load a new one from a serialization object
  23118. * @param source defines the JSON representation of the material
  23119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23120. * @param merge defines whether or not the source must be merged or replace the current content
  23121. */
  23122. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23123. /**
  23124. * Makes a duplicate of the current material.
  23125. * @param name - name to use for the new material.
  23126. */
  23127. clone(name: string): NodeMaterial;
  23128. /**
  23129. * Creates a node material from parsed material data
  23130. * @param source defines the JSON representation of the material
  23131. * @param scene defines the hosting scene
  23132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23133. * @returns a new node material
  23134. */
  23135. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23136. /**
  23137. * Creates a node material from a snippet saved in a remote file
  23138. * @param name defines the name of the material to create
  23139. * @param url defines the url to load from
  23140. * @param scene defines the hosting scene
  23141. * @returns a promise that will resolve to the new node material
  23142. */
  23143. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23144. /**
  23145. * Creates a node material from a snippet saved by the node material editor
  23146. * @param snippetId defines the snippet to load
  23147. * @param scene defines the hosting scene
  23148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23149. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23150. * @returns a promise that will resolve to the new node material
  23151. */
  23152. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23153. /**
  23154. * Creates a new node material set to default basic configuration
  23155. * @param name defines the name of the material
  23156. * @param scene defines the hosting scene
  23157. * @returns a new NodeMaterial
  23158. */
  23159. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23160. }
  23161. }
  23162. declare module "babylonjs/PostProcesses/postProcess" {
  23163. import { Nullable } from "babylonjs/types";
  23164. import { SmartArray } from "babylonjs/Misc/smartArray";
  23165. import { Observable } from "babylonjs/Misc/observable";
  23166. import { Vector2 } from "babylonjs/Maths/math.vector";
  23167. import { Camera } from "babylonjs/Cameras/camera";
  23168. import { Effect } from "babylonjs/Materials/effect";
  23169. import "babylonjs/Shaders/postprocess.vertex";
  23170. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23171. import { Engine } from "babylonjs/Engines/engine";
  23172. import { Color4 } from "babylonjs/Maths/math.color";
  23173. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23174. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23176. /**
  23177. * Size options for a post process
  23178. */
  23179. export type PostProcessOptions = {
  23180. width: number;
  23181. height: number;
  23182. };
  23183. /**
  23184. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23185. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23186. */
  23187. export class PostProcess {
  23188. /** Name of the PostProcess. */
  23189. name: string;
  23190. /**
  23191. * Gets or sets the unique id of the post process
  23192. */
  23193. uniqueId: number;
  23194. /**
  23195. * Width of the texture to apply the post process on
  23196. */
  23197. width: number;
  23198. /**
  23199. * Height of the texture to apply the post process on
  23200. */
  23201. height: number;
  23202. /**
  23203. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23204. */
  23205. nodeMaterialSource: Nullable<NodeMaterial>;
  23206. /**
  23207. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23208. * @hidden
  23209. */
  23210. _outputTexture: Nullable<InternalTexture>;
  23211. /**
  23212. * Sampling mode used by the shader
  23213. * See https://doc.babylonjs.com/classes/3.1/texture
  23214. */
  23215. renderTargetSamplingMode: number;
  23216. /**
  23217. * Clear color to use when screen clearing
  23218. */
  23219. clearColor: Color4;
  23220. /**
  23221. * If the buffer needs to be cleared before applying the post process. (default: true)
  23222. * Should be set to false if shader will overwrite all previous pixels.
  23223. */
  23224. autoClear: boolean;
  23225. /**
  23226. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23227. */
  23228. alphaMode: number;
  23229. /**
  23230. * Sets the setAlphaBlendConstants of the babylon engine
  23231. */
  23232. alphaConstants: Color4;
  23233. /**
  23234. * Animations to be used for the post processing
  23235. */
  23236. animations: import("babylonjs/Animations/animation").Animation[];
  23237. /**
  23238. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23239. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23240. */
  23241. enablePixelPerfectMode: boolean;
  23242. /**
  23243. * Force the postprocess to be applied without taking in account viewport
  23244. */
  23245. forceFullscreenViewport: boolean;
  23246. /**
  23247. * List of inspectable custom properties (used by the Inspector)
  23248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23249. */
  23250. inspectableCustomProperties: IInspectable[];
  23251. /**
  23252. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23253. *
  23254. * | Value | Type | Description |
  23255. * | ----- | ----------------------------------- | ----------- |
  23256. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23257. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23258. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23259. *
  23260. */
  23261. scaleMode: number;
  23262. /**
  23263. * Force textures to be a power of two (default: false)
  23264. */
  23265. alwaysForcePOT: boolean;
  23266. private _samples;
  23267. /**
  23268. * Number of sample textures (default: 1)
  23269. */
  23270. get samples(): number;
  23271. set samples(n: number);
  23272. /**
  23273. * Modify the scale of the post process to be the same as the viewport (default: false)
  23274. */
  23275. adaptScaleToCurrentViewport: boolean;
  23276. private _camera;
  23277. private _scene;
  23278. private _engine;
  23279. private _options;
  23280. private _reusable;
  23281. private _textureType;
  23282. private _textureFormat;
  23283. /**
  23284. * Smart array of input and output textures for the post process.
  23285. * @hidden
  23286. */
  23287. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23288. /**
  23289. * The index in _textures that corresponds to the output texture.
  23290. * @hidden
  23291. */
  23292. _currentRenderTextureInd: number;
  23293. private _effect;
  23294. private _samplers;
  23295. private _fragmentUrl;
  23296. private _vertexUrl;
  23297. private _parameters;
  23298. private _scaleRatio;
  23299. protected _indexParameters: any;
  23300. private _shareOutputWithPostProcess;
  23301. private _texelSize;
  23302. private _forcedOutputTexture;
  23303. /**
  23304. * Returns the fragment url or shader name used in the post process.
  23305. * @returns the fragment url or name in the shader store.
  23306. */
  23307. getEffectName(): string;
  23308. /**
  23309. * An event triggered when the postprocess is activated.
  23310. */
  23311. onActivateObservable: Observable<Camera>;
  23312. private _onActivateObserver;
  23313. /**
  23314. * A function that is added to the onActivateObservable
  23315. */
  23316. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23317. /**
  23318. * An event triggered when the postprocess changes its size.
  23319. */
  23320. onSizeChangedObservable: Observable<PostProcess>;
  23321. private _onSizeChangedObserver;
  23322. /**
  23323. * A function that is added to the onSizeChangedObservable
  23324. */
  23325. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23326. /**
  23327. * An event triggered when the postprocess applies its effect.
  23328. */
  23329. onApplyObservable: Observable<Effect>;
  23330. private _onApplyObserver;
  23331. /**
  23332. * A function that is added to the onApplyObservable
  23333. */
  23334. set onApply(callback: (effect: Effect) => void);
  23335. /**
  23336. * An event triggered before rendering the postprocess
  23337. */
  23338. onBeforeRenderObservable: Observable<Effect>;
  23339. private _onBeforeRenderObserver;
  23340. /**
  23341. * A function that is added to the onBeforeRenderObservable
  23342. */
  23343. set onBeforeRender(callback: (effect: Effect) => void);
  23344. /**
  23345. * An event triggered after rendering the postprocess
  23346. */
  23347. onAfterRenderObservable: Observable<Effect>;
  23348. private _onAfterRenderObserver;
  23349. /**
  23350. * A function that is added to the onAfterRenderObservable
  23351. */
  23352. set onAfterRender(callback: (efect: Effect) => void);
  23353. /**
  23354. * 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
  23355. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23356. */
  23357. get inputTexture(): InternalTexture;
  23358. set inputTexture(value: InternalTexture);
  23359. /**
  23360. * Gets the camera which post process is applied to.
  23361. * @returns The camera the post process is applied to.
  23362. */
  23363. getCamera(): Camera;
  23364. /**
  23365. * Gets the texel size of the postprocess.
  23366. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23367. */
  23368. get texelSize(): Vector2;
  23369. /**
  23370. * Creates a new instance PostProcess
  23371. * @param name The name of the PostProcess.
  23372. * @param fragmentUrl The url of the fragment shader to be used.
  23373. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23374. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23375. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23376. * @param camera The camera to apply the render pass to.
  23377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23378. * @param engine The engine which the post process will be applied. (default: current engine)
  23379. * @param reusable If the post process can be reused on the same frame. (default: false)
  23380. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23381. * @param textureType Type of textures used when performing the post process. (default: 0)
  23382. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23383. * @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
  23384. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23385. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23386. */
  23387. constructor(
  23388. /** Name of the PostProcess. */
  23389. 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);
  23390. /**
  23391. * Gets a string idenfifying the name of the class
  23392. * @returns "PostProcess" string
  23393. */
  23394. getClassName(): string;
  23395. /**
  23396. * Gets the engine which this post process belongs to.
  23397. * @returns The engine the post process was enabled with.
  23398. */
  23399. getEngine(): Engine;
  23400. /**
  23401. * The effect that is created when initializing the post process.
  23402. * @returns The created effect corresponding the the postprocess.
  23403. */
  23404. getEffect(): Effect;
  23405. /**
  23406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23407. * @param postProcess The post process to share the output with.
  23408. * @returns This post process.
  23409. */
  23410. shareOutputWith(postProcess: PostProcess): PostProcess;
  23411. /**
  23412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23414. */
  23415. useOwnOutput(): void;
  23416. /**
  23417. * Updates the effect with the current post process compile time values and recompiles the shader.
  23418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23421. * @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
  23422. * @param onCompiled Called when the shader has been compiled.
  23423. * @param onError Called if there is an error when compiling a shader.
  23424. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23425. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23426. */
  23427. 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;
  23428. /**
  23429. * The post process is reusable if it can be used multiple times within one frame.
  23430. * @returns If the post process is reusable
  23431. */
  23432. isReusable(): boolean;
  23433. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23434. markTextureDirty(): void;
  23435. /**
  23436. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23437. * 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.
  23438. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23439. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23440. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23441. * @returns The target texture that was bound to be written to.
  23442. */
  23443. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23444. /**
  23445. * If the post process is supported.
  23446. */
  23447. get isSupported(): boolean;
  23448. /**
  23449. * The aspect ratio of the output texture.
  23450. */
  23451. get aspectRatio(): number;
  23452. /**
  23453. * Get a value indicating if the post-process is ready to be used
  23454. * @returns true if the post-process is ready (shader is compiled)
  23455. */
  23456. isReady(): boolean;
  23457. /**
  23458. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23459. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23460. */
  23461. apply(): Nullable<Effect>;
  23462. private _disposeTextures;
  23463. /**
  23464. * Disposes the post process.
  23465. * @param camera The camera to dispose the post process on.
  23466. */
  23467. dispose(camera?: Camera): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23471. /** @hidden */
  23472. export var kernelBlurVaryingDeclaration: {
  23473. name: string;
  23474. shader: string;
  23475. };
  23476. }
  23477. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23478. /** @hidden */
  23479. export var kernelBlurFragment: {
  23480. name: string;
  23481. shader: string;
  23482. };
  23483. }
  23484. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23485. /** @hidden */
  23486. export var kernelBlurFragment2: {
  23487. name: string;
  23488. shader: string;
  23489. };
  23490. }
  23491. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23492. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23493. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23494. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23495. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23496. /** @hidden */
  23497. export var kernelBlurPixelShader: {
  23498. name: string;
  23499. shader: string;
  23500. };
  23501. }
  23502. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23503. /** @hidden */
  23504. export var kernelBlurVertex: {
  23505. name: string;
  23506. shader: string;
  23507. };
  23508. }
  23509. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23510. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23511. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23512. /** @hidden */
  23513. export var kernelBlurVertexShader: {
  23514. name: string;
  23515. shader: string;
  23516. };
  23517. }
  23518. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23519. import { Vector2 } from "babylonjs/Maths/math.vector";
  23520. import { Nullable } from "babylonjs/types";
  23521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23522. import { Camera } from "babylonjs/Cameras/camera";
  23523. import { Effect } from "babylonjs/Materials/effect";
  23524. import { Engine } from "babylonjs/Engines/engine";
  23525. import "babylonjs/Shaders/kernelBlur.fragment";
  23526. import "babylonjs/Shaders/kernelBlur.vertex";
  23527. /**
  23528. * The Blur Post Process which blurs an image based on a kernel and direction.
  23529. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23530. */
  23531. export class BlurPostProcess extends PostProcess {
  23532. /** The direction in which to blur the image. */
  23533. direction: Vector2;
  23534. private blockCompilation;
  23535. protected _kernel: number;
  23536. protected _idealKernel: number;
  23537. protected _packedFloat: boolean;
  23538. private _staticDefines;
  23539. /**
  23540. * Sets the length in pixels of the blur sample region
  23541. */
  23542. set kernel(v: number);
  23543. /**
  23544. * Gets the length in pixels of the blur sample region
  23545. */
  23546. get kernel(): number;
  23547. /**
  23548. * Sets wether or not the blur needs to unpack/repack floats
  23549. */
  23550. set packedFloat(v: boolean);
  23551. /**
  23552. * Gets wether or not the blur is unpacking/repacking floats
  23553. */
  23554. get packedFloat(): boolean;
  23555. /**
  23556. * Creates a new instance BlurPostProcess
  23557. * @param name The name of the effect.
  23558. * @param direction The direction in which to blur the image.
  23559. * @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.
  23560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23561. * @param camera The camera to apply the render pass to.
  23562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23563. * @param engine The engine which the post process will be applied. (default: current engine)
  23564. * @param reusable If the post process can be reused on the same frame. (default: false)
  23565. * @param textureType Type of textures used when performing the post process. (default: 0)
  23566. * @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)
  23567. */
  23568. constructor(name: string,
  23569. /** The direction in which to blur the image. */
  23570. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23571. /**
  23572. * Updates the effect with the current post process compile time values and recompiles the shader.
  23573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23576. * @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
  23577. * @param onCompiled Called when the shader has been compiled.
  23578. * @param onError Called if there is an error when compiling a shader.
  23579. */
  23580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23581. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23582. /**
  23583. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23584. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23585. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23586. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23587. * The gaps between physical kernels are compensated for in the weighting of the samples
  23588. * @param idealKernel Ideal blur kernel.
  23589. * @return Nearest best kernel.
  23590. */
  23591. protected _nearestBestKernel(idealKernel: number): number;
  23592. /**
  23593. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23594. * @param x The point on the Gaussian distribution to sample.
  23595. * @return the value of the Gaussian function at x.
  23596. */
  23597. protected _gaussianWeight(x: number): number;
  23598. /**
  23599. * Generates a string that can be used as a floating point number in GLSL.
  23600. * @param x Value to print.
  23601. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23602. * @return GLSL float string.
  23603. */
  23604. protected _glslFloat(x: number, decimalFigures?: number): string;
  23605. }
  23606. }
  23607. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23608. import { Scene } from "babylonjs/scene";
  23609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23610. import { Plane } from "babylonjs/Maths/math.plane";
  23611. /**
  23612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23614. * You can then easily use it as a reflectionTexture on a flat surface.
  23615. * In case the surface is not a plane, please consider relying on reflection probes.
  23616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23617. */
  23618. export class MirrorTexture extends RenderTargetTexture {
  23619. private scene;
  23620. /**
  23621. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23622. * 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.
  23623. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23624. */
  23625. mirrorPlane: Plane;
  23626. /**
  23627. * Define the blur ratio used to blur the reflection if needed.
  23628. */
  23629. set blurRatio(value: number);
  23630. get blurRatio(): number;
  23631. /**
  23632. * Define the adaptive blur kernel used to blur the reflection if needed.
  23633. * This will autocompute the closest best match for the `blurKernel`
  23634. */
  23635. set adaptiveBlurKernel(value: number);
  23636. /**
  23637. * Define the blur kernel used to blur the reflection if needed.
  23638. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23639. */
  23640. set blurKernel(value: number);
  23641. /**
  23642. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23643. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23644. */
  23645. set blurKernelX(value: number);
  23646. get blurKernelX(): number;
  23647. /**
  23648. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23649. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23650. */
  23651. set blurKernelY(value: number);
  23652. get blurKernelY(): number;
  23653. private _autoComputeBlurKernel;
  23654. protected _onRatioRescale(): void;
  23655. private _updateGammaSpace;
  23656. private _imageProcessingConfigChangeObserver;
  23657. private _transformMatrix;
  23658. private _mirrorMatrix;
  23659. private _savedViewMatrix;
  23660. private _blurX;
  23661. private _blurY;
  23662. private _adaptiveBlurKernel;
  23663. private _blurKernelX;
  23664. private _blurKernelY;
  23665. private _blurRatio;
  23666. /**
  23667. * Instantiates a Mirror Texture.
  23668. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23669. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23670. * You can then easily use it as a reflectionTexture on a flat surface.
  23671. * In case the surface is not a plane, please consider relying on reflection probes.
  23672. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23673. * @param name
  23674. * @param size
  23675. * @param scene
  23676. * @param generateMipMaps
  23677. * @param type
  23678. * @param samplingMode
  23679. * @param generateDepthBuffer
  23680. */
  23681. constructor(name: string, size: number | {
  23682. width: number;
  23683. height: number;
  23684. } | {
  23685. ratio: number;
  23686. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23687. private _preparePostProcesses;
  23688. /**
  23689. * Clone the mirror texture.
  23690. * @returns the cloned texture
  23691. */
  23692. clone(): MirrorTexture;
  23693. /**
  23694. * Serialize the texture to a JSON representation you could use in Parse later on
  23695. * @returns the serialized JSON representation
  23696. */
  23697. serialize(): any;
  23698. /**
  23699. * Dispose the texture and release its associated resources.
  23700. */
  23701. dispose(): void;
  23702. }
  23703. }
  23704. declare module "babylonjs/Materials/Textures/texture" {
  23705. import { Observable } from "babylonjs/Misc/observable";
  23706. import { Nullable } from "babylonjs/types";
  23707. import { Matrix } from "babylonjs/Maths/math.vector";
  23708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23709. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23710. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23711. import { Scene } from "babylonjs/scene";
  23712. /**
  23713. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23714. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23715. */
  23716. export class Texture extends BaseTexture {
  23717. /**
  23718. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23719. */
  23720. static SerializeBuffers: boolean;
  23721. /** @hidden */
  23722. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23723. /** @hidden */
  23724. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23725. /** @hidden */
  23726. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23727. /** nearest is mag = nearest and min = nearest and mip = linear */
  23728. static readonly NEAREST_SAMPLINGMODE: number;
  23729. /** nearest is mag = nearest and min = nearest and mip = linear */
  23730. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23732. static readonly BILINEAR_SAMPLINGMODE: number;
  23733. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23734. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23735. /** Trilinear is mag = linear and min = linear and mip = linear */
  23736. static readonly TRILINEAR_SAMPLINGMODE: number;
  23737. /** Trilinear is mag = linear and min = linear and mip = linear */
  23738. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23739. /** mag = nearest and min = nearest and mip = nearest */
  23740. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23741. /** mag = nearest and min = linear and mip = nearest */
  23742. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23743. /** mag = nearest and min = linear and mip = linear */
  23744. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23745. /** mag = nearest and min = linear and mip = none */
  23746. static readonly NEAREST_LINEAR: number;
  23747. /** mag = nearest and min = nearest and mip = none */
  23748. static readonly NEAREST_NEAREST: number;
  23749. /** mag = linear and min = nearest and mip = nearest */
  23750. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23751. /** mag = linear and min = nearest and mip = linear */
  23752. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23753. /** mag = linear and min = linear and mip = none */
  23754. static readonly LINEAR_LINEAR: number;
  23755. /** mag = linear and min = nearest and mip = none */
  23756. static readonly LINEAR_NEAREST: number;
  23757. /** Explicit coordinates mode */
  23758. static readonly EXPLICIT_MODE: number;
  23759. /** Spherical coordinates mode */
  23760. static readonly SPHERICAL_MODE: number;
  23761. /** Planar coordinates mode */
  23762. static readonly PLANAR_MODE: number;
  23763. /** Cubic coordinates mode */
  23764. static readonly CUBIC_MODE: number;
  23765. /** Projection coordinates mode */
  23766. static readonly PROJECTION_MODE: number;
  23767. /** Inverse Cubic coordinates mode */
  23768. static readonly SKYBOX_MODE: number;
  23769. /** Inverse Cubic coordinates mode */
  23770. static readonly INVCUBIC_MODE: number;
  23771. /** Equirectangular coordinates mode */
  23772. static readonly EQUIRECTANGULAR_MODE: number;
  23773. /** Equirectangular Fixed coordinates mode */
  23774. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23775. /** Equirectangular Fixed Mirrored coordinates mode */
  23776. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23777. /** Texture is not repeating outside of 0..1 UVs */
  23778. static readonly CLAMP_ADDRESSMODE: number;
  23779. /** Texture is repeating outside of 0..1 UVs */
  23780. static readonly WRAP_ADDRESSMODE: number;
  23781. /** Texture is repeating and mirrored */
  23782. static readonly MIRROR_ADDRESSMODE: number;
  23783. /**
  23784. * 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
  23785. */
  23786. static UseSerializedUrlIfAny: boolean;
  23787. /**
  23788. * Define the url of the texture.
  23789. */
  23790. url: Nullable<string>;
  23791. /**
  23792. * Define an offset on the texture to offset the u coordinates of the UVs
  23793. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23794. */
  23795. uOffset: number;
  23796. /**
  23797. * Define an offset on the texture to offset the v coordinates of the UVs
  23798. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23799. */
  23800. vOffset: number;
  23801. /**
  23802. * Define an offset on the texture to scale the u coordinates of the UVs
  23803. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23804. */
  23805. uScale: number;
  23806. /**
  23807. * Define an offset on the texture to scale the v coordinates of the UVs
  23808. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23809. */
  23810. vScale: number;
  23811. /**
  23812. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23813. * @see http://doc.babylonjs.com/how_to/more_materials
  23814. */
  23815. uAng: number;
  23816. /**
  23817. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23818. * @see http://doc.babylonjs.com/how_to/more_materials
  23819. */
  23820. vAng: number;
  23821. /**
  23822. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23823. * @see http://doc.babylonjs.com/how_to/more_materials
  23824. */
  23825. wAng: number;
  23826. /**
  23827. * Defines the center of rotation (U)
  23828. */
  23829. uRotationCenter: number;
  23830. /**
  23831. * Defines the center of rotation (V)
  23832. */
  23833. vRotationCenter: number;
  23834. /**
  23835. * Defines the center of rotation (W)
  23836. */
  23837. wRotationCenter: number;
  23838. /**
  23839. * Are mip maps generated for this texture or not.
  23840. */
  23841. get noMipmap(): boolean;
  23842. /**
  23843. * List of inspectable custom properties (used by the Inspector)
  23844. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23845. */
  23846. inspectableCustomProperties: Nullable<IInspectable[]>;
  23847. private _noMipmap;
  23848. /** @hidden */
  23849. _invertY: boolean;
  23850. private _rowGenerationMatrix;
  23851. private _cachedTextureMatrix;
  23852. private _projectionModeMatrix;
  23853. private _t0;
  23854. private _t1;
  23855. private _t2;
  23856. private _cachedUOffset;
  23857. private _cachedVOffset;
  23858. private _cachedUScale;
  23859. private _cachedVScale;
  23860. private _cachedUAng;
  23861. private _cachedVAng;
  23862. private _cachedWAng;
  23863. private _cachedProjectionMatrixId;
  23864. private _cachedCoordinatesMode;
  23865. /** @hidden */
  23866. protected _initialSamplingMode: number;
  23867. /** @hidden */
  23868. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23869. private _deleteBuffer;
  23870. protected _format: Nullable<number>;
  23871. private _delayedOnLoad;
  23872. private _delayedOnError;
  23873. private _mimeType?;
  23874. /**
  23875. * Observable triggered once the texture has been loaded.
  23876. */
  23877. onLoadObservable: Observable<Texture>;
  23878. protected _isBlocking: boolean;
  23879. /**
  23880. * Is the texture preventing material to render while loading.
  23881. * If false, a default texture will be used instead of the loading one during the preparation step.
  23882. */
  23883. set isBlocking(value: boolean);
  23884. get isBlocking(): boolean;
  23885. /**
  23886. * Get the current sampling mode associated with the texture.
  23887. */
  23888. get samplingMode(): number;
  23889. /**
  23890. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23891. */
  23892. get invertY(): boolean;
  23893. /**
  23894. * Instantiates a new texture.
  23895. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23896. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23897. * @param url defines the url of the picture to load as a texture
  23898. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23899. * @param noMipmap defines if the texture will require mip maps or not
  23900. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23901. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23902. * @param onLoad defines a callback triggered when the texture has been loaded
  23903. * @param onError defines a callback triggered when an error occurred during the loading session
  23904. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23905. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23906. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23907. * @param mimeType defines an optional mime type information
  23908. */
  23909. 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);
  23910. /**
  23911. * Update the url (and optional buffer) of this texture if url was null during construction.
  23912. * @param url the url of the texture
  23913. * @param buffer the buffer of the texture (defaults to null)
  23914. * @param onLoad callback called when the texture is loaded (defaults to null)
  23915. */
  23916. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23917. /**
  23918. * Finish the loading sequence of a texture flagged as delayed load.
  23919. * @hidden
  23920. */
  23921. delayLoad(): void;
  23922. private _prepareRowForTextureGeneration;
  23923. /**
  23924. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23925. * @returns the transform matrix of the texture.
  23926. */
  23927. getTextureMatrix(uBase?: number): Matrix;
  23928. /**
  23929. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23930. * @returns The reflection texture transform
  23931. */
  23932. getReflectionTextureMatrix(): Matrix;
  23933. /**
  23934. * Clones the texture.
  23935. * @returns the cloned texture
  23936. */
  23937. clone(): Texture;
  23938. /**
  23939. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23940. * @returns The JSON representation of the texture
  23941. */
  23942. serialize(): any;
  23943. /**
  23944. * Get the current class name of the texture useful for serialization or dynamic coding.
  23945. * @returns "Texture"
  23946. */
  23947. getClassName(): string;
  23948. /**
  23949. * Dispose the texture and release its associated resources.
  23950. */
  23951. dispose(): void;
  23952. /**
  23953. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23954. * @param parsedTexture Define the JSON representation of the texture
  23955. * @param scene Define the scene the parsed texture should be instantiated in
  23956. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23957. * @returns The parsed texture if successful
  23958. */
  23959. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23960. /**
  23961. * Creates a texture from its base 64 representation.
  23962. * @param data Define the base64 payload without the data: prefix
  23963. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23964. * @param scene Define the scene the texture should belong to
  23965. * @param noMipmap Forces the texture to not create mip map information if true
  23966. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23967. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23968. * @param onLoad define a callback triggered when the texture has been loaded
  23969. * @param onError define a callback triggered when an error occurred during the loading session
  23970. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23971. * @returns the created texture
  23972. */
  23973. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23974. /**
  23975. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23976. * @param data Define the base64 payload without the data: prefix
  23977. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23978. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23979. * @param scene Define the scene the texture should belong to
  23980. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23981. * @param noMipmap Forces the texture to not create mip map information if true
  23982. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23983. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23984. * @param onLoad define a callback triggered when the texture has been loaded
  23985. * @param onError define a callback triggered when an error occurred during the loading session
  23986. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23987. * @returns the created texture
  23988. */
  23989. 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;
  23990. }
  23991. }
  23992. declare module "babylonjs/PostProcesses/postProcessManager" {
  23993. import { Nullable } from "babylonjs/types";
  23994. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23995. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23996. import { Scene } from "babylonjs/scene";
  23997. /**
  23998. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23999. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24000. */
  24001. export class PostProcessManager {
  24002. private _scene;
  24003. private _indexBuffer;
  24004. private _vertexBuffers;
  24005. /**
  24006. * Creates a new instance PostProcess
  24007. * @param scene The scene that the post process is associated with.
  24008. */
  24009. constructor(scene: Scene);
  24010. private _prepareBuffers;
  24011. private _buildIndexBuffer;
  24012. /**
  24013. * Rebuilds the vertex buffers of the manager.
  24014. * @hidden
  24015. */
  24016. _rebuild(): void;
  24017. /**
  24018. * Prepares a frame to be run through a post process.
  24019. * @param sourceTexture The input texture to the post procesess. (default: null)
  24020. * @param postProcesses An array of post processes to be run. (default: null)
  24021. * @returns True if the post processes were able to be run.
  24022. * @hidden
  24023. */
  24024. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24025. /**
  24026. * Manually render a set of post processes to a texture.
  24027. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24028. * @param postProcesses An array of post processes to be run.
  24029. * @param targetTexture The target texture to render to.
  24030. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24031. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24032. * @param lodLevel defines which lod of the texture to render to
  24033. */
  24034. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  24035. /**
  24036. * Finalize the result of the output of the postprocesses.
  24037. * @param doNotPresent If true the result will not be displayed to the screen.
  24038. * @param targetTexture The target texture to render to.
  24039. * @param faceIndex The index of the face to bind the target texture to.
  24040. * @param postProcesses The array of post processes to render.
  24041. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24042. * @hidden
  24043. */
  24044. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24045. /**
  24046. * Disposes of the post process manager.
  24047. */
  24048. dispose(): void;
  24049. }
  24050. }
  24051. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24052. import { Observable } from "babylonjs/Misc/observable";
  24053. import { SmartArray } from "babylonjs/Misc/smartArray";
  24054. import { Nullable, Immutable } from "babylonjs/types";
  24055. import { Camera } from "babylonjs/Cameras/camera";
  24056. import { Scene } from "babylonjs/scene";
  24057. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24058. import { Color4 } from "babylonjs/Maths/math.color";
  24059. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24061. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24062. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24063. import { Texture } from "babylonjs/Materials/Textures/texture";
  24064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24065. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24066. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24067. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24068. import { Engine } from "babylonjs/Engines/engine";
  24069. /**
  24070. * This Helps creating a texture that will be created from a camera in your scene.
  24071. * It is basically a dynamic texture that could be used to create special effects for instance.
  24072. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24073. */
  24074. export class RenderTargetTexture extends Texture {
  24075. isCube: boolean;
  24076. /**
  24077. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24078. */
  24079. static readonly REFRESHRATE_RENDER_ONCE: number;
  24080. /**
  24081. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24082. */
  24083. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24084. /**
  24085. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24086. * the central point of your effect and can save a lot of performances.
  24087. */
  24088. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24089. /**
  24090. * Use this predicate to dynamically define the list of mesh you want to render.
  24091. * If set, the renderList property will be overwritten.
  24092. */
  24093. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24094. private _renderList;
  24095. /**
  24096. * Use this list to define the list of mesh you want to render.
  24097. */
  24098. get renderList(): Nullable<Array<AbstractMesh>>;
  24099. set renderList(value: Nullable<Array<AbstractMesh>>);
  24100. /**
  24101. * Use this function to overload the renderList array at rendering time.
  24102. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24103. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24104. * the cube (if the RTT is a cube, else layerOrFace=0).
  24105. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24106. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24107. * hold dummy elements!
  24108. */
  24109. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24110. private _hookArray;
  24111. /**
  24112. * Define if particles should be rendered in your texture.
  24113. */
  24114. renderParticles: boolean;
  24115. /**
  24116. * Define if sprites should be rendered in your texture.
  24117. */
  24118. renderSprites: boolean;
  24119. /**
  24120. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24121. */
  24122. coordinatesMode: number;
  24123. /**
  24124. * Define the camera used to render the texture.
  24125. */
  24126. activeCamera: Nullable<Camera>;
  24127. /**
  24128. * Override the mesh isReady function with your own one.
  24129. */
  24130. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24131. /**
  24132. * Override the render function of the texture with your own one.
  24133. */
  24134. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24135. /**
  24136. * Define if camera post processes should be use while rendering the texture.
  24137. */
  24138. useCameraPostProcesses: boolean;
  24139. /**
  24140. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24141. */
  24142. ignoreCameraViewport: boolean;
  24143. private _postProcessManager;
  24144. private _postProcesses;
  24145. private _resizeObserver;
  24146. /**
  24147. * An event triggered when the texture is unbind.
  24148. */
  24149. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24150. /**
  24151. * An event triggered when the texture is unbind.
  24152. */
  24153. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24154. private _onAfterUnbindObserver;
  24155. /**
  24156. * Set a after unbind callback in the texture.
  24157. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24158. */
  24159. set onAfterUnbind(callback: () => void);
  24160. /**
  24161. * An event triggered before rendering the texture
  24162. */
  24163. onBeforeRenderObservable: Observable<number>;
  24164. private _onBeforeRenderObserver;
  24165. /**
  24166. * Set a before render callback in the texture.
  24167. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24168. */
  24169. set onBeforeRender(callback: (faceIndex: number) => void);
  24170. /**
  24171. * An event triggered after rendering the texture
  24172. */
  24173. onAfterRenderObservable: Observable<number>;
  24174. private _onAfterRenderObserver;
  24175. /**
  24176. * Set a after render callback in the texture.
  24177. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24178. */
  24179. set onAfterRender(callback: (faceIndex: number) => void);
  24180. /**
  24181. * An event triggered after the texture clear
  24182. */
  24183. onClearObservable: Observable<Engine>;
  24184. private _onClearObserver;
  24185. /**
  24186. * Set a clear callback in the texture.
  24187. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24188. */
  24189. set onClear(callback: (Engine: Engine) => void);
  24190. /**
  24191. * An event triggered when the texture is resized.
  24192. */
  24193. onResizeObservable: Observable<RenderTargetTexture>;
  24194. /**
  24195. * Define the clear color of the Render Target if it should be different from the scene.
  24196. */
  24197. clearColor: Color4;
  24198. protected _size: number | {
  24199. width: number;
  24200. height: number;
  24201. layers?: number;
  24202. };
  24203. protected _initialSizeParameter: number | {
  24204. width: number;
  24205. height: number;
  24206. } | {
  24207. ratio: number;
  24208. };
  24209. protected _sizeRatio: Nullable<number>;
  24210. /** @hidden */
  24211. _generateMipMaps: boolean;
  24212. protected _renderingManager: RenderingManager;
  24213. /** @hidden */
  24214. _waitingRenderList: string[];
  24215. protected _doNotChangeAspectRatio: boolean;
  24216. protected _currentRefreshId: number;
  24217. protected _refreshRate: number;
  24218. protected _textureMatrix: Matrix;
  24219. protected _samples: number;
  24220. protected _renderTargetOptions: RenderTargetCreationOptions;
  24221. /**
  24222. * Gets render target creation options that were used.
  24223. */
  24224. get renderTargetOptions(): RenderTargetCreationOptions;
  24225. protected _onRatioRescale(): void;
  24226. /**
  24227. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24228. * It must define where the camera used to render the texture is set
  24229. */
  24230. boundingBoxPosition: Vector3;
  24231. private _boundingBoxSize;
  24232. /**
  24233. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24234. * When defined, the cubemap will switch to local mode
  24235. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24236. * @example https://www.babylonjs-playground.com/#RNASML
  24237. */
  24238. set boundingBoxSize(value: Vector3);
  24239. get boundingBoxSize(): Vector3;
  24240. /**
  24241. * In case the RTT has been created with a depth texture, get the associated
  24242. * depth texture.
  24243. * Otherwise, return null.
  24244. */
  24245. get depthStencilTexture(): Nullable<InternalTexture>;
  24246. /**
  24247. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24248. * or used a shadow, depth texture...
  24249. * @param name The friendly name of the texture
  24250. * @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)
  24251. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24252. * @param generateMipMaps True if mip maps need to be generated after render.
  24253. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24254. * @param type The type of the buffer in the RTT (int, half float, float...)
  24255. * @param isCube True if a cube texture needs to be created
  24256. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24257. * @param generateDepthBuffer True to generate a depth buffer
  24258. * @param generateStencilBuffer True to generate a stencil buffer
  24259. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24260. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24261. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24262. */
  24263. constructor(name: string, size: number | {
  24264. width: number;
  24265. height: number;
  24266. layers?: number;
  24267. } | {
  24268. ratio: number;
  24269. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24270. /**
  24271. * Creates a depth stencil texture.
  24272. * This is only available in WebGL 2 or with the depth texture extension available.
  24273. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24274. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24275. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24276. */
  24277. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24278. private _processSizeParameter;
  24279. /**
  24280. * Define the number of samples to use in case of MSAA.
  24281. * It defaults to one meaning no MSAA has been enabled.
  24282. */
  24283. get samples(): number;
  24284. set samples(value: number);
  24285. /**
  24286. * Resets the refresh counter of the texture and start bak from scratch.
  24287. * Could be useful to regenerate the texture if it is setup to render only once.
  24288. */
  24289. resetRefreshCounter(): void;
  24290. /**
  24291. * Define the refresh rate of the texture or the rendering frequency.
  24292. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24293. */
  24294. get refreshRate(): number;
  24295. set refreshRate(value: number);
  24296. /**
  24297. * Adds a post process to the render target rendering passes.
  24298. * @param postProcess define the post process to add
  24299. */
  24300. addPostProcess(postProcess: PostProcess): void;
  24301. /**
  24302. * Clear all the post processes attached to the render target
  24303. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24304. */
  24305. clearPostProcesses(dispose?: boolean): void;
  24306. /**
  24307. * Remove one of the post process from the list of attached post processes to the texture
  24308. * @param postProcess define the post process to remove from the list
  24309. */
  24310. removePostProcess(postProcess: PostProcess): void;
  24311. /** @hidden */
  24312. _shouldRender(): boolean;
  24313. /**
  24314. * Gets the actual render size of the texture.
  24315. * @returns the width of the render size
  24316. */
  24317. getRenderSize(): number;
  24318. /**
  24319. * Gets the actual render width of the texture.
  24320. * @returns the width of the render size
  24321. */
  24322. getRenderWidth(): number;
  24323. /**
  24324. * Gets the actual render height of the texture.
  24325. * @returns the height of the render size
  24326. */
  24327. getRenderHeight(): number;
  24328. /**
  24329. * Gets the actual number of layers of the texture.
  24330. * @returns the number of layers
  24331. */
  24332. getRenderLayers(): number;
  24333. /**
  24334. * Get if the texture can be rescaled or not.
  24335. */
  24336. get canRescale(): boolean;
  24337. /**
  24338. * Resize the texture using a ratio.
  24339. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24340. */
  24341. scale(ratio: number): void;
  24342. /**
  24343. * Get the texture reflection matrix used to rotate/transform the reflection.
  24344. * @returns the reflection matrix
  24345. */
  24346. getReflectionTextureMatrix(): Matrix;
  24347. /**
  24348. * Resize the texture to a new desired size.
  24349. * Be carrefull as it will recreate all the data in the new texture.
  24350. * @param size Define the new size. It can be:
  24351. * - a number for squared texture,
  24352. * - an object containing { width: number, height: number }
  24353. * - or an object containing a ratio { ratio: number }
  24354. */
  24355. resize(size: number | {
  24356. width: number;
  24357. height: number;
  24358. } | {
  24359. ratio: number;
  24360. }): void;
  24361. private _defaultRenderListPrepared;
  24362. /**
  24363. * Renders all the objects from the render list into the texture.
  24364. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24365. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24366. */
  24367. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24368. private _bestReflectionRenderTargetDimension;
  24369. private _prepareRenderingManager;
  24370. /**
  24371. * @hidden
  24372. * @param faceIndex face index to bind to if this is a cubetexture
  24373. * @param layer defines the index of the texture to bind in the array
  24374. */
  24375. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24376. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24377. private renderToTarget;
  24378. /**
  24379. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24380. * This allowed control for front to back rendering or reversly depending of the special needs.
  24381. *
  24382. * @param renderingGroupId The rendering group id corresponding to its index
  24383. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24384. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24385. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24386. */
  24387. 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;
  24388. /**
  24389. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24390. *
  24391. * @param renderingGroupId The rendering group id corresponding to its index
  24392. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24393. */
  24394. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24395. /**
  24396. * Clones the texture.
  24397. * @returns the cloned texture
  24398. */
  24399. clone(): RenderTargetTexture;
  24400. /**
  24401. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24402. * @returns The JSON representation of the texture
  24403. */
  24404. serialize(): any;
  24405. /**
  24406. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24407. */
  24408. disposeFramebufferObjects(): void;
  24409. /**
  24410. * Dispose the texture and release its associated resources.
  24411. */
  24412. dispose(): void;
  24413. /** @hidden */
  24414. _rebuild(): void;
  24415. /**
  24416. * Clear the info related to rendering groups preventing retention point in material dispose.
  24417. */
  24418. freeRenderingGroups(): void;
  24419. /**
  24420. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24421. * @returns the view count
  24422. */
  24423. getViewCount(): number;
  24424. }
  24425. }
  24426. declare module "babylonjs/Misc/guid" {
  24427. /**
  24428. * Class used to manipulate GUIDs
  24429. */
  24430. export class GUID {
  24431. /**
  24432. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24433. * Be aware Math.random() could cause collisions, but:
  24434. * "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"
  24435. * @returns a pseudo random id
  24436. */
  24437. static RandomId(): string;
  24438. }
  24439. }
  24440. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24441. import { Nullable } from "babylonjs/types";
  24442. import { Scene } from "babylonjs/scene";
  24443. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24444. import { Material } from "babylonjs/Materials/material";
  24445. import { Effect } from "babylonjs/Materials/effect";
  24446. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24447. /**
  24448. * Options to be used when creating a shadow depth material
  24449. */
  24450. export interface IIOptionShadowDepthMaterial {
  24451. /** Variables in the vertex shader code that need to have their names remapped.
  24452. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24453. * "var_name" should be either: worldPos or vNormalW
  24454. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24455. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24456. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24457. */
  24458. remappedVariables?: string[];
  24459. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24460. standalone?: boolean;
  24461. }
  24462. /**
  24463. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24464. */
  24465. export class ShadowDepthWrapper {
  24466. private _scene;
  24467. private _options?;
  24468. private _baseMaterial;
  24469. private _onEffectCreatedObserver;
  24470. private _subMeshToEffect;
  24471. private _subMeshToDepthEffect;
  24472. private _meshes;
  24473. /** @hidden */
  24474. _matriceNames: any;
  24475. /** Gets the standalone status of the wrapper */
  24476. get standalone(): boolean;
  24477. /** Gets the base material the wrapper is built upon */
  24478. get baseMaterial(): Material;
  24479. /**
  24480. * Instantiate a new shadow depth wrapper.
  24481. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24482. * generate the shadow depth map. For more information, please refer to the documentation:
  24483. * https://doc.babylonjs.com/babylon101/shadows
  24484. * @param baseMaterial Material to wrap
  24485. * @param scene Define the scene the material belongs to
  24486. * @param options Options used to create the wrapper
  24487. */
  24488. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24489. /**
  24490. * Gets the effect to use to generate the depth map
  24491. * @param subMesh subMesh to get the effect for
  24492. * @param shadowGenerator shadow generator to get the effect for
  24493. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24494. */
  24495. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24496. /**
  24497. * Specifies that the submesh is ready to be used for depth rendering
  24498. * @param subMesh submesh to check
  24499. * @param defines the list of defines to take into account when checking the effect
  24500. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24501. * @param useInstances specifies that instances should be used
  24502. * @returns a boolean indicating that the submesh is ready or not
  24503. */
  24504. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24505. /**
  24506. * Disposes the resources
  24507. */
  24508. dispose(): void;
  24509. private _makeEffect;
  24510. }
  24511. }
  24512. declare module "babylonjs/Materials/material" {
  24513. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24514. import { SmartArray } from "babylonjs/Misc/smartArray";
  24515. import { Observable } from "babylonjs/Misc/observable";
  24516. import { Nullable } from "babylonjs/types";
  24517. import { Scene } from "babylonjs/scene";
  24518. import { Matrix } from "babylonjs/Maths/math.vector";
  24519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24521. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24522. import { Effect } from "babylonjs/Materials/effect";
  24523. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24525. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24526. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24527. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24528. import { Mesh } from "babylonjs/Meshes/mesh";
  24529. import { Animation } from "babylonjs/Animations/animation";
  24530. /**
  24531. * Options for compiling materials.
  24532. */
  24533. export interface IMaterialCompilationOptions {
  24534. /**
  24535. * Defines whether clip planes are enabled.
  24536. */
  24537. clipPlane: boolean;
  24538. /**
  24539. * Defines whether instances are enabled.
  24540. */
  24541. useInstances: boolean;
  24542. }
  24543. /**
  24544. * Options passed when calling customShaderNameResolve
  24545. */
  24546. export interface ICustomShaderNameResolveOptions {
  24547. /**
  24548. * 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
  24549. */
  24550. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24551. }
  24552. /**
  24553. * Base class for the main features of a material in Babylon.js
  24554. */
  24555. export class Material implements IAnimatable {
  24556. /**
  24557. * Returns the triangle fill mode
  24558. */
  24559. static readonly TriangleFillMode: number;
  24560. /**
  24561. * Returns the wireframe mode
  24562. */
  24563. static readonly WireFrameFillMode: number;
  24564. /**
  24565. * Returns the point fill mode
  24566. */
  24567. static readonly PointFillMode: number;
  24568. /**
  24569. * Returns the point list draw mode
  24570. */
  24571. static readonly PointListDrawMode: number;
  24572. /**
  24573. * Returns the line list draw mode
  24574. */
  24575. static readonly LineListDrawMode: number;
  24576. /**
  24577. * Returns the line loop draw mode
  24578. */
  24579. static readonly LineLoopDrawMode: number;
  24580. /**
  24581. * Returns the line strip draw mode
  24582. */
  24583. static readonly LineStripDrawMode: number;
  24584. /**
  24585. * Returns the triangle strip draw mode
  24586. */
  24587. static readonly TriangleStripDrawMode: number;
  24588. /**
  24589. * Returns the triangle fan draw mode
  24590. */
  24591. static readonly TriangleFanDrawMode: number;
  24592. /**
  24593. * Stores the clock-wise side orientation
  24594. */
  24595. static readonly ClockWiseSideOrientation: number;
  24596. /**
  24597. * Stores the counter clock-wise side orientation
  24598. */
  24599. static readonly CounterClockWiseSideOrientation: number;
  24600. /**
  24601. * The dirty texture flag value
  24602. */
  24603. static readonly TextureDirtyFlag: number;
  24604. /**
  24605. * The dirty light flag value
  24606. */
  24607. static readonly LightDirtyFlag: number;
  24608. /**
  24609. * The dirty fresnel flag value
  24610. */
  24611. static readonly FresnelDirtyFlag: number;
  24612. /**
  24613. * The dirty attribute flag value
  24614. */
  24615. static readonly AttributesDirtyFlag: number;
  24616. /**
  24617. * The dirty misc flag value
  24618. */
  24619. static readonly MiscDirtyFlag: number;
  24620. /**
  24621. * The all dirty flag value
  24622. */
  24623. static readonly AllDirtyFlag: number;
  24624. /**
  24625. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24626. */
  24627. static readonly MATERIAL_OPAQUE: number;
  24628. /**
  24629. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24630. */
  24631. static readonly MATERIAL_ALPHATEST: number;
  24632. /**
  24633. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24634. */
  24635. static readonly MATERIAL_ALPHABLEND: number;
  24636. /**
  24637. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24638. * They are also discarded below the alpha cutoff threshold to improve performances.
  24639. */
  24640. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24641. /**
  24642. * The Whiteout method is used to blend normals.
  24643. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24644. */
  24645. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24646. /**
  24647. * The Reoriented Normal Mapping method is used to blend normals.
  24648. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24649. */
  24650. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24651. /**
  24652. * Custom callback helping to override the default shader used in the material.
  24653. */
  24654. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24655. /**
  24656. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24657. */
  24658. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24659. /**
  24660. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24661. * This means that the material can keep using a previous shader while a new one is being compiled.
  24662. * This is mostly used when shader parallel compilation is supported (true by default)
  24663. */
  24664. allowShaderHotSwapping: boolean;
  24665. /**
  24666. * The ID of the material
  24667. */
  24668. id: string;
  24669. /**
  24670. * Gets or sets the unique id of the material
  24671. */
  24672. uniqueId: number;
  24673. /**
  24674. * The name of the material
  24675. */
  24676. name: string;
  24677. /**
  24678. * Gets or sets user defined metadata
  24679. */
  24680. metadata: any;
  24681. /**
  24682. * For internal use only. Please do not use.
  24683. */
  24684. reservedDataStore: any;
  24685. /**
  24686. * Specifies if the ready state should be checked on each call
  24687. */
  24688. checkReadyOnEveryCall: boolean;
  24689. /**
  24690. * Specifies if the ready state should be checked once
  24691. */
  24692. checkReadyOnlyOnce: boolean;
  24693. /**
  24694. * The state of the material
  24695. */
  24696. state: string;
  24697. /**
  24698. * The alpha value of the material
  24699. */
  24700. protected _alpha: number;
  24701. /**
  24702. * List of inspectable custom properties (used by the Inspector)
  24703. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24704. */
  24705. inspectableCustomProperties: IInspectable[];
  24706. /**
  24707. * Sets the alpha value of the material
  24708. */
  24709. set alpha(value: number);
  24710. /**
  24711. * Gets the alpha value of the material
  24712. */
  24713. get alpha(): number;
  24714. /**
  24715. * Specifies if back face culling is enabled
  24716. */
  24717. protected _backFaceCulling: boolean;
  24718. /**
  24719. * Sets the back-face culling state
  24720. */
  24721. set backFaceCulling(value: boolean);
  24722. /**
  24723. * Gets the back-face culling state
  24724. */
  24725. get backFaceCulling(): boolean;
  24726. /**
  24727. * Stores the value for side orientation
  24728. */
  24729. sideOrientation: number;
  24730. /**
  24731. * Callback triggered when the material is compiled
  24732. */
  24733. onCompiled: Nullable<(effect: Effect) => void>;
  24734. /**
  24735. * Callback triggered when an error occurs
  24736. */
  24737. onError: Nullable<(effect: Effect, errors: string) => void>;
  24738. /**
  24739. * Callback triggered to get the render target textures
  24740. */
  24741. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24742. /**
  24743. * Gets a boolean indicating that current material needs to register RTT
  24744. */
  24745. get hasRenderTargetTextures(): boolean;
  24746. /**
  24747. * Specifies if the material should be serialized
  24748. */
  24749. doNotSerialize: boolean;
  24750. /**
  24751. * @hidden
  24752. */
  24753. _storeEffectOnSubMeshes: boolean;
  24754. /**
  24755. * Stores the animations for the material
  24756. */
  24757. animations: Nullable<Array<Animation>>;
  24758. /**
  24759. * An event triggered when the material is disposed
  24760. */
  24761. onDisposeObservable: Observable<Material>;
  24762. /**
  24763. * An observer which watches for dispose events
  24764. */
  24765. private _onDisposeObserver;
  24766. private _onUnBindObservable;
  24767. /**
  24768. * Called during a dispose event
  24769. */
  24770. set onDispose(callback: () => void);
  24771. private _onBindObservable;
  24772. /**
  24773. * An event triggered when the material is bound
  24774. */
  24775. get onBindObservable(): Observable<AbstractMesh>;
  24776. /**
  24777. * An observer which watches for bind events
  24778. */
  24779. private _onBindObserver;
  24780. /**
  24781. * Called during a bind event
  24782. */
  24783. set onBind(callback: (Mesh: AbstractMesh) => void);
  24784. /**
  24785. * An event triggered when the material is unbound
  24786. */
  24787. get onUnBindObservable(): Observable<Material>;
  24788. protected _onEffectCreatedObservable: Nullable<Observable<{
  24789. effect: Effect;
  24790. subMesh: Nullable<SubMesh>;
  24791. }>>;
  24792. /**
  24793. * An event triggered when the effect is (re)created
  24794. */
  24795. get onEffectCreatedObservable(): Observable<{
  24796. effect: Effect;
  24797. subMesh: Nullable<SubMesh>;
  24798. }>;
  24799. /**
  24800. * Stores the value of the alpha mode
  24801. */
  24802. private _alphaMode;
  24803. /**
  24804. * Sets the value of the alpha mode.
  24805. *
  24806. * | Value | Type | Description |
  24807. * | --- | --- | --- |
  24808. * | 0 | ALPHA_DISABLE | |
  24809. * | 1 | ALPHA_ADD | |
  24810. * | 2 | ALPHA_COMBINE | |
  24811. * | 3 | ALPHA_SUBTRACT | |
  24812. * | 4 | ALPHA_MULTIPLY | |
  24813. * | 5 | ALPHA_MAXIMIZED | |
  24814. * | 6 | ALPHA_ONEONE | |
  24815. * | 7 | ALPHA_PREMULTIPLIED | |
  24816. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24817. * | 9 | ALPHA_INTERPOLATE | |
  24818. * | 10 | ALPHA_SCREENMODE | |
  24819. *
  24820. */
  24821. set alphaMode(value: number);
  24822. /**
  24823. * Gets the value of the alpha mode
  24824. */
  24825. get alphaMode(): number;
  24826. /**
  24827. * Stores the state of the need depth pre-pass value
  24828. */
  24829. private _needDepthPrePass;
  24830. /**
  24831. * Sets the need depth pre-pass value
  24832. */
  24833. set needDepthPrePass(value: boolean);
  24834. /**
  24835. * Gets the depth pre-pass value
  24836. */
  24837. get needDepthPrePass(): boolean;
  24838. /**
  24839. * Specifies if depth writing should be disabled
  24840. */
  24841. disableDepthWrite: boolean;
  24842. /**
  24843. * Specifies if color writing should be disabled
  24844. */
  24845. disableColorWrite: boolean;
  24846. /**
  24847. * Specifies if depth writing should be forced
  24848. */
  24849. forceDepthWrite: boolean;
  24850. /**
  24851. * Specifies the depth function that should be used. 0 means the default engine function
  24852. */
  24853. depthFunction: number;
  24854. /**
  24855. * Specifies if there should be a separate pass for culling
  24856. */
  24857. separateCullingPass: boolean;
  24858. /**
  24859. * Stores the state specifing if fog should be enabled
  24860. */
  24861. private _fogEnabled;
  24862. /**
  24863. * Sets the state for enabling fog
  24864. */
  24865. set fogEnabled(value: boolean);
  24866. /**
  24867. * Gets the value of the fog enabled state
  24868. */
  24869. get fogEnabled(): boolean;
  24870. /**
  24871. * Stores the size of points
  24872. */
  24873. pointSize: number;
  24874. /**
  24875. * Stores the z offset value
  24876. */
  24877. zOffset: number;
  24878. get wireframe(): boolean;
  24879. /**
  24880. * Sets the state of wireframe mode
  24881. */
  24882. set wireframe(value: boolean);
  24883. /**
  24884. * Gets the value specifying if point clouds are enabled
  24885. */
  24886. get pointsCloud(): boolean;
  24887. /**
  24888. * Sets the state of point cloud mode
  24889. */
  24890. set pointsCloud(value: boolean);
  24891. /**
  24892. * Gets the material fill mode
  24893. */
  24894. get fillMode(): number;
  24895. /**
  24896. * Sets the material fill mode
  24897. */
  24898. set fillMode(value: number);
  24899. /**
  24900. * @hidden
  24901. * Stores the effects for the material
  24902. */
  24903. _effect: Nullable<Effect>;
  24904. /**
  24905. * Specifies if uniform buffers should be used
  24906. */
  24907. private _useUBO;
  24908. /**
  24909. * Stores a reference to the scene
  24910. */
  24911. private _scene;
  24912. /**
  24913. * Stores the fill mode state
  24914. */
  24915. private _fillMode;
  24916. /**
  24917. * Specifies if the depth write state should be cached
  24918. */
  24919. private _cachedDepthWriteState;
  24920. /**
  24921. * Specifies if the color write state should be cached
  24922. */
  24923. private _cachedColorWriteState;
  24924. /**
  24925. * Specifies if the depth function state should be cached
  24926. */
  24927. private _cachedDepthFunctionState;
  24928. /**
  24929. * Stores the uniform buffer
  24930. */
  24931. protected _uniformBuffer: UniformBuffer;
  24932. /** @hidden */
  24933. _indexInSceneMaterialArray: number;
  24934. /** @hidden */
  24935. meshMap: Nullable<{
  24936. [id: string]: AbstractMesh | undefined;
  24937. }>;
  24938. /**
  24939. * Creates a material instance
  24940. * @param name defines the name of the material
  24941. * @param scene defines the scene to reference
  24942. * @param doNotAdd specifies if the material should be added to the scene
  24943. */
  24944. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24945. /**
  24946. * Returns a string representation of the current material
  24947. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24948. * @returns a string with material information
  24949. */
  24950. toString(fullDetails?: boolean): string;
  24951. /**
  24952. * Gets the class name of the material
  24953. * @returns a string with the class name of the material
  24954. */
  24955. getClassName(): string;
  24956. /**
  24957. * Specifies if updates for the material been locked
  24958. */
  24959. get isFrozen(): boolean;
  24960. /**
  24961. * Locks updates for the material
  24962. */
  24963. freeze(): void;
  24964. /**
  24965. * Unlocks updates for the material
  24966. */
  24967. unfreeze(): void;
  24968. /**
  24969. * Specifies if the material is ready to be used
  24970. * @param mesh defines the mesh to check
  24971. * @param useInstances specifies if instances should be used
  24972. * @returns a boolean indicating if the material is ready to be used
  24973. */
  24974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24975. /**
  24976. * Specifies that the submesh is ready to be used
  24977. * @param mesh defines the mesh to check
  24978. * @param subMesh defines which submesh to check
  24979. * @param useInstances specifies that instances should be used
  24980. * @returns a boolean indicating that the submesh is ready or not
  24981. */
  24982. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24983. /**
  24984. * Returns the material effect
  24985. * @returns the effect associated with the material
  24986. */
  24987. getEffect(): Nullable<Effect>;
  24988. /**
  24989. * Returns the current scene
  24990. * @returns a Scene
  24991. */
  24992. getScene(): Scene;
  24993. /**
  24994. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24995. */
  24996. protected _forceAlphaTest: boolean;
  24997. /**
  24998. * The transparency mode of the material.
  24999. */
  25000. protected _transparencyMode: Nullable<number>;
  25001. /**
  25002. * Gets the current transparency mode.
  25003. */
  25004. get transparencyMode(): Nullable<number>;
  25005. /**
  25006. * Sets the transparency mode of the material.
  25007. *
  25008. * | Value | Type | Description |
  25009. * | ----- | ----------------------------------- | ----------- |
  25010. * | 0 | OPAQUE | |
  25011. * | 1 | ALPHATEST | |
  25012. * | 2 | ALPHABLEND | |
  25013. * | 3 | ALPHATESTANDBLEND | |
  25014. *
  25015. */
  25016. set transparencyMode(value: Nullable<number>);
  25017. /**
  25018. * Returns true if alpha blending should be disabled.
  25019. */
  25020. protected get _disableAlphaBlending(): boolean;
  25021. /**
  25022. * Specifies whether or not this material should be rendered in alpha blend mode.
  25023. * @returns a boolean specifying if alpha blending is needed
  25024. */
  25025. needAlphaBlending(): boolean;
  25026. /**
  25027. * Specifies if the mesh will require alpha blending
  25028. * @param mesh defines the mesh to check
  25029. * @returns a boolean specifying if alpha blending is needed for the mesh
  25030. */
  25031. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25032. /**
  25033. * Specifies whether or not this material should be rendered in alpha test mode.
  25034. * @returns a boolean specifying if an alpha test is needed.
  25035. */
  25036. needAlphaTesting(): boolean;
  25037. /**
  25038. * Specifies if material alpha testing should be turned on for the mesh
  25039. * @param mesh defines the mesh to check
  25040. */
  25041. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25042. /**
  25043. * Gets the texture used for the alpha test
  25044. * @returns the texture to use for alpha testing
  25045. */
  25046. getAlphaTestTexture(): Nullable<BaseTexture>;
  25047. /**
  25048. * Marks the material to indicate that it needs to be re-calculated
  25049. */
  25050. markDirty(): void;
  25051. /** @hidden */
  25052. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25053. /**
  25054. * Binds the material to the mesh
  25055. * @param world defines the world transformation matrix
  25056. * @param mesh defines the mesh to bind the material to
  25057. */
  25058. bind(world: Matrix, mesh?: Mesh): void;
  25059. /**
  25060. * Binds the submesh to the material
  25061. * @param world defines the world transformation matrix
  25062. * @param mesh defines the mesh containing the submesh
  25063. * @param subMesh defines the submesh to bind the material to
  25064. */
  25065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25066. /**
  25067. * Binds the world matrix to the material
  25068. * @param world defines the world transformation matrix
  25069. */
  25070. bindOnlyWorldMatrix(world: Matrix): void;
  25071. /**
  25072. * Binds the scene's uniform buffer to the effect.
  25073. * @param effect defines the effect to bind to the scene uniform buffer
  25074. * @param sceneUbo defines the uniform buffer storing scene data
  25075. */
  25076. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25077. /**
  25078. * Binds the view matrix to the effect
  25079. * @param effect defines the effect to bind the view matrix to
  25080. */
  25081. bindView(effect: Effect): void;
  25082. /**
  25083. * Binds the view projection matrix to the effect
  25084. * @param effect defines the effect to bind the view projection matrix to
  25085. */
  25086. bindViewProjection(effect: Effect): void;
  25087. /**
  25088. * Processes to execute after binding the material to a mesh
  25089. * @param mesh defines the rendered mesh
  25090. */
  25091. protected _afterBind(mesh?: Mesh): void;
  25092. /**
  25093. * Unbinds the material from the mesh
  25094. */
  25095. unbind(): void;
  25096. /**
  25097. * Gets the active textures from the material
  25098. * @returns an array of textures
  25099. */
  25100. getActiveTextures(): BaseTexture[];
  25101. /**
  25102. * Specifies if the material uses a texture
  25103. * @param texture defines the texture to check against the material
  25104. * @returns a boolean specifying if the material uses the texture
  25105. */
  25106. hasTexture(texture: BaseTexture): boolean;
  25107. /**
  25108. * Makes a duplicate of the material, and gives it a new name
  25109. * @param name defines the new name for the duplicated material
  25110. * @returns the cloned material
  25111. */
  25112. clone(name: string): Nullable<Material>;
  25113. /**
  25114. * Gets the meshes bound to the material
  25115. * @returns an array of meshes bound to the material
  25116. */
  25117. getBindedMeshes(): AbstractMesh[];
  25118. /**
  25119. * Force shader compilation
  25120. * @param mesh defines the mesh associated with this material
  25121. * @param onCompiled defines a function to execute once the material is compiled
  25122. * @param options defines the options to configure the compilation
  25123. * @param onError defines a function to execute if the material fails compiling
  25124. */
  25125. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25126. /**
  25127. * Force shader compilation
  25128. * @param mesh defines the mesh that will use this material
  25129. * @param options defines additional options for compiling the shaders
  25130. * @returns a promise that resolves when the compilation completes
  25131. */
  25132. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25133. private static readonly _AllDirtyCallBack;
  25134. private static readonly _ImageProcessingDirtyCallBack;
  25135. private static readonly _TextureDirtyCallBack;
  25136. private static readonly _FresnelDirtyCallBack;
  25137. private static readonly _MiscDirtyCallBack;
  25138. private static readonly _LightsDirtyCallBack;
  25139. private static readonly _AttributeDirtyCallBack;
  25140. private static _FresnelAndMiscDirtyCallBack;
  25141. private static _TextureAndMiscDirtyCallBack;
  25142. private static readonly _DirtyCallbackArray;
  25143. private static readonly _RunDirtyCallBacks;
  25144. /**
  25145. * Marks a define in the material to indicate that it needs to be re-computed
  25146. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25147. */
  25148. markAsDirty(flag: number): void;
  25149. /**
  25150. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25151. * @param func defines a function which checks material defines against the submeshes
  25152. */
  25153. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25154. /**
  25155. * Indicates that we need to re-calculated for all submeshes
  25156. */
  25157. protected _markAllSubMeshesAsAllDirty(): void;
  25158. /**
  25159. * Indicates that image processing needs to be re-calculated for all submeshes
  25160. */
  25161. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25162. /**
  25163. * Indicates that textures need to be re-calculated for all submeshes
  25164. */
  25165. protected _markAllSubMeshesAsTexturesDirty(): void;
  25166. /**
  25167. * Indicates that fresnel needs to be re-calculated for all submeshes
  25168. */
  25169. protected _markAllSubMeshesAsFresnelDirty(): void;
  25170. /**
  25171. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25172. */
  25173. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25174. /**
  25175. * Indicates that lights need to be re-calculated for all submeshes
  25176. */
  25177. protected _markAllSubMeshesAsLightsDirty(): void;
  25178. /**
  25179. * Indicates that attributes need to be re-calculated for all submeshes
  25180. */
  25181. protected _markAllSubMeshesAsAttributesDirty(): void;
  25182. /**
  25183. * Indicates that misc needs to be re-calculated for all submeshes
  25184. */
  25185. protected _markAllSubMeshesAsMiscDirty(): void;
  25186. /**
  25187. * Indicates that textures and misc need to be re-calculated for all submeshes
  25188. */
  25189. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25190. /**
  25191. * Disposes the material
  25192. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25193. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25194. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25195. */
  25196. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25197. /** @hidden */
  25198. private releaseVertexArrayObject;
  25199. /**
  25200. * Serializes this material
  25201. * @returns the serialized material object
  25202. */
  25203. serialize(): any;
  25204. /**
  25205. * Creates a material from parsed material data
  25206. * @param parsedMaterial defines parsed material data
  25207. * @param scene defines the hosting scene
  25208. * @param rootUrl defines the root URL to use to load textures
  25209. * @returns a new material
  25210. */
  25211. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25212. }
  25213. }
  25214. declare module "babylonjs/Materials/multiMaterial" {
  25215. import { Nullable } from "babylonjs/types";
  25216. import { Scene } from "babylonjs/scene";
  25217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25218. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25220. import { Material } from "babylonjs/Materials/material";
  25221. /**
  25222. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25223. * separate meshes. This can be use to improve performances.
  25224. * @see http://doc.babylonjs.com/how_to/multi_materials
  25225. */
  25226. export class MultiMaterial extends Material {
  25227. private _subMaterials;
  25228. /**
  25229. * Gets or Sets the list of Materials used within the multi material.
  25230. * They need to be ordered according to the submeshes order in the associated mesh
  25231. */
  25232. get subMaterials(): Nullable<Material>[];
  25233. set subMaterials(value: Nullable<Material>[]);
  25234. /**
  25235. * Function used to align with Node.getChildren()
  25236. * @returns the list of Materials used within the multi material
  25237. */
  25238. getChildren(): Nullable<Material>[];
  25239. /**
  25240. * Instantiates a new Multi Material
  25241. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25242. * separate meshes. This can be use to improve performances.
  25243. * @see http://doc.babylonjs.com/how_to/multi_materials
  25244. * @param name Define the name in the scene
  25245. * @param scene Define the scene the material belongs to
  25246. */
  25247. constructor(name: string, scene: Scene);
  25248. private _hookArray;
  25249. /**
  25250. * Get one of the submaterial by its index in the submaterials array
  25251. * @param index The index to look the sub material at
  25252. * @returns The Material if the index has been defined
  25253. */
  25254. getSubMaterial(index: number): Nullable<Material>;
  25255. /**
  25256. * Get the list of active textures for the whole sub materials list.
  25257. * @returns All the textures that will be used during the rendering
  25258. */
  25259. getActiveTextures(): BaseTexture[];
  25260. /**
  25261. * Gets the current class name of the material e.g. "MultiMaterial"
  25262. * Mainly use in serialization.
  25263. * @returns the class name
  25264. */
  25265. getClassName(): string;
  25266. /**
  25267. * Checks if the material is ready to render the requested sub mesh
  25268. * @param mesh Define the mesh the submesh belongs to
  25269. * @param subMesh Define the sub mesh to look readyness for
  25270. * @param useInstances Define whether or not the material is used with instances
  25271. * @returns true if ready, otherwise false
  25272. */
  25273. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25274. /**
  25275. * Clones the current material and its related sub materials
  25276. * @param name Define the name of the newly cloned material
  25277. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25278. * @returns the cloned material
  25279. */
  25280. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25281. /**
  25282. * Serializes the materials into a JSON representation.
  25283. * @returns the JSON representation
  25284. */
  25285. serialize(): any;
  25286. /**
  25287. * Dispose the material and release its associated resources
  25288. * @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)
  25289. * @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)
  25290. * @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)
  25291. */
  25292. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25293. /**
  25294. * Creates a MultiMaterial from parsed MultiMaterial data.
  25295. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25296. * @param scene defines the hosting scene
  25297. * @returns a new MultiMaterial
  25298. */
  25299. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25300. }
  25301. }
  25302. declare module "babylonjs/Meshes/subMesh" {
  25303. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25304. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25305. import { Engine } from "babylonjs/Engines/engine";
  25306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25307. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25308. import { Effect } from "babylonjs/Materials/effect";
  25309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25310. import { Plane } from "babylonjs/Maths/math.plane";
  25311. import { Collider } from "babylonjs/Collisions/collider";
  25312. import { Material } from "babylonjs/Materials/material";
  25313. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25315. import { Mesh } from "babylonjs/Meshes/mesh";
  25316. import { Ray } from "babylonjs/Culling/ray";
  25317. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25318. /**
  25319. * Defines a subdivision inside a mesh
  25320. */
  25321. export class SubMesh implements ICullable {
  25322. /** the material index to use */
  25323. materialIndex: number;
  25324. /** vertex index start */
  25325. verticesStart: number;
  25326. /** vertices count */
  25327. verticesCount: number;
  25328. /** index start */
  25329. indexStart: number;
  25330. /** indices count */
  25331. indexCount: number;
  25332. /** @hidden */
  25333. _materialDefines: Nullable<MaterialDefines>;
  25334. /** @hidden */
  25335. _materialEffect: Nullable<Effect>;
  25336. /** @hidden */
  25337. _effectOverride: Nullable<Effect>;
  25338. /**
  25339. * Gets material defines used by the effect associated to the sub mesh
  25340. */
  25341. get materialDefines(): Nullable<MaterialDefines>;
  25342. /**
  25343. * Sets material defines used by the effect associated to the sub mesh
  25344. */
  25345. set materialDefines(defines: Nullable<MaterialDefines>);
  25346. /**
  25347. * Gets associated effect
  25348. */
  25349. get effect(): Nullable<Effect>;
  25350. /**
  25351. * Sets associated effect (effect used to render this submesh)
  25352. * @param effect defines the effect to associate with
  25353. * @param defines defines the set of defines used to compile this effect
  25354. */
  25355. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25356. /** @hidden */
  25357. _linesIndexCount: number;
  25358. private _mesh;
  25359. private _renderingMesh;
  25360. private _boundingInfo;
  25361. private _linesIndexBuffer;
  25362. /** @hidden */
  25363. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25364. /** @hidden */
  25365. _trianglePlanes: Plane[];
  25366. /** @hidden */
  25367. _lastColliderTransformMatrix: Nullable<Matrix>;
  25368. /** @hidden */
  25369. _renderId: number;
  25370. /** @hidden */
  25371. _alphaIndex: number;
  25372. /** @hidden */
  25373. _distanceToCamera: number;
  25374. /** @hidden */
  25375. _id: number;
  25376. private _currentMaterial;
  25377. /**
  25378. * Add a new submesh to a mesh
  25379. * @param materialIndex defines the material index to use
  25380. * @param verticesStart defines vertex index start
  25381. * @param verticesCount defines vertices count
  25382. * @param indexStart defines index start
  25383. * @param indexCount defines indices count
  25384. * @param mesh defines the parent mesh
  25385. * @param renderingMesh defines an optional rendering mesh
  25386. * @param createBoundingBox defines if bounding box should be created for this submesh
  25387. * @returns the new submesh
  25388. */
  25389. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25390. /**
  25391. * Creates a new submesh
  25392. * @param materialIndex defines the material index to use
  25393. * @param verticesStart defines vertex index start
  25394. * @param verticesCount defines vertices count
  25395. * @param indexStart defines index start
  25396. * @param indexCount defines indices count
  25397. * @param mesh defines the parent mesh
  25398. * @param renderingMesh defines an optional rendering mesh
  25399. * @param createBoundingBox defines if bounding box should be created for this submesh
  25400. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25401. */
  25402. constructor(
  25403. /** the material index to use */
  25404. materialIndex: number,
  25405. /** vertex index start */
  25406. verticesStart: number,
  25407. /** vertices count */
  25408. verticesCount: number,
  25409. /** index start */
  25410. indexStart: number,
  25411. /** indices count */
  25412. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25413. /**
  25414. * Returns true if this submesh covers the entire parent mesh
  25415. * @ignorenaming
  25416. */
  25417. get IsGlobal(): boolean;
  25418. /**
  25419. * Returns the submesh BoudingInfo object
  25420. * @returns current bounding info (or mesh's one if the submesh is global)
  25421. */
  25422. getBoundingInfo(): BoundingInfo;
  25423. /**
  25424. * Sets the submesh BoundingInfo
  25425. * @param boundingInfo defines the new bounding info to use
  25426. * @returns the SubMesh
  25427. */
  25428. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25429. /**
  25430. * Returns the mesh of the current submesh
  25431. * @return the parent mesh
  25432. */
  25433. getMesh(): AbstractMesh;
  25434. /**
  25435. * Returns the rendering mesh of the submesh
  25436. * @returns the rendering mesh (could be different from parent mesh)
  25437. */
  25438. getRenderingMesh(): Mesh;
  25439. /**
  25440. * Returns the replacement mesh of the submesh
  25441. * @returns the replacement mesh (could be different from parent mesh)
  25442. */
  25443. getReplacementMesh(): Nullable<AbstractMesh>;
  25444. /**
  25445. * Returns the effective mesh of the submesh
  25446. * @returns the effective mesh (could be different from parent mesh)
  25447. */
  25448. getEffectiveMesh(): AbstractMesh;
  25449. /**
  25450. * Returns the submesh material
  25451. * @returns null or the current material
  25452. */
  25453. getMaterial(): Nullable<Material>;
  25454. /**
  25455. * Sets a new updated BoundingInfo object to the submesh
  25456. * @param data defines an optional position array to use to determine the bounding info
  25457. * @returns the SubMesh
  25458. */
  25459. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25460. /** @hidden */
  25461. _checkCollision(collider: Collider): boolean;
  25462. /**
  25463. * Updates the submesh BoundingInfo
  25464. * @param world defines the world matrix to use to update the bounding info
  25465. * @returns the submesh
  25466. */
  25467. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25468. /**
  25469. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25470. * @param frustumPlanes defines the frustum planes
  25471. * @returns true if the submesh is intersecting with the frustum
  25472. */
  25473. isInFrustum(frustumPlanes: Plane[]): boolean;
  25474. /**
  25475. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25476. * @param frustumPlanes defines the frustum planes
  25477. * @returns true if the submesh is inside the frustum
  25478. */
  25479. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25480. /**
  25481. * Renders the submesh
  25482. * @param enableAlphaMode defines if alpha needs to be used
  25483. * @returns the submesh
  25484. */
  25485. render(enableAlphaMode: boolean): SubMesh;
  25486. /**
  25487. * @hidden
  25488. */
  25489. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25490. /**
  25491. * Checks if the submesh intersects with a ray
  25492. * @param ray defines the ray to test
  25493. * @returns true is the passed ray intersects the submesh bounding box
  25494. */
  25495. canIntersects(ray: Ray): boolean;
  25496. /**
  25497. * Intersects current submesh with a ray
  25498. * @param ray defines the ray to test
  25499. * @param positions defines mesh's positions array
  25500. * @param indices defines mesh's indices array
  25501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25503. * @returns intersection info or null if no intersection
  25504. */
  25505. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25506. /** @hidden */
  25507. private _intersectLines;
  25508. /** @hidden */
  25509. private _intersectUnIndexedLines;
  25510. /** @hidden */
  25511. private _intersectTriangles;
  25512. /** @hidden */
  25513. private _intersectUnIndexedTriangles;
  25514. /** @hidden */
  25515. _rebuild(): void;
  25516. /**
  25517. * Creates a new submesh from the passed mesh
  25518. * @param newMesh defines the new hosting mesh
  25519. * @param newRenderingMesh defines an optional rendering mesh
  25520. * @returns the new submesh
  25521. */
  25522. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25523. /**
  25524. * Release associated resources
  25525. */
  25526. dispose(): void;
  25527. /**
  25528. * Gets the class name
  25529. * @returns the string "SubMesh".
  25530. */
  25531. getClassName(): string;
  25532. /**
  25533. * Creates a new submesh from indices data
  25534. * @param materialIndex the index of the main mesh material
  25535. * @param startIndex the index where to start the copy in the mesh indices array
  25536. * @param indexCount the number of indices to copy then from the startIndex
  25537. * @param mesh the main mesh to create the submesh from
  25538. * @param renderingMesh the optional rendering mesh
  25539. * @returns a new submesh
  25540. */
  25541. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25542. }
  25543. }
  25544. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25545. /**
  25546. * Class used to represent data loading progression
  25547. */
  25548. export class SceneLoaderFlags {
  25549. private static _ForceFullSceneLoadingForIncremental;
  25550. private static _ShowLoadingScreen;
  25551. private static _CleanBoneMatrixWeights;
  25552. private static _loggingLevel;
  25553. /**
  25554. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25555. */
  25556. static get ForceFullSceneLoadingForIncremental(): boolean;
  25557. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25558. /**
  25559. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25560. */
  25561. static get ShowLoadingScreen(): boolean;
  25562. static set ShowLoadingScreen(value: boolean);
  25563. /**
  25564. * Defines the current logging level (while loading the scene)
  25565. * @ignorenaming
  25566. */
  25567. static get loggingLevel(): number;
  25568. static set loggingLevel(value: number);
  25569. /**
  25570. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25571. */
  25572. static get CleanBoneMatrixWeights(): boolean;
  25573. static set CleanBoneMatrixWeights(value: boolean);
  25574. }
  25575. }
  25576. declare module "babylonjs/Meshes/geometry" {
  25577. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25578. import { Scene } from "babylonjs/scene";
  25579. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25580. import { Engine } from "babylonjs/Engines/engine";
  25581. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25582. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25583. import { Effect } from "babylonjs/Materials/effect";
  25584. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25585. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25586. import { Mesh } from "babylonjs/Meshes/mesh";
  25587. /**
  25588. * Class used to store geometry data (vertex buffers + index buffer)
  25589. */
  25590. export class Geometry implements IGetSetVerticesData {
  25591. /**
  25592. * Gets or sets the ID of the geometry
  25593. */
  25594. id: string;
  25595. /**
  25596. * Gets or sets the unique ID of the geometry
  25597. */
  25598. uniqueId: number;
  25599. /**
  25600. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25601. */
  25602. delayLoadState: number;
  25603. /**
  25604. * Gets the file containing the data to load when running in delay load state
  25605. */
  25606. delayLoadingFile: Nullable<string>;
  25607. /**
  25608. * Callback called when the geometry is updated
  25609. */
  25610. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25611. private _scene;
  25612. private _engine;
  25613. private _meshes;
  25614. private _totalVertices;
  25615. /** @hidden */
  25616. _indices: IndicesArray;
  25617. /** @hidden */
  25618. _vertexBuffers: {
  25619. [key: string]: VertexBuffer;
  25620. };
  25621. private _isDisposed;
  25622. private _extend;
  25623. private _boundingBias;
  25624. /** @hidden */
  25625. _delayInfo: Array<string>;
  25626. private _indexBuffer;
  25627. private _indexBufferIsUpdatable;
  25628. /** @hidden */
  25629. _boundingInfo: Nullable<BoundingInfo>;
  25630. /** @hidden */
  25631. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25632. /** @hidden */
  25633. _softwareSkinningFrameId: number;
  25634. private _vertexArrayObjects;
  25635. private _updatable;
  25636. /** @hidden */
  25637. _positions: Nullable<Vector3[]>;
  25638. /**
  25639. * 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
  25640. */
  25641. get boundingBias(): Vector2;
  25642. /**
  25643. * 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
  25644. */
  25645. set boundingBias(value: Vector2);
  25646. /**
  25647. * Static function used to attach a new empty geometry to a mesh
  25648. * @param mesh defines the mesh to attach the geometry to
  25649. * @returns the new Geometry
  25650. */
  25651. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25652. /** Get the list of meshes using this geometry */
  25653. get meshes(): Mesh[];
  25654. /**
  25655. * Creates a new geometry
  25656. * @param id defines the unique ID
  25657. * @param scene defines the hosting scene
  25658. * @param vertexData defines the VertexData used to get geometry data
  25659. * @param updatable defines if geometry must be updatable (false by default)
  25660. * @param mesh defines the mesh that will be associated with the geometry
  25661. */
  25662. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25663. /**
  25664. * Gets the current extend of the geometry
  25665. */
  25666. get extend(): {
  25667. minimum: Vector3;
  25668. maximum: Vector3;
  25669. };
  25670. /**
  25671. * Gets the hosting scene
  25672. * @returns the hosting Scene
  25673. */
  25674. getScene(): Scene;
  25675. /**
  25676. * Gets the hosting engine
  25677. * @returns the hosting Engine
  25678. */
  25679. getEngine(): Engine;
  25680. /**
  25681. * Defines if the geometry is ready to use
  25682. * @returns true if the geometry is ready to be used
  25683. */
  25684. isReady(): boolean;
  25685. /**
  25686. * Gets a value indicating that the geometry should not be serialized
  25687. */
  25688. get doNotSerialize(): boolean;
  25689. /** @hidden */
  25690. _rebuild(): void;
  25691. /**
  25692. * Affects all geometry data in one call
  25693. * @param vertexData defines the geometry data
  25694. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25695. */
  25696. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25697. /**
  25698. * Set specific vertex data
  25699. * @param kind defines the data kind (Position, normal, etc...)
  25700. * @param data defines the vertex data to use
  25701. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25702. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25703. */
  25704. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25705. /**
  25706. * Removes a specific vertex data
  25707. * @param kind defines the data kind (Position, normal, etc...)
  25708. */
  25709. removeVerticesData(kind: string): void;
  25710. /**
  25711. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25712. * @param buffer defines the vertex buffer to use
  25713. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25714. */
  25715. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25716. /**
  25717. * Update a specific vertex buffer
  25718. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25719. * It will do nothing if the buffer is not updatable
  25720. * @param kind defines the data kind (Position, normal, etc...)
  25721. * @param data defines the data to use
  25722. * @param offset defines the offset in the target buffer where to store the data
  25723. * @param useBytes set to true if the offset is in bytes
  25724. */
  25725. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25726. /**
  25727. * Update a specific vertex buffer
  25728. * This function will create a new buffer if the current one is not updatable
  25729. * @param kind defines the data kind (Position, normal, etc...)
  25730. * @param data defines the data to use
  25731. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25732. */
  25733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25734. private _updateBoundingInfo;
  25735. /** @hidden */
  25736. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25737. /**
  25738. * Gets total number of vertices
  25739. * @returns the total number of vertices
  25740. */
  25741. getTotalVertices(): number;
  25742. /**
  25743. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25744. * @param kind defines the data kind (Position, normal, etc...)
  25745. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25747. * @returns a float array containing vertex data
  25748. */
  25749. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25750. /**
  25751. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25752. * @param kind defines the data kind (Position, normal, etc...)
  25753. * @returns true if the vertex buffer with the specified kind is updatable
  25754. */
  25755. isVertexBufferUpdatable(kind: string): boolean;
  25756. /**
  25757. * Gets a specific vertex buffer
  25758. * @param kind defines the data kind (Position, normal, etc...)
  25759. * @returns a VertexBuffer
  25760. */
  25761. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25762. /**
  25763. * Returns all vertex buffers
  25764. * @return an object holding all vertex buffers indexed by kind
  25765. */
  25766. getVertexBuffers(): Nullable<{
  25767. [key: string]: VertexBuffer;
  25768. }>;
  25769. /**
  25770. * Gets a boolean indicating if specific vertex buffer is present
  25771. * @param kind defines the data kind (Position, normal, etc...)
  25772. * @returns true if data is present
  25773. */
  25774. isVerticesDataPresent(kind: string): boolean;
  25775. /**
  25776. * Gets a list of all attached data kinds (Position, normal, etc...)
  25777. * @returns a list of string containing all kinds
  25778. */
  25779. getVerticesDataKinds(): string[];
  25780. /**
  25781. * Update index buffer
  25782. * @param indices defines the indices to store in the index buffer
  25783. * @param offset defines the offset in the target buffer where to store the data
  25784. * @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)
  25785. */
  25786. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25787. /**
  25788. * Creates a new index buffer
  25789. * @param indices defines the indices to store in the index buffer
  25790. * @param totalVertices defines the total number of vertices (could be null)
  25791. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25792. */
  25793. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25794. /**
  25795. * Return the total number of indices
  25796. * @returns the total number of indices
  25797. */
  25798. getTotalIndices(): number;
  25799. /**
  25800. * Gets the index buffer array
  25801. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25802. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25803. * @returns the index buffer array
  25804. */
  25805. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25806. /**
  25807. * Gets the index buffer
  25808. * @return the index buffer
  25809. */
  25810. getIndexBuffer(): Nullable<DataBuffer>;
  25811. /** @hidden */
  25812. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25813. /**
  25814. * Release the associated resources for a specific mesh
  25815. * @param mesh defines the source mesh
  25816. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25817. */
  25818. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25819. /**
  25820. * Apply current geometry to a given mesh
  25821. * @param mesh defines the mesh to apply geometry to
  25822. */
  25823. applyToMesh(mesh: Mesh): void;
  25824. private _updateExtend;
  25825. private _applyToMesh;
  25826. private notifyUpdate;
  25827. /**
  25828. * Load the geometry if it was flagged as delay loaded
  25829. * @param scene defines the hosting scene
  25830. * @param onLoaded defines a callback called when the geometry is loaded
  25831. */
  25832. load(scene: Scene, onLoaded?: () => void): void;
  25833. private _queueLoad;
  25834. /**
  25835. * Invert the geometry to move from a right handed system to a left handed one.
  25836. */
  25837. toLeftHanded(): void;
  25838. /** @hidden */
  25839. _resetPointsArrayCache(): void;
  25840. /** @hidden */
  25841. _generatePointsArray(): boolean;
  25842. /**
  25843. * Gets a value indicating if the geometry is disposed
  25844. * @returns true if the geometry was disposed
  25845. */
  25846. isDisposed(): boolean;
  25847. private _disposeVertexArrayObjects;
  25848. /**
  25849. * Free all associated resources
  25850. */
  25851. dispose(): void;
  25852. /**
  25853. * Clone the current geometry into a new geometry
  25854. * @param id defines the unique ID of the new geometry
  25855. * @returns a new geometry object
  25856. */
  25857. copy(id: string): Geometry;
  25858. /**
  25859. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25860. * @return a JSON representation of the current geometry data (without the vertices data)
  25861. */
  25862. serialize(): any;
  25863. private toNumberArray;
  25864. /**
  25865. * Serialize all vertices data into a JSON oject
  25866. * @returns a JSON representation of the current geometry data
  25867. */
  25868. serializeVerticeData(): any;
  25869. /**
  25870. * Extracts a clone of a mesh geometry
  25871. * @param mesh defines the source mesh
  25872. * @param id defines the unique ID of the new geometry object
  25873. * @returns the new geometry object
  25874. */
  25875. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25876. /**
  25877. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25878. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25879. * Be aware Math.random() could cause collisions, but:
  25880. * "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"
  25881. * @returns a string containing a new GUID
  25882. */
  25883. static RandomId(): string;
  25884. /** @hidden */
  25885. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25886. private static _CleanMatricesWeights;
  25887. /**
  25888. * Create a new geometry from persisted data (Using .babylon file format)
  25889. * @param parsedVertexData defines the persisted data
  25890. * @param scene defines the hosting scene
  25891. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25892. * @returns the new geometry object
  25893. */
  25894. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25895. }
  25896. }
  25897. declare module "babylonjs/Meshes/mesh.vertexData" {
  25898. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25899. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25901. import { Geometry } from "babylonjs/Meshes/geometry";
  25902. import { Mesh } from "babylonjs/Meshes/mesh";
  25903. /**
  25904. * Define an interface for all classes that will get and set the data on vertices
  25905. */
  25906. export interface IGetSetVerticesData {
  25907. /**
  25908. * Gets a boolean indicating if specific vertex data is present
  25909. * @param kind defines the vertex data kind to use
  25910. * @returns true is data kind is present
  25911. */
  25912. isVerticesDataPresent(kind: string): boolean;
  25913. /**
  25914. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25915. * @param kind defines the data kind (Position, normal, etc...)
  25916. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25917. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25918. * @returns a float array containing vertex data
  25919. */
  25920. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25921. /**
  25922. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25923. * @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.
  25924. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25925. * @returns the indices array or an empty array if the mesh has no geometry
  25926. */
  25927. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25928. /**
  25929. * Set specific vertex data
  25930. * @param kind defines the data kind (Position, normal, etc...)
  25931. * @param data defines the vertex data to use
  25932. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25933. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25934. */
  25935. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25936. /**
  25937. * Update a specific associated vertex buffer
  25938. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25939. * - VertexBuffer.PositionKind
  25940. * - VertexBuffer.UVKind
  25941. * - VertexBuffer.UV2Kind
  25942. * - VertexBuffer.UV3Kind
  25943. * - VertexBuffer.UV4Kind
  25944. * - VertexBuffer.UV5Kind
  25945. * - VertexBuffer.UV6Kind
  25946. * - VertexBuffer.ColorKind
  25947. * - VertexBuffer.MatricesIndicesKind
  25948. * - VertexBuffer.MatricesIndicesExtraKind
  25949. * - VertexBuffer.MatricesWeightsKind
  25950. * - VertexBuffer.MatricesWeightsExtraKind
  25951. * @param data defines the data source
  25952. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25953. * @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)
  25954. */
  25955. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25956. /**
  25957. * Creates a new index buffer
  25958. * @param indices defines the indices to store in the index buffer
  25959. * @param totalVertices defines the total number of vertices (could be null)
  25960. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25961. */
  25962. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25963. }
  25964. /**
  25965. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25966. */
  25967. export class VertexData {
  25968. /**
  25969. * Mesh side orientation : usually the external or front surface
  25970. */
  25971. static readonly FRONTSIDE: number;
  25972. /**
  25973. * Mesh side orientation : usually the internal or back surface
  25974. */
  25975. static readonly BACKSIDE: number;
  25976. /**
  25977. * Mesh side orientation : both internal and external or front and back surfaces
  25978. */
  25979. static readonly DOUBLESIDE: number;
  25980. /**
  25981. * Mesh side orientation : by default, `FRONTSIDE`
  25982. */
  25983. static readonly DEFAULTSIDE: number;
  25984. /**
  25985. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25986. */
  25987. positions: Nullable<FloatArray>;
  25988. /**
  25989. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25990. */
  25991. normals: Nullable<FloatArray>;
  25992. /**
  25993. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25994. */
  25995. tangents: Nullable<FloatArray>;
  25996. /**
  25997. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25998. */
  25999. uvs: Nullable<FloatArray>;
  26000. /**
  26001. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26002. */
  26003. uvs2: Nullable<FloatArray>;
  26004. /**
  26005. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26006. */
  26007. uvs3: Nullable<FloatArray>;
  26008. /**
  26009. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26010. */
  26011. uvs4: Nullable<FloatArray>;
  26012. /**
  26013. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26014. */
  26015. uvs5: Nullable<FloatArray>;
  26016. /**
  26017. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26018. */
  26019. uvs6: Nullable<FloatArray>;
  26020. /**
  26021. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26022. */
  26023. colors: Nullable<FloatArray>;
  26024. /**
  26025. * 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).
  26026. */
  26027. matricesIndices: Nullable<FloatArray>;
  26028. /**
  26029. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26030. */
  26031. matricesWeights: Nullable<FloatArray>;
  26032. /**
  26033. * An array extending the number of possible indices
  26034. */
  26035. matricesIndicesExtra: Nullable<FloatArray>;
  26036. /**
  26037. * An array extending the number of possible weights when the number of indices is extended
  26038. */
  26039. matricesWeightsExtra: Nullable<FloatArray>;
  26040. /**
  26041. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26042. */
  26043. indices: Nullable<IndicesArray>;
  26044. /**
  26045. * Uses the passed data array to set the set the values for the specified kind of data
  26046. * @param data a linear array of floating numbers
  26047. * @param kind the type of data that is being set, eg positions, colors etc
  26048. */
  26049. set(data: FloatArray, kind: string): void;
  26050. /**
  26051. * Associates the vertexData to the passed Mesh.
  26052. * Sets it as updatable or not (default `false`)
  26053. * @param mesh the mesh the vertexData is applied to
  26054. * @param updatable when used and having the value true allows new data to update the vertexData
  26055. * @returns the VertexData
  26056. */
  26057. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26058. /**
  26059. * Associates the vertexData to the passed Geometry.
  26060. * Sets it as updatable or not (default `false`)
  26061. * @param geometry the geometry the vertexData is applied to
  26062. * @param updatable when used and having the value true allows new data to update the vertexData
  26063. * @returns VertexData
  26064. */
  26065. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26066. /**
  26067. * Updates the associated mesh
  26068. * @param mesh the mesh to be updated
  26069. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26070. * @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
  26071. * @returns VertexData
  26072. */
  26073. updateMesh(mesh: Mesh): VertexData;
  26074. /**
  26075. * Updates the associated geometry
  26076. * @param geometry the geometry to be updated
  26077. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26078. * @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
  26079. * @returns VertexData.
  26080. */
  26081. updateGeometry(geometry: Geometry): VertexData;
  26082. private _applyTo;
  26083. private _update;
  26084. /**
  26085. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26086. * @param matrix the transforming matrix
  26087. * @returns the VertexData
  26088. */
  26089. transform(matrix: Matrix): VertexData;
  26090. /**
  26091. * Merges the passed VertexData into the current one
  26092. * @param other the VertexData to be merged into the current one
  26093. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26094. * @returns the modified VertexData
  26095. */
  26096. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26097. private _mergeElement;
  26098. private _validate;
  26099. /**
  26100. * Serializes the VertexData
  26101. * @returns a serialized object
  26102. */
  26103. serialize(): any;
  26104. /**
  26105. * Extracts the vertexData from a mesh
  26106. * @param mesh the mesh from which to extract the VertexData
  26107. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26108. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26109. * @returns the object VertexData associated to the passed mesh
  26110. */
  26111. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26112. /**
  26113. * Extracts the vertexData from the geometry
  26114. * @param geometry the geometry from which to extract the VertexData
  26115. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26116. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26117. * @returns the object VertexData associated to the passed mesh
  26118. */
  26119. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26120. private static _ExtractFrom;
  26121. /**
  26122. * Creates the VertexData for a Ribbon
  26123. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26124. * * pathArray array of paths, each of which an array of successive Vector3
  26125. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26126. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26127. * * 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
  26128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26129. * * 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)
  26130. * * 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)
  26131. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26132. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26133. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26134. * @returns the VertexData of the ribbon
  26135. */
  26136. static CreateRibbon(options: {
  26137. pathArray: Vector3[][];
  26138. closeArray?: boolean;
  26139. closePath?: boolean;
  26140. offset?: number;
  26141. sideOrientation?: number;
  26142. frontUVs?: Vector4;
  26143. backUVs?: Vector4;
  26144. invertUV?: boolean;
  26145. uvs?: Vector2[];
  26146. colors?: Color4[];
  26147. }): VertexData;
  26148. /**
  26149. * Creates the VertexData for a box
  26150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26151. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26152. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26153. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26154. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26155. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26156. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26158. * * 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)
  26159. * * 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)
  26160. * @returns the VertexData of the box
  26161. */
  26162. static CreateBox(options: {
  26163. size?: number;
  26164. width?: number;
  26165. height?: number;
  26166. depth?: number;
  26167. faceUV?: Vector4[];
  26168. faceColors?: Color4[];
  26169. sideOrientation?: number;
  26170. frontUVs?: Vector4;
  26171. backUVs?: Vector4;
  26172. }): VertexData;
  26173. /**
  26174. * Creates the VertexData for a tiled box
  26175. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26176. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26177. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26178. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26180. * @returns the VertexData of the box
  26181. */
  26182. static CreateTiledBox(options: {
  26183. pattern?: number;
  26184. width?: number;
  26185. height?: number;
  26186. depth?: number;
  26187. tileSize?: number;
  26188. tileWidth?: number;
  26189. tileHeight?: number;
  26190. alignHorizontal?: number;
  26191. alignVertical?: number;
  26192. faceUV?: Vector4[];
  26193. faceColors?: Color4[];
  26194. sideOrientation?: number;
  26195. }): VertexData;
  26196. /**
  26197. * Creates the VertexData for a tiled plane
  26198. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26199. * * pattern a limited pattern arrangement depending on the number
  26200. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26201. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26202. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26204. * * 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)
  26205. * * 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)
  26206. * @returns the VertexData of the tiled plane
  26207. */
  26208. static CreateTiledPlane(options: {
  26209. pattern?: number;
  26210. tileSize?: number;
  26211. tileWidth?: number;
  26212. tileHeight?: number;
  26213. size?: number;
  26214. width?: number;
  26215. height?: number;
  26216. alignHorizontal?: number;
  26217. alignVertical?: number;
  26218. sideOrientation?: number;
  26219. frontUVs?: Vector4;
  26220. backUVs?: Vector4;
  26221. }): VertexData;
  26222. /**
  26223. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26225. * * segments sets the number of horizontal strips optional, default 32
  26226. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26227. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26228. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26229. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26230. * * 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
  26231. * * 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
  26232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26233. * * 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)
  26234. * * 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)
  26235. * @returns the VertexData of the ellipsoid
  26236. */
  26237. static CreateSphere(options: {
  26238. segments?: number;
  26239. diameter?: number;
  26240. diameterX?: number;
  26241. diameterY?: number;
  26242. diameterZ?: number;
  26243. arc?: number;
  26244. slice?: number;
  26245. sideOrientation?: number;
  26246. frontUVs?: Vector4;
  26247. backUVs?: Vector4;
  26248. }): VertexData;
  26249. /**
  26250. * Creates the VertexData for a cylinder, cone or prism
  26251. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26252. * * height sets the height (y direction) of the cylinder, optional, default 2
  26253. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26254. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26255. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26256. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26257. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26258. * * 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
  26259. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26260. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26261. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26262. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26264. * * 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)
  26265. * * 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)
  26266. * @returns the VertexData of the cylinder, cone or prism
  26267. */
  26268. static CreateCylinder(options: {
  26269. height?: number;
  26270. diameterTop?: number;
  26271. diameterBottom?: number;
  26272. diameter?: number;
  26273. tessellation?: number;
  26274. subdivisions?: number;
  26275. arc?: number;
  26276. faceColors?: Color4[];
  26277. faceUV?: Vector4[];
  26278. hasRings?: boolean;
  26279. enclose?: boolean;
  26280. sideOrientation?: number;
  26281. frontUVs?: Vector4;
  26282. backUVs?: Vector4;
  26283. }): VertexData;
  26284. /**
  26285. * Creates the VertexData for a torus
  26286. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26287. * * diameter the diameter of the torus, optional default 1
  26288. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26289. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26291. * * 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)
  26292. * * 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)
  26293. * @returns the VertexData of the torus
  26294. */
  26295. static CreateTorus(options: {
  26296. diameter?: number;
  26297. thickness?: number;
  26298. tessellation?: number;
  26299. sideOrientation?: number;
  26300. frontUVs?: Vector4;
  26301. backUVs?: Vector4;
  26302. }): VertexData;
  26303. /**
  26304. * Creates the VertexData of the LineSystem
  26305. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26306. * - lines an array of lines, each line being an array of successive Vector3
  26307. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26308. * @returns the VertexData of the LineSystem
  26309. */
  26310. static CreateLineSystem(options: {
  26311. lines: Vector3[][];
  26312. colors?: Nullable<Color4[][]>;
  26313. }): VertexData;
  26314. /**
  26315. * Create the VertexData for a DashedLines
  26316. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26317. * - points an array successive Vector3
  26318. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26319. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26320. * - dashNb the intended total number of dashes, optional, default 200
  26321. * @returns the VertexData for the DashedLines
  26322. */
  26323. static CreateDashedLines(options: {
  26324. points: Vector3[];
  26325. dashSize?: number;
  26326. gapSize?: number;
  26327. dashNb?: number;
  26328. }): VertexData;
  26329. /**
  26330. * Creates the VertexData for a Ground
  26331. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26332. * - width the width (x direction) of the ground, optional, default 1
  26333. * - height the height (z direction) of the ground, optional, default 1
  26334. * - subdivisions the number of subdivisions per side, optional, default 1
  26335. * @returns the VertexData of the Ground
  26336. */
  26337. static CreateGround(options: {
  26338. width?: number;
  26339. height?: number;
  26340. subdivisions?: number;
  26341. subdivisionsX?: number;
  26342. subdivisionsY?: number;
  26343. }): VertexData;
  26344. /**
  26345. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26347. * * xmin the ground minimum X coordinate, optional, default -1
  26348. * * zmin the ground minimum Z coordinate, optional, default -1
  26349. * * xmax the ground maximum X coordinate, optional, default 1
  26350. * * zmax the ground maximum Z coordinate, optional, default 1
  26351. * * 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}
  26352. * * 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}
  26353. * @returns the VertexData of the TiledGround
  26354. */
  26355. static CreateTiledGround(options: {
  26356. xmin: number;
  26357. zmin: number;
  26358. xmax: number;
  26359. zmax: number;
  26360. subdivisions?: {
  26361. w: number;
  26362. h: number;
  26363. };
  26364. precision?: {
  26365. w: number;
  26366. h: number;
  26367. };
  26368. }): VertexData;
  26369. /**
  26370. * Creates the VertexData of the Ground designed from a heightmap
  26371. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26372. * * width the width (x direction) of the ground
  26373. * * height the height (z direction) of the ground
  26374. * * subdivisions the number of subdivisions per side
  26375. * * minHeight the minimum altitude on the ground, optional, default 0
  26376. * * maxHeight the maximum altitude on the ground, optional default 1
  26377. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26378. * * buffer the array holding the image color data
  26379. * * bufferWidth the width of image
  26380. * * bufferHeight the height of image
  26381. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26382. * @returns the VertexData of the Ground designed from a heightmap
  26383. */
  26384. static CreateGroundFromHeightMap(options: {
  26385. width: number;
  26386. height: number;
  26387. subdivisions: number;
  26388. minHeight: number;
  26389. maxHeight: number;
  26390. colorFilter: Color3;
  26391. buffer: Uint8Array;
  26392. bufferWidth: number;
  26393. bufferHeight: number;
  26394. alphaFilter: number;
  26395. }): VertexData;
  26396. /**
  26397. * Creates the VertexData for a Plane
  26398. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26399. * * size sets the width and height of the plane to the value of size, optional default 1
  26400. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26401. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26403. * * 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)
  26404. * * 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)
  26405. * @returns the VertexData of the box
  26406. */
  26407. static CreatePlane(options: {
  26408. size?: number;
  26409. width?: number;
  26410. height?: number;
  26411. sideOrientation?: number;
  26412. frontUVs?: Vector4;
  26413. backUVs?: Vector4;
  26414. }): VertexData;
  26415. /**
  26416. * Creates the VertexData of the Disc or regular Polygon
  26417. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26418. * * radius the radius of the disc, optional default 0.5
  26419. * * tessellation the number of polygon sides, optional, default 64
  26420. * * 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
  26421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26422. * * 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)
  26423. * * 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)
  26424. * @returns the VertexData of the box
  26425. */
  26426. static CreateDisc(options: {
  26427. radius?: number;
  26428. tessellation?: number;
  26429. arc?: number;
  26430. sideOrientation?: number;
  26431. frontUVs?: Vector4;
  26432. backUVs?: Vector4;
  26433. }): VertexData;
  26434. /**
  26435. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26436. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26437. * @param polygon a mesh built from polygonTriangulation.build()
  26438. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26439. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26440. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26441. * @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)
  26442. * @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)
  26443. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26444. * @returns the VertexData of the Polygon
  26445. */
  26446. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26447. /**
  26448. * Creates the VertexData of the IcoSphere
  26449. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26450. * * radius the radius of the IcoSphere, optional default 1
  26451. * * radiusX allows stretching in the x direction, optional, default radius
  26452. * * radiusY allows stretching in the y direction, optional, default radius
  26453. * * radiusZ allows stretching in the z direction, optional, default radius
  26454. * * flat when true creates a flat shaded mesh, optional, default true
  26455. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26457. * * 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)
  26458. * * 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)
  26459. * @returns the VertexData of the IcoSphere
  26460. */
  26461. static CreateIcoSphere(options: {
  26462. radius?: number;
  26463. radiusX?: number;
  26464. radiusY?: number;
  26465. radiusZ?: number;
  26466. flat?: boolean;
  26467. subdivisions?: number;
  26468. sideOrientation?: number;
  26469. frontUVs?: Vector4;
  26470. backUVs?: Vector4;
  26471. }): VertexData;
  26472. /**
  26473. * Creates the VertexData for a Polyhedron
  26474. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26475. * * type provided types are:
  26476. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26477. * * 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)
  26478. * * size the size of the IcoSphere, optional default 1
  26479. * * sizeX allows stretching in the x direction, optional, default size
  26480. * * sizeY allows stretching in the y direction, optional, default size
  26481. * * sizeZ allows stretching in the z direction, optional, default size
  26482. * * 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
  26483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26484. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26485. * * flat when true creates a flat shaded mesh, optional, default true
  26486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26488. * * 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)
  26489. * * 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)
  26490. * @returns the VertexData of the Polyhedron
  26491. */
  26492. static CreatePolyhedron(options: {
  26493. type?: number;
  26494. size?: number;
  26495. sizeX?: number;
  26496. sizeY?: number;
  26497. sizeZ?: number;
  26498. custom?: any;
  26499. faceUV?: Vector4[];
  26500. faceColors?: Color4[];
  26501. flat?: boolean;
  26502. sideOrientation?: number;
  26503. frontUVs?: Vector4;
  26504. backUVs?: Vector4;
  26505. }): VertexData;
  26506. /**
  26507. * Creates the VertexData for a TorusKnot
  26508. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26509. * * radius the radius of the torus knot, optional, default 2
  26510. * * tube the thickness of the tube, optional, default 0.5
  26511. * * radialSegments the number of sides on each tube segments, optional, default 32
  26512. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26513. * * p the number of windings around the z axis, optional, default 2
  26514. * * q the number of windings around the x axis, optional, default 3
  26515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26516. * * 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)
  26517. * * 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)
  26518. * @returns the VertexData of the Torus Knot
  26519. */
  26520. static CreateTorusKnot(options: {
  26521. radius?: number;
  26522. tube?: number;
  26523. radialSegments?: number;
  26524. tubularSegments?: number;
  26525. p?: number;
  26526. q?: number;
  26527. sideOrientation?: number;
  26528. frontUVs?: Vector4;
  26529. backUVs?: Vector4;
  26530. }): VertexData;
  26531. /**
  26532. * Compute normals for given positions and indices
  26533. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26534. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26535. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26536. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26537. * * facetNormals : optional array of facet normals (vector3)
  26538. * * facetPositions : optional array of facet positions (vector3)
  26539. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26540. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26541. * * bInfo : optional bounding info, required for facetPartitioning computation
  26542. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26543. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26544. * * useRightHandedSystem: optional boolean to for right handed system computation
  26545. * * depthSort : optional boolean to enable the facet depth sort computation
  26546. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26547. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26548. */
  26549. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26550. facetNormals?: any;
  26551. facetPositions?: any;
  26552. facetPartitioning?: any;
  26553. ratio?: number;
  26554. bInfo?: any;
  26555. bbSize?: Vector3;
  26556. subDiv?: any;
  26557. useRightHandedSystem?: boolean;
  26558. depthSort?: boolean;
  26559. distanceTo?: Vector3;
  26560. depthSortedFacets?: any;
  26561. }): void;
  26562. /** @hidden */
  26563. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26564. /**
  26565. * Applies VertexData created from the imported parameters to the geometry
  26566. * @param parsedVertexData the parsed data from an imported file
  26567. * @param geometry the geometry to apply the VertexData to
  26568. */
  26569. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26570. }
  26571. }
  26572. declare module "babylonjs/Morph/morphTarget" {
  26573. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26574. import { Observable } from "babylonjs/Misc/observable";
  26575. import { Nullable, FloatArray } from "babylonjs/types";
  26576. import { Scene } from "babylonjs/scene";
  26577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26578. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26579. /**
  26580. * Defines a target to use with MorphTargetManager
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26582. */
  26583. export class MorphTarget implements IAnimatable {
  26584. /** defines the name of the target */
  26585. name: string;
  26586. /**
  26587. * Gets or sets the list of animations
  26588. */
  26589. animations: import("babylonjs/Animations/animation").Animation[];
  26590. private _scene;
  26591. private _positions;
  26592. private _normals;
  26593. private _tangents;
  26594. private _uvs;
  26595. private _influence;
  26596. private _uniqueId;
  26597. /**
  26598. * Observable raised when the influence changes
  26599. */
  26600. onInfluenceChanged: Observable<boolean>;
  26601. /** @hidden */
  26602. _onDataLayoutChanged: Observable<void>;
  26603. /**
  26604. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26605. */
  26606. get influence(): number;
  26607. set influence(influence: number);
  26608. /**
  26609. * Gets or sets the id of the morph Target
  26610. */
  26611. id: string;
  26612. private _animationPropertiesOverride;
  26613. /**
  26614. * Gets or sets the animation properties override
  26615. */
  26616. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26617. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26618. /**
  26619. * Creates a new MorphTarget
  26620. * @param name defines the name of the target
  26621. * @param influence defines the influence to use
  26622. * @param scene defines the scene the morphtarget belongs to
  26623. */
  26624. constructor(
  26625. /** defines the name of the target */
  26626. name: string, influence?: number, scene?: Nullable<Scene>);
  26627. /**
  26628. * Gets the unique ID of this manager
  26629. */
  26630. get uniqueId(): number;
  26631. /**
  26632. * Gets a boolean defining if the target contains position data
  26633. */
  26634. get hasPositions(): boolean;
  26635. /**
  26636. * Gets a boolean defining if the target contains normal data
  26637. */
  26638. get hasNormals(): boolean;
  26639. /**
  26640. * Gets a boolean defining if the target contains tangent data
  26641. */
  26642. get hasTangents(): boolean;
  26643. /**
  26644. * Gets a boolean defining if the target contains texture coordinates data
  26645. */
  26646. get hasUVs(): boolean;
  26647. /**
  26648. * Affects position data to this target
  26649. * @param data defines the position data to use
  26650. */
  26651. setPositions(data: Nullable<FloatArray>): void;
  26652. /**
  26653. * Gets the position data stored in this target
  26654. * @returns a FloatArray containing the position data (or null if not present)
  26655. */
  26656. getPositions(): Nullable<FloatArray>;
  26657. /**
  26658. * Affects normal data to this target
  26659. * @param data defines the normal data to use
  26660. */
  26661. setNormals(data: Nullable<FloatArray>): void;
  26662. /**
  26663. * Gets the normal data stored in this target
  26664. * @returns a FloatArray containing the normal data (or null if not present)
  26665. */
  26666. getNormals(): Nullable<FloatArray>;
  26667. /**
  26668. * Affects tangent data to this target
  26669. * @param data defines the tangent data to use
  26670. */
  26671. setTangents(data: Nullable<FloatArray>): void;
  26672. /**
  26673. * Gets the tangent data stored in this target
  26674. * @returns a FloatArray containing the tangent data (or null if not present)
  26675. */
  26676. getTangents(): Nullable<FloatArray>;
  26677. /**
  26678. * Affects texture coordinates data to this target
  26679. * @param data defines the texture coordinates data to use
  26680. */
  26681. setUVs(data: Nullable<FloatArray>): void;
  26682. /**
  26683. * Gets the texture coordinates data stored in this target
  26684. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26685. */
  26686. getUVs(): Nullable<FloatArray>;
  26687. /**
  26688. * Clone the current target
  26689. * @returns a new MorphTarget
  26690. */
  26691. clone(): MorphTarget;
  26692. /**
  26693. * Serializes the current target into a Serialization object
  26694. * @returns the serialized object
  26695. */
  26696. serialize(): any;
  26697. /**
  26698. * Returns the string "MorphTarget"
  26699. * @returns "MorphTarget"
  26700. */
  26701. getClassName(): string;
  26702. /**
  26703. * Creates a new target from serialized data
  26704. * @param serializationObject defines the serialized data to use
  26705. * @returns a new MorphTarget
  26706. */
  26707. static Parse(serializationObject: any): MorphTarget;
  26708. /**
  26709. * Creates a MorphTarget from mesh data
  26710. * @param mesh defines the source mesh
  26711. * @param name defines the name to use for the new target
  26712. * @param influence defines the influence to attach to the target
  26713. * @returns a new MorphTarget
  26714. */
  26715. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26716. }
  26717. }
  26718. declare module "babylonjs/Morph/morphTargetManager" {
  26719. import { Nullable } from "babylonjs/types";
  26720. import { Scene } from "babylonjs/scene";
  26721. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26722. /**
  26723. * This class is used to deform meshes using morphing between different targets
  26724. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26725. */
  26726. export class MorphTargetManager {
  26727. private _targets;
  26728. private _targetInfluenceChangedObservers;
  26729. private _targetDataLayoutChangedObservers;
  26730. private _activeTargets;
  26731. private _scene;
  26732. private _influences;
  26733. private _supportsNormals;
  26734. private _supportsTangents;
  26735. private _supportsUVs;
  26736. private _vertexCount;
  26737. private _uniqueId;
  26738. private _tempInfluences;
  26739. /**
  26740. * Gets or sets a boolean indicating if normals must be morphed
  26741. */
  26742. enableNormalMorphing: boolean;
  26743. /**
  26744. * Gets or sets a boolean indicating if tangents must be morphed
  26745. */
  26746. enableTangentMorphing: boolean;
  26747. /**
  26748. * Gets or sets a boolean indicating if UV must be morphed
  26749. */
  26750. enableUVMorphing: boolean;
  26751. /**
  26752. * Creates a new MorphTargetManager
  26753. * @param scene defines the current scene
  26754. */
  26755. constructor(scene?: Nullable<Scene>);
  26756. /**
  26757. * Gets the unique ID of this manager
  26758. */
  26759. get uniqueId(): number;
  26760. /**
  26761. * Gets the number of vertices handled by this manager
  26762. */
  26763. get vertexCount(): number;
  26764. /**
  26765. * Gets a boolean indicating if this manager supports morphing of normals
  26766. */
  26767. get supportsNormals(): boolean;
  26768. /**
  26769. * Gets a boolean indicating if this manager supports morphing of tangents
  26770. */
  26771. get supportsTangents(): boolean;
  26772. /**
  26773. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26774. */
  26775. get supportsUVs(): boolean;
  26776. /**
  26777. * Gets the number of targets stored in this manager
  26778. */
  26779. get numTargets(): number;
  26780. /**
  26781. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26782. */
  26783. get numInfluencers(): number;
  26784. /**
  26785. * Gets the list of influences (one per target)
  26786. */
  26787. get influences(): Float32Array;
  26788. /**
  26789. * Gets the active target at specified index. An active target is a target with an influence > 0
  26790. * @param index defines the index to check
  26791. * @returns the requested target
  26792. */
  26793. getActiveTarget(index: number): MorphTarget;
  26794. /**
  26795. * Gets the target at specified index
  26796. * @param index defines the index to check
  26797. * @returns the requested target
  26798. */
  26799. getTarget(index: number): MorphTarget;
  26800. /**
  26801. * Add a new target to this manager
  26802. * @param target defines the target to add
  26803. */
  26804. addTarget(target: MorphTarget): void;
  26805. /**
  26806. * Removes a target from the manager
  26807. * @param target defines the target to remove
  26808. */
  26809. removeTarget(target: MorphTarget): void;
  26810. /**
  26811. * Clone the current manager
  26812. * @returns a new MorphTargetManager
  26813. */
  26814. clone(): MorphTargetManager;
  26815. /**
  26816. * Serializes the current manager into a Serialization object
  26817. * @returns the serialized object
  26818. */
  26819. serialize(): any;
  26820. private _syncActiveTargets;
  26821. /**
  26822. * Syncrhonize the targets with all the meshes using this morph target manager
  26823. */
  26824. synchronize(): void;
  26825. /**
  26826. * Creates a new MorphTargetManager from serialized data
  26827. * @param serializationObject defines the serialized data
  26828. * @param scene defines the hosting scene
  26829. * @returns the new MorphTargetManager
  26830. */
  26831. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26832. }
  26833. }
  26834. declare module "babylonjs/Meshes/meshLODLevel" {
  26835. import { Mesh } from "babylonjs/Meshes/mesh";
  26836. import { Nullable } from "babylonjs/types";
  26837. /**
  26838. * Class used to represent a specific level of detail of a mesh
  26839. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26840. */
  26841. export class MeshLODLevel {
  26842. /** Defines the distance where this level should start being displayed */
  26843. distance: number;
  26844. /** Defines the mesh to use to render this level */
  26845. mesh: Nullable<Mesh>;
  26846. /**
  26847. * Creates a new LOD level
  26848. * @param distance defines the distance where this level should star being displayed
  26849. * @param mesh defines the mesh to use to render this level
  26850. */
  26851. constructor(
  26852. /** Defines the distance where this level should start being displayed */
  26853. distance: number,
  26854. /** Defines the mesh to use to render this level */
  26855. mesh: Nullable<Mesh>);
  26856. }
  26857. }
  26858. declare module "babylonjs/Meshes/groundMesh" {
  26859. import { Scene } from "babylonjs/scene";
  26860. import { Vector3 } from "babylonjs/Maths/math.vector";
  26861. import { Mesh } from "babylonjs/Meshes/mesh";
  26862. /**
  26863. * Mesh representing the gorund
  26864. */
  26865. export class GroundMesh extends Mesh {
  26866. /** If octree should be generated */
  26867. generateOctree: boolean;
  26868. private _heightQuads;
  26869. /** @hidden */
  26870. _subdivisionsX: number;
  26871. /** @hidden */
  26872. _subdivisionsY: number;
  26873. /** @hidden */
  26874. _width: number;
  26875. /** @hidden */
  26876. _height: number;
  26877. /** @hidden */
  26878. _minX: number;
  26879. /** @hidden */
  26880. _maxX: number;
  26881. /** @hidden */
  26882. _minZ: number;
  26883. /** @hidden */
  26884. _maxZ: number;
  26885. constructor(name: string, scene: Scene);
  26886. /**
  26887. * "GroundMesh"
  26888. * @returns "GroundMesh"
  26889. */
  26890. getClassName(): string;
  26891. /**
  26892. * The minimum of x and y subdivisions
  26893. */
  26894. get subdivisions(): number;
  26895. /**
  26896. * X subdivisions
  26897. */
  26898. get subdivisionsX(): number;
  26899. /**
  26900. * Y subdivisions
  26901. */
  26902. get subdivisionsY(): number;
  26903. /**
  26904. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26905. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26906. * @param chunksCount the number of subdivisions for x and y
  26907. * @param octreeBlocksSize (Default: 32)
  26908. */
  26909. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26910. /**
  26911. * Returns a height (y) value in the Worl system :
  26912. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26913. * @param x x coordinate
  26914. * @param z z coordinate
  26915. * @returns the ground y position if (x, z) are outside the ground surface.
  26916. */
  26917. getHeightAtCoordinates(x: number, z: number): number;
  26918. /**
  26919. * Returns a normalized vector (Vector3) orthogonal to the ground
  26920. * at the ground coordinates (x, z) expressed in the World system.
  26921. * @param x x coordinate
  26922. * @param z z coordinate
  26923. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26924. */
  26925. getNormalAtCoordinates(x: number, z: number): Vector3;
  26926. /**
  26927. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26928. * at the ground coordinates (x, z) expressed in the World system.
  26929. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26930. * @param x x coordinate
  26931. * @param z z coordinate
  26932. * @param ref vector to store the result
  26933. * @returns the GroundMesh.
  26934. */
  26935. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26936. /**
  26937. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26938. * if the ground has been updated.
  26939. * This can be used in the render loop.
  26940. * @returns the GroundMesh.
  26941. */
  26942. updateCoordinateHeights(): GroundMesh;
  26943. private _getFacetAt;
  26944. private _initHeightQuads;
  26945. private _computeHeightQuads;
  26946. /**
  26947. * Serializes this ground mesh
  26948. * @param serializationObject object to write serialization to
  26949. */
  26950. serialize(serializationObject: any): void;
  26951. /**
  26952. * Parses a serialized ground mesh
  26953. * @param parsedMesh the serialized mesh
  26954. * @param scene the scene to create the ground mesh in
  26955. * @returns the created ground mesh
  26956. */
  26957. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26958. }
  26959. }
  26960. declare module "babylonjs/Physics/physicsJoint" {
  26961. import { Vector3 } from "babylonjs/Maths/math.vector";
  26962. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26963. /**
  26964. * Interface for Physics-Joint data
  26965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26966. */
  26967. export interface PhysicsJointData {
  26968. /**
  26969. * The main pivot of the joint
  26970. */
  26971. mainPivot?: Vector3;
  26972. /**
  26973. * The connected pivot of the joint
  26974. */
  26975. connectedPivot?: Vector3;
  26976. /**
  26977. * The main axis of the joint
  26978. */
  26979. mainAxis?: Vector3;
  26980. /**
  26981. * The connected axis of the joint
  26982. */
  26983. connectedAxis?: Vector3;
  26984. /**
  26985. * The collision of the joint
  26986. */
  26987. collision?: boolean;
  26988. /**
  26989. * Native Oimo/Cannon/Energy data
  26990. */
  26991. nativeParams?: any;
  26992. }
  26993. /**
  26994. * This is a holder class for the physics joint created by the physics plugin
  26995. * It holds a set of functions to control the underlying joint
  26996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26997. */
  26998. export class PhysicsJoint {
  26999. /**
  27000. * The type of the physics joint
  27001. */
  27002. type: number;
  27003. /**
  27004. * The data for the physics joint
  27005. */
  27006. jointData: PhysicsJointData;
  27007. private _physicsJoint;
  27008. protected _physicsPlugin: IPhysicsEnginePlugin;
  27009. /**
  27010. * Initializes the physics joint
  27011. * @param type The type of the physics joint
  27012. * @param jointData The data for the physics joint
  27013. */
  27014. constructor(
  27015. /**
  27016. * The type of the physics joint
  27017. */
  27018. type: number,
  27019. /**
  27020. * The data for the physics joint
  27021. */
  27022. jointData: PhysicsJointData);
  27023. /**
  27024. * Gets the physics joint
  27025. */
  27026. get physicsJoint(): any;
  27027. /**
  27028. * Sets the physics joint
  27029. */
  27030. set physicsJoint(newJoint: any);
  27031. /**
  27032. * Sets the physics plugin
  27033. */
  27034. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27035. /**
  27036. * Execute a function that is physics-plugin specific.
  27037. * @param {Function} func the function that will be executed.
  27038. * It accepts two parameters: the physics world and the physics joint
  27039. */
  27040. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27041. /**
  27042. * Distance-Joint type
  27043. */
  27044. static DistanceJoint: number;
  27045. /**
  27046. * Hinge-Joint type
  27047. */
  27048. static HingeJoint: number;
  27049. /**
  27050. * Ball-and-Socket joint type
  27051. */
  27052. static BallAndSocketJoint: number;
  27053. /**
  27054. * Wheel-Joint type
  27055. */
  27056. static WheelJoint: number;
  27057. /**
  27058. * Slider-Joint type
  27059. */
  27060. static SliderJoint: number;
  27061. /**
  27062. * Prismatic-Joint type
  27063. */
  27064. static PrismaticJoint: number;
  27065. /**
  27066. * Universal-Joint type
  27067. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27068. */
  27069. static UniversalJoint: number;
  27070. /**
  27071. * Hinge-Joint 2 type
  27072. */
  27073. static Hinge2Joint: number;
  27074. /**
  27075. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27076. */
  27077. static PointToPointJoint: number;
  27078. /**
  27079. * Spring-Joint type
  27080. */
  27081. static SpringJoint: number;
  27082. /**
  27083. * Lock-Joint type
  27084. */
  27085. static LockJoint: number;
  27086. }
  27087. /**
  27088. * A class representing a physics distance joint
  27089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27090. */
  27091. export class DistanceJoint extends PhysicsJoint {
  27092. /**
  27093. *
  27094. * @param jointData The data for the Distance-Joint
  27095. */
  27096. constructor(jointData: DistanceJointData);
  27097. /**
  27098. * Update the predefined distance.
  27099. * @param maxDistance The maximum preferred distance
  27100. * @param minDistance The minimum preferred distance
  27101. */
  27102. updateDistance(maxDistance: number, minDistance?: number): void;
  27103. }
  27104. /**
  27105. * Represents a Motor-Enabled Joint
  27106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27107. */
  27108. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27109. /**
  27110. * Initializes the Motor-Enabled Joint
  27111. * @param type The type of the joint
  27112. * @param jointData The physica joint data for the joint
  27113. */
  27114. constructor(type: number, jointData: PhysicsJointData);
  27115. /**
  27116. * Set the motor values.
  27117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27118. * @param force the force to apply
  27119. * @param maxForce max force for this motor.
  27120. */
  27121. setMotor(force?: number, maxForce?: number): void;
  27122. /**
  27123. * Set the motor's limits.
  27124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27125. * @param upperLimit The upper limit of the motor
  27126. * @param lowerLimit The lower limit of the motor
  27127. */
  27128. setLimit(upperLimit: number, lowerLimit?: number): void;
  27129. }
  27130. /**
  27131. * This class represents a single physics Hinge-Joint
  27132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27133. */
  27134. export class HingeJoint extends MotorEnabledJoint {
  27135. /**
  27136. * Initializes the Hinge-Joint
  27137. * @param jointData The joint data for the Hinge-Joint
  27138. */
  27139. constructor(jointData: PhysicsJointData);
  27140. /**
  27141. * Set the motor values.
  27142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27143. * @param {number} force the force to apply
  27144. * @param {number} maxForce max force for this motor.
  27145. */
  27146. setMotor(force?: number, maxForce?: number): void;
  27147. /**
  27148. * Set the motor's limits.
  27149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27150. * @param upperLimit The upper limit of the motor
  27151. * @param lowerLimit The lower limit of the motor
  27152. */
  27153. setLimit(upperLimit: number, lowerLimit?: number): void;
  27154. }
  27155. /**
  27156. * This class represents a dual hinge physics joint (same as wheel joint)
  27157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27158. */
  27159. export class Hinge2Joint extends MotorEnabledJoint {
  27160. /**
  27161. * Initializes the Hinge2-Joint
  27162. * @param jointData The joint data for the Hinge2-Joint
  27163. */
  27164. constructor(jointData: PhysicsJointData);
  27165. /**
  27166. * Set the motor values.
  27167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27168. * @param {number} targetSpeed the speed the motor is to reach
  27169. * @param {number} maxForce max force for this motor.
  27170. * @param {motorIndex} the motor's index, 0 or 1.
  27171. */
  27172. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27173. /**
  27174. * Set the motor limits.
  27175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27176. * @param {number} upperLimit the upper limit
  27177. * @param {number} lowerLimit lower limit
  27178. * @param {motorIndex} the motor's index, 0 or 1.
  27179. */
  27180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27181. }
  27182. /**
  27183. * Interface for a motor enabled joint
  27184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27185. */
  27186. export interface IMotorEnabledJoint {
  27187. /**
  27188. * Physics joint
  27189. */
  27190. physicsJoint: any;
  27191. /**
  27192. * Sets the motor of the motor-enabled joint
  27193. * @param force The force of the motor
  27194. * @param maxForce The maximum force of the motor
  27195. * @param motorIndex The index of the motor
  27196. */
  27197. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27198. /**
  27199. * Sets the limit of the motor
  27200. * @param upperLimit The upper limit of the motor
  27201. * @param lowerLimit The lower limit of the motor
  27202. * @param motorIndex The index of the motor
  27203. */
  27204. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27205. }
  27206. /**
  27207. * Joint data for a Distance-Joint
  27208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27209. */
  27210. export interface DistanceJointData extends PhysicsJointData {
  27211. /**
  27212. * Max distance the 2 joint objects can be apart
  27213. */
  27214. maxDistance: number;
  27215. }
  27216. /**
  27217. * Joint data from a spring joint
  27218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27219. */
  27220. export interface SpringJointData extends PhysicsJointData {
  27221. /**
  27222. * Length of the spring
  27223. */
  27224. length: number;
  27225. /**
  27226. * Stiffness of the spring
  27227. */
  27228. stiffness: number;
  27229. /**
  27230. * Damping of the spring
  27231. */
  27232. damping: number;
  27233. /** this callback will be called when applying the force to the impostors. */
  27234. forceApplicationCallback: () => void;
  27235. }
  27236. }
  27237. declare module "babylonjs/Physics/physicsRaycastResult" {
  27238. import { Vector3 } from "babylonjs/Maths/math.vector";
  27239. /**
  27240. * Holds the data for the raycast result
  27241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27242. */
  27243. export class PhysicsRaycastResult {
  27244. private _hasHit;
  27245. private _hitDistance;
  27246. private _hitNormalWorld;
  27247. private _hitPointWorld;
  27248. private _rayFromWorld;
  27249. private _rayToWorld;
  27250. /**
  27251. * Gets if there was a hit
  27252. */
  27253. get hasHit(): boolean;
  27254. /**
  27255. * Gets the distance from the hit
  27256. */
  27257. get hitDistance(): number;
  27258. /**
  27259. * Gets the hit normal/direction in the world
  27260. */
  27261. get hitNormalWorld(): Vector3;
  27262. /**
  27263. * Gets the hit point in the world
  27264. */
  27265. get hitPointWorld(): Vector3;
  27266. /**
  27267. * Gets the ray "start point" of the ray in the world
  27268. */
  27269. get rayFromWorld(): Vector3;
  27270. /**
  27271. * Gets the ray "end point" of the ray in the world
  27272. */
  27273. get rayToWorld(): Vector3;
  27274. /**
  27275. * Sets the hit data (normal & point in world space)
  27276. * @param hitNormalWorld defines the normal in world space
  27277. * @param hitPointWorld defines the point in world space
  27278. */
  27279. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27280. /**
  27281. * Sets the distance from the start point to the hit point
  27282. * @param distance
  27283. */
  27284. setHitDistance(distance: number): void;
  27285. /**
  27286. * Calculates the distance manually
  27287. */
  27288. calculateHitDistance(): void;
  27289. /**
  27290. * Resets all the values to default
  27291. * @param from The from point on world space
  27292. * @param to The to point on world space
  27293. */
  27294. reset(from?: Vector3, to?: Vector3): void;
  27295. }
  27296. /**
  27297. * Interface for the size containing width and height
  27298. */
  27299. interface IXYZ {
  27300. /**
  27301. * X
  27302. */
  27303. x: number;
  27304. /**
  27305. * Y
  27306. */
  27307. y: number;
  27308. /**
  27309. * Z
  27310. */
  27311. z: number;
  27312. }
  27313. }
  27314. declare module "babylonjs/Physics/IPhysicsEngine" {
  27315. import { Nullable } from "babylonjs/types";
  27316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27318. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27319. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27321. /**
  27322. * Interface used to describe a physics joint
  27323. */
  27324. export interface PhysicsImpostorJoint {
  27325. /** Defines the main impostor to which the joint is linked */
  27326. mainImpostor: PhysicsImpostor;
  27327. /** Defines the impostor that is connected to the main impostor using this joint */
  27328. connectedImpostor: PhysicsImpostor;
  27329. /** Defines the joint itself */
  27330. joint: PhysicsJoint;
  27331. }
  27332. /** @hidden */
  27333. export interface IPhysicsEnginePlugin {
  27334. world: any;
  27335. name: string;
  27336. setGravity(gravity: Vector3): void;
  27337. setTimeStep(timeStep: number): void;
  27338. getTimeStep(): number;
  27339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27343. removePhysicsBody(impostor: PhysicsImpostor): void;
  27344. generateJoint(joint: PhysicsImpostorJoint): void;
  27345. removeJoint(joint: PhysicsImpostorJoint): void;
  27346. isSupported(): boolean;
  27347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27348. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27354. getBodyMass(impostor: PhysicsImpostor): number;
  27355. getBodyFriction(impostor: PhysicsImpostor): number;
  27356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27357. getBodyRestitution(impostor: PhysicsImpostor): number;
  27358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27359. getBodyPressure?(impostor: PhysicsImpostor): number;
  27360. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27361. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27362. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27363. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27364. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27365. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27366. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27367. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27368. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27369. sleepBody(impostor: PhysicsImpostor): void;
  27370. wakeUpBody(impostor: PhysicsImpostor): void;
  27371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27373. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27375. getRadius(impostor: PhysicsImpostor): number;
  27376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27377. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27378. dispose(): void;
  27379. }
  27380. /**
  27381. * Interface used to define a physics engine
  27382. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27383. */
  27384. export interface IPhysicsEngine {
  27385. /**
  27386. * Gets the gravity vector used by the simulation
  27387. */
  27388. gravity: Vector3;
  27389. /**
  27390. * Sets the gravity vector used by the simulation
  27391. * @param gravity defines the gravity vector to use
  27392. */
  27393. setGravity(gravity: Vector3): void;
  27394. /**
  27395. * Set the time step of the physics engine.
  27396. * Default is 1/60.
  27397. * To slow it down, enter 1/600 for example.
  27398. * To speed it up, 1/30
  27399. * @param newTimeStep the new timestep to apply to this world.
  27400. */
  27401. setTimeStep(newTimeStep: number): void;
  27402. /**
  27403. * Get the time step of the physics engine.
  27404. * @returns the current time step
  27405. */
  27406. getTimeStep(): number;
  27407. /**
  27408. * Set the sub time step of the physics engine.
  27409. * Default is 0 meaning there is no sub steps
  27410. * To increase physics resolution precision, set a small value (like 1 ms)
  27411. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27412. */
  27413. setSubTimeStep(subTimeStep: number): void;
  27414. /**
  27415. * Get the sub time step of the physics engine.
  27416. * @returns the current sub time step
  27417. */
  27418. getSubTimeStep(): number;
  27419. /**
  27420. * Release all resources
  27421. */
  27422. dispose(): void;
  27423. /**
  27424. * Gets the name of the current physics plugin
  27425. * @returns the name of the plugin
  27426. */
  27427. getPhysicsPluginName(): string;
  27428. /**
  27429. * Adding a new impostor for the impostor tracking.
  27430. * This will be done by the impostor itself.
  27431. * @param impostor the impostor to add
  27432. */
  27433. addImpostor(impostor: PhysicsImpostor): void;
  27434. /**
  27435. * Remove an impostor from the engine.
  27436. * This impostor and its mesh will not longer be updated by the physics engine.
  27437. * @param impostor the impostor to remove
  27438. */
  27439. removeImpostor(impostor: PhysicsImpostor): void;
  27440. /**
  27441. * Add a joint to the physics engine
  27442. * @param mainImpostor defines the main impostor to which the joint is added.
  27443. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27444. * @param joint defines the joint that will connect both impostors.
  27445. */
  27446. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27447. /**
  27448. * Removes a joint from the simulation
  27449. * @param mainImpostor defines the impostor used with the joint
  27450. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27451. * @param joint defines the joint to remove
  27452. */
  27453. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27454. /**
  27455. * Gets the current plugin used to run the simulation
  27456. * @returns current plugin
  27457. */
  27458. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27459. /**
  27460. * Gets the list of physic impostors
  27461. * @returns an array of PhysicsImpostor
  27462. */
  27463. getImpostors(): Array<PhysicsImpostor>;
  27464. /**
  27465. * Gets the impostor for a physics enabled object
  27466. * @param object defines the object impersonated by the impostor
  27467. * @returns the PhysicsImpostor or null if not found
  27468. */
  27469. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27470. /**
  27471. * Gets the impostor for a physics body object
  27472. * @param body defines physics body used by the impostor
  27473. * @returns the PhysicsImpostor or null if not found
  27474. */
  27475. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27476. /**
  27477. * Does a raycast in the physics world
  27478. * @param from when should the ray start?
  27479. * @param to when should the ray end?
  27480. * @returns PhysicsRaycastResult
  27481. */
  27482. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27483. /**
  27484. * Called by the scene. No need to call it.
  27485. * @param delta defines the timespam between frames
  27486. */
  27487. _step(delta: number): void;
  27488. }
  27489. }
  27490. declare module "babylonjs/Physics/physicsImpostor" {
  27491. import { Nullable, IndicesArray } from "babylonjs/types";
  27492. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27495. import { Scene } from "babylonjs/scene";
  27496. import { Bone } from "babylonjs/Bones/bone";
  27497. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27498. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27499. import { Space } from "babylonjs/Maths/math.axis";
  27500. /**
  27501. * The interface for the physics imposter parameters
  27502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27503. */
  27504. export interface PhysicsImpostorParameters {
  27505. /**
  27506. * The mass of the physics imposter
  27507. */
  27508. mass: number;
  27509. /**
  27510. * The friction of the physics imposter
  27511. */
  27512. friction?: number;
  27513. /**
  27514. * The coefficient of restitution of the physics imposter
  27515. */
  27516. restitution?: number;
  27517. /**
  27518. * The native options of the physics imposter
  27519. */
  27520. nativeOptions?: any;
  27521. /**
  27522. * Specifies if the parent should be ignored
  27523. */
  27524. ignoreParent?: boolean;
  27525. /**
  27526. * Specifies if bi-directional transformations should be disabled
  27527. */
  27528. disableBidirectionalTransformation?: boolean;
  27529. /**
  27530. * The pressure inside the physics imposter, soft object only
  27531. */
  27532. pressure?: number;
  27533. /**
  27534. * The stiffness the physics imposter, soft object only
  27535. */
  27536. stiffness?: number;
  27537. /**
  27538. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27539. */
  27540. velocityIterations?: number;
  27541. /**
  27542. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27543. */
  27544. positionIterations?: number;
  27545. /**
  27546. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27547. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27548. * Add to fix multiple points
  27549. */
  27550. fixedPoints?: number;
  27551. /**
  27552. * The collision margin around a soft object
  27553. */
  27554. margin?: number;
  27555. /**
  27556. * The collision margin around a soft object
  27557. */
  27558. damping?: number;
  27559. /**
  27560. * The path for a rope based on an extrusion
  27561. */
  27562. path?: any;
  27563. /**
  27564. * The shape of an extrusion used for a rope based on an extrusion
  27565. */
  27566. shape?: any;
  27567. }
  27568. /**
  27569. * Interface for a physics-enabled object
  27570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27571. */
  27572. export interface IPhysicsEnabledObject {
  27573. /**
  27574. * The position of the physics-enabled object
  27575. */
  27576. position: Vector3;
  27577. /**
  27578. * The rotation of the physics-enabled object
  27579. */
  27580. rotationQuaternion: Nullable<Quaternion>;
  27581. /**
  27582. * The scale of the physics-enabled object
  27583. */
  27584. scaling: Vector3;
  27585. /**
  27586. * The rotation of the physics-enabled object
  27587. */
  27588. rotation?: Vector3;
  27589. /**
  27590. * The parent of the physics-enabled object
  27591. */
  27592. parent?: any;
  27593. /**
  27594. * The bounding info of the physics-enabled object
  27595. * @returns The bounding info of the physics-enabled object
  27596. */
  27597. getBoundingInfo(): BoundingInfo;
  27598. /**
  27599. * Computes the world matrix
  27600. * @param force Specifies if the world matrix should be computed by force
  27601. * @returns A world matrix
  27602. */
  27603. computeWorldMatrix(force: boolean): Matrix;
  27604. /**
  27605. * Gets the world matrix
  27606. * @returns A world matrix
  27607. */
  27608. getWorldMatrix?(): Matrix;
  27609. /**
  27610. * Gets the child meshes
  27611. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27612. * @returns An array of abstract meshes
  27613. */
  27614. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27615. /**
  27616. * Gets the vertex data
  27617. * @param kind The type of vertex data
  27618. * @returns A nullable array of numbers, or a float32 array
  27619. */
  27620. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27621. /**
  27622. * Gets the indices from the mesh
  27623. * @returns A nullable array of index arrays
  27624. */
  27625. getIndices?(): Nullable<IndicesArray>;
  27626. /**
  27627. * Gets the scene from the mesh
  27628. * @returns the indices array or null
  27629. */
  27630. getScene?(): Scene;
  27631. /**
  27632. * Gets the absolute position from the mesh
  27633. * @returns the absolute position
  27634. */
  27635. getAbsolutePosition(): Vector3;
  27636. /**
  27637. * Gets the absolute pivot point from the mesh
  27638. * @returns the absolute pivot point
  27639. */
  27640. getAbsolutePivotPoint(): Vector3;
  27641. /**
  27642. * Rotates the mesh
  27643. * @param axis The axis of rotation
  27644. * @param amount The amount of rotation
  27645. * @param space The space of the rotation
  27646. * @returns The rotation transform node
  27647. */
  27648. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27649. /**
  27650. * Translates the mesh
  27651. * @param axis The axis of translation
  27652. * @param distance The distance of translation
  27653. * @param space The space of the translation
  27654. * @returns The transform node
  27655. */
  27656. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27657. /**
  27658. * Sets the absolute position of the mesh
  27659. * @param absolutePosition The absolute position of the mesh
  27660. * @returns The transform node
  27661. */
  27662. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27663. /**
  27664. * Gets the class name of the mesh
  27665. * @returns The class name
  27666. */
  27667. getClassName(): string;
  27668. }
  27669. /**
  27670. * Represents a physics imposter
  27671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27672. */
  27673. export class PhysicsImpostor {
  27674. /**
  27675. * The physics-enabled object used as the physics imposter
  27676. */
  27677. object: IPhysicsEnabledObject;
  27678. /**
  27679. * The type of the physics imposter
  27680. */
  27681. type: number;
  27682. private _options;
  27683. private _scene?;
  27684. /**
  27685. * The default object size of the imposter
  27686. */
  27687. static DEFAULT_OBJECT_SIZE: Vector3;
  27688. /**
  27689. * The identity quaternion of the imposter
  27690. */
  27691. static IDENTITY_QUATERNION: Quaternion;
  27692. /** @hidden */
  27693. _pluginData: any;
  27694. private _physicsEngine;
  27695. private _physicsBody;
  27696. private _bodyUpdateRequired;
  27697. private _onBeforePhysicsStepCallbacks;
  27698. private _onAfterPhysicsStepCallbacks;
  27699. /** @hidden */
  27700. _onPhysicsCollideCallbacks: Array<{
  27701. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27702. otherImpostors: Array<PhysicsImpostor>;
  27703. }>;
  27704. private _deltaPosition;
  27705. private _deltaRotation;
  27706. private _deltaRotationConjugated;
  27707. /** @hidden */
  27708. _isFromLine: boolean;
  27709. private _parent;
  27710. private _isDisposed;
  27711. private static _tmpVecs;
  27712. private static _tmpQuat;
  27713. /**
  27714. * Specifies if the physics imposter is disposed
  27715. */
  27716. get isDisposed(): boolean;
  27717. /**
  27718. * Gets the mass of the physics imposter
  27719. */
  27720. get mass(): number;
  27721. set mass(value: number);
  27722. /**
  27723. * Gets the coefficient of friction
  27724. */
  27725. get friction(): number;
  27726. /**
  27727. * Sets the coefficient of friction
  27728. */
  27729. set friction(value: number);
  27730. /**
  27731. * Gets the coefficient of restitution
  27732. */
  27733. get restitution(): number;
  27734. /**
  27735. * Sets the coefficient of restitution
  27736. */
  27737. set restitution(value: number);
  27738. /**
  27739. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27740. */
  27741. get pressure(): number;
  27742. /**
  27743. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27744. */
  27745. set pressure(value: number);
  27746. /**
  27747. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27748. */
  27749. get stiffness(): number;
  27750. /**
  27751. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27752. */
  27753. set stiffness(value: number);
  27754. /**
  27755. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27756. */
  27757. get velocityIterations(): number;
  27758. /**
  27759. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27760. */
  27761. set velocityIterations(value: number);
  27762. /**
  27763. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27764. */
  27765. get positionIterations(): number;
  27766. /**
  27767. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27768. */
  27769. set positionIterations(value: number);
  27770. /**
  27771. * The unique id of the physics imposter
  27772. * set by the physics engine when adding this impostor to the array
  27773. */
  27774. uniqueId: number;
  27775. /**
  27776. * @hidden
  27777. */
  27778. soft: boolean;
  27779. /**
  27780. * @hidden
  27781. */
  27782. segments: number;
  27783. private _joints;
  27784. /**
  27785. * Initializes the physics imposter
  27786. * @param object The physics-enabled object used as the physics imposter
  27787. * @param type The type of the physics imposter
  27788. * @param _options The options for the physics imposter
  27789. * @param _scene The Babylon scene
  27790. */
  27791. constructor(
  27792. /**
  27793. * The physics-enabled object used as the physics imposter
  27794. */
  27795. object: IPhysicsEnabledObject,
  27796. /**
  27797. * The type of the physics imposter
  27798. */
  27799. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27800. /**
  27801. * This function will completly initialize this impostor.
  27802. * It will create a new body - but only if this mesh has no parent.
  27803. * If it has, this impostor will not be used other than to define the impostor
  27804. * of the child mesh.
  27805. * @hidden
  27806. */
  27807. _init(): void;
  27808. private _getPhysicsParent;
  27809. /**
  27810. * Should a new body be generated.
  27811. * @returns boolean specifying if body initialization is required
  27812. */
  27813. isBodyInitRequired(): boolean;
  27814. /**
  27815. * Sets the updated scaling
  27816. * @param updated Specifies if the scaling is updated
  27817. */
  27818. setScalingUpdated(): void;
  27819. /**
  27820. * Force a regeneration of this or the parent's impostor's body.
  27821. * Use under cautious - This will remove all joints already implemented.
  27822. */
  27823. forceUpdate(): void;
  27824. /**
  27825. * Gets the body that holds this impostor. Either its own, or its parent.
  27826. */
  27827. get physicsBody(): any;
  27828. /**
  27829. * Get the parent of the physics imposter
  27830. * @returns Physics imposter or null
  27831. */
  27832. get parent(): Nullable<PhysicsImpostor>;
  27833. /**
  27834. * Sets the parent of the physics imposter
  27835. */
  27836. set parent(value: Nullable<PhysicsImpostor>);
  27837. /**
  27838. * Set the physics body. Used mainly by the physics engine/plugin
  27839. */
  27840. set physicsBody(physicsBody: any);
  27841. /**
  27842. * Resets the update flags
  27843. */
  27844. resetUpdateFlags(): void;
  27845. /**
  27846. * Gets the object extend size
  27847. * @returns the object extend size
  27848. */
  27849. getObjectExtendSize(): Vector3;
  27850. /**
  27851. * Gets the object center
  27852. * @returns The object center
  27853. */
  27854. getObjectCenter(): Vector3;
  27855. /**
  27856. * Get a specific parameter from the options parameters
  27857. * @param paramName The object parameter name
  27858. * @returns The object parameter
  27859. */
  27860. getParam(paramName: string): any;
  27861. /**
  27862. * Sets a specific parameter in the options given to the physics plugin
  27863. * @param paramName The parameter name
  27864. * @param value The value of the parameter
  27865. */
  27866. setParam(paramName: string, value: number): void;
  27867. /**
  27868. * Specifically change the body's mass option. Won't recreate the physics body object
  27869. * @param mass The mass of the physics imposter
  27870. */
  27871. setMass(mass: number): void;
  27872. /**
  27873. * Gets the linear velocity
  27874. * @returns linear velocity or null
  27875. */
  27876. getLinearVelocity(): Nullable<Vector3>;
  27877. /**
  27878. * Sets the linear velocity
  27879. * @param velocity linear velocity or null
  27880. */
  27881. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27882. /**
  27883. * Gets the angular velocity
  27884. * @returns angular velocity or null
  27885. */
  27886. getAngularVelocity(): Nullable<Vector3>;
  27887. /**
  27888. * Sets the angular velocity
  27889. * @param velocity The velocity or null
  27890. */
  27891. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27892. /**
  27893. * Execute a function with the physics plugin native code
  27894. * Provide a function the will have two variables - the world object and the physics body object
  27895. * @param func The function to execute with the physics plugin native code
  27896. */
  27897. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27898. /**
  27899. * Register a function that will be executed before the physics world is stepping forward
  27900. * @param func The function to execute before the physics world is stepped forward
  27901. */
  27902. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27903. /**
  27904. * Unregister a function that will be executed before the physics world is stepping forward
  27905. * @param func The function to execute before the physics world is stepped forward
  27906. */
  27907. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27908. /**
  27909. * Register a function that will be executed after the physics step
  27910. * @param func The function to execute after physics step
  27911. */
  27912. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27913. /**
  27914. * Unregisters a function that will be executed after the physics step
  27915. * @param func The function to execute after physics step
  27916. */
  27917. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27918. /**
  27919. * register a function that will be executed when this impostor collides against a different body
  27920. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27921. * @param func Callback that is executed on collision
  27922. */
  27923. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27924. /**
  27925. * Unregisters the physics imposter on contact
  27926. * @param collideAgainst The physics object to collide against
  27927. * @param func Callback to execute on collision
  27928. */
  27929. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27930. private _tmpQuat;
  27931. private _tmpQuat2;
  27932. /**
  27933. * Get the parent rotation
  27934. * @returns The parent rotation
  27935. */
  27936. getParentsRotation(): Quaternion;
  27937. /**
  27938. * this function is executed by the physics engine.
  27939. */
  27940. beforeStep: () => void;
  27941. /**
  27942. * this function is executed by the physics engine
  27943. */
  27944. afterStep: () => void;
  27945. /**
  27946. * Legacy collision detection event support
  27947. */
  27948. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27949. /**
  27950. * event and body object due to cannon's event-based architecture.
  27951. */
  27952. onCollide: (e: {
  27953. body: any;
  27954. }) => void;
  27955. /**
  27956. * Apply a force
  27957. * @param force The force to apply
  27958. * @param contactPoint The contact point for the force
  27959. * @returns The physics imposter
  27960. */
  27961. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27962. /**
  27963. * Apply an impulse
  27964. * @param force The impulse force
  27965. * @param contactPoint The contact point for the impulse force
  27966. * @returns The physics imposter
  27967. */
  27968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27969. /**
  27970. * A help function to create a joint
  27971. * @param otherImpostor A physics imposter used to create a joint
  27972. * @param jointType The type of joint
  27973. * @param jointData The data for the joint
  27974. * @returns The physics imposter
  27975. */
  27976. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27977. /**
  27978. * Add a joint to this impostor with a different impostor
  27979. * @param otherImpostor A physics imposter used to add a joint
  27980. * @param joint The joint to add
  27981. * @returns The physics imposter
  27982. */
  27983. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27984. /**
  27985. * Add an anchor to a cloth impostor
  27986. * @param otherImpostor rigid impostor to anchor to
  27987. * @param width ratio across width from 0 to 1
  27988. * @param height ratio up height from 0 to 1
  27989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27990. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27991. * @returns impostor the soft imposter
  27992. */
  27993. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27994. /**
  27995. * Add a hook to a rope impostor
  27996. * @param otherImpostor rigid impostor to anchor to
  27997. * @param length ratio across rope from 0 to 1
  27998. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28000. * @returns impostor the rope imposter
  28001. */
  28002. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28003. /**
  28004. * Will keep this body still, in a sleep mode.
  28005. * @returns the physics imposter
  28006. */
  28007. sleep(): PhysicsImpostor;
  28008. /**
  28009. * Wake the body up.
  28010. * @returns The physics imposter
  28011. */
  28012. wakeUp(): PhysicsImpostor;
  28013. /**
  28014. * Clones the physics imposter
  28015. * @param newObject The physics imposter clones to this physics-enabled object
  28016. * @returns A nullable physics imposter
  28017. */
  28018. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28019. /**
  28020. * Disposes the physics imposter
  28021. */
  28022. dispose(): void;
  28023. /**
  28024. * Sets the delta position
  28025. * @param position The delta position amount
  28026. */
  28027. setDeltaPosition(position: Vector3): void;
  28028. /**
  28029. * Sets the delta rotation
  28030. * @param rotation The delta rotation amount
  28031. */
  28032. setDeltaRotation(rotation: Quaternion): void;
  28033. /**
  28034. * Gets the box size of the physics imposter and stores the result in the input parameter
  28035. * @param result Stores the box size
  28036. * @returns The physics imposter
  28037. */
  28038. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28039. /**
  28040. * Gets the radius of the physics imposter
  28041. * @returns Radius of the physics imposter
  28042. */
  28043. getRadius(): number;
  28044. /**
  28045. * Sync a bone with this impostor
  28046. * @param bone The bone to sync to the impostor.
  28047. * @param boneMesh The mesh that the bone is influencing.
  28048. * @param jointPivot The pivot of the joint / bone in local space.
  28049. * @param distToJoint Optional distance from the impostor to the joint.
  28050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28051. */
  28052. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28053. /**
  28054. * Sync impostor to a bone
  28055. * @param bone The bone that the impostor will be synced to.
  28056. * @param boneMesh The mesh that the bone is influencing.
  28057. * @param jointPivot The pivot of the joint / bone in local space.
  28058. * @param distToJoint Optional distance from the impostor to the joint.
  28059. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28060. * @param boneAxis Optional vector3 axis the bone is aligned with
  28061. */
  28062. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28063. /**
  28064. * No-Imposter type
  28065. */
  28066. static NoImpostor: number;
  28067. /**
  28068. * Sphere-Imposter type
  28069. */
  28070. static SphereImpostor: number;
  28071. /**
  28072. * Box-Imposter type
  28073. */
  28074. static BoxImpostor: number;
  28075. /**
  28076. * Plane-Imposter type
  28077. */
  28078. static PlaneImpostor: number;
  28079. /**
  28080. * Mesh-imposter type
  28081. */
  28082. static MeshImpostor: number;
  28083. /**
  28084. * Capsule-Impostor type (Ammo.js plugin only)
  28085. */
  28086. static CapsuleImpostor: number;
  28087. /**
  28088. * Cylinder-Imposter type
  28089. */
  28090. static CylinderImpostor: number;
  28091. /**
  28092. * Particle-Imposter type
  28093. */
  28094. static ParticleImpostor: number;
  28095. /**
  28096. * Heightmap-Imposter type
  28097. */
  28098. static HeightmapImpostor: number;
  28099. /**
  28100. * ConvexHull-Impostor type (Ammo.js plugin only)
  28101. */
  28102. static ConvexHullImpostor: number;
  28103. /**
  28104. * Custom-Imposter type (Ammo.js plugin only)
  28105. */
  28106. static CustomImpostor: number;
  28107. /**
  28108. * Rope-Imposter type
  28109. */
  28110. static RopeImpostor: number;
  28111. /**
  28112. * Cloth-Imposter type
  28113. */
  28114. static ClothImpostor: number;
  28115. /**
  28116. * Softbody-Imposter type
  28117. */
  28118. static SoftbodyImpostor: number;
  28119. }
  28120. }
  28121. declare module "babylonjs/Meshes/mesh" {
  28122. import { Observable } from "babylonjs/Misc/observable";
  28123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28124. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28125. import { Camera } from "babylonjs/Cameras/camera";
  28126. import { Scene } from "babylonjs/scene";
  28127. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28128. import { Color4 } from "babylonjs/Maths/math.color";
  28129. import { Engine } from "babylonjs/Engines/engine";
  28130. import { Node } from "babylonjs/node";
  28131. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28133. import { Buffer } from "babylonjs/Meshes/buffer";
  28134. import { Geometry } from "babylonjs/Meshes/geometry";
  28135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28137. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28138. import { Effect } from "babylonjs/Materials/effect";
  28139. import { Material } from "babylonjs/Materials/material";
  28140. import { Skeleton } from "babylonjs/Bones/skeleton";
  28141. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28142. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28143. import { Path3D } from "babylonjs/Maths/math.path";
  28144. import { Plane } from "babylonjs/Maths/math.plane";
  28145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28146. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28147. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28148. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28149. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28150. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28151. /**
  28152. * @hidden
  28153. **/
  28154. export class _CreationDataStorage {
  28155. closePath?: boolean;
  28156. closeArray?: boolean;
  28157. idx: number[];
  28158. dashSize: number;
  28159. gapSize: number;
  28160. path3D: Path3D;
  28161. pathArray: Vector3[][];
  28162. arc: number;
  28163. radius: number;
  28164. cap: number;
  28165. tessellation: number;
  28166. }
  28167. /**
  28168. * @hidden
  28169. **/
  28170. class _InstanceDataStorage {
  28171. visibleInstances: any;
  28172. batchCache: _InstancesBatch;
  28173. instancesBufferSize: number;
  28174. instancesBuffer: Nullable<Buffer>;
  28175. instancesData: Float32Array;
  28176. overridenInstanceCount: number;
  28177. isFrozen: boolean;
  28178. previousBatch: Nullable<_InstancesBatch>;
  28179. hardwareInstancedRendering: boolean;
  28180. sideOrientation: number;
  28181. manualUpdate: boolean;
  28182. }
  28183. /**
  28184. * @hidden
  28185. **/
  28186. export class _InstancesBatch {
  28187. mustReturn: boolean;
  28188. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28189. renderSelf: boolean[];
  28190. hardwareInstancedRendering: boolean[];
  28191. }
  28192. /**
  28193. * @hidden
  28194. **/
  28195. class _ThinInstanceDataStorage {
  28196. instancesCount: number;
  28197. matrixBuffer: Nullable<Buffer>;
  28198. matrixBufferSize: number;
  28199. matrixData: Nullable<Float32Array>;
  28200. boundingVectors: Array<Vector3>;
  28201. }
  28202. /**
  28203. * Class used to represent renderable models
  28204. */
  28205. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28206. /**
  28207. * Mesh side orientation : usually the external or front surface
  28208. */
  28209. static readonly FRONTSIDE: number;
  28210. /**
  28211. * Mesh side orientation : usually the internal or back surface
  28212. */
  28213. static readonly BACKSIDE: number;
  28214. /**
  28215. * Mesh side orientation : both internal and external or front and back surfaces
  28216. */
  28217. static readonly DOUBLESIDE: number;
  28218. /**
  28219. * Mesh side orientation : by default, `FRONTSIDE`
  28220. */
  28221. static readonly DEFAULTSIDE: number;
  28222. /**
  28223. * Mesh cap setting : no cap
  28224. */
  28225. static readonly NO_CAP: number;
  28226. /**
  28227. * Mesh cap setting : one cap at the beginning of the mesh
  28228. */
  28229. static readonly CAP_START: number;
  28230. /**
  28231. * Mesh cap setting : one cap at the end of the mesh
  28232. */
  28233. static readonly CAP_END: number;
  28234. /**
  28235. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28236. */
  28237. static readonly CAP_ALL: number;
  28238. /**
  28239. * Mesh pattern setting : no flip or rotate
  28240. */
  28241. static readonly NO_FLIP: number;
  28242. /**
  28243. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28244. */
  28245. static readonly FLIP_TILE: number;
  28246. /**
  28247. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28248. */
  28249. static readonly ROTATE_TILE: number;
  28250. /**
  28251. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28252. */
  28253. static readonly FLIP_ROW: number;
  28254. /**
  28255. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28256. */
  28257. static readonly ROTATE_ROW: number;
  28258. /**
  28259. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28260. */
  28261. static readonly FLIP_N_ROTATE_TILE: number;
  28262. /**
  28263. * Mesh pattern setting : rotate pattern and rotate
  28264. */
  28265. static readonly FLIP_N_ROTATE_ROW: number;
  28266. /**
  28267. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28268. */
  28269. static readonly CENTER: number;
  28270. /**
  28271. * Mesh tile positioning : part tiles on left
  28272. */
  28273. static readonly LEFT: number;
  28274. /**
  28275. * Mesh tile positioning : part tiles on right
  28276. */
  28277. static readonly RIGHT: number;
  28278. /**
  28279. * Mesh tile positioning : part tiles on top
  28280. */
  28281. static readonly TOP: number;
  28282. /**
  28283. * Mesh tile positioning : part tiles on bottom
  28284. */
  28285. static readonly BOTTOM: number;
  28286. /**
  28287. * Gets the default side orientation.
  28288. * @param orientation the orientation to value to attempt to get
  28289. * @returns the default orientation
  28290. * @hidden
  28291. */
  28292. static _GetDefaultSideOrientation(orientation?: number): number;
  28293. private _internalMeshDataInfo;
  28294. /**
  28295. * An event triggered before rendering the mesh
  28296. */
  28297. get onBeforeRenderObservable(): Observable<Mesh>;
  28298. /**
  28299. * An event triggered before binding the mesh
  28300. */
  28301. get onBeforeBindObservable(): Observable<Mesh>;
  28302. /**
  28303. * An event triggered after rendering the mesh
  28304. */
  28305. get onAfterRenderObservable(): Observable<Mesh>;
  28306. /**
  28307. * An event triggered before drawing the mesh
  28308. */
  28309. get onBeforeDrawObservable(): Observable<Mesh>;
  28310. private _onBeforeDrawObserver;
  28311. /**
  28312. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28313. */
  28314. set onBeforeDraw(callback: () => void);
  28315. get hasInstances(): boolean;
  28316. get hasThinInstances(): boolean;
  28317. /**
  28318. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28319. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28320. */
  28321. delayLoadState: number;
  28322. /**
  28323. * Gets the list of instances created from this mesh
  28324. * it is not supposed to be modified manually.
  28325. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28326. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28327. */
  28328. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28329. /**
  28330. * Gets the file containing delay loading data for this mesh
  28331. */
  28332. delayLoadingFile: string;
  28333. /** @hidden */
  28334. _binaryInfo: any;
  28335. /**
  28336. * User defined function used to change how LOD level selection is done
  28337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28338. */
  28339. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28340. /**
  28341. * Gets or sets the morph target manager
  28342. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28343. */
  28344. get morphTargetManager(): Nullable<MorphTargetManager>;
  28345. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28346. /** @hidden */
  28347. _creationDataStorage: Nullable<_CreationDataStorage>;
  28348. /** @hidden */
  28349. _geometry: Nullable<Geometry>;
  28350. /** @hidden */
  28351. _delayInfo: Array<string>;
  28352. /** @hidden */
  28353. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28354. /** @hidden */
  28355. _instanceDataStorage: _InstanceDataStorage;
  28356. /** @hidden */
  28357. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28358. private _effectiveMaterial;
  28359. /** @hidden */
  28360. _shouldGenerateFlatShading: boolean;
  28361. /** @hidden */
  28362. _originalBuilderSideOrientation: number;
  28363. /**
  28364. * Use this property to change the original side orientation defined at construction time
  28365. */
  28366. overrideMaterialSideOrientation: Nullable<number>;
  28367. /**
  28368. * Gets the source mesh (the one used to clone this one from)
  28369. */
  28370. get source(): Nullable<Mesh>;
  28371. /**
  28372. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28373. */
  28374. get isUnIndexed(): boolean;
  28375. set isUnIndexed(value: boolean);
  28376. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28377. get worldMatrixInstancedBuffer(): Float32Array;
  28378. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28379. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28380. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28381. /**
  28382. * @constructor
  28383. * @param name The value used by scene.getMeshByName() to do a lookup.
  28384. * @param scene The scene to add this mesh to.
  28385. * @param parent The parent of this mesh, if it has one
  28386. * @param source An optional Mesh from which geometry is shared, cloned.
  28387. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28388. * When false, achieved by calling a clone(), also passing False.
  28389. * This will make creation of children, recursive.
  28390. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28391. */
  28392. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28393. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28394. doNotInstantiate: boolean;
  28395. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28396. /**
  28397. * Gets the class name
  28398. * @returns the string "Mesh".
  28399. */
  28400. getClassName(): string;
  28401. /** @hidden */
  28402. get _isMesh(): boolean;
  28403. /**
  28404. * Returns a description of this mesh
  28405. * @param fullDetails define if full details about this mesh must be used
  28406. * @returns a descriptive string representing this mesh
  28407. */
  28408. toString(fullDetails?: boolean): string;
  28409. /** @hidden */
  28410. _unBindEffect(): void;
  28411. /**
  28412. * Gets a boolean indicating if this mesh has LOD
  28413. */
  28414. get hasLODLevels(): boolean;
  28415. /**
  28416. * Gets the list of MeshLODLevel associated with the current mesh
  28417. * @returns an array of MeshLODLevel
  28418. */
  28419. getLODLevels(): MeshLODLevel[];
  28420. private _sortLODLevels;
  28421. /**
  28422. * Add a mesh as LOD level triggered at the given distance.
  28423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28424. * @param distance The distance from the center of the object to show this level
  28425. * @param mesh The mesh to be added as LOD level (can be null)
  28426. * @return This mesh (for chaining)
  28427. */
  28428. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28429. /**
  28430. * Returns the LOD level mesh at the passed distance or null if not found.
  28431. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28432. * @param distance The distance from the center of the object to show this level
  28433. * @returns a Mesh or `null`
  28434. */
  28435. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28436. /**
  28437. * Remove a mesh from the LOD array
  28438. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28439. * @param mesh defines the mesh to be removed
  28440. * @return This mesh (for chaining)
  28441. */
  28442. removeLODLevel(mesh: Mesh): Mesh;
  28443. /**
  28444. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28446. * @param camera defines the camera to use to compute distance
  28447. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28448. * @return This mesh (for chaining)
  28449. */
  28450. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28451. /**
  28452. * Gets the mesh internal Geometry object
  28453. */
  28454. get geometry(): Nullable<Geometry>;
  28455. /**
  28456. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28457. * @returns the total number of vertices
  28458. */
  28459. getTotalVertices(): number;
  28460. /**
  28461. * Returns the content of an associated vertex buffer
  28462. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28463. * - VertexBuffer.PositionKind
  28464. * - VertexBuffer.UVKind
  28465. * - VertexBuffer.UV2Kind
  28466. * - VertexBuffer.UV3Kind
  28467. * - VertexBuffer.UV4Kind
  28468. * - VertexBuffer.UV5Kind
  28469. * - VertexBuffer.UV6Kind
  28470. * - VertexBuffer.ColorKind
  28471. * - VertexBuffer.MatricesIndicesKind
  28472. * - VertexBuffer.MatricesIndicesExtraKind
  28473. * - VertexBuffer.MatricesWeightsKind
  28474. * - VertexBuffer.MatricesWeightsExtraKind
  28475. * @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
  28476. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28477. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28478. */
  28479. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28480. /**
  28481. * Returns the mesh VertexBuffer object from the requested `kind`
  28482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28483. * - VertexBuffer.PositionKind
  28484. * - VertexBuffer.NormalKind
  28485. * - VertexBuffer.UVKind
  28486. * - VertexBuffer.UV2Kind
  28487. * - VertexBuffer.UV3Kind
  28488. * - VertexBuffer.UV4Kind
  28489. * - VertexBuffer.UV5Kind
  28490. * - VertexBuffer.UV6Kind
  28491. * - VertexBuffer.ColorKind
  28492. * - VertexBuffer.MatricesIndicesKind
  28493. * - VertexBuffer.MatricesIndicesExtraKind
  28494. * - VertexBuffer.MatricesWeightsKind
  28495. * - VertexBuffer.MatricesWeightsExtraKind
  28496. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28497. */
  28498. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28499. /**
  28500. * Tests if a specific vertex buffer is associated with this mesh
  28501. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28502. * - VertexBuffer.PositionKind
  28503. * - VertexBuffer.NormalKind
  28504. * - VertexBuffer.UVKind
  28505. * - VertexBuffer.UV2Kind
  28506. * - VertexBuffer.UV3Kind
  28507. * - VertexBuffer.UV4Kind
  28508. * - VertexBuffer.UV5Kind
  28509. * - VertexBuffer.UV6Kind
  28510. * - VertexBuffer.ColorKind
  28511. * - VertexBuffer.MatricesIndicesKind
  28512. * - VertexBuffer.MatricesIndicesExtraKind
  28513. * - VertexBuffer.MatricesWeightsKind
  28514. * - VertexBuffer.MatricesWeightsExtraKind
  28515. * @returns a boolean
  28516. */
  28517. isVerticesDataPresent(kind: string): boolean;
  28518. /**
  28519. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28520. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28521. * - VertexBuffer.PositionKind
  28522. * - VertexBuffer.UVKind
  28523. * - VertexBuffer.UV2Kind
  28524. * - VertexBuffer.UV3Kind
  28525. * - VertexBuffer.UV4Kind
  28526. * - VertexBuffer.UV5Kind
  28527. * - VertexBuffer.UV6Kind
  28528. * - VertexBuffer.ColorKind
  28529. * - VertexBuffer.MatricesIndicesKind
  28530. * - VertexBuffer.MatricesIndicesExtraKind
  28531. * - VertexBuffer.MatricesWeightsKind
  28532. * - VertexBuffer.MatricesWeightsExtraKind
  28533. * @returns a boolean
  28534. */
  28535. isVertexBufferUpdatable(kind: string): boolean;
  28536. /**
  28537. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28538. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28539. * - VertexBuffer.PositionKind
  28540. * - VertexBuffer.NormalKind
  28541. * - VertexBuffer.UVKind
  28542. * - VertexBuffer.UV2Kind
  28543. * - VertexBuffer.UV3Kind
  28544. * - VertexBuffer.UV4Kind
  28545. * - VertexBuffer.UV5Kind
  28546. * - VertexBuffer.UV6Kind
  28547. * - VertexBuffer.ColorKind
  28548. * - VertexBuffer.MatricesIndicesKind
  28549. * - VertexBuffer.MatricesIndicesExtraKind
  28550. * - VertexBuffer.MatricesWeightsKind
  28551. * - VertexBuffer.MatricesWeightsExtraKind
  28552. * @returns an array of strings
  28553. */
  28554. getVerticesDataKinds(): string[];
  28555. /**
  28556. * Returns a positive integer : the total number of indices in this mesh geometry.
  28557. * @returns the numner of indices or zero if the mesh has no geometry.
  28558. */
  28559. getTotalIndices(): number;
  28560. /**
  28561. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28562. * @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.
  28563. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28564. * @returns the indices array or an empty array if the mesh has no geometry
  28565. */
  28566. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28567. get isBlocked(): boolean;
  28568. /**
  28569. * Determine if the current mesh is ready to be rendered
  28570. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28571. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28572. * @returns true if all associated assets are ready (material, textures, shaders)
  28573. */
  28574. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28575. /**
  28576. * 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.
  28577. */
  28578. get areNormalsFrozen(): boolean;
  28579. /**
  28580. * 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.
  28581. * @returns the current mesh
  28582. */
  28583. freezeNormals(): Mesh;
  28584. /**
  28585. * 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
  28586. * @returns the current mesh
  28587. */
  28588. unfreezeNormals(): Mesh;
  28589. /**
  28590. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28591. */
  28592. set overridenInstanceCount(count: number);
  28593. /** @hidden */
  28594. _preActivate(): Mesh;
  28595. /** @hidden */
  28596. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28597. /** @hidden */
  28598. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28599. protected _afterComputeWorldMatrix(): void;
  28600. /** @hidden */
  28601. _postActivate(): void;
  28602. /**
  28603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28604. * This means the mesh underlying bounding box and sphere are recomputed.
  28605. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28606. * @returns the current mesh
  28607. */
  28608. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28609. /** @hidden */
  28610. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28611. /**
  28612. * This function will subdivide the mesh into multiple submeshes
  28613. * @param count defines the expected number of submeshes
  28614. */
  28615. subdivide(count: number): void;
  28616. /**
  28617. * Copy a FloatArray into a specific associated vertex buffer
  28618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28619. * - VertexBuffer.PositionKind
  28620. * - VertexBuffer.UVKind
  28621. * - VertexBuffer.UV2Kind
  28622. * - VertexBuffer.UV3Kind
  28623. * - VertexBuffer.UV4Kind
  28624. * - VertexBuffer.UV5Kind
  28625. * - VertexBuffer.UV6Kind
  28626. * - VertexBuffer.ColorKind
  28627. * - VertexBuffer.MatricesIndicesKind
  28628. * - VertexBuffer.MatricesIndicesExtraKind
  28629. * - VertexBuffer.MatricesWeightsKind
  28630. * - VertexBuffer.MatricesWeightsExtraKind
  28631. * @param data defines the data source
  28632. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28633. * @param stride defines the data stride size (can be null)
  28634. * @returns the current mesh
  28635. */
  28636. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28637. /**
  28638. * Delete a vertex buffer associated with this mesh
  28639. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28640. * - VertexBuffer.PositionKind
  28641. * - VertexBuffer.UVKind
  28642. * - VertexBuffer.UV2Kind
  28643. * - VertexBuffer.UV3Kind
  28644. * - VertexBuffer.UV4Kind
  28645. * - VertexBuffer.UV5Kind
  28646. * - VertexBuffer.UV6Kind
  28647. * - VertexBuffer.ColorKind
  28648. * - VertexBuffer.MatricesIndicesKind
  28649. * - VertexBuffer.MatricesIndicesExtraKind
  28650. * - VertexBuffer.MatricesWeightsKind
  28651. * - VertexBuffer.MatricesWeightsExtraKind
  28652. */
  28653. removeVerticesData(kind: string): void;
  28654. /**
  28655. * Flags an associated vertex buffer as updatable
  28656. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28657. * - VertexBuffer.PositionKind
  28658. * - VertexBuffer.UVKind
  28659. * - VertexBuffer.UV2Kind
  28660. * - VertexBuffer.UV3Kind
  28661. * - VertexBuffer.UV4Kind
  28662. * - VertexBuffer.UV5Kind
  28663. * - VertexBuffer.UV6Kind
  28664. * - VertexBuffer.ColorKind
  28665. * - VertexBuffer.MatricesIndicesKind
  28666. * - VertexBuffer.MatricesIndicesExtraKind
  28667. * - VertexBuffer.MatricesWeightsKind
  28668. * - VertexBuffer.MatricesWeightsExtraKind
  28669. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28670. */
  28671. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28672. /**
  28673. * Sets the mesh global Vertex Buffer
  28674. * @param buffer defines the buffer to use
  28675. * @returns the current mesh
  28676. */
  28677. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28678. /**
  28679. * Update a specific associated vertex buffer
  28680. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28681. * - VertexBuffer.PositionKind
  28682. * - VertexBuffer.UVKind
  28683. * - VertexBuffer.UV2Kind
  28684. * - VertexBuffer.UV3Kind
  28685. * - VertexBuffer.UV4Kind
  28686. * - VertexBuffer.UV5Kind
  28687. * - VertexBuffer.UV6Kind
  28688. * - VertexBuffer.ColorKind
  28689. * - VertexBuffer.MatricesIndicesKind
  28690. * - VertexBuffer.MatricesIndicesExtraKind
  28691. * - VertexBuffer.MatricesWeightsKind
  28692. * - VertexBuffer.MatricesWeightsExtraKind
  28693. * @param data defines the data source
  28694. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28695. * @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)
  28696. * @returns the current mesh
  28697. */
  28698. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28699. /**
  28700. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28701. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28702. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28703. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28704. * @returns the current mesh
  28705. */
  28706. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28707. /**
  28708. * Creates a un-shared specific occurence of the geometry for the mesh.
  28709. * @returns the current mesh
  28710. */
  28711. makeGeometryUnique(): Mesh;
  28712. /**
  28713. * Set the index buffer of this mesh
  28714. * @param indices defines the source data
  28715. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28716. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28717. * @returns the current mesh
  28718. */
  28719. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28720. /**
  28721. * Update the current index buffer
  28722. * @param indices defines the source data
  28723. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28724. * @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)
  28725. * @returns the current mesh
  28726. */
  28727. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28728. /**
  28729. * Invert the geometry to move from a right handed system to a left handed one.
  28730. * @returns the current mesh
  28731. */
  28732. toLeftHanded(): Mesh;
  28733. /** @hidden */
  28734. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28735. /** @hidden */
  28736. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28737. /**
  28738. * Registers for this mesh a javascript function called just before the rendering process
  28739. * @param func defines the function to call before rendering this mesh
  28740. * @returns the current mesh
  28741. */
  28742. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28743. /**
  28744. * Disposes a previously registered javascript function called before the rendering
  28745. * @param func defines the function to remove
  28746. * @returns the current mesh
  28747. */
  28748. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28749. /**
  28750. * Registers for this mesh a javascript function called just after the rendering is complete
  28751. * @param func defines the function to call after rendering this mesh
  28752. * @returns the current mesh
  28753. */
  28754. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28755. /**
  28756. * Disposes a previously registered javascript function called after the rendering.
  28757. * @param func defines the function to remove
  28758. * @returns the current mesh
  28759. */
  28760. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28761. /** @hidden */
  28762. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28763. /** @hidden */
  28764. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28765. /** @hidden */
  28766. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28767. /** @hidden */
  28768. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28769. /** @hidden */
  28770. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28771. /** @hidden */
  28772. _rebuild(): void;
  28773. /** @hidden */
  28774. _freeze(): void;
  28775. /** @hidden */
  28776. _unFreeze(): void;
  28777. /**
  28778. * 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
  28779. * @param subMesh defines the subMesh to render
  28780. * @param enableAlphaMode defines if alpha mode can be changed
  28781. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28782. * @returns the current mesh
  28783. */
  28784. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28785. private _onBeforeDraw;
  28786. /**
  28787. * Renormalize the mesh and patch it up if there are no weights
  28788. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28789. * However in the case of zero weights then we set just a single influence to 1.
  28790. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28791. */
  28792. cleanMatrixWeights(): void;
  28793. private normalizeSkinFourWeights;
  28794. private normalizeSkinWeightsAndExtra;
  28795. /**
  28796. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28797. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28798. * the user know there was an issue with importing the mesh
  28799. * @returns a validation object with skinned, valid and report string
  28800. */
  28801. validateSkinning(): {
  28802. skinned: boolean;
  28803. valid: boolean;
  28804. report: string;
  28805. };
  28806. /** @hidden */
  28807. _checkDelayState(): Mesh;
  28808. private _queueLoad;
  28809. /**
  28810. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28811. * A mesh is in the frustum if its bounding box intersects the frustum
  28812. * @param frustumPlanes defines the frustum to test
  28813. * @returns true if the mesh is in the frustum planes
  28814. */
  28815. isInFrustum(frustumPlanes: Plane[]): boolean;
  28816. /**
  28817. * Sets the mesh material by the material or multiMaterial `id` property
  28818. * @param id is a string identifying the material or the multiMaterial
  28819. * @returns the current mesh
  28820. */
  28821. setMaterialByID(id: string): Mesh;
  28822. /**
  28823. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28824. * @returns an array of IAnimatable
  28825. */
  28826. getAnimatables(): IAnimatable[];
  28827. /**
  28828. * Modifies the mesh geometry according to the passed transformation matrix.
  28829. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28830. * The mesh normals are modified using the same transformation.
  28831. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28832. * @param transform defines the transform matrix to use
  28833. * @see http://doc.babylonjs.com/resources/baking_transformations
  28834. * @returns the current mesh
  28835. */
  28836. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28837. /**
  28838. * Modifies the mesh geometry according to its own current World Matrix.
  28839. * The mesh World Matrix is then reset.
  28840. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28841. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28842. * @see http://doc.babylonjs.com/resources/baking_transformations
  28843. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28844. * @returns the current mesh
  28845. */
  28846. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28847. /** @hidden */
  28848. get _positions(): Nullable<Vector3[]>;
  28849. /** @hidden */
  28850. _resetPointsArrayCache(): Mesh;
  28851. /** @hidden */
  28852. _generatePointsArray(): boolean;
  28853. /**
  28854. * Returns a new Mesh object generated from the current mesh properties.
  28855. * This method must not get confused with createInstance()
  28856. * @param name is a string, the name given to the new mesh
  28857. * @param newParent can be any Node object (default `null`)
  28858. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28859. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28860. * @returns a new mesh
  28861. */
  28862. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28863. /**
  28864. * Releases resources associated with this mesh.
  28865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28867. */
  28868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28869. /** @hidden */
  28870. _disposeInstanceSpecificData(): void;
  28871. /** @hidden */
  28872. _disposeThinInstanceSpecificData(): void;
  28873. /**
  28874. * Modifies the mesh geometry according to a displacement map.
  28875. * 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.
  28876. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28877. * @param url is a string, the URL from the image file is to be downloaded.
  28878. * @param minHeight is the lower limit of the displacement.
  28879. * @param maxHeight is the upper limit of the displacement.
  28880. * @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.
  28881. * @param uvOffset is an optional vector2 used to offset UV.
  28882. * @param uvScale is an optional vector2 used to scale UV.
  28883. * @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.
  28884. * @returns the Mesh.
  28885. */
  28886. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28887. /**
  28888. * Modifies the mesh geometry according to a displacementMap buffer.
  28889. * 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.
  28890. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28891. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28892. * @param heightMapWidth is the width of the buffer image.
  28893. * @param heightMapHeight is the height of the buffer image.
  28894. * @param minHeight is the lower limit of the displacement.
  28895. * @param maxHeight is the upper limit of the displacement.
  28896. * @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.
  28897. * @param uvOffset is an optional vector2 used to offset UV.
  28898. * @param uvScale is an optional vector2 used to scale UV.
  28899. * @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.
  28900. * @returns the Mesh.
  28901. */
  28902. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28903. /**
  28904. * Modify the mesh to get a flat shading rendering.
  28905. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28906. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28907. * @returns current mesh
  28908. */
  28909. convertToFlatShadedMesh(): Mesh;
  28910. /**
  28911. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28912. * In other words, more vertices, no more indices and a single bigger VBO.
  28913. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28914. * @returns current mesh
  28915. */
  28916. convertToUnIndexedMesh(): Mesh;
  28917. /**
  28918. * Inverses facet orientations.
  28919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28920. * @param flipNormals will also inverts the normals
  28921. * @returns current mesh
  28922. */
  28923. flipFaces(flipNormals?: boolean): Mesh;
  28924. /**
  28925. * Increase the number of facets and hence vertices in a mesh
  28926. * Vertex normals are interpolated from existing vertex normals
  28927. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28928. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28929. */
  28930. increaseVertices(numberPerEdge: number): void;
  28931. /**
  28932. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28933. * This will undo any application of covertToFlatShadedMesh
  28934. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28935. */
  28936. forceSharedVertices(): void;
  28937. /** @hidden */
  28938. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28939. /** @hidden */
  28940. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28941. /**
  28942. * Creates a new InstancedMesh object from the mesh model.
  28943. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28944. * @param name defines the name of the new instance
  28945. * @returns a new InstancedMesh
  28946. */
  28947. createInstance(name: string): InstancedMesh;
  28948. /**
  28949. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28950. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28951. * @returns the current mesh
  28952. */
  28953. synchronizeInstances(): Mesh;
  28954. /**
  28955. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28956. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28957. * This should be used together with the simplification to avoid disappearing triangles.
  28958. * @param successCallback an optional success callback to be called after the optimization finished.
  28959. * @returns the current mesh
  28960. */
  28961. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28962. /**
  28963. * Serialize current mesh
  28964. * @param serializationObject defines the object which will receive the serialization data
  28965. */
  28966. serialize(serializationObject: any): void;
  28967. /** @hidden */
  28968. _syncGeometryWithMorphTargetManager(): void;
  28969. /** @hidden */
  28970. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28971. /**
  28972. * Returns a new Mesh object parsed from the source provided.
  28973. * @param parsedMesh is the source
  28974. * @param scene defines the hosting scene
  28975. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28976. * @returns a new Mesh
  28977. */
  28978. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28979. /**
  28980. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28981. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28982. * @param name defines the name of the mesh to create
  28983. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28984. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28985. * @param closePath creates a seam between the first and the last points of each path of the path array
  28986. * @param offset is taken in account only if the `pathArray` is containing a single path
  28987. * @param scene defines the hosting scene
  28988. * @param updatable defines if the mesh must be flagged as updatable
  28989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28990. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  28991. * @returns a new Mesh
  28992. */
  28993. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28994. /**
  28995. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28996. * @param name defines the name of the mesh to create
  28997. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28998. * @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
  28999. * @param scene defines the hosting scene
  29000. * @param updatable defines if the mesh must be flagged as updatable
  29001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29002. * @returns a new Mesh
  29003. */
  29004. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29005. /**
  29006. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29007. * @param name defines the name of the mesh to create
  29008. * @param size sets the size (float) of each box side (default 1)
  29009. * @param scene defines the hosting scene
  29010. * @param updatable defines if the mesh must be flagged as updatable
  29011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29012. * @returns a new Mesh
  29013. */
  29014. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29015. /**
  29016. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29017. * @param name defines the name of the mesh to create
  29018. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29019. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29020. * @param scene defines the hosting scene
  29021. * @param updatable defines if the mesh must be flagged as updatable
  29022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29023. * @returns a new Mesh
  29024. */
  29025. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29026. /**
  29027. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29028. * @param name defines the name of the mesh to create
  29029. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29030. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29031. * @param scene defines the hosting scene
  29032. * @returns a new Mesh
  29033. */
  29034. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29035. /**
  29036. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29037. * @param name defines the name of the mesh to create
  29038. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29039. * @param diameterTop set the top cap diameter (floats, default 1)
  29040. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29041. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29042. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29043. * @param scene defines the hosting scene
  29044. * @param updatable defines if the mesh must be flagged as updatable
  29045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29046. * @returns a new Mesh
  29047. */
  29048. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29049. /**
  29050. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29051. * @param name defines the name of the mesh to create
  29052. * @param diameter sets the diameter size (float) of the torus (default 1)
  29053. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29054. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29055. * @param scene defines the hosting scene
  29056. * @param updatable defines if the mesh must be flagged as updatable
  29057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29058. * @returns a new Mesh
  29059. */
  29060. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29061. /**
  29062. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29063. * @param name defines the name of the mesh to create
  29064. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29065. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29066. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29067. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29068. * @param p the number of windings on X axis (positive integers, default 2)
  29069. * @param q the number of windings on Y axis (positive integers, default 3)
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @returns a new Mesh
  29074. */
  29075. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29076. /**
  29077. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29078. * @param name defines the name of the mesh to create
  29079. * @param points is an array successive Vector3
  29080. * @param scene defines the hosting scene
  29081. * @param updatable defines if the mesh must be flagged as updatable
  29082. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  29083. * @returns a new Mesh
  29084. */
  29085. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29086. /**
  29087. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29088. * @param name defines the name of the mesh to create
  29089. * @param points is an array successive Vector3
  29090. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29091. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29092. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29093. * @param scene defines the hosting scene
  29094. * @param updatable defines if the mesh must be flagged as updatable
  29095. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  29096. * @returns a new Mesh
  29097. */
  29098. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29099. /**
  29100. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29101. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29102. * 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.
  29103. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29104. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29105. * Remember you can only change the shape positions, not their number when updating a polygon.
  29106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29107. * @param name defines the name of the mesh to create
  29108. * @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
  29109. * @param scene defines the hosting scene
  29110. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29111. * @param updatable defines if the mesh must be flagged as updatable
  29112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29113. * @param earcutInjection can be used to inject your own earcut reference
  29114. * @returns a new Mesh
  29115. */
  29116. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29117. /**
  29118. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29120. * @param name defines the name of the mesh to create
  29121. * @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
  29122. * @param depth defines the height of extrusion
  29123. * @param scene defines the hosting scene
  29124. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29125. * @param updatable defines if the mesh must be flagged as updatable
  29126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29127. * @param earcutInjection can be used to inject your own earcut reference
  29128. * @returns a new Mesh
  29129. */
  29130. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29131. /**
  29132. * Creates an extruded shape mesh.
  29133. * 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
  29134. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29135. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29136. * @param name defines the name of the mesh to create
  29137. * @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
  29138. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29139. * @param scale is the value to scale the shape
  29140. * @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
  29141. * @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
  29142. * @param scene defines the hosting scene
  29143. * @param updatable defines if the mesh must be flagged as updatable
  29144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29145. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  29146. * @returns a new Mesh
  29147. */
  29148. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29149. /**
  29150. * Creates an custom extruded shape mesh.
  29151. * The custom extrusion is a parametric shape.
  29152. * It has no predefined shape. Its final shape will depend on the input parameters.
  29153. * Please consider using the same method from the MeshBuilder class instead
  29154. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29155. * @param name defines the name of the mesh to create
  29156. * @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
  29157. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29158. * @param scaleFunction is a custom Javascript function called on each path point
  29159. * @param rotationFunction is a custom Javascript function called on each path point
  29160. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29161. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29162. * @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
  29163. * @param scene defines the hosting scene
  29164. * @param updatable defines if the mesh must be flagged as updatable
  29165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29166. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  29167. * @returns a new Mesh
  29168. */
  29169. 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;
  29170. /**
  29171. * Creates lathe mesh.
  29172. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29173. * Please consider using the same method from the MeshBuilder class instead
  29174. * @param name defines the name of the mesh to create
  29175. * @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
  29176. * @param radius is the radius value of the lathe
  29177. * @param tessellation is the side number of the lathe.
  29178. * @param scene defines the hosting scene
  29179. * @param updatable defines if the mesh must be flagged as updatable
  29180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29181. * @returns a new Mesh
  29182. */
  29183. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29184. /**
  29185. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29186. * @param name defines the name of the mesh to create
  29187. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29188. * @param scene defines the hosting scene
  29189. * @param updatable defines if the mesh must be flagged as updatable
  29190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29191. * @returns a new Mesh
  29192. */
  29193. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29194. /**
  29195. * Creates a ground mesh.
  29196. * Please consider using the same method from the MeshBuilder class instead
  29197. * @param name defines the name of the mesh to create
  29198. * @param width set the width of the ground
  29199. * @param height set the height of the ground
  29200. * @param subdivisions sets the number of subdivisions per side
  29201. * @param scene defines the hosting scene
  29202. * @param updatable defines if the mesh must be flagged as updatable
  29203. * @returns a new Mesh
  29204. */
  29205. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29206. /**
  29207. * Creates a tiled ground mesh.
  29208. * Please consider using the same method from the MeshBuilder class instead
  29209. * @param name defines the name of the mesh to create
  29210. * @param xmin set the ground minimum X coordinate
  29211. * @param zmin set the ground minimum Y coordinate
  29212. * @param xmax set the ground maximum X coordinate
  29213. * @param zmax set the ground maximum Z coordinate
  29214. * @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
  29215. * @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
  29216. * @param scene defines the hosting scene
  29217. * @param updatable defines if the mesh must be flagged as updatable
  29218. * @returns a new Mesh
  29219. */
  29220. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29221. w: number;
  29222. h: number;
  29223. }, precision: {
  29224. w: number;
  29225. h: number;
  29226. }, scene: Scene, updatable?: boolean): Mesh;
  29227. /**
  29228. * Creates a ground mesh from a height map.
  29229. * Please consider using the same method from the MeshBuilder class instead
  29230. * @see http://doc.babylonjs.com/babylon101/height_map
  29231. * @param name defines the name of the mesh to create
  29232. * @param url sets the URL of the height map image resource
  29233. * @param width set the ground width size
  29234. * @param height set the ground height size
  29235. * @param subdivisions sets the number of subdivision per side
  29236. * @param minHeight is the minimum altitude on the ground
  29237. * @param maxHeight is the maximum altitude on the ground
  29238. * @param scene defines the hosting scene
  29239. * @param updatable defines if the mesh must be flagged as updatable
  29240. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29241. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29242. * @returns a new Mesh
  29243. */
  29244. 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;
  29245. /**
  29246. * Creates a tube mesh.
  29247. * The tube is a parametric shape.
  29248. * It has no predefined shape. Its final shape will depend on the input parameters.
  29249. * Please consider using the same method from the MeshBuilder class instead
  29250. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29251. * @param name defines the name of the mesh to create
  29252. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29253. * @param radius sets the tube radius size
  29254. * @param tessellation is the number of sides on the tubular surface
  29255. * @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
  29256. * @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
  29257. * @param scene defines the hosting scene
  29258. * @param updatable defines if the mesh must be flagged as updatable
  29259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29260. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  29261. * @returns a new Mesh
  29262. */
  29263. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29264. (i: number, distance: number): number;
  29265. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29266. /**
  29267. * Creates a polyhedron mesh.
  29268. * Please consider using the same method from the MeshBuilder class instead.
  29269. * * 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
  29270. * * The parameter `size` (positive float, default 1) sets the polygon size
  29271. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29272. * * 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`
  29273. * * 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
  29274. * * 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)`)
  29275. * * 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
  29276. * * 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
  29277. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29280. * @param name defines the name of the mesh to create
  29281. * @param options defines the options used to create the mesh
  29282. * @param scene defines the hosting scene
  29283. * @returns a new Mesh
  29284. */
  29285. static CreatePolyhedron(name: string, options: {
  29286. type?: number;
  29287. size?: number;
  29288. sizeX?: number;
  29289. sizeY?: number;
  29290. sizeZ?: number;
  29291. custom?: any;
  29292. faceUV?: Vector4[];
  29293. faceColors?: Color4[];
  29294. updatable?: boolean;
  29295. sideOrientation?: number;
  29296. }, scene: Scene): Mesh;
  29297. /**
  29298. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29299. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29300. * * 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`)
  29301. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29302. * * 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
  29303. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29306. * @param name defines the name of the mesh
  29307. * @param options defines the options used to create the mesh
  29308. * @param scene defines the hosting scene
  29309. * @returns a new Mesh
  29310. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29311. */
  29312. static CreateIcoSphere(name: string, options: {
  29313. radius?: number;
  29314. flat?: boolean;
  29315. subdivisions?: number;
  29316. sideOrientation?: number;
  29317. updatable?: boolean;
  29318. }, scene: Scene): Mesh;
  29319. /**
  29320. * Creates a decal mesh.
  29321. * Please consider using the same method from the MeshBuilder class instead.
  29322. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29323. * @param name defines the name of the mesh
  29324. * @param sourceMesh defines the mesh receiving the decal
  29325. * @param position sets the position of the decal in world coordinates
  29326. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29327. * @param size sets the decal scaling
  29328. * @param angle sets the angle to rotate the decal
  29329. * @returns a new Mesh
  29330. */
  29331. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29332. /**
  29333. * Prepare internal position array for software CPU skinning
  29334. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29335. */
  29336. setPositionsForCPUSkinning(): Float32Array;
  29337. /**
  29338. * Prepare internal normal array for software CPU skinning
  29339. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29340. */
  29341. setNormalsForCPUSkinning(): Float32Array;
  29342. /**
  29343. * Updates the vertex buffer by applying transformation from the bones
  29344. * @param skeleton defines the skeleton to apply to current mesh
  29345. * @returns the current mesh
  29346. */
  29347. applySkeleton(skeleton: Skeleton): Mesh;
  29348. /**
  29349. * 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
  29350. * @param meshes defines the list of meshes to scan
  29351. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29352. */
  29353. static MinMax(meshes: AbstractMesh[]): {
  29354. min: Vector3;
  29355. max: Vector3;
  29356. };
  29357. /**
  29358. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29359. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29360. * @returns a vector3
  29361. */
  29362. static Center(meshesOrMinMaxVector: {
  29363. min: Vector3;
  29364. max: Vector3;
  29365. } | AbstractMesh[]): Vector3;
  29366. /**
  29367. * Merge the array of meshes into a single mesh for performance reasons.
  29368. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29369. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29370. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29371. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29372. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29373. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29374. * @returns a new mesh
  29375. */
  29376. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29377. /** @hidden */
  29378. addInstance(instance: InstancedMesh): void;
  29379. /** @hidden */
  29380. removeInstance(instance: InstancedMesh): void;
  29381. }
  29382. }
  29383. declare module "babylonjs/Cameras/camera" {
  29384. import { SmartArray } from "babylonjs/Misc/smartArray";
  29385. import { Observable } from "babylonjs/Misc/observable";
  29386. import { Nullable } from "babylonjs/types";
  29387. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29388. import { Scene } from "babylonjs/scene";
  29389. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29390. import { Node } from "babylonjs/node";
  29391. import { Mesh } from "babylonjs/Meshes/mesh";
  29392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29393. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29394. import { Viewport } from "babylonjs/Maths/math.viewport";
  29395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29398. import { Ray } from "babylonjs/Culling/ray";
  29399. /**
  29400. * This is the base class of all the camera used in the application.
  29401. * @see http://doc.babylonjs.com/features/cameras
  29402. */
  29403. export class Camera extends Node {
  29404. /** @hidden */
  29405. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29406. /**
  29407. * This is the default projection mode used by the cameras.
  29408. * It helps recreating a feeling of perspective and better appreciate depth.
  29409. * This is the best way to simulate real life cameras.
  29410. */
  29411. static readonly PERSPECTIVE_CAMERA: number;
  29412. /**
  29413. * This helps creating camera with an orthographic mode.
  29414. * 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.
  29415. */
  29416. static readonly ORTHOGRAPHIC_CAMERA: number;
  29417. /**
  29418. * This is the default FOV mode for perspective cameras.
  29419. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29420. */
  29421. static readonly FOVMODE_VERTICAL_FIXED: number;
  29422. /**
  29423. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29424. */
  29425. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29426. /**
  29427. * This specifies ther is no need for a camera rig.
  29428. * Basically only one eye is rendered corresponding to the camera.
  29429. */
  29430. static readonly RIG_MODE_NONE: number;
  29431. /**
  29432. * Simulates a camera Rig with one blue eye and one red eye.
  29433. * This can be use with 3d blue and red glasses.
  29434. */
  29435. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29436. /**
  29437. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29438. */
  29439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29440. /**
  29441. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29442. */
  29443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29444. /**
  29445. * Defines that both eyes of the camera will be rendered over under each other.
  29446. */
  29447. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29448. /**
  29449. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29450. */
  29451. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29452. /**
  29453. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29454. */
  29455. static readonly RIG_MODE_VR: number;
  29456. /**
  29457. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29458. */
  29459. static readonly RIG_MODE_WEBVR: number;
  29460. /**
  29461. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29462. */
  29463. static readonly RIG_MODE_CUSTOM: number;
  29464. /**
  29465. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29466. */
  29467. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29468. /**
  29469. * Define the input manager associated with the camera.
  29470. */
  29471. inputs: CameraInputsManager<Camera>;
  29472. /** @hidden */
  29473. _position: Vector3;
  29474. /**
  29475. * Define the current local position of the camera in the scene
  29476. */
  29477. get position(): Vector3;
  29478. set position(newPosition: Vector3);
  29479. /**
  29480. * The vector the camera should consider as up.
  29481. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29482. */
  29483. upVector: Vector3;
  29484. /**
  29485. * Define the current limit on the left side for an orthographic camera
  29486. * In scene unit
  29487. */
  29488. orthoLeft: Nullable<number>;
  29489. /**
  29490. * Define the current limit on the right side for an orthographic camera
  29491. * In scene unit
  29492. */
  29493. orthoRight: Nullable<number>;
  29494. /**
  29495. * Define the current limit on the bottom side for an orthographic camera
  29496. * In scene unit
  29497. */
  29498. orthoBottom: Nullable<number>;
  29499. /**
  29500. * Define the current limit on the top side for an orthographic camera
  29501. * In scene unit
  29502. */
  29503. orthoTop: Nullable<number>;
  29504. /**
  29505. * Field Of View is set in Radians. (default is 0.8)
  29506. */
  29507. fov: number;
  29508. /**
  29509. * Define the minimum distance the camera can see from.
  29510. * This is important to note that the depth buffer are not infinite and the closer it starts
  29511. * the more your scene might encounter depth fighting issue.
  29512. */
  29513. minZ: number;
  29514. /**
  29515. * Define the maximum distance the camera can see to.
  29516. * This is important to note that the depth buffer are not infinite and the further it end
  29517. * the more your scene might encounter depth fighting issue.
  29518. */
  29519. maxZ: number;
  29520. /**
  29521. * Define the default inertia of the camera.
  29522. * This helps giving a smooth feeling to the camera movement.
  29523. */
  29524. inertia: number;
  29525. /**
  29526. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29527. */
  29528. mode: number;
  29529. /**
  29530. * Define whether the camera is intermediate.
  29531. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29532. */
  29533. isIntermediate: boolean;
  29534. /**
  29535. * Define the viewport of the camera.
  29536. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29537. */
  29538. viewport: Viewport;
  29539. /**
  29540. * Restricts the camera to viewing objects with the same layerMask.
  29541. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29542. */
  29543. layerMask: number;
  29544. /**
  29545. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29546. */
  29547. fovMode: number;
  29548. /**
  29549. * Rig mode of the camera.
  29550. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29551. * This is normally controlled byt the camera themselves as internal use.
  29552. */
  29553. cameraRigMode: number;
  29554. /**
  29555. * Defines the distance between both "eyes" in case of a RIG
  29556. */
  29557. interaxialDistance: number;
  29558. /**
  29559. * Defines if stereoscopic rendering is done side by side or over under.
  29560. */
  29561. isStereoscopicSideBySide: boolean;
  29562. /**
  29563. * 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
  29564. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29565. * else in the scene. (Eg. security camera)
  29566. *
  29567. * 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)
  29568. */
  29569. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29570. /**
  29571. * When set, the camera will render to this render target instead of the default canvas
  29572. *
  29573. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29574. */
  29575. outputRenderTarget: Nullable<RenderTargetTexture>;
  29576. /**
  29577. * Observable triggered when the camera view matrix has changed.
  29578. */
  29579. onViewMatrixChangedObservable: Observable<Camera>;
  29580. /**
  29581. * Observable triggered when the camera Projection matrix has changed.
  29582. */
  29583. onProjectionMatrixChangedObservable: Observable<Camera>;
  29584. /**
  29585. * Observable triggered when the inputs have been processed.
  29586. */
  29587. onAfterCheckInputsObservable: Observable<Camera>;
  29588. /**
  29589. * Observable triggered when reset has been called and applied to the camera.
  29590. */
  29591. onRestoreStateObservable: Observable<Camera>;
  29592. /**
  29593. * Is this camera a part of a rig system?
  29594. */
  29595. isRigCamera: boolean;
  29596. /**
  29597. * If isRigCamera set to true this will be set with the parent camera.
  29598. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29599. */
  29600. rigParent?: Camera;
  29601. /** @hidden */
  29602. _cameraRigParams: any;
  29603. /** @hidden */
  29604. _rigCameras: Camera[];
  29605. /** @hidden */
  29606. _rigPostProcess: Nullable<PostProcess>;
  29607. protected _webvrViewMatrix: Matrix;
  29608. /** @hidden */
  29609. _skipRendering: boolean;
  29610. /** @hidden */
  29611. _projectionMatrix: Matrix;
  29612. /** @hidden */
  29613. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29614. /** @hidden */
  29615. _activeMeshes: SmartArray<AbstractMesh>;
  29616. protected _globalPosition: Vector3;
  29617. /** @hidden */
  29618. _computedViewMatrix: Matrix;
  29619. private _doNotComputeProjectionMatrix;
  29620. private _transformMatrix;
  29621. private _frustumPlanes;
  29622. private _refreshFrustumPlanes;
  29623. private _storedFov;
  29624. private _stateStored;
  29625. /**
  29626. * Instantiates a new camera object.
  29627. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29628. * @see http://doc.babylonjs.com/features/cameras
  29629. * @param name Defines the name of the camera in the scene
  29630. * @param position Defines the position of the camera
  29631. * @param scene Defines the scene the camera belongs too
  29632. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29633. */
  29634. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29635. /**
  29636. * Store current camera state (fov, position, etc..)
  29637. * @returns the camera
  29638. */
  29639. storeState(): Camera;
  29640. /**
  29641. * Restores the camera state values if it has been stored. You must call storeState() first
  29642. */
  29643. protected _restoreStateValues(): boolean;
  29644. /**
  29645. * Restored camera state. You must call storeState() first.
  29646. * @returns true if restored and false otherwise
  29647. */
  29648. restoreState(): boolean;
  29649. /**
  29650. * Gets the class name of the camera.
  29651. * @returns the class name
  29652. */
  29653. getClassName(): string;
  29654. /** @hidden */
  29655. readonly _isCamera: boolean;
  29656. /**
  29657. * Gets a string representation of the camera useful for debug purpose.
  29658. * @param fullDetails Defines that a more verboe level of logging is required
  29659. * @returns the string representation
  29660. */
  29661. toString(fullDetails?: boolean): string;
  29662. /**
  29663. * Gets the current world space position of the camera.
  29664. */
  29665. get globalPosition(): Vector3;
  29666. /**
  29667. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29668. * @returns the active meshe list
  29669. */
  29670. getActiveMeshes(): SmartArray<AbstractMesh>;
  29671. /**
  29672. * Check whether a mesh is part of the current active mesh list of the camera
  29673. * @param mesh Defines the mesh to check
  29674. * @returns true if active, false otherwise
  29675. */
  29676. isActiveMesh(mesh: Mesh): boolean;
  29677. /**
  29678. * Is this camera ready to be used/rendered
  29679. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29680. * @return true if the camera is ready
  29681. */
  29682. isReady(completeCheck?: boolean): boolean;
  29683. /** @hidden */
  29684. _initCache(): void;
  29685. /** @hidden */
  29686. _updateCache(ignoreParentClass?: boolean): void;
  29687. /** @hidden */
  29688. _isSynchronized(): boolean;
  29689. /** @hidden */
  29690. _isSynchronizedViewMatrix(): boolean;
  29691. /** @hidden */
  29692. _isSynchronizedProjectionMatrix(): boolean;
  29693. /**
  29694. * Attach the input controls to a specific dom element to get the input from.
  29695. * @param element Defines the element the controls should be listened from
  29696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29697. */
  29698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29699. /**
  29700. * Detach the current controls from the specified dom element.
  29701. * @param element Defines the element to stop listening the inputs from
  29702. */
  29703. detachControl(element: HTMLElement): void;
  29704. /**
  29705. * Update the camera state according to the different inputs gathered during the frame.
  29706. */
  29707. update(): void;
  29708. /** @hidden */
  29709. _checkInputs(): void;
  29710. /** @hidden */
  29711. get rigCameras(): Camera[];
  29712. /**
  29713. * Gets the post process used by the rig cameras
  29714. */
  29715. get rigPostProcess(): Nullable<PostProcess>;
  29716. /**
  29717. * Internal, gets the first post proces.
  29718. * @returns the first post process to be run on this camera.
  29719. */
  29720. _getFirstPostProcess(): Nullable<PostProcess>;
  29721. private _cascadePostProcessesToRigCams;
  29722. /**
  29723. * Attach a post process to the camera.
  29724. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29725. * @param postProcess The post process to attach to the camera
  29726. * @param insertAt The position of the post process in case several of them are in use in the scene
  29727. * @returns the position the post process has been inserted at
  29728. */
  29729. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29730. /**
  29731. * Detach a post process to the camera.
  29732. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29733. * @param postProcess The post process to detach from the camera
  29734. */
  29735. detachPostProcess(postProcess: PostProcess): void;
  29736. /**
  29737. * Gets the current world matrix of the camera
  29738. */
  29739. getWorldMatrix(): Matrix;
  29740. /** @hidden */
  29741. _getViewMatrix(): Matrix;
  29742. /**
  29743. * Gets the current view matrix of the camera.
  29744. * @param force forces the camera to recompute the matrix without looking at the cached state
  29745. * @returns the view matrix
  29746. */
  29747. getViewMatrix(force?: boolean): Matrix;
  29748. /**
  29749. * Freeze the projection matrix.
  29750. * It will prevent the cache check of the camera projection compute and can speed up perf
  29751. * if no parameter of the camera are meant to change
  29752. * @param projection Defines manually a projection if necessary
  29753. */
  29754. freezeProjectionMatrix(projection?: Matrix): void;
  29755. /**
  29756. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29757. */
  29758. unfreezeProjectionMatrix(): void;
  29759. /**
  29760. * Gets the current projection matrix of the camera.
  29761. * @param force forces the camera to recompute the matrix without looking at the cached state
  29762. * @returns the projection matrix
  29763. */
  29764. getProjectionMatrix(force?: boolean): Matrix;
  29765. /**
  29766. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29767. * @returns a Matrix
  29768. */
  29769. getTransformationMatrix(): Matrix;
  29770. private _updateFrustumPlanes;
  29771. /**
  29772. * Checks if a cullable object (mesh...) is in the camera frustum
  29773. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29774. * @param target The object to check
  29775. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29776. * @returns true if the object is in frustum otherwise false
  29777. */
  29778. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29779. /**
  29780. * Checks if a cullable object (mesh...) is in the camera frustum
  29781. * Unlike isInFrustum this cheks the full bounding box
  29782. * @param target The object to check
  29783. * @returns true if the object is in frustum otherwise false
  29784. */
  29785. isCompletelyInFrustum(target: ICullable): boolean;
  29786. /**
  29787. * Gets a ray in the forward direction from the camera.
  29788. * @param length Defines the length of the ray to create
  29789. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29790. * @param origin Defines the start point of the ray which defaults to the camera position
  29791. * @returns the forward ray
  29792. */
  29793. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29794. /**
  29795. * Releases resources associated with this node.
  29796. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29797. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29798. */
  29799. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29800. /** @hidden */
  29801. _isLeftCamera: boolean;
  29802. /**
  29803. * Gets the left camera of a rig setup in case of Rigged Camera
  29804. */
  29805. get isLeftCamera(): boolean;
  29806. /** @hidden */
  29807. _isRightCamera: boolean;
  29808. /**
  29809. * Gets the right camera of a rig setup in case of Rigged Camera
  29810. */
  29811. get isRightCamera(): boolean;
  29812. /**
  29813. * Gets the left camera of a rig setup in case of Rigged Camera
  29814. */
  29815. get leftCamera(): Nullable<FreeCamera>;
  29816. /**
  29817. * Gets the right camera of a rig setup in case of Rigged Camera
  29818. */
  29819. get rightCamera(): Nullable<FreeCamera>;
  29820. /**
  29821. * Gets the left camera target of a rig setup in case of Rigged Camera
  29822. * @returns the target position
  29823. */
  29824. getLeftTarget(): Nullable<Vector3>;
  29825. /**
  29826. * Gets the right camera target of a rig setup in case of Rigged Camera
  29827. * @returns the target position
  29828. */
  29829. getRightTarget(): Nullable<Vector3>;
  29830. /**
  29831. * @hidden
  29832. */
  29833. setCameraRigMode(mode: number, rigParams: any): void;
  29834. /** @hidden */
  29835. static _setStereoscopicRigMode(camera: Camera): void;
  29836. /** @hidden */
  29837. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29838. /** @hidden */
  29839. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29840. /** @hidden */
  29841. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29842. /** @hidden */
  29843. _getVRProjectionMatrix(): Matrix;
  29844. protected _updateCameraRotationMatrix(): void;
  29845. protected _updateWebVRCameraRotationMatrix(): void;
  29846. /**
  29847. * This function MUST be overwritten by the different WebVR cameras available.
  29848. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29849. * @hidden
  29850. */
  29851. _getWebVRProjectionMatrix(): Matrix;
  29852. /**
  29853. * This function MUST be overwritten by the different WebVR cameras available.
  29854. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29855. * @hidden
  29856. */
  29857. _getWebVRViewMatrix(): Matrix;
  29858. /** @hidden */
  29859. setCameraRigParameter(name: string, value: any): void;
  29860. /**
  29861. * needs to be overridden by children so sub has required properties to be copied
  29862. * @hidden
  29863. */
  29864. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29865. /**
  29866. * May need to be overridden by children
  29867. * @hidden
  29868. */
  29869. _updateRigCameras(): void;
  29870. /** @hidden */
  29871. _setupInputs(): void;
  29872. /**
  29873. * Serialiaze the camera setup to a json represention
  29874. * @returns the JSON representation
  29875. */
  29876. serialize(): any;
  29877. /**
  29878. * Clones the current camera.
  29879. * @param name The cloned camera name
  29880. * @returns the cloned camera
  29881. */
  29882. clone(name: string): Camera;
  29883. /**
  29884. * Gets the direction of the camera relative to a given local axis.
  29885. * @param localAxis Defines the reference axis to provide a relative direction.
  29886. * @return the direction
  29887. */
  29888. getDirection(localAxis: Vector3): Vector3;
  29889. /**
  29890. * Returns the current camera absolute rotation
  29891. */
  29892. get absoluteRotation(): Quaternion;
  29893. /**
  29894. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29895. * @param localAxis Defines the reference axis to provide a relative direction.
  29896. * @param result Defines the vector to store the result in
  29897. */
  29898. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29899. /**
  29900. * Gets a camera constructor for a given camera type
  29901. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29902. * @param name The name of the camera the result will be able to instantiate
  29903. * @param scene The scene the result will construct the camera in
  29904. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29905. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29906. * @returns a factory method to construc the camera
  29907. */
  29908. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29909. /**
  29910. * Compute the world matrix of the camera.
  29911. * @returns the camera world matrix
  29912. */
  29913. computeWorldMatrix(): Matrix;
  29914. /**
  29915. * Parse a JSON and creates the camera from the parsed information
  29916. * @param parsedCamera The JSON to parse
  29917. * @param scene The scene to instantiate the camera in
  29918. * @returns the newly constructed camera
  29919. */
  29920. static Parse(parsedCamera: any, scene: Scene): Camera;
  29921. }
  29922. }
  29923. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29924. import { Nullable } from "babylonjs/types";
  29925. import { Scene } from "babylonjs/scene";
  29926. import { Vector4 } from "babylonjs/Maths/math.vector";
  29927. import { Mesh } from "babylonjs/Meshes/mesh";
  29928. /**
  29929. * Class containing static functions to help procedurally build meshes
  29930. */
  29931. export class DiscBuilder {
  29932. /**
  29933. * Creates a plane polygonal mesh. By default, this is a disc
  29934. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29935. * * 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
  29936. * * 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
  29937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29940. * @param name defines the name of the mesh
  29941. * @param options defines the options used to create the mesh
  29942. * @param scene defines the hosting scene
  29943. * @returns the plane polygonal mesh
  29944. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29945. */
  29946. static CreateDisc(name: string, options: {
  29947. radius?: number;
  29948. tessellation?: number;
  29949. arc?: number;
  29950. updatable?: boolean;
  29951. sideOrientation?: number;
  29952. frontUVs?: Vector4;
  29953. backUVs?: Vector4;
  29954. }, scene?: Nullable<Scene>): Mesh;
  29955. }
  29956. }
  29957. declare module "babylonjs/Materials/fresnelParameters" {
  29958. import { DeepImmutable } from "babylonjs/types";
  29959. import { Color3 } from "babylonjs/Maths/math.color";
  29960. /**
  29961. * Options to be used when creating a FresnelParameters.
  29962. */
  29963. export type IFresnelParametersCreationOptions = {
  29964. /**
  29965. * Define the color used on edges (grazing angle)
  29966. */
  29967. leftColor?: Color3;
  29968. /**
  29969. * Define the color used on center
  29970. */
  29971. rightColor?: Color3;
  29972. /**
  29973. * Define bias applied to computed fresnel term
  29974. */
  29975. bias?: number;
  29976. /**
  29977. * Defined the power exponent applied to fresnel term
  29978. */
  29979. power?: number;
  29980. /**
  29981. * Define if the fresnel effect is enable or not.
  29982. */
  29983. isEnabled?: boolean;
  29984. };
  29985. /**
  29986. * Serialized format for FresnelParameters.
  29987. */
  29988. export type IFresnelParametersSerialized = {
  29989. /**
  29990. * Define the color used on edges (grazing angle) [as an array]
  29991. */
  29992. leftColor: number[];
  29993. /**
  29994. * Define the color used on center [as an array]
  29995. */
  29996. rightColor: number[];
  29997. /**
  29998. * Define bias applied to computed fresnel term
  29999. */
  30000. bias: number;
  30001. /**
  30002. * Defined the power exponent applied to fresnel term
  30003. */
  30004. power?: number;
  30005. /**
  30006. * Define if the fresnel effect is enable or not.
  30007. */
  30008. isEnabled: boolean;
  30009. };
  30010. /**
  30011. * This represents all the required information to add a fresnel effect on a material:
  30012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30013. */
  30014. export class FresnelParameters {
  30015. private _isEnabled;
  30016. /**
  30017. * Define if the fresnel effect is enable or not.
  30018. */
  30019. get isEnabled(): boolean;
  30020. set isEnabled(value: boolean);
  30021. /**
  30022. * Define the color used on edges (grazing angle)
  30023. */
  30024. leftColor: Color3;
  30025. /**
  30026. * Define the color used on center
  30027. */
  30028. rightColor: Color3;
  30029. /**
  30030. * Define bias applied to computed fresnel term
  30031. */
  30032. bias: number;
  30033. /**
  30034. * Defined the power exponent applied to fresnel term
  30035. */
  30036. power: number;
  30037. /**
  30038. * Creates a new FresnelParameters object.
  30039. *
  30040. * @param options provide your own settings to optionally to override defaults
  30041. */
  30042. constructor(options?: IFresnelParametersCreationOptions);
  30043. /**
  30044. * Clones the current fresnel and its valuues
  30045. * @returns a clone fresnel configuration
  30046. */
  30047. clone(): FresnelParameters;
  30048. /**
  30049. * Determines equality between FresnelParameters objects
  30050. * @param otherFresnelParameters defines the second operand
  30051. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30052. */
  30053. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30054. /**
  30055. * Serializes the current fresnel parameters to a JSON representation.
  30056. * @return the JSON serialization
  30057. */
  30058. serialize(): IFresnelParametersSerialized;
  30059. /**
  30060. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30061. * @param parsedFresnelParameters Define the JSON representation
  30062. * @returns the parsed parameters
  30063. */
  30064. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30065. }
  30066. }
  30067. declare module "babylonjs/Materials/materialFlags" {
  30068. /**
  30069. * This groups all the flags used to control the materials channel.
  30070. */
  30071. export class MaterialFlags {
  30072. private static _DiffuseTextureEnabled;
  30073. /**
  30074. * Are diffuse textures enabled in the application.
  30075. */
  30076. static get DiffuseTextureEnabled(): boolean;
  30077. static set DiffuseTextureEnabled(value: boolean);
  30078. private static _DetailTextureEnabled;
  30079. /**
  30080. * Are detail textures enabled in the application.
  30081. */
  30082. static get DetailTextureEnabled(): boolean;
  30083. static set DetailTextureEnabled(value: boolean);
  30084. private static _AmbientTextureEnabled;
  30085. /**
  30086. * Are ambient textures enabled in the application.
  30087. */
  30088. static get AmbientTextureEnabled(): boolean;
  30089. static set AmbientTextureEnabled(value: boolean);
  30090. private static _OpacityTextureEnabled;
  30091. /**
  30092. * Are opacity textures enabled in the application.
  30093. */
  30094. static get OpacityTextureEnabled(): boolean;
  30095. static set OpacityTextureEnabled(value: boolean);
  30096. private static _ReflectionTextureEnabled;
  30097. /**
  30098. * Are reflection textures enabled in the application.
  30099. */
  30100. static get ReflectionTextureEnabled(): boolean;
  30101. static set ReflectionTextureEnabled(value: boolean);
  30102. private static _EmissiveTextureEnabled;
  30103. /**
  30104. * Are emissive textures enabled in the application.
  30105. */
  30106. static get EmissiveTextureEnabled(): boolean;
  30107. static set EmissiveTextureEnabled(value: boolean);
  30108. private static _SpecularTextureEnabled;
  30109. /**
  30110. * Are specular textures enabled in the application.
  30111. */
  30112. static get SpecularTextureEnabled(): boolean;
  30113. static set SpecularTextureEnabled(value: boolean);
  30114. private static _BumpTextureEnabled;
  30115. /**
  30116. * Are bump textures enabled in the application.
  30117. */
  30118. static get BumpTextureEnabled(): boolean;
  30119. static set BumpTextureEnabled(value: boolean);
  30120. private static _LightmapTextureEnabled;
  30121. /**
  30122. * Are lightmap textures enabled in the application.
  30123. */
  30124. static get LightmapTextureEnabled(): boolean;
  30125. static set LightmapTextureEnabled(value: boolean);
  30126. private static _RefractionTextureEnabled;
  30127. /**
  30128. * Are refraction textures enabled in the application.
  30129. */
  30130. static get RefractionTextureEnabled(): boolean;
  30131. static set RefractionTextureEnabled(value: boolean);
  30132. private static _ColorGradingTextureEnabled;
  30133. /**
  30134. * Are color grading textures enabled in the application.
  30135. */
  30136. static get ColorGradingTextureEnabled(): boolean;
  30137. static set ColorGradingTextureEnabled(value: boolean);
  30138. private static _FresnelEnabled;
  30139. /**
  30140. * Are fresnels enabled in the application.
  30141. */
  30142. static get FresnelEnabled(): boolean;
  30143. static set FresnelEnabled(value: boolean);
  30144. private static _ClearCoatTextureEnabled;
  30145. /**
  30146. * Are clear coat textures enabled in the application.
  30147. */
  30148. static get ClearCoatTextureEnabled(): boolean;
  30149. static set ClearCoatTextureEnabled(value: boolean);
  30150. private static _ClearCoatBumpTextureEnabled;
  30151. /**
  30152. * Are clear coat bump textures enabled in the application.
  30153. */
  30154. static get ClearCoatBumpTextureEnabled(): boolean;
  30155. static set ClearCoatBumpTextureEnabled(value: boolean);
  30156. private static _ClearCoatTintTextureEnabled;
  30157. /**
  30158. * Are clear coat tint textures enabled in the application.
  30159. */
  30160. static get ClearCoatTintTextureEnabled(): boolean;
  30161. static set ClearCoatTintTextureEnabled(value: boolean);
  30162. private static _SheenTextureEnabled;
  30163. /**
  30164. * Are sheen textures enabled in the application.
  30165. */
  30166. static get SheenTextureEnabled(): boolean;
  30167. static set SheenTextureEnabled(value: boolean);
  30168. private static _AnisotropicTextureEnabled;
  30169. /**
  30170. * Are anisotropic textures enabled in the application.
  30171. */
  30172. static get AnisotropicTextureEnabled(): boolean;
  30173. static set AnisotropicTextureEnabled(value: boolean);
  30174. private static _ThicknessTextureEnabled;
  30175. /**
  30176. * Are thickness textures enabled in the application.
  30177. */
  30178. static get ThicknessTextureEnabled(): boolean;
  30179. static set ThicknessTextureEnabled(value: boolean);
  30180. }
  30181. }
  30182. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30183. /** @hidden */
  30184. export var defaultFragmentDeclaration: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30190. /** @hidden */
  30191. export var defaultUboDeclaration: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30197. /** @hidden */
  30198. export var lightFragmentDeclaration: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30204. /** @hidden */
  30205. export var lightUboDeclaration: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30211. /** @hidden */
  30212. export var lightsFragmentFunctions: {
  30213. name: string;
  30214. shader: string;
  30215. };
  30216. }
  30217. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30218. /** @hidden */
  30219. export var shadowsFragmentFunctions: {
  30220. name: string;
  30221. shader: string;
  30222. };
  30223. }
  30224. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30225. /** @hidden */
  30226. export var fresnelFunction: {
  30227. name: string;
  30228. shader: string;
  30229. };
  30230. }
  30231. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30232. /** @hidden */
  30233. export var bumpFragmentMainFunctions: {
  30234. name: string;
  30235. shader: string;
  30236. };
  30237. }
  30238. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30239. /** @hidden */
  30240. export var bumpFragmentFunctions: {
  30241. name: string;
  30242. shader: string;
  30243. };
  30244. }
  30245. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30246. /** @hidden */
  30247. export var logDepthDeclaration: {
  30248. name: string;
  30249. shader: string;
  30250. };
  30251. }
  30252. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30253. /** @hidden */
  30254. export var bumpFragment: {
  30255. name: string;
  30256. shader: string;
  30257. };
  30258. }
  30259. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30260. /** @hidden */
  30261. export var depthPrePass: {
  30262. name: string;
  30263. shader: string;
  30264. };
  30265. }
  30266. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30267. /** @hidden */
  30268. export var lightFragment: {
  30269. name: string;
  30270. shader: string;
  30271. };
  30272. }
  30273. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30274. /** @hidden */
  30275. export var logDepthFragment: {
  30276. name: string;
  30277. shader: string;
  30278. };
  30279. }
  30280. declare module "babylonjs/Shaders/default.fragment" {
  30281. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30282. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30284. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30285. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30286. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30287. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30288. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30289. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30290. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30293. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30298. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30299. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30300. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30301. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30302. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30303. /** @hidden */
  30304. export var defaultPixelShader: {
  30305. name: string;
  30306. shader: string;
  30307. };
  30308. }
  30309. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30310. /** @hidden */
  30311. export var defaultVertexDeclaration: {
  30312. name: string;
  30313. shader: string;
  30314. };
  30315. }
  30316. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30317. /** @hidden */
  30318. export var bumpVertexDeclaration: {
  30319. name: string;
  30320. shader: string;
  30321. };
  30322. }
  30323. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30324. /** @hidden */
  30325. export var bumpVertex: {
  30326. name: string;
  30327. shader: string;
  30328. };
  30329. }
  30330. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30331. /** @hidden */
  30332. export var fogVertex: {
  30333. name: string;
  30334. shader: string;
  30335. };
  30336. }
  30337. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30338. /** @hidden */
  30339. export var shadowsVertex: {
  30340. name: string;
  30341. shader: string;
  30342. };
  30343. }
  30344. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30345. /** @hidden */
  30346. export var pointCloudVertex: {
  30347. name: string;
  30348. shader: string;
  30349. };
  30350. }
  30351. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30352. /** @hidden */
  30353. export var logDepthVertex: {
  30354. name: string;
  30355. shader: string;
  30356. };
  30357. }
  30358. declare module "babylonjs/Shaders/default.vertex" {
  30359. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30360. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30362. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30363. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30364. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30365. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30366. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30367. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30368. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30371. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30375. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30376. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30377. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30378. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30379. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30380. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30381. /** @hidden */
  30382. export var defaultVertexShader: {
  30383. name: string;
  30384. shader: string;
  30385. };
  30386. }
  30387. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30391. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30393. /**
  30394. * @hidden
  30395. */
  30396. export interface IMaterialDetailMapDefines {
  30397. DETAIL: boolean;
  30398. DETAILDIRECTUV: number;
  30399. DETAIL_NORMALBLENDMETHOD: number;
  30400. /** @hidden */
  30401. _areTexturesDirty: boolean;
  30402. }
  30403. /**
  30404. * Define the code related to the detail map parameters of a material
  30405. *
  30406. * Inspired from:
  30407. * 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
  30408. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30409. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30410. */
  30411. export class DetailMapConfiguration {
  30412. private _texture;
  30413. /**
  30414. * The detail texture of the material.
  30415. */
  30416. texture: Nullable<BaseTexture>;
  30417. /**
  30418. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30419. * Bigger values mean stronger blending
  30420. */
  30421. diffuseBlendLevel: number;
  30422. /**
  30423. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30424. * Bigger values mean stronger blending. Only used with PBR materials
  30425. */
  30426. roughnessBlendLevel: number;
  30427. /**
  30428. * Defines how strong the bump effect from the detail map is
  30429. * Bigger values mean stronger effect
  30430. */
  30431. bumpLevel: number;
  30432. private _normalBlendMethod;
  30433. /**
  30434. * The method used to blend the bump and detail normals together
  30435. */
  30436. normalBlendMethod: number;
  30437. private _isEnabled;
  30438. /**
  30439. * Enable or disable the detail map on this material
  30440. */
  30441. isEnabled: boolean;
  30442. /** @hidden */
  30443. private _internalMarkAllSubMeshesAsTexturesDirty;
  30444. /** @hidden */
  30445. _markAllSubMeshesAsTexturesDirty(): void;
  30446. /**
  30447. * Instantiate a new detail map
  30448. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30449. */
  30450. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30451. /**
  30452. * Gets whether the submesh is ready to be used or not.
  30453. * @param defines the list of "defines" to update.
  30454. * @param scene defines the scene the material belongs to.
  30455. * @returns - boolean indicating that the submesh is ready or not.
  30456. */
  30457. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30458. /**
  30459. * Update the defines for detail map usage
  30460. * @param defines the list of "defines" to update.
  30461. * @param scene defines the scene the material belongs to.
  30462. */
  30463. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30464. /**
  30465. * Binds the material data.
  30466. * @param uniformBuffer defines the Uniform buffer to fill in.
  30467. * @param scene defines the scene the material belongs to.
  30468. * @param isFrozen defines whether the material is frozen or not.
  30469. */
  30470. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30471. /**
  30472. * Checks to see if a texture is used in the material.
  30473. * @param texture - Base texture to use.
  30474. * @returns - Boolean specifying if a texture is used in the material.
  30475. */
  30476. hasTexture(texture: BaseTexture): boolean;
  30477. /**
  30478. * Returns an array of the actively used textures.
  30479. * @param activeTextures Array of BaseTextures
  30480. */
  30481. getActiveTextures(activeTextures: BaseTexture[]): void;
  30482. /**
  30483. * Returns the animatable textures.
  30484. * @param animatables Array of animatable textures.
  30485. */
  30486. getAnimatables(animatables: IAnimatable[]): void;
  30487. /**
  30488. * Disposes the resources of the material.
  30489. * @param forceDisposeTextures - Forces the disposal of all textures.
  30490. */
  30491. dispose(forceDisposeTextures?: boolean): void;
  30492. /**
  30493. * Get the current class name useful for serialization or dynamic coding.
  30494. * @returns "DetailMap"
  30495. */
  30496. getClassName(): string;
  30497. /**
  30498. * Add the required uniforms to the current list.
  30499. * @param uniforms defines the current uniform list.
  30500. */
  30501. static AddUniforms(uniforms: string[]): void;
  30502. /**
  30503. * Add the required samplers to the current list.
  30504. * @param samplers defines the current sampler list.
  30505. */
  30506. static AddSamplers(samplers: string[]): void;
  30507. /**
  30508. * Add the required uniforms to the current buffer.
  30509. * @param uniformBuffer defines the current uniform buffer.
  30510. */
  30511. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30512. /**
  30513. * Makes a duplicate of the current instance into another one.
  30514. * @param detailMap define the instance where to copy the info
  30515. */
  30516. copyTo(detailMap: DetailMapConfiguration): void;
  30517. /**
  30518. * Serializes this detail map instance
  30519. * @returns - An object with the serialized instance.
  30520. */
  30521. serialize(): any;
  30522. /**
  30523. * Parses a detail map setting from a serialized object.
  30524. * @param source - Serialized object.
  30525. * @param scene Defines the scene we are parsing for
  30526. * @param rootUrl Defines the rootUrl to load from
  30527. */
  30528. parse(source: any, scene: Scene, rootUrl: string): void;
  30529. }
  30530. }
  30531. declare module "babylonjs/Materials/standardMaterial" {
  30532. import { SmartArray } from "babylonjs/Misc/smartArray";
  30533. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30534. import { Nullable } from "babylonjs/types";
  30535. import { Scene } from "babylonjs/scene";
  30536. import { Matrix } from "babylonjs/Maths/math.vector";
  30537. import { Color3 } from "babylonjs/Maths/math.color";
  30538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30540. import { Mesh } from "babylonjs/Meshes/mesh";
  30541. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30542. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30543. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30544. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30545. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30547. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30548. import "babylonjs/Shaders/default.fragment";
  30549. import "babylonjs/Shaders/default.vertex";
  30550. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30551. /** @hidden */
  30552. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30553. MAINUV1: boolean;
  30554. MAINUV2: boolean;
  30555. DIFFUSE: boolean;
  30556. DIFFUSEDIRECTUV: number;
  30557. DETAIL: boolean;
  30558. DETAILDIRECTUV: number;
  30559. DETAIL_NORMALBLENDMETHOD: number;
  30560. AMBIENT: boolean;
  30561. AMBIENTDIRECTUV: number;
  30562. OPACITY: boolean;
  30563. OPACITYDIRECTUV: number;
  30564. OPACITYRGB: boolean;
  30565. REFLECTION: boolean;
  30566. EMISSIVE: boolean;
  30567. EMISSIVEDIRECTUV: number;
  30568. SPECULAR: boolean;
  30569. SPECULARDIRECTUV: number;
  30570. BUMP: boolean;
  30571. BUMPDIRECTUV: number;
  30572. PARALLAX: boolean;
  30573. PARALLAXOCCLUSION: boolean;
  30574. SPECULAROVERALPHA: boolean;
  30575. CLIPPLANE: boolean;
  30576. CLIPPLANE2: boolean;
  30577. CLIPPLANE3: boolean;
  30578. CLIPPLANE4: boolean;
  30579. CLIPPLANE5: boolean;
  30580. CLIPPLANE6: boolean;
  30581. ALPHATEST: boolean;
  30582. DEPTHPREPASS: boolean;
  30583. ALPHAFROMDIFFUSE: boolean;
  30584. POINTSIZE: boolean;
  30585. FOG: boolean;
  30586. SPECULARTERM: boolean;
  30587. DIFFUSEFRESNEL: boolean;
  30588. OPACITYFRESNEL: boolean;
  30589. REFLECTIONFRESNEL: boolean;
  30590. REFRACTIONFRESNEL: boolean;
  30591. EMISSIVEFRESNEL: boolean;
  30592. FRESNEL: boolean;
  30593. NORMAL: boolean;
  30594. UV1: boolean;
  30595. UV2: boolean;
  30596. VERTEXCOLOR: boolean;
  30597. VERTEXALPHA: boolean;
  30598. NUM_BONE_INFLUENCERS: number;
  30599. BonesPerMesh: number;
  30600. BONETEXTURE: boolean;
  30601. INSTANCES: boolean;
  30602. THIN_INSTANCES: boolean;
  30603. GLOSSINESS: boolean;
  30604. ROUGHNESS: boolean;
  30605. EMISSIVEASILLUMINATION: boolean;
  30606. LINKEMISSIVEWITHDIFFUSE: boolean;
  30607. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30608. LIGHTMAP: boolean;
  30609. LIGHTMAPDIRECTUV: number;
  30610. OBJECTSPACE_NORMALMAP: boolean;
  30611. USELIGHTMAPASSHADOWMAP: boolean;
  30612. REFLECTIONMAP_3D: boolean;
  30613. REFLECTIONMAP_SPHERICAL: boolean;
  30614. REFLECTIONMAP_PLANAR: boolean;
  30615. REFLECTIONMAP_CUBIC: boolean;
  30616. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30617. REFLECTIONMAP_PROJECTION: boolean;
  30618. REFLECTIONMAP_SKYBOX: boolean;
  30619. REFLECTIONMAP_EXPLICIT: boolean;
  30620. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30621. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30622. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30623. INVERTCUBICMAP: boolean;
  30624. LOGARITHMICDEPTH: boolean;
  30625. REFRACTION: boolean;
  30626. REFRACTIONMAP_3D: boolean;
  30627. REFLECTIONOVERALPHA: boolean;
  30628. TWOSIDEDLIGHTING: boolean;
  30629. SHADOWFLOAT: boolean;
  30630. MORPHTARGETS: boolean;
  30631. MORPHTARGETS_NORMAL: boolean;
  30632. MORPHTARGETS_TANGENT: boolean;
  30633. MORPHTARGETS_UV: boolean;
  30634. NUM_MORPH_INFLUENCERS: number;
  30635. NONUNIFORMSCALING: boolean;
  30636. PREMULTIPLYALPHA: boolean;
  30637. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30638. ALPHABLEND: boolean;
  30639. RGBDLIGHTMAP: boolean;
  30640. RGBDREFLECTION: boolean;
  30641. RGBDREFRACTION: boolean;
  30642. IMAGEPROCESSING: boolean;
  30643. VIGNETTE: boolean;
  30644. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30645. VIGNETTEBLENDMODEOPAQUE: boolean;
  30646. TONEMAPPING: boolean;
  30647. TONEMAPPING_ACES: boolean;
  30648. CONTRAST: boolean;
  30649. COLORCURVES: boolean;
  30650. COLORGRADING: boolean;
  30651. COLORGRADING3D: boolean;
  30652. SAMPLER3DGREENDEPTH: boolean;
  30653. SAMPLER3DBGRMAP: boolean;
  30654. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30655. MULTIVIEW: boolean;
  30656. /**
  30657. * If the reflection texture on this material is in linear color space
  30658. * @hidden
  30659. */
  30660. IS_REFLECTION_LINEAR: boolean;
  30661. /**
  30662. * If the refraction texture on this material is in linear color space
  30663. * @hidden
  30664. */
  30665. IS_REFRACTION_LINEAR: boolean;
  30666. EXPOSURE: boolean;
  30667. constructor();
  30668. setReflectionMode(modeToEnable: string): void;
  30669. }
  30670. /**
  30671. * This is the default material used in Babylon. It is the best trade off between quality
  30672. * and performances.
  30673. * @see http://doc.babylonjs.com/babylon101/materials
  30674. */
  30675. export class StandardMaterial extends PushMaterial {
  30676. private _diffuseTexture;
  30677. /**
  30678. * The basic texture of the material as viewed under a light.
  30679. */
  30680. diffuseTexture: Nullable<BaseTexture>;
  30681. private _ambientTexture;
  30682. /**
  30683. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30684. */
  30685. ambientTexture: Nullable<BaseTexture>;
  30686. private _opacityTexture;
  30687. /**
  30688. * Define the transparency of the material from a texture.
  30689. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30690. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30691. */
  30692. opacityTexture: Nullable<BaseTexture>;
  30693. private _reflectionTexture;
  30694. /**
  30695. * Define the texture used to display the reflection.
  30696. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30697. */
  30698. reflectionTexture: Nullable<BaseTexture>;
  30699. private _emissiveTexture;
  30700. /**
  30701. * Define texture of the material as if self lit.
  30702. * This will be mixed in the final result even in the absence of light.
  30703. */
  30704. emissiveTexture: Nullable<BaseTexture>;
  30705. private _specularTexture;
  30706. /**
  30707. * Define how the color and intensity of the highlight given by the light in the material.
  30708. */
  30709. specularTexture: Nullable<BaseTexture>;
  30710. private _bumpTexture;
  30711. /**
  30712. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30713. * 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.
  30714. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30715. */
  30716. bumpTexture: Nullable<BaseTexture>;
  30717. private _lightmapTexture;
  30718. /**
  30719. * Complex lighting can be computationally expensive to compute at runtime.
  30720. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30721. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30722. */
  30723. lightmapTexture: Nullable<BaseTexture>;
  30724. private _refractionTexture;
  30725. /**
  30726. * Define the texture used to display the refraction.
  30727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30728. */
  30729. refractionTexture: Nullable<BaseTexture>;
  30730. /**
  30731. * The color of the material lit by the environmental background lighting.
  30732. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30733. */
  30734. ambientColor: Color3;
  30735. /**
  30736. * The basic color of the material as viewed under a light.
  30737. */
  30738. diffuseColor: Color3;
  30739. /**
  30740. * Define how the color and intensity of the highlight given by the light in the material.
  30741. */
  30742. specularColor: Color3;
  30743. /**
  30744. * Define the color of the material as if self lit.
  30745. * This will be mixed in the final result even in the absence of light.
  30746. */
  30747. emissiveColor: Color3;
  30748. /**
  30749. * Defines how sharp are the highlights in the material.
  30750. * The bigger the value the sharper giving a more glossy feeling to the result.
  30751. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30752. */
  30753. specularPower: number;
  30754. private _useAlphaFromDiffuseTexture;
  30755. /**
  30756. * Does the transparency come from the diffuse texture alpha channel.
  30757. */
  30758. useAlphaFromDiffuseTexture: boolean;
  30759. private _useEmissiveAsIllumination;
  30760. /**
  30761. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30762. */
  30763. useEmissiveAsIllumination: boolean;
  30764. private _linkEmissiveWithDiffuse;
  30765. /**
  30766. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30767. * the emissive level when the final color is close to one.
  30768. */
  30769. linkEmissiveWithDiffuse: boolean;
  30770. private _useSpecularOverAlpha;
  30771. /**
  30772. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30773. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30774. */
  30775. useSpecularOverAlpha: boolean;
  30776. private _useReflectionOverAlpha;
  30777. /**
  30778. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30779. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30780. */
  30781. useReflectionOverAlpha: boolean;
  30782. private _disableLighting;
  30783. /**
  30784. * Does lights from the scene impacts this material.
  30785. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30786. */
  30787. disableLighting: boolean;
  30788. private _useObjectSpaceNormalMap;
  30789. /**
  30790. * Allows using an object space normal map (instead of tangent space).
  30791. */
  30792. useObjectSpaceNormalMap: boolean;
  30793. private _useParallax;
  30794. /**
  30795. * Is parallax enabled or not.
  30796. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30797. */
  30798. useParallax: boolean;
  30799. private _useParallaxOcclusion;
  30800. /**
  30801. * Is parallax occlusion enabled or not.
  30802. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30803. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30804. */
  30805. useParallaxOcclusion: boolean;
  30806. /**
  30807. * 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.
  30808. */
  30809. parallaxScaleBias: number;
  30810. private _roughness;
  30811. /**
  30812. * Helps to define how blurry the reflections should appears in the material.
  30813. */
  30814. roughness: number;
  30815. /**
  30816. * In case of refraction, define the value of the index of refraction.
  30817. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30818. */
  30819. indexOfRefraction: number;
  30820. /**
  30821. * Invert the refraction texture alongside the y axis.
  30822. * It can be useful with procedural textures or probe for instance.
  30823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30824. */
  30825. invertRefractionY: boolean;
  30826. /**
  30827. * Defines the alpha limits in alpha test mode.
  30828. */
  30829. alphaCutOff: number;
  30830. private _useLightmapAsShadowmap;
  30831. /**
  30832. * In case of light mapping, define whether the map contains light or shadow informations.
  30833. */
  30834. useLightmapAsShadowmap: boolean;
  30835. private _diffuseFresnelParameters;
  30836. /**
  30837. * Define the diffuse fresnel parameters of the material.
  30838. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30839. */
  30840. diffuseFresnelParameters: FresnelParameters;
  30841. private _opacityFresnelParameters;
  30842. /**
  30843. * Define the opacity fresnel parameters of the material.
  30844. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30845. */
  30846. opacityFresnelParameters: FresnelParameters;
  30847. private _reflectionFresnelParameters;
  30848. /**
  30849. * Define the reflection fresnel parameters of the material.
  30850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30851. */
  30852. reflectionFresnelParameters: FresnelParameters;
  30853. private _refractionFresnelParameters;
  30854. /**
  30855. * Define the refraction fresnel parameters of the material.
  30856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30857. */
  30858. refractionFresnelParameters: FresnelParameters;
  30859. private _emissiveFresnelParameters;
  30860. /**
  30861. * Define the emissive fresnel parameters of the material.
  30862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30863. */
  30864. emissiveFresnelParameters: FresnelParameters;
  30865. private _useReflectionFresnelFromSpecular;
  30866. /**
  30867. * If true automatically deducts the fresnels values from the material specularity.
  30868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30869. */
  30870. useReflectionFresnelFromSpecular: boolean;
  30871. private _useGlossinessFromSpecularMapAlpha;
  30872. /**
  30873. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30874. */
  30875. useGlossinessFromSpecularMapAlpha: boolean;
  30876. private _maxSimultaneousLights;
  30877. /**
  30878. * Defines the maximum number of lights that can be used in the material
  30879. */
  30880. maxSimultaneousLights: number;
  30881. private _invertNormalMapX;
  30882. /**
  30883. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30884. */
  30885. invertNormalMapX: boolean;
  30886. private _invertNormalMapY;
  30887. /**
  30888. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30889. */
  30890. invertNormalMapY: boolean;
  30891. private _twoSidedLighting;
  30892. /**
  30893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30894. */
  30895. twoSidedLighting: boolean;
  30896. /**
  30897. * Default configuration related to image processing available in the standard Material.
  30898. */
  30899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30900. /**
  30901. * Gets the image processing configuration used either in this material.
  30902. */
  30903. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30904. /**
  30905. * Sets the Default image processing configuration used either in the this material.
  30906. *
  30907. * If sets to null, the scene one is in use.
  30908. */
  30909. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30910. /**
  30911. * Keep track of the image processing observer to allow dispose and replace.
  30912. */
  30913. private _imageProcessingObserver;
  30914. /**
  30915. * Attaches a new image processing configuration to the Standard Material.
  30916. * @param configuration
  30917. */
  30918. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30919. /**
  30920. * Gets wether the color curves effect is enabled.
  30921. */
  30922. get cameraColorCurvesEnabled(): boolean;
  30923. /**
  30924. * Sets wether the color curves effect is enabled.
  30925. */
  30926. set cameraColorCurvesEnabled(value: boolean);
  30927. /**
  30928. * Gets wether the color grading effect is enabled.
  30929. */
  30930. get cameraColorGradingEnabled(): boolean;
  30931. /**
  30932. * Gets wether the color grading effect is enabled.
  30933. */
  30934. set cameraColorGradingEnabled(value: boolean);
  30935. /**
  30936. * Gets wether tonemapping is enabled or not.
  30937. */
  30938. get cameraToneMappingEnabled(): boolean;
  30939. /**
  30940. * Sets wether tonemapping is enabled or not
  30941. */
  30942. set cameraToneMappingEnabled(value: boolean);
  30943. /**
  30944. * The camera exposure used on this material.
  30945. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30946. * This corresponds to a photographic exposure.
  30947. */
  30948. get cameraExposure(): number;
  30949. /**
  30950. * The camera exposure used on this material.
  30951. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30952. * This corresponds to a photographic exposure.
  30953. */
  30954. set cameraExposure(value: number);
  30955. /**
  30956. * Gets The camera contrast used on this material.
  30957. */
  30958. get cameraContrast(): number;
  30959. /**
  30960. * Sets The camera contrast used on this material.
  30961. */
  30962. set cameraContrast(value: number);
  30963. /**
  30964. * Gets the Color Grading 2D Lookup Texture.
  30965. */
  30966. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30967. /**
  30968. * Sets the Color Grading 2D Lookup Texture.
  30969. */
  30970. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30971. /**
  30972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30974. * 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;
  30975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30976. */
  30977. get cameraColorCurves(): Nullable<ColorCurves>;
  30978. /**
  30979. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30980. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30981. * 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;
  30982. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30983. */
  30984. set cameraColorCurves(value: Nullable<ColorCurves>);
  30985. /**
  30986. * Defines the detail map parameters for the material.
  30987. */
  30988. readonly detailMap: DetailMapConfiguration;
  30989. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30990. protected _worldViewProjectionMatrix: Matrix;
  30991. protected _globalAmbientColor: Color3;
  30992. protected _useLogarithmicDepth: boolean;
  30993. protected _rebuildInParallel: boolean;
  30994. /**
  30995. * Instantiates a new standard material.
  30996. * This is the default material used in Babylon. It is the best trade off between quality
  30997. * and performances.
  30998. * @see http://doc.babylonjs.com/babylon101/materials
  30999. * @param name Define the name of the material in the scene
  31000. * @param scene Define the scene the material belong to
  31001. */
  31002. constructor(name: string, scene: Scene);
  31003. /**
  31004. * Gets a boolean indicating that current material needs to register RTT
  31005. */
  31006. get hasRenderTargetTextures(): boolean;
  31007. /**
  31008. * Gets the current class name of the material e.g. "StandardMaterial"
  31009. * Mainly use in serialization.
  31010. * @returns the class name
  31011. */
  31012. getClassName(): string;
  31013. /**
  31014. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31015. * You can try switching to logarithmic depth.
  31016. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31017. */
  31018. get useLogarithmicDepth(): boolean;
  31019. set useLogarithmicDepth(value: boolean);
  31020. /**
  31021. * Specifies if the material will require alpha blending
  31022. * @returns a boolean specifying if alpha blending is needed
  31023. */
  31024. needAlphaBlending(): boolean;
  31025. /**
  31026. * Specifies if this material should be rendered in alpha test mode
  31027. * @returns a boolean specifying if an alpha test is needed.
  31028. */
  31029. needAlphaTesting(): boolean;
  31030. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31031. /**
  31032. * Get the texture used for alpha test purpose.
  31033. * @returns the diffuse texture in case of the standard material.
  31034. */
  31035. getAlphaTestTexture(): Nullable<BaseTexture>;
  31036. /**
  31037. * Get if the submesh is ready to be used and all its information available.
  31038. * Child classes can use it to update shaders
  31039. * @param mesh defines the mesh to check
  31040. * @param subMesh defines which submesh to check
  31041. * @param useInstances specifies that instances should be used
  31042. * @returns a boolean indicating that the submesh is ready or not
  31043. */
  31044. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31045. /**
  31046. * Builds the material UBO layouts.
  31047. * Used internally during the effect preparation.
  31048. */
  31049. buildUniformLayout(): void;
  31050. /**
  31051. * Unbinds the material from the mesh
  31052. */
  31053. unbind(): void;
  31054. /**
  31055. * Binds the submesh to this material by preparing the effect and shader to draw
  31056. * @param world defines the world transformation matrix
  31057. * @param mesh defines the mesh containing the submesh
  31058. * @param subMesh defines the submesh to bind the material to
  31059. */
  31060. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31061. /**
  31062. * Get the list of animatables in the material.
  31063. * @returns the list of animatables object used in the material
  31064. */
  31065. getAnimatables(): IAnimatable[];
  31066. /**
  31067. * Gets the active textures from the material
  31068. * @returns an array of textures
  31069. */
  31070. getActiveTextures(): BaseTexture[];
  31071. /**
  31072. * Specifies if the material uses a texture
  31073. * @param texture defines the texture to check against the material
  31074. * @returns a boolean specifying if the material uses the texture
  31075. */
  31076. hasTexture(texture: BaseTexture): boolean;
  31077. /**
  31078. * Disposes the material
  31079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31080. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31081. */
  31082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31083. /**
  31084. * Makes a duplicate of the material, and gives it a new name
  31085. * @param name defines the new name for the duplicated material
  31086. * @returns the cloned material
  31087. */
  31088. clone(name: string): StandardMaterial;
  31089. /**
  31090. * Serializes this material in a JSON representation
  31091. * @returns the serialized material object
  31092. */
  31093. serialize(): any;
  31094. /**
  31095. * Creates a standard material from parsed material data
  31096. * @param source defines the JSON representation of the material
  31097. * @param scene defines the hosting scene
  31098. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31099. * @returns a new standard material
  31100. */
  31101. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31102. /**
  31103. * Are diffuse textures enabled in the application.
  31104. */
  31105. static get DiffuseTextureEnabled(): boolean;
  31106. static set DiffuseTextureEnabled(value: boolean);
  31107. /**
  31108. * Are detail textures enabled in the application.
  31109. */
  31110. static get DetailTextureEnabled(): boolean;
  31111. static set DetailTextureEnabled(value: boolean);
  31112. /**
  31113. * Are ambient textures enabled in the application.
  31114. */
  31115. static get AmbientTextureEnabled(): boolean;
  31116. static set AmbientTextureEnabled(value: boolean);
  31117. /**
  31118. * Are opacity textures enabled in the application.
  31119. */
  31120. static get OpacityTextureEnabled(): boolean;
  31121. static set OpacityTextureEnabled(value: boolean);
  31122. /**
  31123. * Are reflection textures enabled in the application.
  31124. */
  31125. static get ReflectionTextureEnabled(): boolean;
  31126. static set ReflectionTextureEnabled(value: boolean);
  31127. /**
  31128. * Are emissive textures enabled in the application.
  31129. */
  31130. static get EmissiveTextureEnabled(): boolean;
  31131. static set EmissiveTextureEnabled(value: boolean);
  31132. /**
  31133. * Are specular textures enabled in the application.
  31134. */
  31135. static get SpecularTextureEnabled(): boolean;
  31136. static set SpecularTextureEnabled(value: boolean);
  31137. /**
  31138. * Are bump textures enabled in the application.
  31139. */
  31140. static get BumpTextureEnabled(): boolean;
  31141. static set BumpTextureEnabled(value: boolean);
  31142. /**
  31143. * Are lightmap textures enabled in the application.
  31144. */
  31145. static get LightmapTextureEnabled(): boolean;
  31146. static set LightmapTextureEnabled(value: boolean);
  31147. /**
  31148. * Are refraction textures enabled in the application.
  31149. */
  31150. static get RefractionTextureEnabled(): boolean;
  31151. static set RefractionTextureEnabled(value: boolean);
  31152. /**
  31153. * Are color grading textures enabled in the application.
  31154. */
  31155. static get ColorGradingTextureEnabled(): boolean;
  31156. static set ColorGradingTextureEnabled(value: boolean);
  31157. /**
  31158. * Are fresnels enabled in the application.
  31159. */
  31160. static get FresnelEnabled(): boolean;
  31161. static set FresnelEnabled(value: boolean);
  31162. }
  31163. }
  31164. declare module "babylonjs/Particles/solidParticleSystem" {
  31165. import { Nullable } from "babylonjs/types";
  31166. import { Mesh } from "babylonjs/Meshes/mesh";
  31167. import { Scene, IDisposable } from "babylonjs/scene";
  31168. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31169. import { Material } from "babylonjs/Materials/material";
  31170. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31171. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31172. /**
  31173. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31174. *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.
  31175. * The SPS is also a particle system. It provides some methods to manage the particles.
  31176. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31177. *
  31178. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31179. */
  31180. export class SolidParticleSystem implements IDisposable {
  31181. /**
  31182. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31183. * Example : var p = SPS.particles[i];
  31184. */
  31185. particles: SolidParticle[];
  31186. /**
  31187. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31188. */
  31189. nbParticles: number;
  31190. /**
  31191. * If the particles must ever face the camera (default false). Useful for planar particles.
  31192. */
  31193. billboard: boolean;
  31194. /**
  31195. * Recompute normals when adding a shape
  31196. */
  31197. recomputeNormals: boolean;
  31198. /**
  31199. * This a counter ofr your own usage. It's not set by any SPS functions.
  31200. */
  31201. counter: number;
  31202. /**
  31203. * The SPS name. This name is also given to the underlying mesh.
  31204. */
  31205. name: string;
  31206. /**
  31207. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31208. */
  31209. mesh: Mesh;
  31210. /**
  31211. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31212. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31213. */
  31214. vars: any;
  31215. /**
  31216. * This array is populated when the SPS is set as 'pickable'.
  31217. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31218. * Each element of this array is an object `{idx: int, faceId: int}`.
  31219. * `idx` is the picked particle index in the `SPS.particles` array
  31220. * `faceId` is the picked face index counted within this particle.
  31221. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31222. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31223. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31224. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31225. */
  31226. pickedParticles: {
  31227. idx: number;
  31228. faceId: number;
  31229. }[];
  31230. /**
  31231. * This array is populated when the SPS is set as 'pickable'
  31232. * Each key of this array is a submesh index.
  31233. * Each element of this array is a second array defined like this :
  31234. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31235. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31236. * `idx` is the picked particle index in the `SPS.particles` array
  31237. * `faceId` is the picked face index counted within this particle.
  31238. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31239. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31240. */
  31241. pickedBySubMesh: {
  31242. idx: number;
  31243. faceId: number;
  31244. }[][];
  31245. /**
  31246. * This array is populated when `enableDepthSort` is set to true.
  31247. * Each element of this array is an instance of the class DepthSortedParticle.
  31248. */
  31249. depthSortedParticles: DepthSortedParticle[];
  31250. /**
  31251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31252. * @hidden
  31253. */
  31254. _bSphereOnly: boolean;
  31255. /**
  31256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31257. * @hidden
  31258. */
  31259. _bSphereRadiusFactor: number;
  31260. private _scene;
  31261. private _positions;
  31262. private _indices;
  31263. private _normals;
  31264. private _colors;
  31265. private _uvs;
  31266. private _indices32;
  31267. private _positions32;
  31268. private _normals32;
  31269. private _fixedNormal32;
  31270. private _colors32;
  31271. private _uvs32;
  31272. private _index;
  31273. private _updatable;
  31274. private _pickable;
  31275. private _isVisibilityBoxLocked;
  31276. private _alwaysVisible;
  31277. private _depthSort;
  31278. private _expandable;
  31279. private _shapeCounter;
  31280. private _copy;
  31281. private _color;
  31282. private _computeParticleColor;
  31283. private _computeParticleTexture;
  31284. private _computeParticleRotation;
  31285. private _computeParticleVertex;
  31286. private _computeBoundingBox;
  31287. private _depthSortParticles;
  31288. private _camera;
  31289. private _mustUnrotateFixedNormals;
  31290. private _particlesIntersect;
  31291. private _needs32Bits;
  31292. private _isNotBuilt;
  31293. private _lastParticleId;
  31294. private _idxOfId;
  31295. private _multimaterialEnabled;
  31296. private _useModelMaterial;
  31297. private _indicesByMaterial;
  31298. private _materialIndexes;
  31299. private _depthSortFunction;
  31300. private _materialSortFunction;
  31301. private _materials;
  31302. private _multimaterial;
  31303. private _materialIndexesById;
  31304. private _defaultMaterial;
  31305. private _autoUpdateSubMeshes;
  31306. private _tmpVertex;
  31307. /**
  31308. * Creates a SPS (Solid Particle System) object.
  31309. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31310. * @param scene (Scene) is the scene in which the SPS is added.
  31311. * @param options defines the options of the sps e.g.
  31312. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31313. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31314. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31315. * * 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.
  31316. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31317. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31318. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31319. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31320. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31321. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31322. */
  31323. constructor(name: string, scene: Scene, options?: {
  31324. updatable?: boolean;
  31325. isPickable?: boolean;
  31326. enableDepthSort?: boolean;
  31327. particleIntersection?: boolean;
  31328. boundingSphereOnly?: boolean;
  31329. bSphereRadiusFactor?: number;
  31330. expandable?: boolean;
  31331. useModelMaterial?: boolean;
  31332. enableMultiMaterial?: boolean;
  31333. });
  31334. /**
  31335. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31336. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31337. * @returns the created mesh
  31338. */
  31339. buildMesh(): Mesh;
  31340. /**
  31341. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31342. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31343. * Thus the particles generated from `digest()` have their property `position` set yet.
  31344. * @param mesh ( Mesh ) is the mesh to be digested
  31345. * @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
  31346. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31347. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31348. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31349. * @returns the current SPS
  31350. */
  31351. digest(mesh: Mesh, options?: {
  31352. facetNb?: number;
  31353. number?: number;
  31354. delta?: number;
  31355. storage?: [];
  31356. }): SolidParticleSystem;
  31357. /**
  31358. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31359. * @hidden
  31360. */
  31361. private _unrotateFixedNormals;
  31362. /**
  31363. * Resets the temporary working copy particle
  31364. * @hidden
  31365. */
  31366. private _resetCopy;
  31367. /**
  31368. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31369. * @param p the current index in the positions array to be updated
  31370. * @param ind the current index in the indices array
  31371. * @param shape a Vector3 array, the shape geometry
  31372. * @param positions the positions array to be updated
  31373. * @param meshInd the shape indices array
  31374. * @param indices the indices array to be updated
  31375. * @param meshUV the shape uv array
  31376. * @param uvs the uv array to be updated
  31377. * @param meshCol the shape color array
  31378. * @param colors the color array to be updated
  31379. * @param meshNor the shape normals array
  31380. * @param normals the normals array to be updated
  31381. * @param idx the particle index
  31382. * @param idxInShape the particle index in its shape
  31383. * @param options the addShape() method passed options
  31384. * @model the particle model
  31385. * @hidden
  31386. */
  31387. private _meshBuilder;
  31388. /**
  31389. * Returns a shape Vector3 array from positions float array
  31390. * @param positions float array
  31391. * @returns a vector3 array
  31392. * @hidden
  31393. */
  31394. private _posToShape;
  31395. /**
  31396. * Returns a shapeUV array from a float uvs (array deep copy)
  31397. * @param uvs as a float array
  31398. * @returns a shapeUV array
  31399. * @hidden
  31400. */
  31401. private _uvsToShapeUV;
  31402. /**
  31403. * Adds a new particle object in the particles array
  31404. * @param idx particle index in particles array
  31405. * @param id particle id
  31406. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31407. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31408. * @param model particle ModelShape object
  31409. * @param shapeId model shape identifier
  31410. * @param idxInShape index of the particle in the current model
  31411. * @param bInfo model bounding info object
  31412. * @param storage target storage array, if any
  31413. * @hidden
  31414. */
  31415. private _addParticle;
  31416. /**
  31417. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31418. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31419. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31420. * @param nb (positive integer) the number of particles to be created from this model
  31421. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31422. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31423. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31424. * @returns the number of shapes in the system
  31425. */
  31426. addShape(mesh: Mesh, nb: number, options?: {
  31427. positionFunction?: any;
  31428. vertexFunction?: any;
  31429. storage?: [];
  31430. }): number;
  31431. /**
  31432. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31433. * @hidden
  31434. */
  31435. private _rebuildParticle;
  31436. /**
  31437. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31438. * @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.
  31439. * @returns the SPS.
  31440. */
  31441. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31442. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31443. * Returns an array with the removed particles.
  31444. * 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.
  31445. * The SPS can't be empty so at least one particle needs to remain in place.
  31446. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31447. * @param start index of the first particle to remove
  31448. * @param end index of the last particle to remove (included)
  31449. * @returns an array populated with the removed particles
  31450. */
  31451. removeParticles(start: number, end: number): SolidParticle[];
  31452. /**
  31453. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31454. * @param solidParticleArray an array populated with Solid Particles objects
  31455. * @returns the SPS
  31456. */
  31457. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31458. /**
  31459. * Creates a new particle and modifies the SPS mesh geometry :
  31460. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31461. * - calls _addParticle() to populate the particle array
  31462. * factorized code from addShape() and insertParticlesFromArray()
  31463. * @param idx particle index in the particles array
  31464. * @param i particle index in its shape
  31465. * @param modelShape particle ModelShape object
  31466. * @param shape shape vertex array
  31467. * @param meshInd shape indices array
  31468. * @param meshUV shape uv array
  31469. * @param meshCol shape color array
  31470. * @param meshNor shape normals array
  31471. * @param bbInfo shape bounding info
  31472. * @param storage target particle storage
  31473. * @options addShape() passed options
  31474. * @hidden
  31475. */
  31476. private _insertNewParticle;
  31477. /**
  31478. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31479. * This method calls `updateParticle()` for each particle of the SPS.
  31480. * For an animated SPS, it is usually called within the render loop.
  31481. * 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.
  31482. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31483. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31484. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31485. * @returns the SPS.
  31486. */
  31487. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31488. /**
  31489. * Disposes the SPS.
  31490. */
  31491. dispose(): void;
  31492. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31493. * idx is the particle index in the SPS
  31494. * faceId is the picked face index counted within this particle.
  31495. * Returns null if the pickInfo can't identify a picked particle.
  31496. * @param pickingInfo (PickingInfo object)
  31497. * @returns {idx: number, faceId: number} or null
  31498. */
  31499. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31500. idx: number;
  31501. faceId: number;
  31502. }>;
  31503. /**
  31504. * Returns a SolidParticle object from its identifier : particle.id
  31505. * @param id (integer) the particle Id
  31506. * @returns the searched particle or null if not found in the SPS.
  31507. */
  31508. getParticleById(id: number): Nullable<SolidParticle>;
  31509. /**
  31510. * Returns a new array populated with the particles having the passed shapeId.
  31511. * @param shapeId (integer) the shape identifier
  31512. * @returns a new solid particle array
  31513. */
  31514. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31515. /**
  31516. * Populates the passed array "ref" with the particles having the passed shapeId.
  31517. * @param shapeId the shape identifier
  31518. * @returns the SPS
  31519. * @param ref
  31520. */
  31521. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31522. /**
  31523. * Computes the required SubMeshes according the materials assigned to the particles.
  31524. * @returns the solid particle system.
  31525. * Does nothing if called before the SPS mesh is built.
  31526. */
  31527. computeSubMeshes(): SolidParticleSystem;
  31528. /**
  31529. * Sorts the solid particles by material when MultiMaterial is enabled.
  31530. * Updates the indices32 array.
  31531. * Updates the indicesByMaterial array.
  31532. * Updates the mesh indices array.
  31533. * @returns the SPS
  31534. * @hidden
  31535. */
  31536. private _sortParticlesByMaterial;
  31537. /**
  31538. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31539. * @hidden
  31540. */
  31541. private _setMaterialIndexesById;
  31542. /**
  31543. * Returns an array with unique values of Materials from the passed array
  31544. * @param array the material array to be checked and filtered
  31545. * @hidden
  31546. */
  31547. private _filterUniqueMaterialId;
  31548. /**
  31549. * Sets a new Standard Material as _defaultMaterial if not already set.
  31550. * @hidden
  31551. */
  31552. private _setDefaultMaterial;
  31553. /**
  31554. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31556. * @returns the SPS.
  31557. */
  31558. refreshVisibleSize(): SolidParticleSystem;
  31559. /**
  31560. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31561. * @param size the size (float) of the visibility box
  31562. * note : this doesn't lock the SPS mesh bounding box.
  31563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31564. */
  31565. setVisibilityBox(size: number): void;
  31566. /**
  31567. * Gets whether the SPS as always visible or not
  31568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31569. */
  31570. get isAlwaysVisible(): boolean;
  31571. /**
  31572. * Sets the SPS as always visible or not
  31573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31574. */
  31575. set isAlwaysVisible(val: boolean);
  31576. /**
  31577. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31579. */
  31580. set isVisibilityBoxLocked(val: boolean);
  31581. /**
  31582. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31584. */
  31585. get isVisibilityBoxLocked(): boolean;
  31586. /**
  31587. * Tells to `setParticles()` to compute the particle rotations or not.
  31588. * Default value : true. The SPS is faster when it's set to false.
  31589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31590. */
  31591. set computeParticleRotation(val: boolean);
  31592. /**
  31593. * Tells to `setParticles()` to compute the particle colors or not.
  31594. * Default value : true. The SPS is faster when it's set to false.
  31595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31596. */
  31597. set computeParticleColor(val: boolean);
  31598. set computeParticleTexture(val: boolean);
  31599. /**
  31600. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31601. * Default value : false. The SPS is faster when it's set to false.
  31602. * Note : the particle custom vertex positions aren't stored values.
  31603. */
  31604. set computeParticleVertex(val: boolean);
  31605. /**
  31606. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31607. */
  31608. set computeBoundingBox(val: boolean);
  31609. /**
  31610. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31612. * Default : `true`
  31613. */
  31614. set depthSortParticles(val: boolean);
  31615. /**
  31616. * Gets if `setParticles()` computes the particle rotations or not.
  31617. * Default value : true. The SPS is faster when it's set to false.
  31618. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31619. */
  31620. get computeParticleRotation(): boolean;
  31621. /**
  31622. * Gets if `setParticles()` computes the particle colors or not.
  31623. * Default value : true. The SPS is faster when it's set to false.
  31624. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31625. */
  31626. get computeParticleColor(): boolean;
  31627. /**
  31628. * Gets if `setParticles()` computes the particle textures or not.
  31629. * Default value : true. The SPS is faster when it's set to false.
  31630. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31631. */
  31632. get computeParticleTexture(): boolean;
  31633. /**
  31634. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31635. * Default value : false. The SPS is faster when it's set to false.
  31636. * Note : the particle custom vertex positions aren't stored values.
  31637. */
  31638. get computeParticleVertex(): boolean;
  31639. /**
  31640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31641. */
  31642. get computeBoundingBox(): boolean;
  31643. /**
  31644. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31646. * Default : `true`
  31647. */
  31648. get depthSortParticles(): boolean;
  31649. /**
  31650. * Gets if the SPS is created as expandable at construction time.
  31651. * Default : `false`
  31652. */
  31653. get expandable(): boolean;
  31654. /**
  31655. * Gets if the SPS supports the Multi Materials
  31656. */
  31657. get multimaterialEnabled(): boolean;
  31658. /**
  31659. * Gets if the SPS uses the model materials for its own multimaterial.
  31660. */
  31661. get useModelMaterial(): boolean;
  31662. /**
  31663. * The SPS used material array.
  31664. */
  31665. get materials(): Material[];
  31666. /**
  31667. * Sets the SPS MultiMaterial from the passed materials.
  31668. * Note : the passed array is internally copied and not used then by reference.
  31669. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31670. */
  31671. setMultiMaterial(materials: Material[]): void;
  31672. /**
  31673. * The SPS computed multimaterial object
  31674. */
  31675. get multimaterial(): MultiMaterial;
  31676. set multimaterial(mm: MultiMaterial);
  31677. /**
  31678. * If the subMeshes must be updated on the next call to setParticles()
  31679. */
  31680. get autoUpdateSubMeshes(): boolean;
  31681. set autoUpdateSubMeshes(val: boolean);
  31682. /**
  31683. * This function does nothing. It may be overwritten to set all the particle first values.
  31684. * The SPS doesn't call this function, you may have to call it by your own.
  31685. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31686. */
  31687. initParticles(): void;
  31688. /**
  31689. * This function does nothing. It may be overwritten to recycle a particle.
  31690. * The SPS doesn't call this function, you may have to call it by your own.
  31691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31692. * @param particle The particle to recycle
  31693. * @returns the recycled particle
  31694. */
  31695. recycleParticle(particle: SolidParticle): SolidParticle;
  31696. /**
  31697. * Updates a particle : this function should be overwritten by the user.
  31698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31700. * @example : just set a particle position or velocity and recycle conditions
  31701. * @param particle The particle to update
  31702. * @returns the updated particle
  31703. */
  31704. updateParticle(particle: SolidParticle): SolidParticle;
  31705. /**
  31706. * Updates a vertex of a particle : it can be overwritten by the user.
  31707. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31708. * @param particle the current particle
  31709. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31710. * @param pt the index of the current vertex in the particle shape
  31711. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31712. * @example : just set a vertex particle position or color
  31713. * @returns the sps
  31714. */
  31715. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31716. /**
  31717. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31718. * This does nothing and may be overwritten by the user.
  31719. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31721. * @param update the boolean update value actually passed to setParticles()
  31722. */
  31723. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31724. /**
  31725. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31726. * This will be passed three parameters.
  31727. * This does nothing and may be overwritten by the user.
  31728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31730. * @param update the boolean update value actually passed to setParticles()
  31731. */
  31732. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31733. }
  31734. }
  31735. declare module "babylonjs/Particles/solidParticle" {
  31736. import { Nullable } from "babylonjs/types";
  31737. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31738. import { Color4 } from "babylonjs/Maths/math.color";
  31739. import { Mesh } from "babylonjs/Meshes/mesh";
  31740. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31741. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31742. import { Plane } from "babylonjs/Maths/math.plane";
  31743. import { Material } from "babylonjs/Materials/material";
  31744. /**
  31745. * Represents one particle of a solid particle system.
  31746. */
  31747. export class SolidParticle {
  31748. /**
  31749. * particle global index
  31750. */
  31751. idx: number;
  31752. /**
  31753. * particle identifier
  31754. */
  31755. id: number;
  31756. /**
  31757. * The color of the particle
  31758. */
  31759. color: Nullable<Color4>;
  31760. /**
  31761. * The world space position of the particle.
  31762. */
  31763. position: Vector3;
  31764. /**
  31765. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31766. */
  31767. rotation: Vector3;
  31768. /**
  31769. * The world space rotation quaternion of the particle.
  31770. */
  31771. rotationQuaternion: Nullable<Quaternion>;
  31772. /**
  31773. * The scaling of the particle.
  31774. */
  31775. scaling: Vector3;
  31776. /**
  31777. * The uvs of the particle.
  31778. */
  31779. uvs: Vector4;
  31780. /**
  31781. * The current speed of the particle.
  31782. */
  31783. velocity: Vector3;
  31784. /**
  31785. * The pivot point in the particle local space.
  31786. */
  31787. pivot: Vector3;
  31788. /**
  31789. * Must the particle be translated from its pivot point in its local space ?
  31790. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31791. * Default : false
  31792. */
  31793. translateFromPivot: boolean;
  31794. /**
  31795. * Is the particle active or not ?
  31796. */
  31797. alive: boolean;
  31798. /**
  31799. * Is the particle visible or not ?
  31800. */
  31801. isVisible: boolean;
  31802. /**
  31803. * Index of this particle in the global "positions" array (Internal use)
  31804. * @hidden
  31805. */
  31806. _pos: number;
  31807. /**
  31808. * @hidden Index of this particle in the global "indices" array (Internal use)
  31809. */
  31810. _ind: number;
  31811. /**
  31812. * @hidden ModelShape of this particle (Internal use)
  31813. */
  31814. _model: ModelShape;
  31815. /**
  31816. * ModelShape id of this particle
  31817. */
  31818. shapeId: number;
  31819. /**
  31820. * Index of the particle in its shape id
  31821. */
  31822. idxInShape: number;
  31823. /**
  31824. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31825. */
  31826. _modelBoundingInfo: BoundingInfo;
  31827. /**
  31828. * @hidden Particle BoundingInfo object (Internal use)
  31829. */
  31830. _boundingInfo: BoundingInfo;
  31831. /**
  31832. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31833. */
  31834. _sps: SolidParticleSystem;
  31835. /**
  31836. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31837. */
  31838. _stillInvisible: boolean;
  31839. /**
  31840. * @hidden Last computed particle rotation matrix
  31841. */
  31842. _rotationMatrix: number[];
  31843. /**
  31844. * Parent particle Id, if any.
  31845. * Default null.
  31846. */
  31847. parentId: Nullable<number>;
  31848. /**
  31849. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31850. */
  31851. materialIndex: Nullable<number>;
  31852. /**
  31853. * Custom object or properties.
  31854. */
  31855. props: Nullable<any>;
  31856. /**
  31857. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31858. * The possible values are :
  31859. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31860. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31862. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31863. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31864. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31865. * */
  31866. cullingStrategy: number;
  31867. /**
  31868. * @hidden Internal global position in the SPS.
  31869. */
  31870. _globalPosition: Vector3;
  31871. /**
  31872. * Creates a Solid Particle object.
  31873. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31874. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31875. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31876. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31877. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31878. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31879. * @param shapeId (integer) is the model shape identifier in the SPS.
  31880. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31881. * @param sps defines the sps it is associated to
  31882. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31883. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31884. */
  31885. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31886. /**
  31887. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31888. * @param target the particle target
  31889. * @returns the current particle
  31890. */
  31891. copyToRef(target: SolidParticle): SolidParticle;
  31892. /**
  31893. * Legacy support, changed scale to scaling
  31894. */
  31895. get scale(): Vector3;
  31896. /**
  31897. * Legacy support, changed scale to scaling
  31898. */
  31899. set scale(scale: Vector3);
  31900. /**
  31901. * Legacy support, changed quaternion to rotationQuaternion
  31902. */
  31903. get quaternion(): Nullable<Quaternion>;
  31904. /**
  31905. * Legacy support, changed quaternion to rotationQuaternion
  31906. */
  31907. set quaternion(q: Nullable<Quaternion>);
  31908. /**
  31909. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31910. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31911. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31912. * @returns true if it intersects
  31913. */
  31914. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31915. /**
  31916. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31917. * A particle is in the frustum if its bounding box intersects the frustum
  31918. * @param frustumPlanes defines the frustum to test
  31919. * @returns true if the particle is in the frustum planes
  31920. */
  31921. isInFrustum(frustumPlanes: Plane[]): boolean;
  31922. /**
  31923. * get the rotation matrix of the particle
  31924. * @hidden
  31925. */
  31926. getRotationMatrix(m: Matrix): void;
  31927. }
  31928. /**
  31929. * Represents the shape of the model used by one particle of a solid particle system.
  31930. * SPS internal tool, don't use it manually.
  31931. */
  31932. export class ModelShape {
  31933. /**
  31934. * The shape id
  31935. * @hidden
  31936. */
  31937. shapeID: number;
  31938. /**
  31939. * flat array of model positions (internal use)
  31940. * @hidden
  31941. */
  31942. _shape: Vector3[];
  31943. /**
  31944. * flat array of model UVs (internal use)
  31945. * @hidden
  31946. */
  31947. _shapeUV: number[];
  31948. /**
  31949. * color array of the model
  31950. * @hidden
  31951. */
  31952. _shapeColors: number[];
  31953. /**
  31954. * indices array of the model
  31955. * @hidden
  31956. */
  31957. _indices: number[];
  31958. /**
  31959. * normals array of the model
  31960. * @hidden
  31961. */
  31962. _normals: number[];
  31963. /**
  31964. * length of the shape in the model indices array (internal use)
  31965. * @hidden
  31966. */
  31967. _indicesLength: number;
  31968. /**
  31969. * Custom position function (internal use)
  31970. * @hidden
  31971. */
  31972. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31973. /**
  31974. * Custom vertex function (internal use)
  31975. * @hidden
  31976. */
  31977. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31978. /**
  31979. * Model material (internal use)
  31980. * @hidden
  31981. */
  31982. _material: Nullable<Material>;
  31983. /**
  31984. * 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.
  31985. * SPS internal tool, don't use it manually.
  31986. * @hidden
  31987. */
  31988. 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>);
  31989. }
  31990. /**
  31991. * Represents a Depth Sorted Particle in the solid particle system.
  31992. * @hidden
  31993. */
  31994. export class DepthSortedParticle {
  31995. /**
  31996. * Particle index
  31997. */
  31998. idx: number;
  31999. /**
  32000. * Index of the particle in the "indices" array
  32001. */
  32002. ind: number;
  32003. /**
  32004. * Length of the particle shape in the "indices" array
  32005. */
  32006. indicesLength: number;
  32007. /**
  32008. * Squared distance from the particle to the camera
  32009. */
  32010. sqDistance: number;
  32011. /**
  32012. * Material index when used with MultiMaterials
  32013. */
  32014. materialIndex: number;
  32015. /**
  32016. * Creates a new sorted particle
  32017. * @param materialIndex
  32018. */
  32019. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32020. }
  32021. /**
  32022. * Represents a solid particle vertex
  32023. */
  32024. export class SolidParticleVertex {
  32025. /**
  32026. * Vertex position
  32027. */
  32028. position: Vector3;
  32029. /**
  32030. * Vertex color
  32031. */
  32032. color: Color4;
  32033. /**
  32034. * Vertex UV
  32035. */
  32036. uv: Vector2;
  32037. /**
  32038. * Creates a new solid particle vertex
  32039. */
  32040. constructor();
  32041. /** Vertex x coordinate */
  32042. get x(): number;
  32043. set x(val: number);
  32044. /** Vertex y coordinate */
  32045. get y(): number;
  32046. set y(val: number);
  32047. /** Vertex z coordinate */
  32048. get z(): number;
  32049. set z(val: number);
  32050. }
  32051. }
  32052. declare module "babylonjs/Collisions/meshCollisionData" {
  32053. import { Collider } from "babylonjs/Collisions/collider";
  32054. import { Vector3 } from "babylonjs/Maths/math.vector";
  32055. import { Nullable } from "babylonjs/types";
  32056. import { Observer } from "babylonjs/Misc/observable";
  32057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32058. /**
  32059. * @hidden
  32060. */
  32061. export class _MeshCollisionData {
  32062. _checkCollisions: boolean;
  32063. _collisionMask: number;
  32064. _collisionGroup: number;
  32065. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32066. _collider: Nullable<Collider>;
  32067. _oldPositionForCollisions: Vector3;
  32068. _diffPositionForCollisions: Vector3;
  32069. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32070. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32071. }
  32072. }
  32073. declare module "babylonjs/Meshes/abstractMesh" {
  32074. import { Observable } from "babylonjs/Misc/observable";
  32075. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32076. import { Camera } from "babylonjs/Cameras/camera";
  32077. import { Scene, IDisposable } from "babylonjs/scene";
  32078. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32079. import { Node } from "babylonjs/node";
  32080. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32081. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32083. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32084. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32085. import { Material } from "babylonjs/Materials/material";
  32086. import { Light } from "babylonjs/Lights/light";
  32087. import { Skeleton } from "babylonjs/Bones/skeleton";
  32088. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32089. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32090. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32091. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32092. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32093. import { Plane } from "babylonjs/Maths/math.plane";
  32094. import { Ray } from "babylonjs/Culling/ray";
  32095. import { Collider } from "babylonjs/Collisions/collider";
  32096. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32097. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32098. /** @hidden */
  32099. class _FacetDataStorage {
  32100. facetPositions: Vector3[];
  32101. facetNormals: Vector3[];
  32102. facetPartitioning: number[][];
  32103. facetNb: number;
  32104. partitioningSubdivisions: number;
  32105. partitioningBBoxRatio: number;
  32106. facetDataEnabled: boolean;
  32107. facetParameters: any;
  32108. bbSize: Vector3;
  32109. subDiv: {
  32110. max: number;
  32111. X: number;
  32112. Y: number;
  32113. Z: number;
  32114. };
  32115. facetDepthSort: boolean;
  32116. facetDepthSortEnabled: boolean;
  32117. depthSortedIndices: IndicesArray;
  32118. depthSortedFacets: {
  32119. ind: number;
  32120. sqDistance: number;
  32121. }[];
  32122. facetDepthSortFunction: (f1: {
  32123. ind: number;
  32124. sqDistance: number;
  32125. }, f2: {
  32126. ind: number;
  32127. sqDistance: number;
  32128. }) => number;
  32129. facetDepthSortFrom: Vector3;
  32130. facetDepthSortOrigin: Vector3;
  32131. invertedMatrix: Matrix;
  32132. }
  32133. /**
  32134. * @hidden
  32135. **/
  32136. class _InternalAbstractMeshDataInfo {
  32137. _hasVertexAlpha: boolean;
  32138. _useVertexColors: boolean;
  32139. _numBoneInfluencers: number;
  32140. _applyFog: boolean;
  32141. _receiveShadows: boolean;
  32142. _facetData: _FacetDataStorage;
  32143. _visibility: number;
  32144. _skeleton: Nullable<Skeleton>;
  32145. _layerMask: number;
  32146. _computeBonesUsingShaders: boolean;
  32147. _isActive: boolean;
  32148. _onlyForInstances: boolean;
  32149. _isActiveIntermediate: boolean;
  32150. _onlyForInstancesIntermediate: boolean;
  32151. _actAsRegularMesh: boolean;
  32152. }
  32153. /**
  32154. * Class used to store all common mesh properties
  32155. */
  32156. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32157. /** No occlusion */
  32158. static OCCLUSION_TYPE_NONE: number;
  32159. /** Occlusion set to optimisitic */
  32160. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32161. /** Occlusion set to strict */
  32162. static OCCLUSION_TYPE_STRICT: number;
  32163. /** Use an accurante occlusion algorithm */
  32164. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32165. /** Use a conservative occlusion algorithm */
  32166. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32167. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32168. * Test order :
  32169. * Is the bounding sphere outside the frustum ?
  32170. * If not, are the bounding box vertices outside the frustum ?
  32171. * It not, then the cullable object is in the frustum.
  32172. */
  32173. static readonly CULLINGSTRATEGY_STANDARD: number;
  32174. /** Culling strategy : Bounding Sphere Only.
  32175. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32176. * It's also less accurate than the standard because some not visible objects can still be selected.
  32177. * Test : is the bounding sphere outside the frustum ?
  32178. * If not, then the cullable object is in the frustum.
  32179. */
  32180. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32181. /** Culling strategy : Optimistic Inclusion.
  32182. * This in an inclusion test first, then the standard exclusion test.
  32183. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32184. * 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.
  32185. * Anyway, it's as accurate as the standard strategy.
  32186. * Test :
  32187. * Is the cullable object bounding sphere center in the frustum ?
  32188. * If not, apply the default culling strategy.
  32189. */
  32190. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32191. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32192. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32193. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32194. * 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.
  32195. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32196. * Test :
  32197. * Is the cullable object bounding sphere center in the frustum ?
  32198. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32199. */
  32200. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32201. /**
  32202. * No billboard
  32203. */
  32204. static get BILLBOARDMODE_NONE(): number;
  32205. /** Billboard on X axis */
  32206. static get BILLBOARDMODE_X(): number;
  32207. /** Billboard on Y axis */
  32208. static get BILLBOARDMODE_Y(): number;
  32209. /** Billboard on Z axis */
  32210. static get BILLBOARDMODE_Z(): number;
  32211. /** Billboard on all axes */
  32212. static get BILLBOARDMODE_ALL(): number;
  32213. /** Billboard on using position instead of orientation */
  32214. static get BILLBOARDMODE_USE_POSITION(): number;
  32215. /** @hidden */
  32216. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32217. /**
  32218. * The culling strategy to use to check whether the mesh must be rendered or not.
  32219. * This value can be changed at any time and will be used on the next render mesh selection.
  32220. * The possible values are :
  32221. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32222. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32224. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32225. * Please read each static variable documentation to get details about the culling process.
  32226. * */
  32227. cullingStrategy: number;
  32228. /**
  32229. * Gets the number of facets in the mesh
  32230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32231. */
  32232. get facetNb(): number;
  32233. /**
  32234. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32236. */
  32237. get partitioningSubdivisions(): number;
  32238. set partitioningSubdivisions(nb: number);
  32239. /**
  32240. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32241. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32243. */
  32244. get partitioningBBoxRatio(): number;
  32245. set partitioningBBoxRatio(ratio: number);
  32246. /**
  32247. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32248. * Works only for updatable meshes.
  32249. * Doesn't work with multi-materials
  32250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32251. */
  32252. get mustDepthSortFacets(): boolean;
  32253. set mustDepthSortFacets(sort: boolean);
  32254. /**
  32255. * The location (Vector3) where the facet depth sort must be computed from.
  32256. * By default, the active camera position.
  32257. * Used only when facet depth sort is enabled
  32258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32259. */
  32260. get facetDepthSortFrom(): Vector3;
  32261. set facetDepthSortFrom(location: Vector3);
  32262. /**
  32263. * gets a boolean indicating if facetData is enabled
  32264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32265. */
  32266. get isFacetDataEnabled(): boolean;
  32267. /** @hidden */
  32268. _updateNonUniformScalingState(value: boolean): boolean;
  32269. /**
  32270. * An event triggered when this mesh collides with another one
  32271. */
  32272. onCollideObservable: Observable<AbstractMesh>;
  32273. /** Set a function to call when this mesh collides with another one */
  32274. set onCollide(callback: () => void);
  32275. /**
  32276. * An event triggered when the collision's position changes
  32277. */
  32278. onCollisionPositionChangeObservable: Observable<Vector3>;
  32279. /** Set a function to call when the collision's position changes */
  32280. set onCollisionPositionChange(callback: () => void);
  32281. /**
  32282. * An event triggered when material is changed
  32283. */
  32284. onMaterialChangedObservable: Observable<AbstractMesh>;
  32285. /**
  32286. * Gets or sets the orientation for POV movement & rotation
  32287. */
  32288. definedFacingForward: boolean;
  32289. /** @hidden */
  32290. _occlusionQuery: Nullable<WebGLQuery>;
  32291. /** @hidden */
  32292. _renderingGroup: Nullable<RenderingGroup>;
  32293. /**
  32294. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32295. */
  32296. get visibility(): number;
  32297. /**
  32298. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32299. */
  32300. set visibility(value: number);
  32301. /** Gets or sets the alpha index used to sort transparent meshes
  32302. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32303. */
  32304. alphaIndex: number;
  32305. /**
  32306. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32307. */
  32308. isVisible: boolean;
  32309. /**
  32310. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32311. */
  32312. isPickable: boolean;
  32313. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32314. showSubMeshesBoundingBox: boolean;
  32315. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32316. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32317. */
  32318. isBlocker: boolean;
  32319. /**
  32320. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32321. */
  32322. enablePointerMoveEvents: boolean;
  32323. /**
  32324. * Specifies the rendering group id for this mesh (0 by default)
  32325. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32326. */
  32327. renderingGroupId: number;
  32328. private _material;
  32329. /** Gets or sets current material */
  32330. get material(): Nullable<Material>;
  32331. set material(value: Nullable<Material>);
  32332. /**
  32333. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32334. * @see http://doc.babylonjs.com/babylon101/shadows
  32335. */
  32336. get receiveShadows(): boolean;
  32337. set receiveShadows(value: boolean);
  32338. /** Defines color to use when rendering outline */
  32339. outlineColor: Color3;
  32340. /** Define width to use when rendering outline */
  32341. outlineWidth: number;
  32342. /** Defines color to use when rendering overlay */
  32343. overlayColor: Color3;
  32344. /** Defines alpha to use when rendering overlay */
  32345. overlayAlpha: number;
  32346. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32347. get hasVertexAlpha(): boolean;
  32348. set hasVertexAlpha(value: boolean);
  32349. /** 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) */
  32350. get useVertexColors(): boolean;
  32351. set useVertexColors(value: boolean);
  32352. /**
  32353. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32354. */
  32355. get computeBonesUsingShaders(): boolean;
  32356. set computeBonesUsingShaders(value: boolean);
  32357. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32358. get numBoneInfluencers(): number;
  32359. set numBoneInfluencers(value: number);
  32360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32361. get applyFog(): boolean;
  32362. set applyFog(value: boolean);
  32363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32364. useOctreeForRenderingSelection: boolean;
  32365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32366. useOctreeForPicking: boolean;
  32367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32368. useOctreeForCollisions: boolean;
  32369. /**
  32370. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32371. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32372. */
  32373. get layerMask(): number;
  32374. set layerMask(value: number);
  32375. /**
  32376. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32377. */
  32378. alwaysSelectAsActiveMesh: boolean;
  32379. /**
  32380. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32381. */
  32382. doNotSyncBoundingInfo: boolean;
  32383. /**
  32384. * Gets or sets the current action manager
  32385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32386. */
  32387. actionManager: Nullable<AbstractActionManager>;
  32388. private _meshCollisionData;
  32389. /**
  32390. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32392. */
  32393. ellipsoid: Vector3;
  32394. /**
  32395. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32397. */
  32398. ellipsoidOffset: Vector3;
  32399. /**
  32400. * Gets or sets a collision mask used to mask collisions (default is -1).
  32401. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32402. */
  32403. get collisionMask(): number;
  32404. set collisionMask(mask: number);
  32405. /**
  32406. * Gets or sets the current collision group mask (-1 by default).
  32407. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32408. */
  32409. get collisionGroup(): number;
  32410. set collisionGroup(mask: number);
  32411. /**
  32412. * Gets or sets current surrounding meshes (null by default).
  32413. *
  32414. * By default collision detection is tested against every mesh in the scene.
  32415. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32416. * meshes will be tested for the collision.
  32417. *
  32418. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32419. */
  32420. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32421. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32422. /**
  32423. * Defines edge width used when edgesRenderer is enabled
  32424. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32425. */
  32426. edgesWidth: number;
  32427. /**
  32428. * Defines edge color used when edgesRenderer is enabled
  32429. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32430. */
  32431. edgesColor: Color4;
  32432. /** @hidden */
  32433. _edgesRenderer: Nullable<IEdgesRenderer>;
  32434. /** @hidden */
  32435. _masterMesh: Nullable<AbstractMesh>;
  32436. /** @hidden */
  32437. _boundingInfo: Nullable<BoundingInfo>;
  32438. /** @hidden */
  32439. _renderId: number;
  32440. /**
  32441. * Gets or sets the list of subMeshes
  32442. * @see http://doc.babylonjs.com/how_to/multi_materials
  32443. */
  32444. subMeshes: SubMesh[];
  32445. /** @hidden */
  32446. _intersectionsInProgress: AbstractMesh[];
  32447. /** @hidden */
  32448. _unIndexed: boolean;
  32449. /** @hidden */
  32450. _lightSources: Light[];
  32451. /** Gets the list of lights affecting that mesh */
  32452. get lightSources(): Light[];
  32453. /** @hidden */
  32454. get _positions(): Nullable<Vector3[]>;
  32455. /** @hidden */
  32456. _waitingData: {
  32457. lods: Nullable<any>;
  32458. actions: Nullable<any>;
  32459. freezeWorldMatrix: Nullable<boolean>;
  32460. };
  32461. /** @hidden */
  32462. _bonesTransformMatrices: Nullable<Float32Array>;
  32463. /** @hidden */
  32464. _transformMatrixTexture: Nullable<RawTexture>;
  32465. /**
  32466. * Gets or sets a skeleton to apply skining transformations
  32467. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32468. */
  32469. set skeleton(value: Nullable<Skeleton>);
  32470. get skeleton(): Nullable<Skeleton>;
  32471. /**
  32472. * An event triggered when the mesh is rebuilt.
  32473. */
  32474. onRebuildObservable: Observable<AbstractMesh>;
  32475. /**
  32476. * Creates a new AbstractMesh
  32477. * @param name defines the name of the mesh
  32478. * @param scene defines the hosting scene
  32479. */
  32480. constructor(name: string, scene?: Nullable<Scene>);
  32481. /**
  32482. * Returns the string "AbstractMesh"
  32483. * @returns "AbstractMesh"
  32484. */
  32485. getClassName(): string;
  32486. /**
  32487. * Gets a string representation of the current mesh
  32488. * @param fullDetails defines a boolean indicating if full details must be included
  32489. * @returns a string representation of the current mesh
  32490. */
  32491. toString(fullDetails?: boolean): string;
  32492. /**
  32493. * @hidden
  32494. */
  32495. protected _getEffectiveParent(): Nullable<Node>;
  32496. /** @hidden */
  32497. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32498. /** @hidden */
  32499. _rebuild(): void;
  32500. /** @hidden */
  32501. _resyncLightSources(): void;
  32502. /** @hidden */
  32503. _resyncLightSource(light: Light): void;
  32504. /** @hidden */
  32505. _unBindEffect(): void;
  32506. /** @hidden */
  32507. _removeLightSource(light: Light, dispose: boolean): void;
  32508. private _markSubMeshesAsDirty;
  32509. /** @hidden */
  32510. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32511. /** @hidden */
  32512. _markSubMeshesAsAttributesDirty(): void;
  32513. /** @hidden */
  32514. _markSubMeshesAsMiscDirty(): void;
  32515. /**
  32516. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32517. */
  32518. get scaling(): Vector3;
  32519. set scaling(newScaling: Vector3);
  32520. /**
  32521. * Returns true if the mesh is blocked. Implemented by child classes
  32522. */
  32523. get isBlocked(): boolean;
  32524. /**
  32525. * Returns the mesh itself by default. Implemented by child classes
  32526. * @param camera defines the camera to use to pick the right LOD level
  32527. * @returns the currentAbstractMesh
  32528. */
  32529. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32530. /**
  32531. * Returns 0 by default. Implemented by child classes
  32532. * @returns an integer
  32533. */
  32534. getTotalVertices(): number;
  32535. /**
  32536. * Returns a positive integer : the total number of indices in this mesh geometry.
  32537. * @returns the numner of indices or zero if the mesh has no geometry.
  32538. */
  32539. getTotalIndices(): number;
  32540. /**
  32541. * Returns null by default. Implemented by child classes
  32542. * @returns null
  32543. */
  32544. getIndices(): Nullable<IndicesArray>;
  32545. /**
  32546. * Returns the array of the requested vertex data kind. Implemented by child classes
  32547. * @param kind defines the vertex data kind to use
  32548. * @returns null
  32549. */
  32550. getVerticesData(kind: string): Nullable<FloatArray>;
  32551. /**
  32552. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32553. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32554. * Note that a new underlying VertexBuffer object is created each call.
  32555. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32556. * @param kind defines vertex data kind:
  32557. * * VertexBuffer.PositionKind
  32558. * * VertexBuffer.UVKind
  32559. * * VertexBuffer.UV2Kind
  32560. * * VertexBuffer.UV3Kind
  32561. * * VertexBuffer.UV4Kind
  32562. * * VertexBuffer.UV5Kind
  32563. * * VertexBuffer.UV6Kind
  32564. * * VertexBuffer.ColorKind
  32565. * * VertexBuffer.MatricesIndicesKind
  32566. * * VertexBuffer.MatricesIndicesExtraKind
  32567. * * VertexBuffer.MatricesWeightsKind
  32568. * * VertexBuffer.MatricesWeightsExtraKind
  32569. * @param data defines the data source
  32570. * @param updatable defines if the data must be flagged as updatable (or static)
  32571. * @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
  32572. * @returns the current mesh
  32573. */
  32574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32575. /**
  32576. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32577. * If the mesh has no geometry, it is simply returned as it is.
  32578. * @param kind defines vertex data kind:
  32579. * * VertexBuffer.PositionKind
  32580. * * VertexBuffer.UVKind
  32581. * * VertexBuffer.UV2Kind
  32582. * * VertexBuffer.UV3Kind
  32583. * * VertexBuffer.UV4Kind
  32584. * * VertexBuffer.UV5Kind
  32585. * * VertexBuffer.UV6Kind
  32586. * * VertexBuffer.ColorKind
  32587. * * VertexBuffer.MatricesIndicesKind
  32588. * * VertexBuffer.MatricesIndicesExtraKind
  32589. * * VertexBuffer.MatricesWeightsKind
  32590. * * VertexBuffer.MatricesWeightsExtraKind
  32591. * @param data defines the data source
  32592. * @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
  32593. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32594. * @returns the current mesh
  32595. */
  32596. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32597. /**
  32598. * Sets the mesh indices,
  32599. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32600. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32601. * @param totalVertices Defines the total number of vertices
  32602. * @returns the current mesh
  32603. */
  32604. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32605. /**
  32606. * Gets a boolean indicating if specific vertex data is present
  32607. * @param kind defines the vertex data kind to use
  32608. * @returns true is data kind is present
  32609. */
  32610. isVerticesDataPresent(kind: string): boolean;
  32611. /**
  32612. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32613. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32614. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32615. * @returns a BoundingInfo
  32616. */
  32617. getBoundingInfo(): BoundingInfo;
  32618. /**
  32619. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32620. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32621. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32622. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32623. * @returns the current mesh
  32624. */
  32625. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32626. /**
  32627. * Overwrite the current bounding info
  32628. * @param boundingInfo defines the new bounding info
  32629. * @returns the current mesh
  32630. */
  32631. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32632. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32633. get useBones(): boolean;
  32634. /** @hidden */
  32635. _preActivate(): void;
  32636. /** @hidden */
  32637. _preActivateForIntermediateRendering(renderId: number): void;
  32638. /** @hidden */
  32639. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32640. /** @hidden */
  32641. _postActivate(): void;
  32642. /** @hidden */
  32643. _freeze(): void;
  32644. /** @hidden */
  32645. _unFreeze(): void;
  32646. /**
  32647. * Gets the current world matrix
  32648. * @returns a Matrix
  32649. */
  32650. getWorldMatrix(): Matrix;
  32651. /** @hidden */
  32652. _getWorldMatrixDeterminant(): number;
  32653. /**
  32654. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32655. */
  32656. get isAnInstance(): boolean;
  32657. /**
  32658. * Gets a boolean indicating if this mesh has instances
  32659. */
  32660. get hasInstances(): boolean;
  32661. /**
  32662. * Gets a boolean indicating if this mesh has thin instances
  32663. */
  32664. get hasThinInstances(): boolean;
  32665. /**
  32666. * Perform relative position change from the point of view of behind the front of the mesh.
  32667. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32668. * Supports definition of mesh facing forward or backward
  32669. * @param amountRight defines the distance on the right axis
  32670. * @param amountUp defines the distance on the up axis
  32671. * @param amountForward defines the distance on the forward axis
  32672. * @returns the current mesh
  32673. */
  32674. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32675. /**
  32676. * Calculate relative position change from the point of view of behind the front of the mesh.
  32677. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32678. * Supports definition of mesh facing forward or backward
  32679. * @param amountRight defines the distance on the right axis
  32680. * @param amountUp defines the distance on the up axis
  32681. * @param amountForward defines the distance on the forward axis
  32682. * @returns the new displacement vector
  32683. */
  32684. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32685. /**
  32686. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32687. * Supports definition of mesh facing forward or backward
  32688. * @param flipBack defines the flip
  32689. * @param twirlClockwise defines the twirl
  32690. * @param tiltRight defines the tilt
  32691. * @returns the current mesh
  32692. */
  32693. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32694. /**
  32695. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32696. * Supports definition of mesh facing forward or backward.
  32697. * @param flipBack defines the flip
  32698. * @param twirlClockwise defines the twirl
  32699. * @param tiltRight defines the tilt
  32700. * @returns the new rotation vector
  32701. */
  32702. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32703. /**
  32704. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32705. * This means the mesh underlying bounding box and sphere are recomputed.
  32706. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32707. * @returns the current mesh
  32708. */
  32709. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32710. /** @hidden */
  32711. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32712. /** @hidden */
  32713. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32714. /** @hidden */
  32715. _updateBoundingInfo(): AbstractMesh;
  32716. /** @hidden */
  32717. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32718. /** @hidden */
  32719. protected _afterComputeWorldMatrix(): void;
  32720. /** @hidden */
  32721. get _effectiveMesh(): AbstractMesh;
  32722. /**
  32723. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32724. * A mesh is in the frustum if its bounding box intersects the frustum
  32725. * @param frustumPlanes defines the frustum to test
  32726. * @returns true if the mesh is in the frustum planes
  32727. */
  32728. isInFrustum(frustumPlanes: Plane[]): boolean;
  32729. /**
  32730. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32731. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32732. * @param frustumPlanes defines the frustum to test
  32733. * @returns true if the mesh is completely in the frustum planes
  32734. */
  32735. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32736. /**
  32737. * True if the mesh intersects another mesh or a SolidParticle object
  32738. * @param mesh defines a target mesh or SolidParticle to test
  32739. * @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)
  32740. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32741. * @returns true if there is an intersection
  32742. */
  32743. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32744. /**
  32745. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32746. * @param point defines the point to test
  32747. * @returns true if there is an intersection
  32748. */
  32749. intersectsPoint(point: Vector3): boolean;
  32750. /**
  32751. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32753. */
  32754. get checkCollisions(): boolean;
  32755. set checkCollisions(collisionEnabled: boolean);
  32756. /**
  32757. * Gets Collider object used to compute collisions (not physics)
  32758. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32759. */
  32760. get collider(): Nullable<Collider>;
  32761. /**
  32762. * Move the mesh using collision engine
  32763. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32764. * @param displacement defines the requested displacement vector
  32765. * @returns the current mesh
  32766. */
  32767. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32768. private _onCollisionPositionChange;
  32769. /** @hidden */
  32770. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32771. /** @hidden */
  32772. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32773. /** @hidden */
  32774. _checkCollision(collider: Collider): AbstractMesh;
  32775. /** @hidden */
  32776. _generatePointsArray(): boolean;
  32777. /**
  32778. * Checks if the passed Ray intersects with the mesh
  32779. * @param ray defines the ray to use
  32780. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32781. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32782. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32783. * @returns the picking info
  32784. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32785. */
  32786. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32787. /**
  32788. * Clones the current mesh
  32789. * @param name defines the mesh name
  32790. * @param newParent defines the new mesh parent
  32791. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32792. * @returns the new mesh
  32793. */
  32794. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32795. /**
  32796. * Disposes all the submeshes of the current meshnp
  32797. * @returns the current mesh
  32798. */
  32799. releaseSubMeshes(): AbstractMesh;
  32800. /**
  32801. * Releases resources associated with this abstract mesh.
  32802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32804. */
  32805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32806. /**
  32807. * Adds the passed mesh as a child to the current mesh
  32808. * @param mesh defines the child mesh
  32809. * @returns the current mesh
  32810. */
  32811. addChild(mesh: AbstractMesh): AbstractMesh;
  32812. /**
  32813. * Removes the passed mesh from the current mesh children list
  32814. * @param mesh defines the child mesh
  32815. * @returns the current mesh
  32816. */
  32817. removeChild(mesh: AbstractMesh): AbstractMesh;
  32818. /** @hidden */
  32819. private _initFacetData;
  32820. /**
  32821. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32822. * This method can be called within the render loop.
  32823. * 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
  32824. * @returns the current mesh
  32825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32826. */
  32827. updateFacetData(): AbstractMesh;
  32828. /**
  32829. * Returns the facetLocalNormals array.
  32830. * The normals are expressed in the mesh local spac
  32831. * @returns an array of Vector3
  32832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32833. */
  32834. getFacetLocalNormals(): Vector3[];
  32835. /**
  32836. * Returns the facetLocalPositions array.
  32837. * The facet positions are expressed in the mesh local space
  32838. * @returns an array of Vector3
  32839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32840. */
  32841. getFacetLocalPositions(): Vector3[];
  32842. /**
  32843. * Returns the facetLocalPartioning array
  32844. * @returns an array of array of numbers
  32845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32846. */
  32847. getFacetLocalPartitioning(): number[][];
  32848. /**
  32849. * Returns the i-th facet position in the world system.
  32850. * This method allocates a new Vector3 per call
  32851. * @param i defines the facet index
  32852. * @returns a new Vector3
  32853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32854. */
  32855. getFacetPosition(i: number): Vector3;
  32856. /**
  32857. * Sets the reference Vector3 with the i-th facet position in the world system
  32858. * @param i defines the facet index
  32859. * @param ref defines the target vector
  32860. * @returns the current mesh
  32861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32862. */
  32863. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32864. /**
  32865. * Returns the i-th facet normal in the world system.
  32866. * This method allocates a new Vector3 per call
  32867. * @param i defines the facet index
  32868. * @returns a new Vector3
  32869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32870. */
  32871. getFacetNormal(i: number): Vector3;
  32872. /**
  32873. * Sets the reference Vector3 with the i-th facet normal in the world system
  32874. * @param i defines the facet index
  32875. * @param ref defines the target vector
  32876. * @returns the current mesh
  32877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32878. */
  32879. getFacetNormalToRef(i: number, ref: Vector3): this;
  32880. /**
  32881. * 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)
  32882. * @param x defines x coordinate
  32883. * @param y defines y coordinate
  32884. * @param z defines z coordinate
  32885. * @returns the array of facet indexes
  32886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32887. */
  32888. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32889. /**
  32890. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32891. * @param projected sets as the (x,y,z) world projection on the facet
  32892. * @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
  32893. * @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
  32894. * @param x defines x coordinate
  32895. * @param y defines y coordinate
  32896. * @param z defines z coordinate
  32897. * @returns the face index if found (or null instead)
  32898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32899. */
  32900. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32901. /**
  32902. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32903. * @param projected sets as the (x,y,z) local projection on the facet
  32904. * @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
  32905. * @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
  32906. * @param x defines x coordinate
  32907. * @param y defines y coordinate
  32908. * @param z defines z coordinate
  32909. * @returns the face index if found (or null instead)
  32910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32911. */
  32912. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32913. /**
  32914. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32915. * @returns the parameters
  32916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32917. */
  32918. getFacetDataParameters(): any;
  32919. /**
  32920. * Disables the feature FacetData and frees the related memory
  32921. * @returns the current mesh
  32922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32923. */
  32924. disableFacetData(): AbstractMesh;
  32925. /**
  32926. * Updates the AbstractMesh indices array
  32927. * @param indices defines the data source
  32928. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32929. * @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)
  32930. * @returns the current mesh
  32931. */
  32932. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32933. /**
  32934. * Creates new normals data for the mesh
  32935. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32936. * @returns the current mesh
  32937. */
  32938. createNormals(updatable: boolean): AbstractMesh;
  32939. /**
  32940. * Align the mesh with a normal
  32941. * @param normal defines the normal to use
  32942. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32943. * @returns the current mesh
  32944. */
  32945. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32946. /** @hidden */
  32947. _checkOcclusionQuery(): boolean;
  32948. /**
  32949. * Disables the mesh edge rendering mode
  32950. * @returns the currentAbstractMesh
  32951. */
  32952. disableEdgesRendering(): AbstractMesh;
  32953. /**
  32954. * Enables the edge rendering mode on the mesh.
  32955. * This mode makes the mesh edges visible
  32956. * @param epsilon defines the maximal distance between two angles to detect a face
  32957. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32958. * @returns the currentAbstractMesh
  32959. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32960. */
  32961. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32962. }
  32963. }
  32964. declare module "babylonjs/Actions/actionEvent" {
  32965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32966. import { Nullable } from "babylonjs/types";
  32967. import { Sprite } from "babylonjs/Sprites/sprite";
  32968. import { Scene } from "babylonjs/scene";
  32969. import { Vector2 } from "babylonjs/Maths/math.vector";
  32970. /**
  32971. * Interface used to define ActionEvent
  32972. */
  32973. export interface IActionEvent {
  32974. /** The mesh or sprite that triggered the action */
  32975. source: any;
  32976. /** The X mouse cursor position at the time of the event */
  32977. pointerX: number;
  32978. /** The Y mouse cursor position at the time of the event */
  32979. pointerY: number;
  32980. /** The mesh that is currently pointed at (can be null) */
  32981. meshUnderPointer: Nullable<AbstractMesh>;
  32982. /** the original (browser) event that triggered the ActionEvent */
  32983. sourceEvent?: any;
  32984. /** additional data for the event */
  32985. additionalData?: any;
  32986. }
  32987. /**
  32988. * ActionEvent is the event being sent when an action is triggered.
  32989. */
  32990. export class ActionEvent implements IActionEvent {
  32991. /** The mesh or sprite that triggered the action */
  32992. source: any;
  32993. /** The X mouse cursor position at the time of the event */
  32994. pointerX: number;
  32995. /** The Y mouse cursor position at the time of the event */
  32996. pointerY: number;
  32997. /** The mesh that is currently pointed at (can be null) */
  32998. meshUnderPointer: Nullable<AbstractMesh>;
  32999. /** the original (browser) event that triggered the ActionEvent */
  33000. sourceEvent?: any;
  33001. /** additional data for the event */
  33002. additionalData?: any;
  33003. /**
  33004. * Creates a new ActionEvent
  33005. * @param source The mesh or sprite that triggered the action
  33006. * @param pointerX The X mouse cursor position at the time of the event
  33007. * @param pointerY The Y mouse cursor position at the time of the event
  33008. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33009. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33010. * @param additionalData additional data for the event
  33011. */
  33012. constructor(
  33013. /** The mesh or sprite that triggered the action */
  33014. source: any,
  33015. /** The X mouse cursor position at the time of the event */
  33016. pointerX: number,
  33017. /** The Y mouse cursor position at the time of the event */
  33018. pointerY: number,
  33019. /** The mesh that is currently pointed at (can be null) */
  33020. meshUnderPointer: Nullable<AbstractMesh>,
  33021. /** the original (browser) event that triggered the ActionEvent */
  33022. sourceEvent?: any,
  33023. /** additional data for the event */
  33024. additionalData?: any);
  33025. /**
  33026. * Helper function to auto-create an ActionEvent from a source mesh.
  33027. * @param source The source mesh that triggered the event
  33028. * @param evt The original (browser) event
  33029. * @param additionalData additional data for the event
  33030. * @returns the new ActionEvent
  33031. */
  33032. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33033. /**
  33034. * Helper function to auto-create an ActionEvent from a source sprite
  33035. * @param source The source sprite that triggered the event
  33036. * @param scene Scene associated with the sprite
  33037. * @param evt The original (browser) event
  33038. * @param additionalData additional data for the event
  33039. * @returns the new ActionEvent
  33040. */
  33041. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33042. /**
  33043. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33044. * @param scene the scene where the event occurred
  33045. * @param evt The original (browser) event
  33046. * @returns the new ActionEvent
  33047. */
  33048. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33049. /**
  33050. * Helper function to auto-create an ActionEvent from a primitive
  33051. * @param prim defines the target primitive
  33052. * @param pointerPos defines the pointer position
  33053. * @param evt The original (browser) event
  33054. * @param additionalData additional data for the event
  33055. * @returns the new ActionEvent
  33056. */
  33057. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33058. }
  33059. }
  33060. declare module "babylonjs/Actions/abstractActionManager" {
  33061. import { IDisposable } from "babylonjs/scene";
  33062. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33063. import { IAction } from "babylonjs/Actions/action";
  33064. import { Nullable } from "babylonjs/types";
  33065. /**
  33066. * Abstract class used to decouple action Manager from scene and meshes.
  33067. * Do not instantiate.
  33068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33069. */
  33070. export abstract class AbstractActionManager implements IDisposable {
  33071. /** Gets the list of active triggers */
  33072. static Triggers: {
  33073. [key: string]: number;
  33074. };
  33075. /** Gets the cursor to use when hovering items */
  33076. hoverCursor: string;
  33077. /** Gets the list of actions */
  33078. actions: IAction[];
  33079. /**
  33080. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33081. */
  33082. isRecursive: boolean;
  33083. /**
  33084. * Releases all associated resources
  33085. */
  33086. abstract dispose(): void;
  33087. /**
  33088. * Does this action manager has pointer triggers
  33089. */
  33090. abstract get hasPointerTriggers(): boolean;
  33091. /**
  33092. * Does this action manager has pick triggers
  33093. */
  33094. abstract get hasPickTriggers(): boolean;
  33095. /**
  33096. * Process a specific trigger
  33097. * @param trigger defines the trigger to process
  33098. * @param evt defines the event details to be processed
  33099. */
  33100. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33101. /**
  33102. * Does this action manager handles actions of any of the given triggers
  33103. * @param triggers defines the triggers to be tested
  33104. * @return a boolean indicating whether one (or more) of the triggers is handled
  33105. */
  33106. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33107. /**
  33108. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33109. * speed.
  33110. * @param triggerA defines the trigger to be tested
  33111. * @param triggerB defines the trigger to be tested
  33112. * @return a boolean indicating whether one (or more) of the triggers is handled
  33113. */
  33114. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33115. /**
  33116. * Does this action manager handles actions of a given trigger
  33117. * @param trigger defines the trigger to be tested
  33118. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33119. * @return whether the trigger is handled
  33120. */
  33121. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33122. /**
  33123. * Serialize this manager to a JSON object
  33124. * @param name defines the property name to store this manager
  33125. * @returns a JSON representation of this manager
  33126. */
  33127. abstract serialize(name: string): any;
  33128. /**
  33129. * Registers an action to this action manager
  33130. * @param action defines the action to be registered
  33131. * @return the action amended (prepared) after registration
  33132. */
  33133. abstract registerAction(action: IAction): Nullable<IAction>;
  33134. /**
  33135. * Unregisters an action to this action manager
  33136. * @param action defines the action to be unregistered
  33137. * @return a boolean indicating whether the action has been unregistered
  33138. */
  33139. abstract unregisterAction(action: IAction): Boolean;
  33140. /**
  33141. * Does exist one action manager with at least one trigger
  33142. **/
  33143. static get HasTriggers(): boolean;
  33144. /**
  33145. * Does exist one action manager with at least one pick trigger
  33146. **/
  33147. static get HasPickTriggers(): boolean;
  33148. /**
  33149. * Does exist one action manager that handles actions of a given trigger
  33150. * @param trigger defines the trigger to be tested
  33151. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33152. **/
  33153. static HasSpecificTrigger(trigger: number): boolean;
  33154. }
  33155. }
  33156. declare module "babylonjs/node" {
  33157. import { Scene } from "babylonjs/scene";
  33158. import { Nullable } from "babylonjs/types";
  33159. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33160. import { Engine } from "babylonjs/Engines/engine";
  33161. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33162. import { Observable } from "babylonjs/Misc/observable";
  33163. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33164. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33165. import { Animatable } from "babylonjs/Animations/animatable";
  33166. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33167. import { Animation } from "babylonjs/Animations/animation";
  33168. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33170. /**
  33171. * Defines how a node can be built from a string name.
  33172. */
  33173. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33174. /**
  33175. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33176. */
  33177. export class Node implements IBehaviorAware<Node> {
  33178. /** @hidden */
  33179. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33180. private static _NodeConstructors;
  33181. /**
  33182. * Add a new node constructor
  33183. * @param type defines the type name of the node to construct
  33184. * @param constructorFunc defines the constructor function
  33185. */
  33186. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33187. /**
  33188. * Returns a node constructor based on type name
  33189. * @param type defines the type name
  33190. * @param name defines the new node name
  33191. * @param scene defines the hosting scene
  33192. * @param options defines optional options to transmit to constructors
  33193. * @returns the new constructor or null
  33194. */
  33195. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33196. /**
  33197. * Gets or sets the name of the node
  33198. */
  33199. name: string;
  33200. /**
  33201. * Gets or sets the id of the node
  33202. */
  33203. id: string;
  33204. /**
  33205. * Gets or sets the unique id of the node
  33206. */
  33207. uniqueId: number;
  33208. /**
  33209. * Gets or sets a string used to store user defined state for the node
  33210. */
  33211. state: string;
  33212. /**
  33213. * Gets or sets an object used to store user defined information for the node
  33214. */
  33215. metadata: any;
  33216. /**
  33217. * For internal use only. Please do not use.
  33218. */
  33219. reservedDataStore: any;
  33220. /**
  33221. * List of inspectable custom properties (used by the Inspector)
  33222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33223. */
  33224. inspectableCustomProperties: IInspectable[];
  33225. private _doNotSerialize;
  33226. /**
  33227. * Gets or sets a boolean used to define if the node must be serialized
  33228. */
  33229. get doNotSerialize(): boolean;
  33230. set doNotSerialize(value: boolean);
  33231. /** @hidden */
  33232. _isDisposed: boolean;
  33233. /**
  33234. * Gets a list of Animations associated with the node
  33235. */
  33236. animations: import("babylonjs/Animations/animation").Animation[];
  33237. protected _ranges: {
  33238. [name: string]: Nullable<AnimationRange>;
  33239. };
  33240. /**
  33241. * Callback raised when the node is ready to be used
  33242. */
  33243. onReady: Nullable<(node: Node) => void>;
  33244. private _isEnabled;
  33245. private _isParentEnabled;
  33246. private _isReady;
  33247. /** @hidden */
  33248. _currentRenderId: number;
  33249. private _parentUpdateId;
  33250. /** @hidden */
  33251. _childUpdateId: number;
  33252. /** @hidden */
  33253. _waitingParentId: Nullable<string>;
  33254. /** @hidden */
  33255. _scene: Scene;
  33256. /** @hidden */
  33257. _cache: any;
  33258. private _parentNode;
  33259. private _children;
  33260. /** @hidden */
  33261. _worldMatrix: Matrix;
  33262. /** @hidden */
  33263. _worldMatrixDeterminant: number;
  33264. /** @hidden */
  33265. _worldMatrixDeterminantIsDirty: boolean;
  33266. /** @hidden */
  33267. private _sceneRootNodesIndex;
  33268. /**
  33269. * Gets a boolean indicating if the node has been disposed
  33270. * @returns true if the node was disposed
  33271. */
  33272. isDisposed(): boolean;
  33273. /**
  33274. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33275. * @see https://doc.babylonjs.com/how_to/parenting
  33276. */
  33277. set parent(parent: Nullable<Node>);
  33278. get parent(): Nullable<Node>;
  33279. /** @hidden */
  33280. _addToSceneRootNodes(): void;
  33281. /** @hidden */
  33282. _removeFromSceneRootNodes(): void;
  33283. private _animationPropertiesOverride;
  33284. /**
  33285. * Gets or sets the animation properties override
  33286. */
  33287. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33288. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33289. /**
  33290. * Gets a string idenfifying the name of the class
  33291. * @returns "Node" string
  33292. */
  33293. getClassName(): string;
  33294. /** @hidden */
  33295. readonly _isNode: boolean;
  33296. /**
  33297. * An event triggered when the mesh is disposed
  33298. */
  33299. onDisposeObservable: Observable<Node>;
  33300. private _onDisposeObserver;
  33301. /**
  33302. * Sets a callback that will be raised when the node will be disposed
  33303. */
  33304. set onDispose(callback: () => void);
  33305. /**
  33306. * Creates a new Node
  33307. * @param name the name and id to be given to this node
  33308. * @param scene the scene this node will be added to
  33309. */
  33310. constructor(name: string, scene?: Nullable<Scene>);
  33311. /**
  33312. * Gets the scene of the node
  33313. * @returns a scene
  33314. */
  33315. getScene(): Scene;
  33316. /**
  33317. * Gets the engine of the node
  33318. * @returns a Engine
  33319. */
  33320. getEngine(): Engine;
  33321. private _behaviors;
  33322. /**
  33323. * Attach a behavior to the node
  33324. * @see http://doc.babylonjs.com/features/behaviour
  33325. * @param behavior defines the behavior to attach
  33326. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33327. * @returns the current Node
  33328. */
  33329. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33330. /**
  33331. * Remove an attached behavior
  33332. * @see http://doc.babylonjs.com/features/behaviour
  33333. * @param behavior defines the behavior to attach
  33334. * @returns the current Node
  33335. */
  33336. removeBehavior(behavior: Behavior<Node>): Node;
  33337. /**
  33338. * Gets the list of attached behaviors
  33339. * @see http://doc.babylonjs.com/features/behaviour
  33340. */
  33341. get behaviors(): Behavior<Node>[];
  33342. /**
  33343. * Gets an attached behavior by name
  33344. * @param name defines the name of the behavior to look for
  33345. * @see http://doc.babylonjs.com/features/behaviour
  33346. * @returns null if behavior was not found else the requested behavior
  33347. */
  33348. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33349. /**
  33350. * Returns the latest update of the World matrix
  33351. * @returns a Matrix
  33352. */
  33353. getWorldMatrix(): Matrix;
  33354. /** @hidden */
  33355. _getWorldMatrixDeterminant(): number;
  33356. /**
  33357. * Returns directly the latest state of the mesh World matrix.
  33358. * A Matrix is returned.
  33359. */
  33360. get worldMatrixFromCache(): Matrix;
  33361. /** @hidden */
  33362. _initCache(): void;
  33363. /** @hidden */
  33364. updateCache(force?: boolean): void;
  33365. /** @hidden */
  33366. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33367. /** @hidden */
  33368. _updateCache(ignoreParentClass?: boolean): void;
  33369. /** @hidden */
  33370. _isSynchronized(): boolean;
  33371. /** @hidden */
  33372. _markSyncedWithParent(): void;
  33373. /** @hidden */
  33374. isSynchronizedWithParent(): boolean;
  33375. /** @hidden */
  33376. isSynchronized(): boolean;
  33377. /**
  33378. * Is this node ready to be used/rendered
  33379. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33380. * @return true if the node is ready
  33381. */
  33382. isReady(completeCheck?: boolean): boolean;
  33383. /**
  33384. * Is this node enabled?
  33385. * 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
  33386. * @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
  33387. * @return whether this node (and its parent) is enabled
  33388. */
  33389. isEnabled(checkAncestors?: boolean): boolean;
  33390. /** @hidden */
  33391. protected _syncParentEnabledState(): void;
  33392. /**
  33393. * Set the enabled state of this node
  33394. * @param value defines the new enabled state
  33395. */
  33396. setEnabled(value: boolean): void;
  33397. /**
  33398. * Is this node a descendant of the given node?
  33399. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33400. * @param ancestor defines the parent node to inspect
  33401. * @returns a boolean indicating if this node is a descendant of the given node
  33402. */
  33403. isDescendantOf(ancestor: Node): boolean;
  33404. /** @hidden */
  33405. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33406. /**
  33407. * Will return all nodes that have this node as ascendant
  33408. * @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
  33409. * @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
  33410. * @return all children nodes of all types
  33411. */
  33412. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33413. /**
  33414. * Get all child-meshes of this node
  33415. * @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)
  33416. * @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
  33417. * @returns an array of AbstractMesh
  33418. */
  33419. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33420. /**
  33421. * Get all direct children of this node
  33422. * @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
  33423. * @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)
  33424. * @returns an array of Node
  33425. */
  33426. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33427. /** @hidden */
  33428. _setReady(state: boolean): void;
  33429. /**
  33430. * Get an animation by name
  33431. * @param name defines the name of the animation to look for
  33432. * @returns null if not found else the requested animation
  33433. */
  33434. getAnimationByName(name: string): Nullable<Animation>;
  33435. /**
  33436. * Creates an animation range for this node
  33437. * @param name defines the name of the range
  33438. * @param from defines the starting key
  33439. * @param to defines the end key
  33440. */
  33441. createAnimationRange(name: string, from: number, to: number): void;
  33442. /**
  33443. * Delete a specific animation range
  33444. * @param name defines the name of the range to delete
  33445. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33446. */
  33447. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33448. /**
  33449. * Get an animation range by name
  33450. * @param name defines the name of the animation range to look for
  33451. * @returns null if not found else the requested animation range
  33452. */
  33453. getAnimationRange(name: string): Nullable<AnimationRange>;
  33454. /**
  33455. * Gets the list of all animation ranges defined on this node
  33456. * @returns an array
  33457. */
  33458. getAnimationRanges(): Nullable<AnimationRange>[];
  33459. /**
  33460. * Will start the animation sequence
  33461. * @param name defines the range frames for animation sequence
  33462. * @param loop defines if the animation should loop (false by default)
  33463. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33464. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33465. * @returns the object created for this animation. If range does not exist, it will return null
  33466. */
  33467. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33468. /**
  33469. * Serialize animation ranges into a JSON compatible object
  33470. * @returns serialization object
  33471. */
  33472. serializeAnimationRanges(): any;
  33473. /**
  33474. * Computes the world matrix of the node
  33475. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33476. * @returns the world matrix
  33477. */
  33478. computeWorldMatrix(force?: boolean): Matrix;
  33479. /**
  33480. * Releases resources associated with this node.
  33481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33483. */
  33484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33485. /**
  33486. * Parse animation range data from a serialization object and store them into a given node
  33487. * @param node defines where to store the animation ranges
  33488. * @param parsedNode defines the serialization object to read data from
  33489. * @param scene defines the hosting scene
  33490. */
  33491. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33492. /**
  33493. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33494. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33495. * @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
  33496. * @returns the new bounding vectors
  33497. */
  33498. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33499. min: Vector3;
  33500. max: Vector3;
  33501. };
  33502. }
  33503. }
  33504. declare module "babylonjs/Animations/animation" {
  33505. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33506. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33507. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33508. import { Nullable } from "babylonjs/types";
  33509. import { Scene } from "babylonjs/scene";
  33510. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33511. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33512. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33513. import { Node } from "babylonjs/node";
  33514. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33515. import { Size } from "babylonjs/Maths/math.size";
  33516. import { Animatable } from "babylonjs/Animations/animatable";
  33517. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33518. /**
  33519. * @hidden
  33520. */
  33521. export class _IAnimationState {
  33522. key: number;
  33523. repeatCount: number;
  33524. workValue?: any;
  33525. loopMode?: number;
  33526. offsetValue?: any;
  33527. highLimitValue?: any;
  33528. }
  33529. /**
  33530. * Class used to store any kind of animation
  33531. */
  33532. export class Animation {
  33533. /**Name of the animation */
  33534. name: string;
  33535. /**Property to animate */
  33536. targetProperty: string;
  33537. /**The frames per second of the animation */
  33538. framePerSecond: number;
  33539. /**The data type of the animation */
  33540. dataType: number;
  33541. /**The loop mode of the animation */
  33542. loopMode?: number | undefined;
  33543. /**Specifies if blending should be enabled */
  33544. enableBlending?: boolean | undefined;
  33545. /**
  33546. * Use matrix interpolation instead of using direct key value when animating matrices
  33547. */
  33548. static AllowMatricesInterpolation: boolean;
  33549. /**
  33550. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33551. */
  33552. static AllowMatrixDecomposeForInterpolation: boolean;
  33553. /** Define the Url to load snippets */
  33554. static SnippetUrl: string;
  33555. /** Snippet ID if the animation was created from the snippet server */
  33556. snippetId: string;
  33557. /**
  33558. * Stores the key frames of the animation
  33559. */
  33560. private _keys;
  33561. /**
  33562. * Stores the easing function of the animation
  33563. */
  33564. private _easingFunction;
  33565. /**
  33566. * @hidden Internal use only
  33567. */
  33568. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33569. /**
  33570. * The set of event that will be linked to this animation
  33571. */
  33572. private _events;
  33573. /**
  33574. * Stores an array of target property paths
  33575. */
  33576. targetPropertyPath: string[];
  33577. /**
  33578. * Stores the blending speed of the animation
  33579. */
  33580. blendingSpeed: number;
  33581. /**
  33582. * Stores the animation ranges for the animation
  33583. */
  33584. private _ranges;
  33585. /**
  33586. * @hidden Internal use
  33587. */
  33588. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33589. /**
  33590. * Sets up an animation
  33591. * @param property The property to animate
  33592. * @param animationType The animation type to apply
  33593. * @param framePerSecond The frames per second of the animation
  33594. * @param easingFunction The easing function used in the animation
  33595. * @returns The created animation
  33596. */
  33597. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33598. /**
  33599. * Create and start an animation on a node
  33600. * @param name defines the name of the global animation that will be run on all nodes
  33601. * @param node defines the root node where the animation will take place
  33602. * @param targetProperty defines property to animate
  33603. * @param framePerSecond defines the number of frame per second yo use
  33604. * @param totalFrame defines the number of frames in total
  33605. * @param from defines the initial value
  33606. * @param to defines the final value
  33607. * @param loopMode defines which loop mode you want to use (off by default)
  33608. * @param easingFunction defines the easing function to use (linear by default)
  33609. * @param onAnimationEnd defines the callback to call when animation end
  33610. * @returns the animatable created for this animation
  33611. */
  33612. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33613. /**
  33614. * Create and start an animation on a node and its descendants
  33615. * @param name defines the name of the global animation that will be run on all nodes
  33616. * @param node defines the root node where the animation will take place
  33617. * @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
  33618. * @param targetProperty defines property to animate
  33619. * @param framePerSecond defines the number of frame per second to use
  33620. * @param totalFrame defines the number of frames in total
  33621. * @param from defines the initial value
  33622. * @param to defines the final value
  33623. * @param loopMode defines which loop mode you want to use (off by default)
  33624. * @param easingFunction defines the easing function to use (linear by default)
  33625. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33626. * @returns the list of animatables created for all nodes
  33627. * @example https://www.babylonjs-playground.com/#MH0VLI
  33628. */
  33629. 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[]>;
  33630. /**
  33631. * Creates a new animation, merges it with the existing animations and starts it
  33632. * @param name Name of the animation
  33633. * @param node Node which contains the scene that begins the animations
  33634. * @param targetProperty Specifies which property to animate
  33635. * @param framePerSecond The frames per second of the animation
  33636. * @param totalFrame The total number of frames
  33637. * @param from The frame at the beginning of the animation
  33638. * @param to The frame at the end of the animation
  33639. * @param loopMode Specifies the loop mode of the animation
  33640. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33641. * @param onAnimationEnd Callback to run once the animation is complete
  33642. * @returns Nullable animation
  33643. */
  33644. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33645. /**
  33646. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33647. * @param sourceAnimation defines the Animation containing keyframes to convert
  33648. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33649. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33650. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33651. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33652. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33653. */
  33654. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33655. /**
  33656. * Transition property of an host to the target Value
  33657. * @param property The property to transition
  33658. * @param targetValue The target Value of the property
  33659. * @param host The object where the property to animate belongs
  33660. * @param scene Scene used to run the animation
  33661. * @param frameRate Framerate (in frame/s) to use
  33662. * @param transition The transition type we want to use
  33663. * @param duration The duration of the animation, in milliseconds
  33664. * @param onAnimationEnd Callback trigger at the end of the animation
  33665. * @returns Nullable animation
  33666. */
  33667. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33668. /**
  33669. * Return the array of runtime animations currently using this animation
  33670. */
  33671. get runtimeAnimations(): RuntimeAnimation[];
  33672. /**
  33673. * Specifies if any of the runtime animations are currently running
  33674. */
  33675. get hasRunningRuntimeAnimations(): boolean;
  33676. /**
  33677. * Initializes the animation
  33678. * @param name Name of the animation
  33679. * @param targetProperty Property to animate
  33680. * @param framePerSecond The frames per second of the animation
  33681. * @param dataType The data type of the animation
  33682. * @param loopMode The loop mode of the animation
  33683. * @param enableBlending Specifies if blending should be enabled
  33684. */
  33685. constructor(
  33686. /**Name of the animation */
  33687. name: string,
  33688. /**Property to animate */
  33689. targetProperty: string,
  33690. /**The frames per second of the animation */
  33691. framePerSecond: number,
  33692. /**The data type of the animation */
  33693. dataType: number,
  33694. /**The loop mode of the animation */
  33695. loopMode?: number | undefined,
  33696. /**Specifies if blending should be enabled */
  33697. enableBlending?: boolean | undefined);
  33698. /**
  33699. * Converts the animation to a string
  33700. * @param fullDetails support for multiple levels of logging within scene loading
  33701. * @returns String form of the animation
  33702. */
  33703. toString(fullDetails?: boolean): string;
  33704. /**
  33705. * Add an event to this animation
  33706. * @param event Event to add
  33707. */
  33708. addEvent(event: AnimationEvent): void;
  33709. /**
  33710. * Remove all events found at the given frame
  33711. * @param frame The frame to remove events from
  33712. */
  33713. removeEvents(frame: number): void;
  33714. /**
  33715. * Retrieves all the events from the animation
  33716. * @returns Events from the animation
  33717. */
  33718. getEvents(): AnimationEvent[];
  33719. /**
  33720. * Creates an animation range
  33721. * @param name Name of the animation range
  33722. * @param from Starting frame of the animation range
  33723. * @param to Ending frame of the animation
  33724. */
  33725. createRange(name: string, from: number, to: number): void;
  33726. /**
  33727. * Deletes an animation range by name
  33728. * @param name Name of the animation range to delete
  33729. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33730. */
  33731. deleteRange(name: string, deleteFrames?: boolean): void;
  33732. /**
  33733. * Gets the animation range by name, or null if not defined
  33734. * @param name Name of the animation range
  33735. * @returns Nullable animation range
  33736. */
  33737. getRange(name: string): Nullable<AnimationRange>;
  33738. /**
  33739. * Gets the key frames from the animation
  33740. * @returns The key frames of the animation
  33741. */
  33742. getKeys(): Array<IAnimationKey>;
  33743. /**
  33744. * Gets the highest frame rate of the animation
  33745. * @returns Highest frame rate of the animation
  33746. */
  33747. getHighestFrame(): number;
  33748. /**
  33749. * Gets the easing function of the animation
  33750. * @returns Easing function of the animation
  33751. */
  33752. getEasingFunction(): IEasingFunction;
  33753. /**
  33754. * Sets the easing function of the animation
  33755. * @param easingFunction A custom mathematical formula for animation
  33756. */
  33757. setEasingFunction(easingFunction: EasingFunction): void;
  33758. /**
  33759. * Interpolates a scalar linearly
  33760. * @param startValue Start value of the animation curve
  33761. * @param endValue End value of the animation curve
  33762. * @param gradient Scalar amount to interpolate
  33763. * @returns Interpolated scalar value
  33764. */
  33765. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33766. /**
  33767. * Interpolates a scalar cubically
  33768. * @param startValue Start value of the animation curve
  33769. * @param outTangent End tangent of the animation
  33770. * @param endValue End value of the animation curve
  33771. * @param inTangent Start tangent of the animation curve
  33772. * @param gradient Scalar amount to interpolate
  33773. * @returns Interpolated scalar value
  33774. */
  33775. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33776. /**
  33777. * Interpolates a quaternion using a spherical linear interpolation
  33778. * @param startValue Start value of the animation curve
  33779. * @param endValue End value of the animation curve
  33780. * @param gradient Scalar amount to interpolate
  33781. * @returns Interpolated quaternion value
  33782. */
  33783. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33784. /**
  33785. * Interpolates a quaternion cubically
  33786. * @param startValue Start value of the animation curve
  33787. * @param outTangent End tangent of the animation curve
  33788. * @param endValue End value of the animation curve
  33789. * @param inTangent Start tangent of the animation curve
  33790. * @param gradient Scalar amount to interpolate
  33791. * @returns Interpolated quaternion value
  33792. */
  33793. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33794. /**
  33795. * Interpolates a Vector3 linearl
  33796. * @param startValue Start value of the animation curve
  33797. * @param endValue End value of the animation curve
  33798. * @param gradient Scalar amount to interpolate
  33799. * @returns Interpolated scalar value
  33800. */
  33801. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33802. /**
  33803. * Interpolates a Vector3 cubically
  33804. * @param startValue Start value of the animation curve
  33805. * @param outTangent End tangent of the animation
  33806. * @param endValue End value of the animation curve
  33807. * @param inTangent Start tangent of the animation curve
  33808. * @param gradient Scalar amount to interpolate
  33809. * @returns InterpolatedVector3 value
  33810. */
  33811. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33812. /**
  33813. * Interpolates a Vector2 linearly
  33814. * @param startValue Start value of the animation curve
  33815. * @param endValue End value of the animation curve
  33816. * @param gradient Scalar amount to interpolate
  33817. * @returns Interpolated Vector2 value
  33818. */
  33819. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33820. /**
  33821. * Interpolates a Vector2 cubically
  33822. * @param startValue Start value of the animation curve
  33823. * @param outTangent End tangent of the animation
  33824. * @param endValue End value of the animation curve
  33825. * @param inTangent Start tangent of the animation curve
  33826. * @param gradient Scalar amount to interpolate
  33827. * @returns Interpolated Vector2 value
  33828. */
  33829. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33830. /**
  33831. * Interpolates a size linearly
  33832. * @param startValue Start value of the animation curve
  33833. * @param endValue End value of the animation curve
  33834. * @param gradient Scalar amount to interpolate
  33835. * @returns Interpolated Size value
  33836. */
  33837. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33838. /**
  33839. * Interpolates a Color3 linearly
  33840. * @param startValue Start value of the animation curve
  33841. * @param endValue End value of the animation curve
  33842. * @param gradient Scalar amount to interpolate
  33843. * @returns Interpolated Color3 value
  33844. */
  33845. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33846. /**
  33847. * Interpolates a Color4 linearly
  33848. * @param startValue Start value of the animation curve
  33849. * @param endValue End value of the animation curve
  33850. * @param gradient Scalar amount to interpolate
  33851. * @returns Interpolated Color3 value
  33852. */
  33853. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33854. /**
  33855. * @hidden Internal use only
  33856. */
  33857. _getKeyValue(value: any): any;
  33858. /**
  33859. * @hidden Internal use only
  33860. */
  33861. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33862. /**
  33863. * Defines the function to use to interpolate matrices
  33864. * @param startValue defines the start matrix
  33865. * @param endValue defines the end matrix
  33866. * @param gradient defines the gradient between both matrices
  33867. * @param result defines an optional target matrix where to store the interpolation
  33868. * @returns the interpolated matrix
  33869. */
  33870. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33871. /**
  33872. * Makes a copy of the animation
  33873. * @returns Cloned animation
  33874. */
  33875. clone(): Animation;
  33876. /**
  33877. * Sets the key frames of the animation
  33878. * @param values The animation key frames to set
  33879. */
  33880. setKeys(values: Array<IAnimationKey>): void;
  33881. /**
  33882. * Serializes the animation to an object
  33883. * @returns Serialized object
  33884. */
  33885. serialize(): any;
  33886. /**
  33887. * Float animation type
  33888. */
  33889. static readonly ANIMATIONTYPE_FLOAT: number;
  33890. /**
  33891. * Vector3 animation type
  33892. */
  33893. static readonly ANIMATIONTYPE_VECTOR3: number;
  33894. /**
  33895. * Quaternion animation type
  33896. */
  33897. static readonly ANIMATIONTYPE_QUATERNION: number;
  33898. /**
  33899. * Matrix animation type
  33900. */
  33901. static readonly ANIMATIONTYPE_MATRIX: number;
  33902. /**
  33903. * Color3 animation type
  33904. */
  33905. static readonly ANIMATIONTYPE_COLOR3: number;
  33906. /**
  33907. * Color3 animation type
  33908. */
  33909. static readonly ANIMATIONTYPE_COLOR4: number;
  33910. /**
  33911. * Vector2 animation type
  33912. */
  33913. static readonly ANIMATIONTYPE_VECTOR2: number;
  33914. /**
  33915. * Size animation type
  33916. */
  33917. static readonly ANIMATIONTYPE_SIZE: number;
  33918. /**
  33919. * Relative Loop Mode
  33920. */
  33921. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33922. /**
  33923. * Cycle Loop Mode
  33924. */
  33925. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33926. /**
  33927. * Constant Loop Mode
  33928. */
  33929. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33930. /** @hidden */
  33931. static _UniversalLerp(left: any, right: any, amount: number): any;
  33932. /**
  33933. * Parses an animation object and creates an animation
  33934. * @param parsedAnimation Parsed animation object
  33935. * @returns Animation object
  33936. */
  33937. static Parse(parsedAnimation: any): Animation;
  33938. /**
  33939. * Appends the serialized animations from the source animations
  33940. * @param source Source containing the animations
  33941. * @param destination Target to store the animations
  33942. */
  33943. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33944. /**
  33945. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33946. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33947. * @param url defines the url to load from
  33948. * @returns a promise that will resolve to the new animation or an array of animations
  33949. */
  33950. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33951. /**
  33952. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33953. * @param snippetId defines the snippet to load
  33954. * @returns a promise that will resolve to the new animation or a new array of animations
  33955. */
  33956. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33957. }
  33958. }
  33959. declare module "babylonjs/Animations/animatable.interface" {
  33960. import { Nullable } from "babylonjs/types";
  33961. import { Animation } from "babylonjs/Animations/animation";
  33962. /**
  33963. * Interface containing an array of animations
  33964. */
  33965. export interface IAnimatable {
  33966. /**
  33967. * Array of animations
  33968. */
  33969. animations: Nullable<Array<Animation>>;
  33970. }
  33971. }
  33972. declare module "babylonjs/Misc/decorators" {
  33973. import { Nullable } from "babylonjs/types";
  33974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33975. import { Scene } from "babylonjs/scene";
  33976. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33977. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33978. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33979. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33980. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33981. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33982. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33983. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33984. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33985. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33986. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33987. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33988. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33989. /**
  33990. * Decorator used to define property that can be serialized as reference to a camera
  33991. * @param sourceName defines the name of the property to decorate
  33992. */
  33993. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33994. /**
  33995. * Class used to help serialization objects
  33996. */
  33997. export class SerializationHelper {
  33998. /** @hidden */
  33999. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  34000. /** @hidden */
  34001. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  34002. /** @hidden */
  34003. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  34004. /** @hidden */
  34005. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  34006. /**
  34007. * Appends the serialized animations from the source animations
  34008. * @param source Source containing the animations
  34009. * @param destination Target to store the animations
  34010. */
  34011. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34012. /**
  34013. * Static function used to serialized a specific entity
  34014. * @param entity defines the entity to serialize
  34015. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34016. * @returns a JSON compatible object representing the serialization of the entity
  34017. */
  34018. static Serialize<T>(entity: T, serializationObject?: any): any;
  34019. /**
  34020. * Creates a new entity from a serialization data object
  34021. * @param creationFunction defines a function used to instanciated the new entity
  34022. * @param source defines the source serialization data
  34023. * @param scene defines the hosting scene
  34024. * @param rootUrl defines the root url for resources
  34025. * @returns a new entity
  34026. */
  34027. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34028. /**
  34029. * Clones an object
  34030. * @param creationFunction defines the function used to instanciate the new object
  34031. * @param source defines the source object
  34032. * @returns the cloned object
  34033. */
  34034. static Clone<T>(creationFunction: () => T, source: T): T;
  34035. /**
  34036. * Instanciates a new object based on a source one (some data will be shared between both object)
  34037. * @param creationFunction defines the function used to instanciate the new object
  34038. * @param source defines the source object
  34039. * @returns the new object
  34040. */
  34041. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34042. }
  34043. }
  34044. declare module "babylonjs/Materials/Textures/baseTexture" {
  34045. import { Observable } from "babylonjs/Misc/observable";
  34046. import { Nullable } from "babylonjs/types";
  34047. import { Scene } from "babylonjs/scene";
  34048. import { Matrix } from "babylonjs/Maths/math.vector";
  34049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34050. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34051. import { ISize } from "babylonjs/Maths/math.size";
  34052. import "babylonjs/Misc/fileTools";
  34053. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34054. /**
  34055. * Base class of all the textures in babylon.
  34056. * It groups all the common properties the materials, post process, lights... might need
  34057. * in order to make a correct use of the texture.
  34058. */
  34059. export class BaseTexture implements IAnimatable {
  34060. /**
  34061. * Default anisotropic filtering level for the application.
  34062. * It is set to 4 as a good tradeoff between perf and quality.
  34063. */
  34064. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34065. /**
  34066. * Gets or sets the unique id of the texture
  34067. */
  34068. uniqueId: number;
  34069. /**
  34070. * Define the name of the texture.
  34071. */
  34072. name: string;
  34073. /**
  34074. * Gets or sets an object used to store user defined information.
  34075. */
  34076. metadata: any;
  34077. /**
  34078. * For internal use only. Please do not use.
  34079. */
  34080. reservedDataStore: any;
  34081. private _hasAlpha;
  34082. /**
  34083. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34084. */
  34085. set hasAlpha(value: boolean);
  34086. get hasAlpha(): boolean;
  34087. /**
  34088. * Defines if the alpha value should be determined via the rgb values.
  34089. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34090. */
  34091. getAlphaFromRGB: boolean;
  34092. /**
  34093. * Intensity or strength of the texture.
  34094. * It is commonly used by materials to fine tune the intensity of the texture
  34095. */
  34096. level: number;
  34097. /**
  34098. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34099. * This is part of the texture as textures usually maps to one uv set.
  34100. */
  34101. coordinatesIndex: number;
  34102. private _coordinatesMode;
  34103. /**
  34104. * How a texture is mapped.
  34105. *
  34106. * | Value | Type | Description |
  34107. * | ----- | ----------------------------------- | ----------- |
  34108. * | 0 | EXPLICIT_MODE | |
  34109. * | 1 | SPHERICAL_MODE | |
  34110. * | 2 | PLANAR_MODE | |
  34111. * | 3 | CUBIC_MODE | |
  34112. * | 4 | PROJECTION_MODE | |
  34113. * | 5 | SKYBOX_MODE | |
  34114. * | 6 | INVCUBIC_MODE | |
  34115. * | 7 | EQUIRECTANGULAR_MODE | |
  34116. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34117. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34118. */
  34119. set coordinatesMode(value: number);
  34120. get coordinatesMode(): number;
  34121. /**
  34122. * | Value | Type | Description |
  34123. * | ----- | ------------------ | ----------- |
  34124. * | 0 | CLAMP_ADDRESSMODE | |
  34125. * | 1 | WRAP_ADDRESSMODE | |
  34126. * | 2 | MIRROR_ADDRESSMODE | |
  34127. */
  34128. wrapU: number;
  34129. /**
  34130. * | Value | Type | Description |
  34131. * | ----- | ------------------ | ----------- |
  34132. * | 0 | CLAMP_ADDRESSMODE | |
  34133. * | 1 | WRAP_ADDRESSMODE | |
  34134. * | 2 | MIRROR_ADDRESSMODE | |
  34135. */
  34136. wrapV: number;
  34137. /**
  34138. * | Value | Type | Description |
  34139. * | ----- | ------------------ | ----------- |
  34140. * | 0 | CLAMP_ADDRESSMODE | |
  34141. * | 1 | WRAP_ADDRESSMODE | |
  34142. * | 2 | MIRROR_ADDRESSMODE | |
  34143. */
  34144. wrapR: number;
  34145. /**
  34146. * With compliant hardware and browser (supporting anisotropic filtering)
  34147. * this defines the level of anisotropic filtering in the texture.
  34148. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34149. */
  34150. anisotropicFilteringLevel: number;
  34151. /**
  34152. * Define if the texture is a cube texture or if false a 2d texture.
  34153. */
  34154. get isCube(): boolean;
  34155. set isCube(value: boolean);
  34156. /**
  34157. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34158. */
  34159. get is3D(): boolean;
  34160. set is3D(value: boolean);
  34161. /**
  34162. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34163. */
  34164. get is2DArray(): boolean;
  34165. set is2DArray(value: boolean);
  34166. /**
  34167. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34168. * HDR texture are usually stored in linear space.
  34169. * This only impacts the PBR and Background materials
  34170. */
  34171. gammaSpace: boolean;
  34172. /**
  34173. * Gets or sets whether or not the texture contains RGBD data.
  34174. */
  34175. get isRGBD(): boolean;
  34176. set isRGBD(value: boolean);
  34177. /**
  34178. * Is Z inverted in the texture (useful in a cube texture).
  34179. */
  34180. invertZ: boolean;
  34181. /**
  34182. * Are mip maps generated for this texture or not.
  34183. */
  34184. get noMipmap(): boolean;
  34185. /**
  34186. * @hidden
  34187. */
  34188. lodLevelInAlpha: boolean;
  34189. /**
  34190. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34191. */
  34192. get lodGenerationOffset(): number;
  34193. set lodGenerationOffset(value: number);
  34194. /**
  34195. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34196. */
  34197. get lodGenerationScale(): number;
  34198. set lodGenerationScale(value: number);
  34199. /**
  34200. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34201. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34202. * average roughness values.
  34203. */
  34204. get linearSpecularLOD(): boolean;
  34205. set linearSpecularLOD(value: boolean);
  34206. /**
  34207. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34208. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34209. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34210. */
  34211. get irradianceTexture(): Nullable<BaseTexture>;
  34212. set irradianceTexture(value: Nullable<BaseTexture>);
  34213. /**
  34214. * Define if the texture is a render target.
  34215. */
  34216. isRenderTarget: boolean;
  34217. /**
  34218. * Define the unique id of the texture in the scene.
  34219. */
  34220. get uid(): string;
  34221. /** @hidden */
  34222. _prefiltered: boolean;
  34223. /**
  34224. * Return a string representation of the texture.
  34225. * @returns the texture as a string
  34226. */
  34227. toString(): string;
  34228. /**
  34229. * Get the class name of the texture.
  34230. * @returns "BaseTexture"
  34231. */
  34232. getClassName(): string;
  34233. /**
  34234. * Define the list of animation attached to the texture.
  34235. */
  34236. animations: import("babylonjs/Animations/animation").Animation[];
  34237. /**
  34238. * An event triggered when the texture is disposed.
  34239. */
  34240. onDisposeObservable: Observable<BaseTexture>;
  34241. private _onDisposeObserver;
  34242. /**
  34243. * Callback triggered when the texture has been disposed.
  34244. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34245. */
  34246. set onDispose(callback: () => void);
  34247. /**
  34248. * Define the current state of the loading sequence when in delayed load mode.
  34249. */
  34250. delayLoadState: number;
  34251. private _scene;
  34252. private _engine;
  34253. /** @hidden */
  34254. _texture: Nullable<InternalTexture>;
  34255. private _uid;
  34256. /**
  34257. * Define if the texture is preventinga material to render or not.
  34258. * If not and the texture is not ready, the engine will use a default black texture instead.
  34259. */
  34260. get isBlocking(): boolean;
  34261. /**
  34262. * Instantiates a new BaseTexture.
  34263. * Base class of all the textures in babylon.
  34264. * It groups all the common properties the materials, post process, lights... might need
  34265. * in order to make a correct use of the texture.
  34266. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34267. */
  34268. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34269. /**
  34270. * Get the scene the texture belongs to.
  34271. * @returns the scene or null if undefined
  34272. */
  34273. getScene(): Nullable<Scene>;
  34274. /** @hidden */
  34275. protected _getEngine(): Nullable<ThinEngine>;
  34276. /**
  34277. * Get the texture transform matrix used to offset tile the texture for istance.
  34278. * @returns the transformation matrix
  34279. */
  34280. getTextureMatrix(): Matrix;
  34281. /**
  34282. * Get the texture reflection matrix used to rotate/transform the reflection.
  34283. * @returns the reflection matrix
  34284. */
  34285. getReflectionTextureMatrix(): Matrix;
  34286. /**
  34287. * Get the underlying lower level texture from Babylon.
  34288. * @returns the insternal texture
  34289. */
  34290. getInternalTexture(): Nullable<InternalTexture>;
  34291. /**
  34292. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34293. * @returns true if ready or not blocking
  34294. */
  34295. isReadyOrNotBlocking(): boolean;
  34296. /**
  34297. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34298. * @returns true if fully ready
  34299. */
  34300. isReady(): boolean;
  34301. private _cachedSize;
  34302. /**
  34303. * Get the size of the texture.
  34304. * @returns the texture size.
  34305. */
  34306. getSize(): ISize;
  34307. /**
  34308. * Get the base size of the texture.
  34309. * It can be different from the size if the texture has been resized for POT for instance
  34310. * @returns the base size
  34311. */
  34312. getBaseSize(): ISize;
  34313. /**
  34314. * Update the sampling mode of the texture.
  34315. * Default is Trilinear mode.
  34316. *
  34317. * | Value | Type | Description |
  34318. * | ----- | ------------------ | ----------- |
  34319. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34320. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34321. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34322. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34323. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34324. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34325. * | 7 | NEAREST_LINEAR | |
  34326. * | 8 | NEAREST_NEAREST | |
  34327. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34328. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34329. * | 11 | LINEAR_LINEAR | |
  34330. * | 12 | LINEAR_NEAREST | |
  34331. *
  34332. * > _mag_: magnification filter (close to the viewer)
  34333. * > _min_: minification filter (far from the viewer)
  34334. * > _mip_: filter used between mip map levels
  34335. *@param samplingMode Define the new sampling mode of the texture
  34336. */
  34337. updateSamplingMode(samplingMode: number): void;
  34338. /**
  34339. * Scales the texture if is `canRescale()`
  34340. * @param ratio the resize factor we want to use to rescale
  34341. */
  34342. scale(ratio: number): void;
  34343. /**
  34344. * Get if the texture can rescale.
  34345. */
  34346. get canRescale(): boolean;
  34347. /** @hidden */
  34348. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34349. /** @hidden */
  34350. _rebuild(): void;
  34351. /**
  34352. * Triggers the load sequence in delayed load mode.
  34353. */
  34354. delayLoad(): void;
  34355. /**
  34356. * Clones the texture.
  34357. * @returns the cloned texture
  34358. */
  34359. clone(): Nullable<BaseTexture>;
  34360. /**
  34361. * Get the texture underlying type (INT, FLOAT...)
  34362. */
  34363. get textureType(): number;
  34364. /**
  34365. * Get the texture underlying format (RGB, RGBA...)
  34366. */
  34367. get textureFormat(): number;
  34368. /**
  34369. * Indicates that textures need to be re-calculated for all materials
  34370. */
  34371. protected _markAllSubMeshesAsTexturesDirty(): void;
  34372. /**
  34373. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34374. * This will returns an RGBA array buffer containing either in values (0-255) or
  34375. * float values (0-1) depending of the underlying buffer type.
  34376. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34377. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34378. * @param buffer defines a user defined buffer to fill with data (can be null)
  34379. * @returns The Array buffer containing the pixels data.
  34380. */
  34381. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34382. /**
  34383. * Release and destroy the underlying lower level texture aka internalTexture.
  34384. */
  34385. releaseInternalTexture(): void;
  34386. /** @hidden */
  34387. get _lodTextureHigh(): Nullable<BaseTexture>;
  34388. /** @hidden */
  34389. get _lodTextureMid(): Nullable<BaseTexture>;
  34390. /** @hidden */
  34391. get _lodTextureLow(): Nullable<BaseTexture>;
  34392. /**
  34393. * Dispose the texture and release its associated resources.
  34394. */
  34395. dispose(): void;
  34396. /**
  34397. * Serialize the texture into a JSON representation that can be parsed later on.
  34398. * @returns the JSON representation of the texture
  34399. */
  34400. serialize(): any;
  34401. /**
  34402. * Helper function to be called back once a list of texture contains only ready textures.
  34403. * @param textures Define the list of textures to wait for
  34404. * @param callback Define the callback triggered once the entire list will be ready
  34405. */
  34406. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34407. private static _isScene;
  34408. }
  34409. }
  34410. declare module "babylonjs/Materials/effect" {
  34411. import { Observable } from "babylonjs/Misc/observable";
  34412. import { Nullable } from "babylonjs/types";
  34413. import { IDisposable } from "babylonjs/scene";
  34414. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34415. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34416. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34417. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34418. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34419. import { Engine } from "babylonjs/Engines/engine";
  34420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34422. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34424. /**
  34425. * Options to be used when creating an effect.
  34426. */
  34427. export interface IEffectCreationOptions {
  34428. /**
  34429. * Atrributes that will be used in the shader.
  34430. */
  34431. attributes: string[];
  34432. /**
  34433. * Uniform varible names that will be set in the shader.
  34434. */
  34435. uniformsNames: string[];
  34436. /**
  34437. * Uniform buffer variable names that will be set in the shader.
  34438. */
  34439. uniformBuffersNames: string[];
  34440. /**
  34441. * Sampler texture variable names that will be set in the shader.
  34442. */
  34443. samplers: string[];
  34444. /**
  34445. * Define statements that will be set in the shader.
  34446. */
  34447. defines: any;
  34448. /**
  34449. * Possible fallbacks for this effect to improve performance when needed.
  34450. */
  34451. fallbacks: Nullable<IEffectFallbacks>;
  34452. /**
  34453. * Callback that will be called when the shader is compiled.
  34454. */
  34455. onCompiled: Nullable<(effect: Effect) => void>;
  34456. /**
  34457. * Callback that will be called if an error occurs during shader compilation.
  34458. */
  34459. onError: Nullable<(effect: Effect, errors: string) => void>;
  34460. /**
  34461. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34462. */
  34463. indexParameters?: any;
  34464. /**
  34465. * Max number of lights that can be used in the shader.
  34466. */
  34467. maxSimultaneousLights?: number;
  34468. /**
  34469. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34470. */
  34471. transformFeedbackVaryings?: Nullable<string[]>;
  34472. /**
  34473. * 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
  34474. */
  34475. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34476. }
  34477. /**
  34478. * Effect containing vertex and fragment shader that can be executed on an object.
  34479. */
  34480. export class Effect implements IDisposable {
  34481. /**
  34482. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34483. */
  34484. static ShadersRepository: string;
  34485. /**
  34486. * Enable logging of the shader code when a compilation error occurs
  34487. */
  34488. static LogShaderCodeOnCompilationError: boolean;
  34489. /**
  34490. * Name of the effect.
  34491. */
  34492. name: any;
  34493. /**
  34494. * String container all the define statements that should be set on the shader.
  34495. */
  34496. defines: string;
  34497. /**
  34498. * Callback that will be called when the shader is compiled.
  34499. */
  34500. onCompiled: Nullable<(effect: Effect) => void>;
  34501. /**
  34502. * Callback that will be called if an error occurs during shader compilation.
  34503. */
  34504. onError: Nullable<(effect: Effect, errors: string) => void>;
  34505. /**
  34506. * Callback that will be called when effect is bound.
  34507. */
  34508. onBind: Nullable<(effect: Effect) => void>;
  34509. /**
  34510. * Unique ID of the effect.
  34511. */
  34512. uniqueId: number;
  34513. /**
  34514. * Observable that will be called when the shader is compiled.
  34515. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34516. */
  34517. onCompileObservable: Observable<Effect>;
  34518. /**
  34519. * Observable that will be called if an error occurs during shader compilation.
  34520. */
  34521. onErrorObservable: Observable<Effect>;
  34522. /** @hidden */
  34523. _onBindObservable: Nullable<Observable<Effect>>;
  34524. /**
  34525. * @hidden
  34526. * Specifies if the effect was previously ready
  34527. */
  34528. _wasPreviouslyReady: boolean;
  34529. /**
  34530. * Observable that will be called when effect is bound.
  34531. */
  34532. get onBindObservable(): Observable<Effect>;
  34533. /** @hidden */
  34534. _bonesComputationForcedToCPU: boolean;
  34535. private static _uniqueIdSeed;
  34536. private _engine;
  34537. private _uniformBuffersNames;
  34538. private _uniformBuffersNamesList;
  34539. private _uniformsNames;
  34540. private _samplerList;
  34541. private _samplers;
  34542. private _isReady;
  34543. private _compilationError;
  34544. private _allFallbacksProcessed;
  34545. private _attributesNames;
  34546. private _attributes;
  34547. private _attributeLocationByName;
  34548. private _uniforms;
  34549. /**
  34550. * Key for the effect.
  34551. * @hidden
  34552. */
  34553. _key: string;
  34554. private _indexParameters;
  34555. private _fallbacks;
  34556. private _vertexSourceCode;
  34557. private _fragmentSourceCode;
  34558. private _vertexSourceCodeOverride;
  34559. private _fragmentSourceCodeOverride;
  34560. private _transformFeedbackVaryings;
  34561. /**
  34562. * Compiled shader to webGL program.
  34563. * @hidden
  34564. */
  34565. _pipelineContext: Nullable<IPipelineContext>;
  34566. private _valueCache;
  34567. private static _baseCache;
  34568. /**
  34569. * Instantiates an effect.
  34570. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34571. * @param baseName Name of the effect.
  34572. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34573. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34574. * @param samplers List of sampler variables that will be passed to the shader.
  34575. * @param engine Engine to be used to render the effect
  34576. * @param defines Define statements to be added to the shader.
  34577. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34578. * @param onCompiled Callback that will be called when the shader is compiled.
  34579. * @param onError Callback that will be called if an error occurs during shader compilation.
  34580. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34581. */
  34582. 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);
  34583. private _useFinalCode;
  34584. /**
  34585. * Unique key for this effect
  34586. */
  34587. get key(): string;
  34588. /**
  34589. * If the effect has been compiled and prepared.
  34590. * @returns if the effect is compiled and prepared.
  34591. */
  34592. isReady(): boolean;
  34593. private _isReadyInternal;
  34594. /**
  34595. * The engine the effect was initialized with.
  34596. * @returns the engine.
  34597. */
  34598. getEngine(): Engine;
  34599. /**
  34600. * The pipeline context for this effect
  34601. * @returns the associated pipeline context
  34602. */
  34603. getPipelineContext(): Nullable<IPipelineContext>;
  34604. /**
  34605. * The set of names of attribute variables for the shader.
  34606. * @returns An array of attribute names.
  34607. */
  34608. getAttributesNames(): string[];
  34609. /**
  34610. * Returns the attribute at the given index.
  34611. * @param index The index of the attribute.
  34612. * @returns The location of the attribute.
  34613. */
  34614. getAttributeLocation(index: number): number;
  34615. /**
  34616. * Returns the attribute based on the name of the variable.
  34617. * @param name of the attribute to look up.
  34618. * @returns the attribute location.
  34619. */
  34620. getAttributeLocationByName(name: string): number;
  34621. /**
  34622. * The number of attributes.
  34623. * @returns the numnber of attributes.
  34624. */
  34625. getAttributesCount(): number;
  34626. /**
  34627. * Gets the index of a uniform variable.
  34628. * @param uniformName of the uniform to look up.
  34629. * @returns the index.
  34630. */
  34631. getUniformIndex(uniformName: string): number;
  34632. /**
  34633. * Returns the attribute based on the name of the variable.
  34634. * @param uniformName of the uniform to look up.
  34635. * @returns the location of the uniform.
  34636. */
  34637. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34638. /**
  34639. * Returns an array of sampler variable names
  34640. * @returns The array of sampler variable names.
  34641. */
  34642. getSamplers(): string[];
  34643. /**
  34644. * Returns an array of uniform variable names
  34645. * @returns The array of uniform variable names.
  34646. */
  34647. getUniformNames(): string[];
  34648. /**
  34649. * Returns an array of uniform buffer variable names
  34650. * @returns The array of uniform buffer variable names.
  34651. */
  34652. getUniformBuffersNames(): string[];
  34653. /**
  34654. * Returns the index parameters used to create the effect
  34655. * @returns The index parameters object
  34656. */
  34657. getIndexParameters(): any;
  34658. /**
  34659. * The error from the last compilation.
  34660. * @returns the error string.
  34661. */
  34662. getCompilationError(): string;
  34663. /**
  34664. * Gets a boolean indicating that all fallbacks were used during compilation
  34665. * @returns true if all fallbacks were used
  34666. */
  34667. allFallbacksProcessed(): boolean;
  34668. /**
  34669. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34670. * @param func The callback to be used.
  34671. */
  34672. executeWhenCompiled(func: (effect: Effect) => void): void;
  34673. private _checkIsReady;
  34674. private _loadShader;
  34675. /**
  34676. * Gets the vertex shader source code of this effect
  34677. */
  34678. get vertexSourceCode(): string;
  34679. /**
  34680. * Gets the fragment shader source code of this effect
  34681. */
  34682. get fragmentSourceCode(): string;
  34683. /**
  34684. * Recompiles the webGL program
  34685. * @param vertexSourceCode The source code for the vertex shader.
  34686. * @param fragmentSourceCode The source code for the fragment shader.
  34687. * @param onCompiled Callback called when completed.
  34688. * @param onError Callback called on error.
  34689. * @hidden
  34690. */
  34691. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34692. /**
  34693. * Prepares the effect
  34694. * @hidden
  34695. */
  34696. _prepareEffect(): void;
  34697. private _getShaderCodeAndErrorLine;
  34698. private _processCompilationErrors;
  34699. /**
  34700. * Checks if the effect is supported. (Must be called after compilation)
  34701. */
  34702. get isSupported(): boolean;
  34703. /**
  34704. * Binds a texture to the engine to be used as output of the shader.
  34705. * @param channel Name of the output variable.
  34706. * @param texture Texture to bind.
  34707. * @hidden
  34708. */
  34709. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34710. /**
  34711. * Sets a texture on the engine to be used in the shader.
  34712. * @param channel Name of the sampler variable.
  34713. * @param texture Texture to set.
  34714. */
  34715. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34716. /**
  34717. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34718. * @param channel Name of the sampler variable.
  34719. * @param texture Texture to set.
  34720. */
  34721. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34722. /**
  34723. * Sets an array of textures on the engine to be used in the shader.
  34724. * @param channel Name of the variable.
  34725. * @param textures Textures to set.
  34726. */
  34727. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34728. /**
  34729. * 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)
  34730. * @param channel Name of the sampler variable.
  34731. * @param postProcess Post process to get the input texture from.
  34732. */
  34733. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34734. /**
  34735. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34736. * 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)
  34737. * @param channel Name of the sampler variable.
  34738. * @param postProcess Post process to get the output texture from.
  34739. */
  34740. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34741. /** @hidden */
  34742. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34743. /** @hidden */
  34744. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34745. /** @hidden */
  34746. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34747. /** @hidden */
  34748. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34749. /**
  34750. * Binds a buffer to a uniform.
  34751. * @param buffer Buffer to bind.
  34752. * @param name Name of the uniform variable to bind to.
  34753. */
  34754. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34755. /**
  34756. * Binds block to a uniform.
  34757. * @param blockName Name of the block to bind.
  34758. * @param index Index to bind.
  34759. */
  34760. bindUniformBlock(blockName: string, index: number): void;
  34761. /**
  34762. * Sets an interger value on a uniform variable.
  34763. * @param uniformName Name of the variable.
  34764. * @param value Value to be set.
  34765. * @returns this effect.
  34766. */
  34767. setInt(uniformName: string, value: number): Effect;
  34768. /**
  34769. * Sets an int array on a uniform variable.
  34770. * @param uniformName Name of the variable.
  34771. * @param array array to be set.
  34772. * @returns this effect.
  34773. */
  34774. setIntArray(uniformName: string, array: Int32Array): Effect;
  34775. /**
  34776. * 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)
  34777. * @param uniformName Name of the variable.
  34778. * @param array array to be set.
  34779. * @returns this effect.
  34780. */
  34781. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34782. /**
  34783. * 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)
  34784. * @param uniformName Name of the variable.
  34785. * @param array array to be set.
  34786. * @returns this effect.
  34787. */
  34788. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34789. /**
  34790. * 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)
  34791. * @param uniformName Name of the variable.
  34792. * @param array array to be set.
  34793. * @returns this effect.
  34794. */
  34795. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34796. /**
  34797. * Sets an float array on a uniform variable.
  34798. * @param uniformName Name of the variable.
  34799. * @param array array to be set.
  34800. * @returns this effect.
  34801. */
  34802. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34803. /**
  34804. * 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)
  34805. * @param uniformName Name of the variable.
  34806. * @param array array to be set.
  34807. * @returns this effect.
  34808. */
  34809. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34810. /**
  34811. * 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)
  34812. * @param uniformName Name of the variable.
  34813. * @param array array to be set.
  34814. * @returns this effect.
  34815. */
  34816. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34817. /**
  34818. * 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)
  34819. * @param uniformName Name of the variable.
  34820. * @param array array to be set.
  34821. * @returns this effect.
  34822. */
  34823. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34824. /**
  34825. * Sets an array on a uniform variable.
  34826. * @param uniformName Name of the variable.
  34827. * @param array array to be set.
  34828. * @returns this effect.
  34829. */
  34830. setArray(uniformName: string, array: number[]): Effect;
  34831. /**
  34832. * 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)
  34833. * @param uniformName Name of the variable.
  34834. * @param array array to be set.
  34835. * @returns this effect.
  34836. */
  34837. setArray2(uniformName: string, array: number[]): Effect;
  34838. /**
  34839. * 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)
  34840. * @param uniformName Name of the variable.
  34841. * @param array array to be set.
  34842. * @returns this effect.
  34843. */
  34844. setArray3(uniformName: string, array: number[]): Effect;
  34845. /**
  34846. * 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)
  34847. * @param uniformName Name of the variable.
  34848. * @param array array to be set.
  34849. * @returns this effect.
  34850. */
  34851. setArray4(uniformName: string, array: number[]): Effect;
  34852. /**
  34853. * Sets matrices on a uniform variable.
  34854. * @param uniformName Name of the variable.
  34855. * @param matrices matrices to be set.
  34856. * @returns this effect.
  34857. */
  34858. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34859. /**
  34860. * Sets matrix on a uniform variable.
  34861. * @param uniformName Name of the variable.
  34862. * @param matrix matrix to be set.
  34863. * @returns this effect.
  34864. */
  34865. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34866. /**
  34867. * 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)
  34868. * @param uniformName Name of the variable.
  34869. * @param matrix matrix to be set.
  34870. * @returns this effect.
  34871. */
  34872. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34873. /**
  34874. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34875. * @param uniformName Name of the variable.
  34876. * @param matrix matrix to be set.
  34877. * @returns this effect.
  34878. */
  34879. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34880. /**
  34881. * Sets a float on a uniform variable.
  34882. * @param uniformName Name of the variable.
  34883. * @param value value to be set.
  34884. * @returns this effect.
  34885. */
  34886. setFloat(uniformName: string, value: number): Effect;
  34887. /**
  34888. * Sets a boolean on a uniform variable.
  34889. * @param uniformName Name of the variable.
  34890. * @param bool value to be set.
  34891. * @returns this effect.
  34892. */
  34893. setBool(uniformName: string, bool: boolean): Effect;
  34894. /**
  34895. * Sets a Vector2 on a uniform variable.
  34896. * @param uniformName Name of the variable.
  34897. * @param vector2 vector2 to be set.
  34898. * @returns this effect.
  34899. */
  34900. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34901. /**
  34902. * Sets a float2 on a uniform variable.
  34903. * @param uniformName Name of the variable.
  34904. * @param x First float in float2.
  34905. * @param y Second float in float2.
  34906. * @returns this effect.
  34907. */
  34908. setFloat2(uniformName: string, x: number, y: number): Effect;
  34909. /**
  34910. * Sets a Vector3 on a uniform variable.
  34911. * @param uniformName Name of the variable.
  34912. * @param vector3 Value to be set.
  34913. * @returns this effect.
  34914. */
  34915. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34916. /**
  34917. * Sets a float3 on a uniform variable.
  34918. * @param uniformName Name of the variable.
  34919. * @param x First float in float3.
  34920. * @param y Second float in float3.
  34921. * @param z Third float in float3.
  34922. * @returns this effect.
  34923. */
  34924. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34925. /**
  34926. * Sets a Vector4 on a uniform variable.
  34927. * @param uniformName Name of the variable.
  34928. * @param vector4 Value to be set.
  34929. * @returns this effect.
  34930. */
  34931. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34932. /**
  34933. * Sets a float4 on a uniform variable.
  34934. * @param uniformName Name of the variable.
  34935. * @param x First float in float4.
  34936. * @param y Second float in float4.
  34937. * @param z Third float in float4.
  34938. * @param w Fourth float in float4.
  34939. * @returns this effect.
  34940. */
  34941. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34942. /**
  34943. * Sets a Color3 on a uniform variable.
  34944. * @param uniformName Name of the variable.
  34945. * @param color3 Value to be set.
  34946. * @returns this effect.
  34947. */
  34948. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34949. /**
  34950. * Sets a Color4 on a uniform variable.
  34951. * @param uniformName Name of the variable.
  34952. * @param color3 Value to be set.
  34953. * @param alpha Alpha value to be set.
  34954. * @returns this effect.
  34955. */
  34956. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34957. /**
  34958. * Sets a Color4 on a uniform variable
  34959. * @param uniformName defines the name of the variable
  34960. * @param color4 defines the value to be set
  34961. * @returns this effect.
  34962. */
  34963. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34964. /** Release all associated resources */
  34965. dispose(): void;
  34966. /**
  34967. * This function will add a new shader to the shader store
  34968. * @param name the name of the shader
  34969. * @param pixelShader optional pixel shader content
  34970. * @param vertexShader optional vertex shader content
  34971. */
  34972. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34973. /**
  34974. * Store of each shader (The can be looked up using effect.key)
  34975. */
  34976. static ShadersStore: {
  34977. [key: string]: string;
  34978. };
  34979. /**
  34980. * Store of each included file for a shader (The can be looked up using effect.key)
  34981. */
  34982. static IncludesShadersStore: {
  34983. [key: string]: string;
  34984. };
  34985. /**
  34986. * Resets the cache of effects.
  34987. */
  34988. static ResetCache(): void;
  34989. }
  34990. }
  34991. declare module "babylonjs/Engines/engineCapabilities" {
  34992. /**
  34993. * Interface used to describe the capabilities of the engine relatively to the current browser
  34994. */
  34995. export interface EngineCapabilities {
  34996. /** Maximum textures units per fragment shader */
  34997. maxTexturesImageUnits: number;
  34998. /** Maximum texture units per vertex shader */
  34999. maxVertexTextureImageUnits: number;
  35000. /** Maximum textures units in the entire pipeline */
  35001. maxCombinedTexturesImageUnits: number;
  35002. /** Maximum texture size */
  35003. maxTextureSize: number;
  35004. /** Maximum texture samples */
  35005. maxSamples?: number;
  35006. /** Maximum cube texture size */
  35007. maxCubemapTextureSize: number;
  35008. /** Maximum render texture size */
  35009. maxRenderTextureSize: number;
  35010. /** Maximum number of vertex attributes */
  35011. maxVertexAttribs: number;
  35012. /** Maximum number of varyings */
  35013. maxVaryingVectors: number;
  35014. /** Maximum number of uniforms per vertex shader */
  35015. maxVertexUniformVectors: number;
  35016. /** Maximum number of uniforms per fragment shader */
  35017. maxFragmentUniformVectors: number;
  35018. /** Defines if standard derivates (dx/dy) are supported */
  35019. standardDerivatives: boolean;
  35020. /** Defines if s3tc texture compression is supported */
  35021. s3tc?: WEBGL_compressed_texture_s3tc;
  35022. /** Defines if pvrtc texture compression is supported */
  35023. pvrtc: any;
  35024. /** Defines if etc1 texture compression is supported */
  35025. etc1: any;
  35026. /** Defines if etc2 texture compression is supported */
  35027. etc2: any;
  35028. /** Defines if astc texture compression is supported */
  35029. astc: any;
  35030. /** Defines if float textures are supported */
  35031. textureFloat: boolean;
  35032. /** Defines if vertex array objects are supported */
  35033. vertexArrayObject: boolean;
  35034. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35035. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35036. /** Gets the maximum level of anisotropy supported */
  35037. maxAnisotropy: number;
  35038. /** Defines if instancing is supported */
  35039. instancedArrays: boolean;
  35040. /** Defines if 32 bits indices are supported */
  35041. uintIndices: boolean;
  35042. /** Defines if high precision shaders are supported */
  35043. highPrecisionShaderSupported: boolean;
  35044. /** Defines if depth reading in the fragment shader is supported */
  35045. fragmentDepthSupported: boolean;
  35046. /** Defines if float texture linear filtering is supported*/
  35047. textureFloatLinearFiltering: boolean;
  35048. /** Defines if rendering to float textures is supported */
  35049. textureFloatRender: boolean;
  35050. /** Defines if half float textures are supported*/
  35051. textureHalfFloat: boolean;
  35052. /** Defines if half float texture linear filtering is supported*/
  35053. textureHalfFloatLinearFiltering: boolean;
  35054. /** Defines if rendering to half float textures is supported */
  35055. textureHalfFloatRender: boolean;
  35056. /** Defines if textureLOD shader command is supported */
  35057. textureLOD: boolean;
  35058. /** Defines if draw buffers extension is supported */
  35059. drawBuffersExtension: boolean;
  35060. /** Defines if depth textures are supported */
  35061. depthTextureExtension: boolean;
  35062. /** Defines if float color buffer are supported */
  35063. colorBufferFloat: boolean;
  35064. /** Gets disjoint timer query extension (null if not supported) */
  35065. timerQuery?: EXT_disjoint_timer_query;
  35066. /** Defines if timestamp can be used with timer query */
  35067. canUseTimestampForTimerQuery: boolean;
  35068. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35069. multiview?: any;
  35070. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35071. oculusMultiview?: any;
  35072. /** Function used to let the system compiles shaders in background */
  35073. parallelShaderCompile?: {
  35074. COMPLETION_STATUS_KHR: number;
  35075. };
  35076. /** Max number of texture samples for MSAA */
  35077. maxMSAASamples: number;
  35078. /** Defines if the blend min max extension is supported */
  35079. blendMinMax: boolean;
  35080. }
  35081. }
  35082. declare module "babylonjs/States/depthCullingState" {
  35083. import { Nullable } from "babylonjs/types";
  35084. /**
  35085. * @hidden
  35086. **/
  35087. export class DepthCullingState {
  35088. private _isDepthTestDirty;
  35089. private _isDepthMaskDirty;
  35090. private _isDepthFuncDirty;
  35091. private _isCullFaceDirty;
  35092. private _isCullDirty;
  35093. private _isZOffsetDirty;
  35094. private _isFrontFaceDirty;
  35095. private _depthTest;
  35096. private _depthMask;
  35097. private _depthFunc;
  35098. private _cull;
  35099. private _cullFace;
  35100. private _zOffset;
  35101. private _frontFace;
  35102. /**
  35103. * Initializes the state.
  35104. */
  35105. constructor();
  35106. get isDirty(): boolean;
  35107. get zOffset(): number;
  35108. set zOffset(value: number);
  35109. get cullFace(): Nullable<number>;
  35110. set cullFace(value: Nullable<number>);
  35111. get cull(): Nullable<boolean>;
  35112. set cull(value: Nullable<boolean>);
  35113. get depthFunc(): Nullable<number>;
  35114. set depthFunc(value: Nullable<number>);
  35115. get depthMask(): boolean;
  35116. set depthMask(value: boolean);
  35117. get depthTest(): boolean;
  35118. set depthTest(value: boolean);
  35119. get frontFace(): Nullable<number>;
  35120. set frontFace(value: Nullable<number>);
  35121. reset(): void;
  35122. apply(gl: WebGLRenderingContext): void;
  35123. }
  35124. }
  35125. declare module "babylonjs/States/stencilState" {
  35126. /**
  35127. * @hidden
  35128. **/
  35129. export class StencilState {
  35130. /** 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 */
  35131. static readonly ALWAYS: number;
  35132. /** Passed to stencilOperation to specify that stencil value must be kept */
  35133. static readonly KEEP: number;
  35134. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35135. static readonly REPLACE: number;
  35136. private _isStencilTestDirty;
  35137. private _isStencilMaskDirty;
  35138. private _isStencilFuncDirty;
  35139. private _isStencilOpDirty;
  35140. private _stencilTest;
  35141. private _stencilMask;
  35142. private _stencilFunc;
  35143. private _stencilFuncRef;
  35144. private _stencilFuncMask;
  35145. private _stencilOpStencilFail;
  35146. private _stencilOpDepthFail;
  35147. private _stencilOpStencilDepthPass;
  35148. get isDirty(): boolean;
  35149. get stencilFunc(): number;
  35150. set stencilFunc(value: number);
  35151. get stencilFuncRef(): number;
  35152. set stencilFuncRef(value: number);
  35153. get stencilFuncMask(): number;
  35154. set stencilFuncMask(value: number);
  35155. get stencilOpStencilFail(): number;
  35156. set stencilOpStencilFail(value: number);
  35157. get stencilOpDepthFail(): number;
  35158. set stencilOpDepthFail(value: number);
  35159. get stencilOpStencilDepthPass(): number;
  35160. set stencilOpStencilDepthPass(value: number);
  35161. get stencilMask(): number;
  35162. set stencilMask(value: number);
  35163. get stencilTest(): boolean;
  35164. set stencilTest(value: boolean);
  35165. constructor();
  35166. reset(): void;
  35167. apply(gl: WebGLRenderingContext): void;
  35168. }
  35169. }
  35170. declare module "babylonjs/States/alphaCullingState" {
  35171. /**
  35172. * @hidden
  35173. **/
  35174. export class AlphaState {
  35175. private _isAlphaBlendDirty;
  35176. private _isBlendFunctionParametersDirty;
  35177. private _isBlendEquationParametersDirty;
  35178. private _isBlendConstantsDirty;
  35179. private _alphaBlend;
  35180. private _blendFunctionParameters;
  35181. private _blendEquationParameters;
  35182. private _blendConstants;
  35183. /**
  35184. * Initializes the state.
  35185. */
  35186. constructor();
  35187. get isDirty(): boolean;
  35188. get alphaBlend(): boolean;
  35189. set alphaBlend(value: boolean);
  35190. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35191. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35192. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35193. reset(): void;
  35194. apply(gl: WebGLRenderingContext): void;
  35195. }
  35196. }
  35197. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35199. /** @hidden */
  35200. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35201. attributeProcessor(attribute: string): string;
  35202. varyingProcessor(varying: string, isFragment: boolean): string;
  35203. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35204. }
  35205. }
  35206. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35207. /**
  35208. * Interface for attribute information associated with buffer instanciation
  35209. */
  35210. export interface InstancingAttributeInfo {
  35211. /**
  35212. * Name of the GLSL attribute
  35213. * if attribute index is not specified, this is used to retrieve the index from the effect
  35214. */
  35215. attributeName: string;
  35216. /**
  35217. * Index/offset of the attribute in the vertex shader
  35218. * if not specified, this will be computes from the name.
  35219. */
  35220. index?: number;
  35221. /**
  35222. * size of the attribute, 1, 2, 3 or 4
  35223. */
  35224. attributeSize: number;
  35225. /**
  35226. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35227. */
  35228. offset: number;
  35229. /**
  35230. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35231. * default to 1
  35232. */
  35233. divisor?: number;
  35234. /**
  35235. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35236. * default is FLOAT
  35237. */
  35238. attributeType?: number;
  35239. /**
  35240. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35241. */
  35242. normalized?: boolean;
  35243. }
  35244. }
  35245. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35247. import { Nullable } from "babylonjs/types";
  35248. module "babylonjs/Engines/thinEngine" {
  35249. interface ThinEngine {
  35250. /**
  35251. * Update a video texture
  35252. * @param texture defines the texture to update
  35253. * @param video defines the video element to use
  35254. * @param invertY defines if data must be stored with Y axis inverted
  35255. */
  35256. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35257. }
  35258. }
  35259. }
  35260. declare module "babylonjs/Materials/Textures/videoTexture" {
  35261. import { Observable } from "babylonjs/Misc/observable";
  35262. import { Nullable } from "babylonjs/types";
  35263. import { Scene } from "babylonjs/scene";
  35264. import { Texture } from "babylonjs/Materials/Textures/texture";
  35265. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35266. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35267. /**
  35268. * Settings for finer control over video usage
  35269. */
  35270. export interface VideoTextureSettings {
  35271. /**
  35272. * Applies `autoplay` to video, if specified
  35273. */
  35274. autoPlay?: boolean;
  35275. /**
  35276. * Applies `loop` to video, if specified
  35277. */
  35278. loop?: boolean;
  35279. /**
  35280. * Automatically updates internal texture from video at every frame in the render loop
  35281. */
  35282. autoUpdateTexture: boolean;
  35283. /**
  35284. * Image src displayed during the video loading or until the user interacts with the video.
  35285. */
  35286. poster?: string;
  35287. }
  35288. /**
  35289. * If you want to display a video in your scene, this is the special texture for that.
  35290. * This special texture works similar to other textures, with the exception of a few parameters.
  35291. * @see https://doc.babylonjs.com/how_to/video_texture
  35292. */
  35293. export class VideoTexture extends Texture {
  35294. /**
  35295. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35296. */
  35297. readonly autoUpdateTexture: boolean;
  35298. /**
  35299. * The video instance used by the texture internally
  35300. */
  35301. readonly video: HTMLVideoElement;
  35302. private _onUserActionRequestedObservable;
  35303. /**
  35304. * Event triggerd when a dom action is required by the user to play the video.
  35305. * This happens due to recent changes in browser policies preventing video to auto start.
  35306. */
  35307. get onUserActionRequestedObservable(): Observable<Texture>;
  35308. private _generateMipMaps;
  35309. private _stillImageCaptured;
  35310. private _displayingPosterTexture;
  35311. private _settings;
  35312. private _createInternalTextureOnEvent;
  35313. private _frameId;
  35314. private _currentSrc;
  35315. /**
  35316. * Creates a video texture.
  35317. * If you want to display a video in your scene, this is the special texture for that.
  35318. * This special texture works similar to other textures, with the exception of a few parameters.
  35319. * @see https://doc.babylonjs.com/how_to/video_texture
  35320. * @param name optional name, will detect from video source, if not defined
  35321. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35322. * @param scene is obviously the current scene.
  35323. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35324. * @param invertY is false by default but can be used to invert video on Y axis
  35325. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35326. * @param settings allows finer control over video usage
  35327. */
  35328. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35329. private _getName;
  35330. private _getVideo;
  35331. private _createInternalTexture;
  35332. private reset;
  35333. /**
  35334. * @hidden Internal method to initiate `update`.
  35335. */
  35336. _rebuild(): void;
  35337. /**
  35338. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35339. */
  35340. update(): void;
  35341. /**
  35342. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35343. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35344. */
  35345. updateTexture(isVisible: boolean): void;
  35346. protected _updateInternalTexture: () => void;
  35347. /**
  35348. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35349. * @param url New url.
  35350. */
  35351. updateURL(url: string): void;
  35352. /**
  35353. * Clones the texture.
  35354. * @returns the cloned texture
  35355. */
  35356. clone(): VideoTexture;
  35357. /**
  35358. * Dispose the texture and release its associated resources.
  35359. */
  35360. dispose(): void;
  35361. /**
  35362. * Creates a video texture straight from a stream.
  35363. * @param scene Define the scene the texture should be created in
  35364. * @param stream Define the stream the texture should be created from
  35365. * @returns The created video texture as a promise
  35366. */
  35367. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35368. /**
  35369. * Creates a video texture straight from your WebCam video feed.
  35370. * @param scene Define the scene the texture should be created in
  35371. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35372. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35373. * @returns The created video texture as a promise
  35374. */
  35375. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35376. minWidth: number;
  35377. maxWidth: number;
  35378. minHeight: number;
  35379. maxHeight: number;
  35380. deviceId: string;
  35381. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35382. /**
  35383. * Creates a video texture straight from your WebCam video feed.
  35384. * @param scene Define the scene the texture should be created in
  35385. * @param onReady Define a callback to triggered once the texture will be ready
  35386. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35387. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35388. */
  35389. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35390. minWidth: number;
  35391. maxWidth: number;
  35392. minHeight: number;
  35393. maxHeight: number;
  35394. deviceId: string;
  35395. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35396. }
  35397. }
  35398. declare module "babylonjs/Engines/thinEngine" {
  35399. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35400. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35401. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35402. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35403. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35404. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35405. import { Observable } from "babylonjs/Misc/observable";
  35406. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35407. import { StencilState } from "babylonjs/States/stencilState";
  35408. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35409. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35410. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35412. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35414. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35415. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35416. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35417. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35418. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35419. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35420. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35421. import { WebRequest } from "babylonjs/Misc/webRequest";
  35422. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35423. /**
  35424. * Defines the interface used by objects working like Scene
  35425. * @hidden
  35426. */
  35427. export interface ISceneLike {
  35428. _addPendingData(data: any): void;
  35429. _removePendingData(data: any): void;
  35430. offlineProvider: IOfflineProvider;
  35431. }
  35432. /** Interface defining initialization parameters for Engine class */
  35433. export interface EngineOptions extends WebGLContextAttributes {
  35434. /**
  35435. * Defines if the engine should no exceed a specified device ratio
  35436. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35437. */
  35438. limitDeviceRatio?: number;
  35439. /**
  35440. * Defines if webvr should be enabled automatically
  35441. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35442. */
  35443. autoEnableWebVR?: boolean;
  35444. /**
  35445. * Defines if webgl2 should be turned off even if supported
  35446. * @see http://doc.babylonjs.com/features/webgl2
  35447. */
  35448. disableWebGL2Support?: boolean;
  35449. /**
  35450. * Defines if webaudio should be initialized as well
  35451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35452. */
  35453. audioEngine?: boolean;
  35454. /**
  35455. * Defines if animations should run using a deterministic lock step
  35456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35457. */
  35458. deterministicLockstep?: boolean;
  35459. /** Defines the maximum steps to use with deterministic lock step mode */
  35460. lockstepMaxSteps?: number;
  35461. /** Defines the seconds between each deterministic lock step */
  35462. timeStep?: number;
  35463. /**
  35464. * Defines that engine should ignore context lost events
  35465. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35466. */
  35467. doNotHandleContextLost?: boolean;
  35468. /**
  35469. * Defines that engine should ignore modifying touch action attribute and style
  35470. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35471. */
  35472. doNotHandleTouchAction?: boolean;
  35473. /**
  35474. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35475. */
  35476. useHighPrecisionFloats?: boolean;
  35477. /**
  35478. * Make the canvas XR Compatible for XR sessions
  35479. */
  35480. xrCompatible?: boolean;
  35481. }
  35482. /**
  35483. * The base engine class (root of all engines)
  35484. */
  35485. export class ThinEngine {
  35486. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35487. static ExceptionList: ({
  35488. key: string;
  35489. capture: string;
  35490. captureConstraint: number;
  35491. targets: string[];
  35492. } | {
  35493. key: string;
  35494. capture: null;
  35495. captureConstraint: null;
  35496. targets: string[];
  35497. })[];
  35498. /** @hidden */
  35499. static _TextureLoaders: IInternalTextureLoader[];
  35500. /**
  35501. * Returns the current npm package of the sdk
  35502. */
  35503. static get NpmPackage(): string;
  35504. /**
  35505. * Returns the current version of the framework
  35506. */
  35507. static get Version(): string;
  35508. /**
  35509. * Returns a string describing the current engine
  35510. */
  35511. get description(): string;
  35512. /**
  35513. * Gets or sets the epsilon value used by collision engine
  35514. */
  35515. static CollisionsEpsilon: number;
  35516. /**
  35517. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35518. */
  35519. static get ShadersRepository(): string;
  35520. static set ShadersRepository(value: string);
  35521. /** @hidden */
  35522. _shaderProcessor: IShaderProcessor;
  35523. /**
  35524. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35525. */
  35526. forcePOTTextures: boolean;
  35527. /**
  35528. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35529. */
  35530. isFullscreen: boolean;
  35531. /**
  35532. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35533. */
  35534. cullBackFaces: boolean;
  35535. /**
  35536. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35537. */
  35538. renderEvenInBackground: boolean;
  35539. /**
  35540. * Gets or sets a boolean indicating that cache can be kept between frames
  35541. */
  35542. preventCacheWipeBetweenFrames: boolean;
  35543. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35544. validateShaderPrograms: boolean;
  35545. /**
  35546. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35547. * This can provide greater z depth for distant objects.
  35548. */
  35549. useReverseDepthBuffer: boolean;
  35550. /**
  35551. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35552. */
  35553. disableUniformBuffers: boolean;
  35554. /** @hidden */
  35555. _uniformBuffers: UniformBuffer[];
  35556. /**
  35557. * Gets a boolean indicating that the engine supports uniform buffers
  35558. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35559. */
  35560. get supportsUniformBuffers(): boolean;
  35561. /** @hidden */
  35562. _gl: WebGLRenderingContext;
  35563. /** @hidden */
  35564. _webGLVersion: number;
  35565. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35566. protected _windowIsBackground: boolean;
  35567. protected _creationOptions: EngineOptions;
  35568. protected _highPrecisionShadersAllowed: boolean;
  35569. /** @hidden */
  35570. get _shouldUseHighPrecisionShader(): boolean;
  35571. /**
  35572. * Gets a boolean indicating that only power of 2 textures are supported
  35573. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35574. */
  35575. get needPOTTextures(): boolean;
  35576. /** @hidden */
  35577. _badOS: boolean;
  35578. /** @hidden */
  35579. _badDesktopOS: boolean;
  35580. private _hardwareScalingLevel;
  35581. /** @hidden */
  35582. _caps: EngineCapabilities;
  35583. private _isStencilEnable;
  35584. private _glVersion;
  35585. private _glRenderer;
  35586. private _glVendor;
  35587. /** @hidden */
  35588. _videoTextureSupported: boolean;
  35589. protected _renderingQueueLaunched: boolean;
  35590. protected _activeRenderLoops: (() => void)[];
  35591. /**
  35592. * Observable signaled when a context lost event is raised
  35593. */
  35594. onContextLostObservable: Observable<ThinEngine>;
  35595. /**
  35596. * Observable signaled when a context restored event is raised
  35597. */
  35598. onContextRestoredObservable: Observable<ThinEngine>;
  35599. private _onContextLost;
  35600. private _onContextRestored;
  35601. protected _contextWasLost: boolean;
  35602. /** @hidden */
  35603. _doNotHandleContextLost: boolean;
  35604. /**
  35605. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35607. */
  35608. get doNotHandleContextLost(): boolean;
  35609. set doNotHandleContextLost(value: boolean);
  35610. /**
  35611. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35612. */
  35613. disableVertexArrayObjects: boolean;
  35614. /** @hidden */
  35615. protected _colorWrite: boolean;
  35616. /** @hidden */
  35617. protected _colorWriteChanged: boolean;
  35618. /** @hidden */
  35619. protected _depthCullingState: DepthCullingState;
  35620. /** @hidden */
  35621. protected _stencilState: StencilState;
  35622. /** @hidden */
  35623. _alphaState: AlphaState;
  35624. /** @hidden */
  35625. _alphaMode: number;
  35626. /** @hidden */
  35627. _alphaEquation: number;
  35628. /** @hidden */
  35629. _internalTexturesCache: InternalTexture[];
  35630. /** @hidden */
  35631. protected _activeChannel: number;
  35632. private _currentTextureChannel;
  35633. /** @hidden */
  35634. protected _boundTexturesCache: {
  35635. [key: string]: Nullable<InternalTexture>;
  35636. };
  35637. /** @hidden */
  35638. protected _currentEffect: Nullable<Effect>;
  35639. /** @hidden */
  35640. protected _currentProgram: Nullable<WebGLProgram>;
  35641. private _compiledEffects;
  35642. private _vertexAttribArraysEnabled;
  35643. /** @hidden */
  35644. protected _cachedViewport: Nullable<IViewportLike>;
  35645. private _cachedVertexArrayObject;
  35646. /** @hidden */
  35647. protected _cachedVertexBuffers: any;
  35648. /** @hidden */
  35649. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35650. /** @hidden */
  35651. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35652. /** @hidden */
  35653. _currentRenderTarget: Nullable<InternalTexture>;
  35654. private _uintIndicesCurrentlySet;
  35655. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35656. /** @hidden */
  35657. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35658. /** @hidden */
  35659. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35660. private _currentBufferPointers;
  35661. private _currentInstanceLocations;
  35662. private _currentInstanceBuffers;
  35663. private _textureUnits;
  35664. /** @hidden */
  35665. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35666. /** @hidden */
  35667. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35668. /** @hidden */
  35669. _boundRenderFunction: any;
  35670. private _vaoRecordInProgress;
  35671. private _mustWipeVertexAttributes;
  35672. private _emptyTexture;
  35673. private _emptyCubeTexture;
  35674. private _emptyTexture3D;
  35675. private _emptyTexture2DArray;
  35676. /** @hidden */
  35677. _frameHandler: number;
  35678. private _nextFreeTextureSlots;
  35679. private _maxSimultaneousTextures;
  35680. private _activeRequests;
  35681. /** @hidden */
  35682. _transformTextureUrl: Nullable<(url: string) => string>;
  35683. protected get _supportsHardwareTextureRescaling(): boolean;
  35684. private _framebufferDimensionsObject;
  35685. /**
  35686. * sets the object from which width and height will be taken from when getting render width and height
  35687. * Will fallback to the gl object
  35688. * @param dimensions the framebuffer width and height that will be used.
  35689. */
  35690. set framebufferDimensionsObject(dimensions: Nullable<{
  35691. framebufferWidth: number;
  35692. framebufferHeight: number;
  35693. }>);
  35694. /**
  35695. * Gets the current viewport
  35696. */
  35697. get currentViewport(): Nullable<IViewportLike>;
  35698. /**
  35699. * Gets the default empty texture
  35700. */
  35701. get emptyTexture(): InternalTexture;
  35702. /**
  35703. * Gets the default empty 3D texture
  35704. */
  35705. get emptyTexture3D(): InternalTexture;
  35706. /**
  35707. * Gets the default empty 2D array texture
  35708. */
  35709. get emptyTexture2DArray(): InternalTexture;
  35710. /**
  35711. * Gets the default empty cube texture
  35712. */
  35713. get emptyCubeTexture(): InternalTexture;
  35714. /**
  35715. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35716. */
  35717. readonly premultipliedAlpha: boolean;
  35718. /**
  35719. * Observable event triggered before each texture is initialized
  35720. */
  35721. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35722. /**
  35723. * Creates a new engine
  35724. * @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
  35725. * @param antialias defines enable antialiasing (default: false)
  35726. * @param options defines further options to be sent to the getContext() function
  35727. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35728. */
  35729. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35730. private _rebuildInternalTextures;
  35731. private _rebuildEffects;
  35732. /**
  35733. * Gets a boolean indicating if all created effects are ready
  35734. * @returns true if all effects are ready
  35735. */
  35736. areAllEffectsReady(): boolean;
  35737. protected _rebuildBuffers(): void;
  35738. protected _initGLContext(): void;
  35739. /**
  35740. * Gets version of the current webGL context
  35741. */
  35742. get webGLVersion(): number;
  35743. /**
  35744. * Gets a string idenfifying the name of the class
  35745. * @returns "Engine" string
  35746. */
  35747. getClassName(): string;
  35748. /**
  35749. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35750. */
  35751. get isStencilEnable(): boolean;
  35752. /** @hidden */
  35753. _prepareWorkingCanvas(): void;
  35754. /**
  35755. * Reset the texture cache to empty state
  35756. */
  35757. resetTextureCache(): void;
  35758. /**
  35759. * Gets an object containing information about the current webGL context
  35760. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35761. */
  35762. getGlInfo(): {
  35763. vendor: string;
  35764. renderer: string;
  35765. version: string;
  35766. };
  35767. /**
  35768. * Defines the hardware scaling level.
  35769. * By default the hardware scaling level is computed from the window device ratio.
  35770. * 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.
  35771. * @param level defines the level to use
  35772. */
  35773. setHardwareScalingLevel(level: number): void;
  35774. /**
  35775. * Gets the current hardware scaling level.
  35776. * By default the hardware scaling level is computed from the window device ratio.
  35777. * 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.
  35778. * @returns a number indicating the current hardware scaling level
  35779. */
  35780. getHardwareScalingLevel(): number;
  35781. /**
  35782. * Gets the list of loaded textures
  35783. * @returns an array containing all loaded textures
  35784. */
  35785. getLoadedTexturesCache(): InternalTexture[];
  35786. /**
  35787. * Gets the object containing all engine capabilities
  35788. * @returns the EngineCapabilities object
  35789. */
  35790. getCaps(): EngineCapabilities;
  35791. /**
  35792. * stop executing a render loop function and remove it from the execution array
  35793. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35794. */
  35795. stopRenderLoop(renderFunction?: () => void): void;
  35796. /** @hidden */
  35797. _renderLoop(): void;
  35798. /**
  35799. * Gets the HTML canvas attached with the current webGL context
  35800. * @returns a HTML canvas
  35801. */
  35802. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35803. /**
  35804. * Gets host window
  35805. * @returns the host window object
  35806. */
  35807. getHostWindow(): Nullable<Window>;
  35808. /**
  35809. * Gets the current render width
  35810. * @param useScreen defines if screen size must be used (or the current render target if any)
  35811. * @returns a number defining the current render width
  35812. */
  35813. getRenderWidth(useScreen?: boolean): number;
  35814. /**
  35815. * Gets the current render height
  35816. * @param useScreen defines if screen size must be used (or the current render target if any)
  35817. * @returns a number defining the current render height
  35818. */
  35819. getRenderHeight(useScreen?: boolean): number;
  35820. /**
  35821. * Can be used to override the current requestAnimationFrame requester.
  35822. * @hidden
  35823. */
  35824. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35825. /**
  35826. * Register and execute a render loop. The engine can have more than one render function
  35827. * @param renderFunction defines the function to continuously execute
  35828. */
  35829. runRenderLoop(renderFunction: () => void): void;
  35830. /**
  35831. * Clear the current render buffer or the current render target (if any is set up)
  35832. * @param color defines the color to use
  35833. * @param backBuffer defines if the back buffer must be cleared
  35834. * @param depth defines if the depth buffer must be cleared
  35835. * @param stencil defines if the stencil buffer must be cleared
  35836. */
  35837. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35838. private _viewportCached;
  35839. /** @hidden */
  35840. _viewport(x: number, y: number, width: number, height: number): void;
  35841. /**
  35842. * Set the WebGL's viewport
  35843. * @param viewport defines the viewport element to be used
  35844. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35845. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35846. */
  35847. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35848. /**
  35849. * Begin a new frame
  35850. */
  35851. beginFrame(): void;
  35852. /**
  35853. * Enf the current frame
  35854. */
  35855. endFrame(): void;
  35856. /**
  35857. * Resize the view according to the canvas' size
  35858. */
  35859. resize(): void;
  35860. /**
  35861. * Force a specific size of the canvas
  35862. * @param width defines the new canvas' width
  35863. * @param height defines the new canvas' height
  35864. */
  35865. setSize(width: number, height: number): void;
  35866. /**
  35867. * Binds the frame buffer to the specified texture.
  35868. * @param texture The texture to render to or null for the default canvas
  35869. * @param faceIndex The face of the texture to render to in case of cube texture
  35870. * @param requiredWidth The width of the target to render to
  35871. * @param requiredHeight The height of the target to render to
  35872. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35873. * @param lodLevel defines the lod level to bind to the frame buffer
  35874. * @param layer defines the 2d array index to bind to frame buffer to
  35875. */
  35876. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35877. /** @hidden */
  35878. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35879. /**
  35880. * Unbind the current render target texture from the webGL context
  35881. * @param texture defines the render target texture to unbind
  35882. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35883. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35884. */
  35885. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35886. /**
  35887. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35888. */
  35889. flushFramebuffer(): void;
  35890. /**
  35891. * Unbind the current render target and bind the default framebuffer
  35892. */
  35893. restoreDefaultFramebuffer(): void;
  35894. /** @hidden */
  35895. protected _resetVertexBufferBinding(): void;
  35896. /**
  35897. * Creates a vertex buffer
  35898. * @param data the data for the vertex buffer
  35899. * @returns the new WebGL static buffer
  35900. */
  35901. createVertexBuffer(data: DataArray): DataBuffer;
  35902. private _createVertexBuffer;
  35903. /**
  35904. * Creates a dynamic vertex buffer
  35905. * @param data the data for the dynamic vertex buffer
  35906. * @returns the new WebGL dynamic buffer
  35907. */
  35908. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35909. protected _resetIndexBufferBinding(): void;
  35910. /**
  35911. * Creates a new index buffer
  35912. * @param indices defines the content of the index buffer
  35913. * @param updatable defines if the index buffer must be updatable
  35914. * @returns a new webGL buffer
  35915. */
  35916. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35917. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35918. /**
  35919. * Bind a webGL buffer to the webGL context
  35920. * @param buffer defines the buffer to bind
  35921. */
  35922. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35923. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35924. private bindBuffer;
  35925. /**
  35926. * update the bound buffer with the given data
  35927. * @param data defines the data to update
  35928. */
  35929. updateArrayBuffer(data: Float32Array): void;
  35930. private _vertexAttribPointer;
  35931. /** @hidden */
  35932. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35933. private _bindVertexBuffersAttributes;
  35934. /**
  35935. * Records a vertex array object
  35936. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35937. * @param vertexBuffers defines the list of vertex buffers to store
  35938. * @param indexBuffer defines the index buffer to store
  35939. * @param effect defines the effect to store
  35940. * @returns the new vertex array object
  35941. */
  35942. recordVertexArrayObject(vertexBuffers: {
  35943. [key: string]: VertexBuffer;
  35944. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35945. /**
  35946. * Bind a specific vertex array object
  35947. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35948. * @param vertexArrayObject defines the vertex array object to bind
  35949. * @param indexBuffer defines the index buffer to bind
  35950. */
  35951. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35952. /**
  35953. * Bind webGl buffers directly to the webGL context
  35954. * @param vertexBuffer defines the vertex buffer to bind
  35955. * @param indexBuffer defines the index buffer to bind
  35956. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35957. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35958. * @param effect defines the effect associated with the vertex buffer
  35959. */
  35960. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35961. private _unbindVertexArrayObject;
  35962. /**
  35963. * Bind a list of vertex buffers to the webGL context
  35964. * @param vertexBuffers defines the list of vertex buffers to bind
  35965. * @param indexBuffer defines the index buffer to bind
  35966. * @param effect defines the effect associated with the vertex buffers
  35967. */
  35968. bindBuffers(vertexBuffers: {
  35969. [key: string]: Nullable<VertexBuffer>;
  35970. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35971. /**
  35972. * Unbind all instance attributes
  35973. */
  35974. unbindInstanceAttributes(): void;
  35975. /**
  35976. * Release and free the memory of a vertex array object
  35977. * @param vao defines the vertex array object to delete
  35978. */
  35979. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35980. /** @hidden */
  35981. _releaseBuffer(buffer: DataBuffer): boolean;
  35982. protected _deleteBuffer(buffer: DataBuffer): void;
  35983. /**
  35984. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35985. * @param instancesBuffer defines the webGL buffer to update and bind
  35986. * @param data defines the data to store in the buffer
  35987. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35988. */
  35989. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35990. /**
  35991. * Bind the content of a webGL buffer used with instantiation
  35992. * @param instancesBuffer defines the webGL buffer to bind
  35993. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35994. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35995. */
  35996. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35997. /**
  35998. * Disable the instance attribute corresponding to the name in parameter
  35999. * @param name defines the name of the attribute to disable
  36000. */
  36001. disableInstanceAttributeByName(name: string): void;
  36002. /**
  36003. * Disable the instance attribute corresponding to the location in parameter
  36004. * @param attributeLocation defines the attribute location of the attribute to disable
  36005. */
  36006. disableInstanceAttribute(attributeLocation: number): void;
  36007. /**
  36008. * Disable the attribute corresponding to the location in parameter
  36009. * @param attributeLocation defines the attribute location of the attribute to disable
  36010. */
  36011. disableAttributeByIndex(attributeLocation: number): void;
  36012. /**
  36013. * Send a draw order
  36014. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36015. * @param indexStart defines the starting index
  36016. * @param indexCount defines the number of index to draw
  36017. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36018. */
  36019. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36020. /**
  36021. * Draw a list of points
  36022. * @param verticesStart defines the index of first vertex to draw
  36023. * @param verticesCount defines the count of vertices to draw
  36024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36025. */
  36026. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36027. /**
  36028. * Draw a list of unindexed primitives
  36029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36030. * @param verticesStart defines the index of first vertex to draw
  36031. * @param verticesCount defines the count of vertices to draw
  36032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36033. */
  36034. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36035. /**
  36036. * Draw a list of indexed primitives
  36037. * @param fillMode defines the primitive to use
  36038. * @param indexStart defines the starting index
  36039. * @param indexCount defines the number of index to draw
  36040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36041. */
  36042. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36043. /**
  36044. * Draw a list of unindexed primitives
  36045. * @param fillMode defines the primitive to use
  36046. * @param verticesStart defines the index of first vertex to draw
  36047. * @param verticesCount defines the count of vertices to draw
  36048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36049. */
  36050. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36051. private _drawMode;
  36052. /** @hidden */
  36053. protected _reportDrawCall(): void;
  36054. /** @hidden */
  36055. _releaseEffect(effect: Effect): void;
  36056. /** @hidden */
  36057. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36058. /**
  36059. * Create a new effect (used to store vertex/fragment shaders)
  36060. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36061. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36062. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36063. * @param samplers defines an array of string used to represent textures
  36064. * @param defines defines the string containing the defines to use to compile the shaders
  36065. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36066. * @param onCompiled defines a function to call when the effect creation is successful
  36067. * @param onError defines a function to call when the effect creation has failed
  36068. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36069. * @returns the new Effect
  36070. */
  36071. 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;
  36072. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36073. private _compileShader;
  36074. private _compileRawShader;
  36075. /** @hidden */
  36076. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36077. /**
  36078. * Directly creates a webGL program
  36079. * @param pipelineContext defines the pipeline context to attach to
  36080. * @param vertexCode defines the vertex shader code to use
  36081. * @param fragmentCode defines the fragment shader code to use
  36082. * @param context defines the webGL context to use (if not set, the current one will be used)
  36083. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36084. * @returns the new webGL program
  36085. */
  36086. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36087. /**
  36088. * Creates a webGL program
  36089. * @param pipelineContext defines the pipeline context to attach to
  36090. * @param vertexCode defines the vertex shader code to use
  36091. * @param fragmentCode defines the fragment shader code to use
  36092. * @param defines defines the string containing the defines to use to compile the shaders
  36093. * @param context defines the webGL context to use (if not set, the current one will be used)
  36094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36095. * @returns the new webGL program
  36096. */
  36097. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36098. /**
  36099. * Creates a new pipeline context
  36100. * @returns the new pipeline
  36101. */
  36102. createPipelineContext(): IPipelineContext;
  36103. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36104. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36105. /** @hidden */
  36106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36107. /** @hidden */
  36108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36109. /** @hidden */
  36110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36111. /**
  36112. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36113. * @param pipelineContext defines the pipeline context to use
  36114. * @param uniformsNames defines the list of uniform names
  36115. * @returns an array of webGL uniform locations
  36116. */
  36117. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36118. /**
  36119. * Gets the lsit of active attributes for a given webGL program
  36120. * @param pipelineContext defines the pipeline context to use
  36121. * @param attributesNames defines the list of attribute names to get
  36122. * @returns an array of indices indicating the offset of each attribute
  36123. */
  36124. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36125. /**
  36126. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36127. * @param effect defines the effect to activate
  36128. */
  36129. enableEffect(effect: Nullable<Effect>): void;
  36130. /**
  36131. * Set the value of an uniform to a number (int)
  36132. * @param uniform defines the webGL uniform location where to store the value
  36133. * @param value defines the int number to store
  36134. */
  36135. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36136. /**
  36137. * Set the value of an uniform to an array of int32
  36138. * @param uniform defines the webGL uniform location where to store the value
  36139. * @param array defines the array of int32 to store
  36140. */
  36141. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36142. /**
  36143. * Set the value of an uniform to an array of int32 (stored as vec2)
  36144. * @param uniform defines the webGL uniform location where to store the value
  36145. * @param array defines the array of int32 to store
  36146. */
  36147. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36148. /**
  36149. * Set the value of an uniform to an array of int32 (stored as vec3)
  36150. * @param uniform defines the webGL uniform location where to store the value
  36151. * @param array defines the array of int32 to store
  36152. */
  36153. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36154. /**
  36155. * Set the value of an uniform to an array of int32 (stored as vec4)
  36156. * @param uniform defines the webGL uniform location where to store the value
  36157. * @param array defines the array of int32 to store
  36158. */
  36159. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36160. /**
  36161. * Set the value of an uniform to an array of number
  36162. * @param uniform defines the webGL uniform location where to store the value
  36163. * @param array defines the array of number to store
  36164. */
  36165. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36166. /**
  36167. * Set the value of an uniform to an array of number (stored as vec2)
  36168. * @param uniform defines the webGL uniform location where to store the value
  36169. * @param array defines the array of number to store
  36170. */
  36171. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36172. /**
  36173. * Set the value of an uniform to an array of number (stored as vec3)
  36174. * @param uniform defines the webGL uniform location where to store the value
  36175. * @param array defines the array of number to store
  36176. */
  36177. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36178. /**
  36179. * Set the value of an uniform to an array of number (stored as vec4)
  36180. * @param uniform defines the webGL uniform location where to store the value
  36181. * @param array defines the array of number to store
  36182. */
  36183. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36184. /**
  36185. * Set the value of an uniform to an array of float32 (stored as matrices)
  36186. * @param uniform defines the webGL uniform location where to store the value
  36187. * @param matrices defines the array of float32 to store
  36188. */
  36189. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36190. /**
  36191. * Set the value of an uniform to a matrix (3x3)
  36192. * @param uniform defines the webGL uniform location where to store the value
  36193. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36194. */
  36195. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36196. /**
  36197. * Set the value of an uniform to a matrix (2x2)
  36198. * @param uniform defines the webGL uniform location where to store the value
  36199. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36200. */
  36201. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36202. /**
  36203. * Set the value of an uniform to a number (float)
  36204. * @param uniform defines the webGL uniform location where to store the value
  36205. * @param value defines the float number to store
  36206. */
  36207. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36208. /**
  36209. * Set the value of an uniform to a vec2
  36210. * @param uniform defines the webGL uniform location where to store the value
  36211. * @param x defines the 1st component of the value
  36212. * @param y defines the 2nd component of the value
  36213. */
  36214. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36215. /**
  36216. * Set the value of an uniform to a vec3
  36217. * @param uniform defines the webGL uniform location where to store the value
  36218. * @param x defines the 1st component of the value
  36219. * @param y defines the 2nd component of the value
  36220. * @param z defines the 3rd component of the value
  36221. */
  36222. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36223. /**
  36224. * Set the value of an uniform to a vec4
  36225. * @param uniform defines the webGL uniform location where to store the value
  36226. * @param x defines the 1st component of the value
  36227. * @param y defines the 2nd component of the value
  36228. * @param z defines the 3rd component of the value
  36229. * @param w defines the 4th component of the value
  36230. */
  36231. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36232. /**
  36233. * Apply all cached states (depth, culling, stencil and alpha)
  36234. */
  36235. applyStates(): void;
  36236. /**
  36237. * Enable or disable color writing
  36238. * @param enable defines the state to set
  36239. */
  36240. setColorWrite(enable: boolean): void;
  36241. /**
  36242. * Gets a boolean indicating if color writing is enabled
  36243. * @returns the current color writing state
  36244. */
  36245. getColorWrite(): boolean;
  36246. /**
  36247. * Gets the depth culling state manager
  36248. */
  36249. get depthCullingState(): DepthCullingState;
  36250. /**
  36251. * Gets the alpha state manager
  36252. */
  36253. get alphaState(): AlphaState;
  36254. /**
  36255. * Gets the stencil state manager
  36256. */
  36257. get stencilState(): StencilState;
  36258. /**
  36259. * Clears the list of texture accessible through engine.
  36260. * This can help preventing texture load conflict due to name collision.
  36261. */
  36262. clearInternalTexturesCache(): void;
  36263. /**
  36264. * Force the entire cache to be cleared
  36265. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36266. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36267. */
  36268. wipeCaches(bruteForce?: boolean): void;
  36269. /** @hidden */
  36270. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36271. min: number;
  36272. mag: number;
  36273. };
  36274. /** @hidden */
  36275. _createTexture(): WebGLTexture;
  36276. /**
  36277. * Usually called from Texture.ts.
  36278. * Passed information to create a WebGLTexture
  36279. * @param url defines a value which contains one of the following:
  36280. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36281. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36282. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36284. * @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)
  36285. * @param scene needed for loading to the correct scene
  36286. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36287. * @param onLoad optional callback to be called upon successful completion
  36288. * @param onError optional callback to be called upon failure
  36289. * @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
  36290. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36291. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36292. * @param forcedExtension defines the extension to use to pick the right loader
  36293. * @param mimeType defines an optional mime type
  36294. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36295. */
  36296. 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;
  36297. /**
  36298. * Loads an image as an HTMLImageElement.
  36299. * @param input url string, ArrayBuffer, or Blob to load
  36300. * @param onLoad callback called when the image successfully loads
  36301. * @param onError callback called when the image fails to load
  36302. * @param offlineProvider offline provider for caching
  36303. * @param mimeType optional mime type
  36304. * @returns the HTMLImageElement of the loaded image
  36305. * @hidden
  36306. */
  36307. 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>;
  36308. /**
  36309. * @hidden
  36310. */
  36311. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36312. private _unpackFlipYCached;
  36313. /**
  36314. * In case you are sharing the context with other applications, it might
  36315. * be interested to not cache the unpack flip y state to ensure a consistent
  36316. * value would be set.
  36317. */
  36318. enableUnpackFlipYCached: boolean;
  36319. /** @hidden */
  36320. _unpackFlipY(value: boolean): void;
  36321. /** @hidden */
  36322. _getUnpackAlignement(): number;
  36323. private _getTextureTarget;
  36324. /**
  36325. * Update the sampling mode of a given texture
  36326. * @param samplingMode defines the required sampling mode
  36327. * @param texture defines the texture to update
  36328. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36329. */
  36330. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36331. /**
  36332. * Update the sampling mode of a given texture
  36333. * @param texture defines the texture to update
  36334. * @param wrapU defines the texture wrap mode of the u coordinates
  36335. * @param wrapV defines the texture wrap mode of the v coordinates
  36336. * @param wrapR defines the texture wrap mode of the r coordinates
  36337. */
  36338. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36339. /** @hidden */
  36340. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36341. width: number;
  36342. height: number;
  36343. layers?: number;
  36344. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36345. /** @hidden */
  36346. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36347. /** @hidden */
  36348. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36349. /**
  36350. * Update a portion of an internal texture
  36351. * @param texture defines the texture to update
  36352. * @param imageData defines the data to store into the texture
  36353. * @param xOffset defines the x coordinates of the update rectangle
  36354. * @param yOffset defines the y coordinates of the update rectangle
  36355. * @param width defines the width of the update rectangle
  36356. * @param height defines the height of the update rectangle
  36357. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36358. * @param lod defines the lod level to update (0 by default)
  36359. */
  36360. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36361. /** @hidden */
  36362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36363. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36364. private _prepareWebGLTexture;
  36365. /** @hidden */
  36366. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36367. private _getDepthStencilBuffer;
  36368. /** @hidden */
  36369. _releaseFramebufferObjects(texture: InternalTexture): void;
  36370. /** @hidden */
  36371. _releaseTexture(texture: InternalTexture): void;
  36372. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36373. protected _setProgram(program: WebGLProgram): void;
  36374. protected _boundUniforms: {
  36375. [key: number]: WebGLUniformLocation;
  36376. };
  36377. /**
  36378. * Binds an effect to the webGL context
  36379. * @param effect defines the effect to bind
  36380. */
  36381. bindSamplers(effect: Effect): void;
  36382. private _activateCurrentTexture;
  36383. /** @hidden */
  36384. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36385. /** @hidden */
  36386. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36387. /**
  36388. * Unbind all textures from the webGL context
  36389. */
  36390. unbindAllTextures(): void;
  36391. /**
  36392. * Sets a texture to the according uniform.
  36393. * @param channel The texture channel
  36394. * @param uniform The uniform to set
  36395. * @param texture The texture to apply
  36396. */
  36397. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36398. private _bindSamplerUniformToChannel;
  36399. private _getTextureWrapMode;
  36400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36401. /**
  36402. * Sets an array of texture to the webGL context
  36403. * @param channel defines the channel where the texture array must be set
  36404. * @param uniform defines the associated uniform location
  36405. * @param textures defines the array of textures to bind
  36406. */
  36407. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36408. /** @hidden */
  36409. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36410. private _setTextureParameterFloat;
  36411. private _setTextureParameterInteger;
  36412. /**
  36413. * Unbind all vertex attributes from the webGL context
  36414. */
  36415. unbindAllAttributes(): void;
  36416. /**
  36417. * 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
  36418. */
  36419. releaseEffects(): void;
  36420. /**
  36421. * Dispose and release all associated resources
  36422. */
  36423. dispose(): void;
  36424. /**
  36425. * Attach a new callback raised when context lost event is fired
  36426. * @param callback defines the callback to call
  36427. */
  36428. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36429. /**
  36430. * Attach a new callback raised when context restored event is fired
  36431. * @param callback defines the callback to call
  36432. */
  36433. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36434. /**
  36435. * Get the current error code of the webGL context
  36436. * @returns the error code
  36437. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36438. */
  36439. getError(): number;
  36440. private _canRenderToFloatFramebuffer;
  36441. private _canRenderToHalfFloatFramebuffer;
  36442. private _canRenderToFramebuffer;
  36443. /** @hidden */
  36444. _getWebGLTextureType(type: number): number;
  36445. /** @hidden */
  36446. _getInternalFormat(format: number): number;
  36447. /** @hidden */
  36448. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36449. /** @hidden */
  36450. _getRGBAMultiSampleBufferFormat(type: number): number;
  36451. /** @hidden */
  36452. _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;
  36453. /**
  36454. * Loads a file from a url
  36455. * @param url url to load
  36456. * @param onSuccess callback called when the file successfully loads
  36457. * @param onProgress callback called while file is loading (if the server supports this mode)
  36458. * @param offlineProvider defines the offline provider for caching
  36459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36460. * @param onError callback called when the file fails to load
  36461. * @returns a file request object
  36462. * @hidden
  36463. */
  36464. 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;
  36465. /**
  36466. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36467. * @param x defines the x coordinate of the rectangle where pixels must be read
  36468. * @param y defines the y coordinate of the rectangle where pixels must be read
  36469. * @param width defines the width of the rectangle where pixels must be read
  36470. * @param height defines the height of the rectangle where pixels must be read
  36471. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36472. * @returns a Uint8Array containing RGBA colors
  36473. */
  36474. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36475. private static _isSupported;
  36476. /**
  36477. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36478. * @returns true if the engine can be created
  36479. * @ignorenaming
  36480. */
  36481. static isSupported(): boolean;
  36482. /**
  36483. * Find the next highest power of two.
  36484. * @param x Number to start search from.
  36485. * @return Next highest power of two.
  36486. */
  36487. static CeilingPOT(x: number): number;
  36488. /**
  36489. * Find the next lowest power of two.
  36490. * @param x Number to start search from.
  36491. * @return Next lowest power of two.
  36492. */
  36493. static FloorPOT(x: number): number;
  36494. /**
  36495. * Find the nearest power of two.
  36496. * @param x Number to start search from.
  36497. * @return Next nearest power of two.
  36498. */
  36499. static NearestPOT(x: number): number;
  36500. /**
  36501. * Get the closest exponent of two
  36502. * @param value defines the value to approximate
  36503. * @param max defines the maximum value to return
  36504. * @param mode defines how to define the closest value
  36505. * @returns closest exponent of two of the given value
  36506. */
  36507. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36508. /**
  36509. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36510. * @param func - the function to be called
  36511. * @param requester - the object that will request the next frame. Falls back to window.
  36512. * @returns frame number
  36513. */
  36514. static QueueNewFrame(func: () => void, requester?: any): number;
  36515. /**
  36516. * Gets host document
  36517. * @returns the host document object
  36518. */
  36519. getHostDocument(): Nullable<Document>;
  36520. }
  36521. }
  36522. declare module "babylonjs/Maths/sphericalPolynomial" {
  36523. import { Vector3 } from "babylonjs/Maths/math.vector";
  36524. import { Color3 } from "babylonjs/Maths/math.color";
  36525. /**
  36526. * Class representing spherical harmonics coefficients to the 3rd degree
  36527. */
  36528. export class SphericalHarmonics {
  36529. /**
  36530. * Defines whether or not the harmonics have been prescaled for rendering.
  36531. */
  36532. preScaled: boolean;
  36533. /**
  36534. * The l0,0 coefficients of the spherical harmonics
  36535. */
  36536. l00: Vector3;
  36537. /**
  36538. * The l1,-1 coefficients of the spherical harmonics
  36539. */
  36540. l1_1: Vector3;
  36541. /**
  36542. * The l1,0 coefficients of the spherical harmonics
  36543. */
  36544. l10: Vector3;
  36545. /**
  36546. * The l1,1 coefficients of the spherical harmonics
  36547. */
  36548. l11: Vector3;
  36549. /**
  36550. * The l2,-2 coefficients of the spherical harmonics
  36551. */
  36552. l2_2: Vector3;
  36553. /**
  36554. * The l2,-1 coefficients of the spherical harmonics
  36555. */
  36556. l2_1: Vector3;
  36557. /**
  36558. * The l2,0 coefficients of the spherical harmonics
  36559. */
  36560. l20: Vector3;
  36561. /**
  36562. * The l2,1 coefficients of the spherical harmonics
  36563. */
  36564. l21: Vector3;
  36565. /**
  36566. * The l2,2 coefficients of the spherical harmonics
  36567. */
  36568. l22: Vector3;
  36569. /**
  36570. * Adds a light to the spherical harmonics
  36571. * @param direction the direction of the light
  36572. * @param color the color of the light
  36573. * @param deltaSolidAngle the delta solid angle of the light
  36574. */
  36575. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36576. /**
  36577. * Scales the spherical harmonics by the given amount
  36578. * @param scale the amount to scale
  36579. */
  36580. scaleInPlace(scale: number): void;
  36581. /**
  36582. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36583. *
  36584. * ```
  36585. * E_lm = A_l * L_lm
  36586. * ```
  36587. *
  36588. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36589. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36590. * the scaling factors are given in equation 9.
  36591. */
  36592. convertIncidentRadianceToIrradiance(): void;
  36593. /**
  36594. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36595. *
  36596. * ```
  36597. * L = (1/pi) * E * rho
  36598. * ```
  36599. *
  36600. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36601. */
  36602. convertIrradianceToLambertianRadiance(): void;
  36603. /**
  36604. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36605. * required operations at run time.
  36606. *
  36607. * This is simply done by scaling back the SH with Ylm constants parameter.
  36608. * The trigonometric part being applied by the shader at run time.
  36609. */
  36610. preScaleForRendering(): void;
  36611. /**
  36612. * Constructs a spherical harmonics from an array.
  36613. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36614. * @returns the spherical harmonics
  36615. */
  36616. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36617. /**
  36618. * Gets the spherical harmonics from polynomial
  36619. * @param polynomial the spherical polynomial
  36620. * @returns the spherical harmonics
  36621. */
  36622. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36623. }
  36624. /**
  36625. * Class representing spherical polynomial coefficients to the 3rd degree
  36626. */
  36627. export class SphericalPolynomial {
  36628. private _harmonics;
  36629. /**
  36630. * The spherical harmonics used to create the polynomials.
  36631. */
  36632. get preScaledHarmonics(): SphericalHarmonics;
  36633. /**
  36634. * The x coefficients of the spherical polynomial
  36635. */
  36636. x: Vector3;
  36637. /**
  36638. * The y coefficients of the spherical polynomial
  36639. */
  36640. y: Vector3;
  36641. /**
  36642. * The z coefficients of the spherical polynomial
  36643. */
  36644. z: Vector3;
  36645. /**
  36646. * The xx coefficients of the spherical polynomial
  36647. */
  36648. xx: Vector3;
  36649. /**
  36650. * The yy coefficients of the spherical polynomial
  36651. */
  36652. yy: Vector3;
  36653. /**
  36654. * The zz coefficients of the spherical polynomial
  36655. */
  36656. zz: Vector3;
  36657. /**
  36658. * The xy coefficients of the spherical polynomial
  36659. */
  36660. xy: Vector3;
  36661. /**
  36662. * The yz coefficients of the spherical polynomial
  36663. */
  36664. yz: Vector3;
  36665. /**
  36666. * The zx coefficients of the spherical polynomial
  36667. */
  36668. zx: Vector3;
  36669. /**
  36670. * Adds an ambient color to the spherical polynomial
  36671. * @param color the color to add
  36672. */
  36673. addAmbient(color: Color3): void;
  36674. /**
  36675. * Scales the spherical polynomial by the given amount
  36676. * @param scale the amount to scale
  36677. */
  36678. scaleInPlace(scale: number): void;
  36679. /**
  36680. * Gets the spherical polynomial from harmonics
  36681. * @param harmonics the spherical harmonics
  36682. * @returns the spherical polynomial
  36683. */
  36684. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36685. /**
  36686. * Constructs a spherical polynomial from an array.
  36687. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36688. * @returns the spherical polynomial
  36689. */
  36690. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36691. }
  36692. }
  36693. declare module "babylonjs/Materials/Textures/internalTexture" {
  36694. import { Observable } from "babylonjs/Misc/observable";
  36695. import { Nullable, int } from "babylonjs/types";
  36696. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36698. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36699. /**
  36700. * Defines the source of the internal texture
  36701. */
  36702. export enum InternalTextureSource {
  36703. /**
  36704. * The source of the texture data is unknown
  36705. */
  36706. Unknown = 0,
  36707. /**
  36708. * Texture data comes from an URL
  36709. */
  36710. Url = 1,
  36711. /**
  36712. * Texture data is only used for temporary storage
  36713. */
  36714. Temp = 2,
  36715. /**
  36716. * Texture data comes from raw data (ArrayBuffer)
  36717. */
  36718. Raw = 3,
  36719. /**
  36720. * Texture content is dynamic (video or dynamic texture)
  36721. */
  36722. Dynamic = 4,
  36723. /**
  36724. * Texture content is generated by rendering to it
  36725. */
  36726. RenderTarget = 5,
  36727. /**
  36728. * Texture content is part of a multi render target process
  36729. */
  36730. MultiRenderTarget = 6,
  36731. /**
  36732. * Texture data comes from a cube data file
  36733. */
  36734. Cube = 7,
  36735. /**
  36736. * Texture data comes from a raw cube data
  36737. */
  36738. CubeRaw = 8,
  36739. /**
  36740. * Texture data come from a prefiltered cube data file
  36741. */
  36742. CubePrefiltered = 9,
  36743. /**
  36744. * Texture content is raw 3D data
  36745. */
  36746. Raw3D = 10,
  36747. /**
  36748. * Texture content is raw 2D array data
  36749. */
  36750. Raw2DArray = 11,
  36751. /**
  36752. * Texture content is a depth texture
  36753. */
  36754. Depth = 12,
  36755. /**
  36756. * Texture data comes from a raw cube data encoded with RGBD
  36757. */
  36758. CubeRawRGBD = 13
  36759. }
  36760. /**
  36761. * Class used to store data associated with WebGL texture data for the engine
  36762. * This class should not be used directly
  36763. */
  36764. export class InternalTexture {
  36765. /** @hidden */
  36766. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36767. /**
  36768. * Defines if the texture is ready
  36769. */
  36770. isReady: boolean;
  36771. /**
  36772. * Defines if the texture is a cube texture
  36773. */
  36774. isCube: boolean;
  36775. /**
  36776. * Defines if the texture contains 3D data
  36777. */
  36778. is3D: boolean;
  36779. /**
  36780. * Defines if the texture contains 2D array data
  36781. */
  36782. is2DArray: boolean;
  36783. /**
  36784. * Defines if the texture contains multiview data
  36785. */
  36786. isMultiview: boolean;
  36787. /**
  36788. * Gets the URL used to load this texture
  36789. */
  36790. url: string;
  36791. /**
  36792. * Gets the sampling mode of the texture
  36793. */
  36794. samplingMode: number;
  36795. /**
  36796. * Gets a boolean indicating if the texture needs mipmaps generation
  36797. */
  36798. generateMipMaps: boolean;
  36799. /**
  36800. * Gets the number of samples used by the texture (WebGL2+ only)
  36801. */
  36802. samples: number;
  36803. /**
  36804. * Gets the type of the texture (int, float...)
  36805. */
  36806. type: number;
  36807. /**
  36808. * Gets the format of the texture (RGB, RGBA...)
  36809. */
  36810. format: number;
  36811. /**
  36812. * Observable called when the texture is loaded
  36813. */
  36814. onLoadedObservable: Observable<InternalTexture>;
  36815. /**
  36816. * Gets the width of the texture
  36817. */
  36818. width: number;
  36819. /**
  36820. * Gets the height of the texture
  36821. */
  36822. height: number;
  36823. /**
  36824. * Gets the depth of the texture
  36825. */
  36826. depth: number;
  36827. /**
  36828. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36829. */
  36830. baseWidth: number;
  36831. /**
  36832. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36833. */
  36834. baseHeight: number;
  36835. /**
  36836. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36837. */
  36838. baseDepth: number;
  36839. /**
  36840. * Gets a boolean indicating if the texture is inverted on Y axis
  36841. */
  36842. invertY: boolean;
  36843. /** @hidden */
  36844. _invertVScale: boolean;
  36845. /** @hidden */
  36846. _associatedChannel: number;
  36847. /** @hidden */
  36848. _source: InternalTextureSource;
  36849. /** @hidden */
  36850. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36851. /** @hidden */
  36852. _bufferView: Nullable<ArrayBufferView>;
  36853. /** @hidden */
  36854. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36855. /** @hidden */
  36856. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36857. /** @hidden */
  36858. _size: number;
  36859. /** @hidden */
  36860. _extension: string;
  36861. /** @hidden */
  36862. _files: Nullable<string[]>;
  36863. /** @hidden */
  36864. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36865. /** @hidden */
  36866. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36867. /** @hidden */
  36868. _framebuffer: Nullable<WebGLFramebuffer>;
  36869. /** @hidden */
  36870. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36871. /** @hidden */
  36872. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36873. /** @hidden */
  36874. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36875. /** @hidden */
  36876. _attachments: Nullable<number[]>;
  36877. /** @hidden */
  36878. _cachedCoordinatesMode: Nullable<number>;
  36879. /** @hidden */
  36880. _cachedWrapU: Nullable<number>;
  36881. /** @hidden */
  36882. _cachedWrapV: Nullable<number>;
  36883. /** @hidden */
  36884. _cachedWrapR: Nullable<number>;
  36885. /** @hidden */
  36886. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36887. /** @hidden */
  36888. _isDisabled: boolean;
  36889. /** @hidden */
  36890. _compression: Nullable<string>;
  36891. /** @hidden */
  36892. _generateStencilBuffer: boolean;
  36893. /** @hidden */
  36894. _generateDepthBuffer: boolean;
  36895. /** @hidden */
  36896. _comparisonFunction: number;
  36897. /** @hidden */
  36898. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36899. /** @hidden */
  36900. _lodGenerationScale: number;
  36901. /** @hidden */
  36902. _lodGenerationOffset: number;
  36903. /** @hidden */
  36904. _depthStencilTexture: Nullable<InternalTexture>;
  36905. /** @hidden */
  36906. _colorTextureArray: Nullable<WebGLTexture>;
  36907. /** @hidden */
  36908. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36909. /** @hidden */
  36910. _lodTextureHigh: Nullable<BaseTexture>;
  36911. /** @hidden */
  36912. _lodTextureMid: Nullable<BaseTexture>;
  36913. /** @hidden */
  36914. _lodTextureLow: Nullable<BaseTexture>;
  36915. /** @hidden */
  36916. _isRGBD: boolean;
  36917. /** @hidden */
  36918. _linearSpecularLOD: boolean;
  36919. /** @hidden */
  36920. _irradianceTexture: Nullable<BaseTexture>;
  36921. /** @hidden */
  36922. _webGLTexture: Nullable<WebGLTexture>;
  36923. /** @hidden */
  36924. _references: number;
  36925. private _engine;
  36926. /**
  36927. * Gets the Engine the texture belongs to.
  36928. * @returns The babylon engine
  36929. */
  36930. getEngine(): ThinEngine;
  36931. /**
  36932. * Gets the data source type of the texture
  36933. */
  36934. get source(): InternalTextureSource;
  36935. /**
  36936. * Creates a new InternalTexture
  36937. * @param engine defines the engine to use
  36938. * @param source defines the type of data that will be used
  36939. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36940. */
  36941. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36942. /**
  36943. * Increments the number of references (ie. the number of Texture that point to it)
  36944. */
  36945. incrementReferences(): void;
  36946. /**
  36947. * Change the size of the texture (not the size of the content)
  36948. * @param width defines the new width
  36949. * @param height defines the new height
  36950. * @param depth defines the new depth (1 by default)
  36951. */
  36952. updateSize(width: int, height: int, depth?: int): void;
  36953. /** @hidden */
  36954. _rebuild(): void;
  36955. /** @hidden */
  36956. _swapAndDie(target: InternalTexture): void;
  36957. /**
  36958. * Dispose the current allocated resources
  36959. */
  36960. dispose(): void;
  36961. }
  36962. }
  36963. declare module "babylonjs/Audio/analyser" {
  36964. import { Scene } from "babylonjs/scene";
  36965. /**
  36966. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36968. */
  36969. export class Analyser {
  36970. /**
  36971. * Gets or sets the smoothing
  36972. * @ignorenaming
  36973. */
  36974. SMOOTHING: number;
  36975. /**
  36976. * Gets or sets the FFT table size
  36977. * @ignorenaming
  36978. */
  36979. FFT_SIZE: number;
  36980. /**
  36981. * Gets or sets the bar graph amplitude
  36982. * @ignorenaming
  36983. */
  36984. BARGRAPHAMPLITUDE: number;
  36985. /**
  36986. * Gets or sets the position of the debug canvas
  36987. * @ignorenaming
  36988. */
  36989. DEBUGCANVASPOS: {
  36990. x: number;
  36991. y: number;
  36992. };
  36993. /**
  36994. * Gets or sets the debug canvas size
  36995. * @ignorenaming
  36996. */
  36997. DEBUGCANVASSIZE: {
  36998. width: number;
  36999. height: number;
  37000. };
  37001. private _byteFreqs;
  37002. private _byteTime;
  37003. private _floatFreqs;
  37004. private _webAudioAnalyser;
  37005. private _debugCanvas;
  37006. private _debugCanvasContext;
  37007. private _scene;
  37008. private _registerFunc;
  37009. private _audioEngine;
  37010. /**
  37011. * Creates a new analyser
  37012. * @param scene defines hosting scene
  37013. */
  37014. constructor(scene: Scene);
  37015. /**
  37016. * Get the number of data values you will have to play with for the visualization
  37017. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37018. * @returns a number
  37019. */
  37020. getFrequencyBinCount(): number;
  37021. /**
  37022. * Gets the current frequency data as a byte array
  37023. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37024. * @returns a Uint8Array
  37025. */
  37026. getByteFrequencyData(): Uint8Array;
  37027. /**
  37028. * Gets the current waveform as a byte array
  37029. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37030. * @returns a Uint8Array
  37031. */
  37032. getByteTimeDomainData(): Uint8Array;
  37033. /**
  37034. * Gets the current frequency data as a float array
  37035. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37036. * @returns a Float32Array
  37037. */
  37038. getFloatFrequencyData(): Float32Array;
  37039. /**
  37040. * Renders the debug canvas
  37041. */
  37042. drawDebugCanvas(): void;
  37043. /**
  37044. * Stops rendering the debug canvas and removes it
  37045. */
  37046. stopDebugCanvas(): void;
  37047. /**
  37048. * Connects two audio nodes
  37049. * @param inputAudioNode defines first node to connect
  37050. * @param outputAudioNode defines second node to connect
  37051. */
  37052. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37053. /**
  37054. * Releases all associated resources
  37055. */
  37056. dispose(): void;
  37057. }
  37058. }
  37059. declare module "babylonjs/Audio/audioEngine" {
  37060. import { IDisposable } from "babylonjs/scene";
  37061. import { Analyser } from "babylonjs/Audio/analyser";
  37062. import { Nullable } from "babylonjs/types";
  37063. import { Observable } from "babylonjs/Misc/observable";
  37064. /**
  37065. * This represents an audio engine and it is responsible
  37066. * to play, synchronize and analyse sounds throughout the application.
  37067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37068. */
  37069. export interface IAudioEngine extends IDisposable {
  37070. /**
  37071. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37072. */
  37073. readonly canUseWebAudio: boolean;
  37074. /**
  37075. * Gets the current AudioContext if available.
  37076. */
  37077. readonly audioContext: Nullable<AudioContext>;
  37078. /**
  37079. * The master gain node defines the global audio volume of your audio engine.
  37080. */
  37081. readonly masterGain: GainNode;
  37082. /**
  37083. * Gets whether or not mp3 are supported by your browser.
  37084. */
  37085. readonly isMP3supported: boolean;
  37086. /**
  37087. * Gets whether or not ogg are supported by your browser.
  37088. */
  37089. readonly isOGGsupported: boolean;
  37090. /**
  37091. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37092. * @ignoreNaming
  37093. */
  37094. WarnedWebAudioUnsupported: boolean;
  37095. /**
  37096. * Defines if the audio engine relies on a custom unlocked button.
  37097. * In this case, the embedded button will not be displayed.
  37098. */
  37099. useCustomUnlockedButton: boolean;
  37100. /**
  37101. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37102. */
  37103. readonly unlocked: boolean;
  37104. /**
  37105. * Event raised when audio has been unlocked on the browser.
  37106. */
  37107. onAudioUnlockedObservable: Observable<AudioEngine>;
  37108. /**
  37109. * Event raised when audio has been locked on the browser.
  37110. */
  37111. onAudioLockedObservable: Observable<AudioEngine>;
  37112. /**
  37113. * Flags the audio engine in Locked state.
  37114. * This happens due to new browser policies preventing audio to autoplay.
  37115. */
  37116. lock(): void;
  37117. /**
  37118. * Unlocks the audio engine once a user action has been done on the dom.
  37119. * This is helpful to resume play once browser policies have been satisfied.
  37120. */
  37121. unlock(): void;
  37122. /**
  37123. * Gets the global volume sets on the master gain.
  37124. * @returns the global volume if set or -1 otherwise
  37125. */
  37126. getGlobalVolume(): number;
  37127. /**
  37128. * Sets the global volume of your experience (sets on the master gain).
  37129. * @param newVolume Defines the new global volume of the application
  37130. */
  37131. setGlobalVolume(newVolume: number): void;
  37132. /**
  37133. * Connect the audio engine to an audio analyser allowing some amazing
  37134. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37136. * @param analyser The analyser to connect to the engine
  37137. */
  37138. connectToAnalyser(analyser: Analyser): void;
  37139. }
  37140. /**
  37141. * This represents the default audio engine used in babylon.
  37142. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37144. */
  37145. export class AudioEngine implements IAudioEngine {
  37146. private _audioContext;
  37147. private _audioContextInitialized;
  37148. private _muteButton;
  37149. private _hostElement;
  37150. /**
  37151. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37152. */
  37153. canUseWebAudio: boolean;
  37154. /**
  37155. * The master gain node defines the global audio volume of your audio engine.
  37156. */
  37157. masterGain: GainNode;
  37158. /**
  37159. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37160. * @ignoreNaming
  37161. */
  37162. WarnedWebAudioUnsupported: boolean;
  37163. /**
  37164. * Gets whether or not mp3 are supported by your browser.
  37165. */
  37166. isMP3supported: boolean;
  37167. /**
  37168. * Gets whether or not ogg are supported by your browser.
  37169. */
  37170. isOGGsupported: boolean;
  37171. /**
  37172. * Gets whether audio has been unlocked on the device.
  37173. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37174. * a user interaction has happened.
  37175. */
  37176. unlocked: boolean;
  37177. /**
  37178. * Defines if the audio engine relies on a custom unlocked button.
  37179. * In this case, the embedded button will not be displayed.
  37180. */
  37181. useCustomUnlockedButton: boolean;
  37182. /**
  37183. * Event raised when audio has been unlocked on the browser.
  37184. */
  37185. onAudioUnlockedObservable: Observable<AudioEngine>;
  37186. /**
  37187. * Event raised when audio has been locked on the browser.
  37188. */
  37189. onAudioLockedObservable: Observable<AudioEngine>;
  37190. /**
  37191. * Gets the current AudioContext if available.
  37192. */
  37193. get audioContext(): Nullable<AudioContext>;
  37194. private _connectedAnalyser;
  37195. /**
  37196. * Instantiates a new audio engine.
  37197. *
  37198. * There should be only one per page as some browsers restrict the number
  37199. * of audio contexts you can create.
  37200. * @param hostElement defines the host element where to display the mute icon if necessary
  37201. */
  37202. constructor(hostElement?: Nullable<HTMLElement>);
  37203. /**
  37204. * Flags the audio engine in Locked state.
  37205. * This happens due to new browser policies preventing audio to autoplay.
  37206. */
  37207. lock(): void;
  37208. /**
  37209. * Unlocks the audio engine once a user action has been done on the dom.
  37210. * This is helpful to resume play once browser policies have been satisfied.
  37211. */
  37212. unlock(): void;
  37213. private _resumeAudioContext;
  37214. private _initializeAudioContext;
  37215. private _tryToRun;
  37216. private _triggerRunningState;
  37217. private _triggerSuspendedState;
  37218. private _displayMuteButton;
  37219. private _moveButtonToTopLeft;
  37220. private _onResize;
  37221. private _hideMuteButton;
  37222. /**
  37223. * Destroy and release the resources associated with the audio ccontext.
  37224. */
  37225. dispose(): void;
  37226. /**
  37227. * Gets the global volume sets on the master gain.
  37228. * @returns the global volume if set or -1 otherwise
  37229. */
  37230. getGlobalVolume(): number;
  37231. /**
  37232. * Sets the global volume of your experience (sets on the master gain).
  37233. * @param newVolume Defines the new global volume of the application
  37234. */
  37235. setGlobalVolume(newVolume: number): void;
  37236. /**
  37237. * Connect the audio engine to an audio analyser allowing some amazing
  37238. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37240. * @param analyser The analyser to connect to the engine
  37241. */
  37242. connectToAnalyser(analyser: Analyser): void;
  37243. }
  37244. }
  37245. declare module "babylonjs/Loading/loadingScreen" {
  37246. /**
  37247. * Interface used to present a loading screen while loading a scene
  37248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37249. */
  37250. export interface ILoadingScreen {
  37251. /**
  37252. * Function called to display the loading screen
  37253. */
  37254. displayLoadingUI: () => void;
  37255. /**
  37256. * Function called to hide the loading screen
  37257. */
  37258. hideLoadingUI: () => void;
  37259. /**
  37260. * Gets or sets the color to use for the background
  37261. */
  37262. loadingUIBackgroundColor: string;
  37263. /**
  37264. * Gets or sets the text to display while loading
  37265. */
  37266. loadingUIText: string;
  37267. }
  37268. /**
  37269. * Class used for the default loading screen
  37270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37271. */
  37272. export class DefaultLoadingScreen implements ILoadingScreen {
  37273. private _renderingCanvas;
  37274. private _loadingText;
  37275. private _loadingDivBackgroundColor;
  37276. private _loadingDiv;
  37277. private _loadingTextDiv;
  37278. /** Gets or sets the logo url to use for the default loading screen */
  37279. static DefaultLogoUrl: string;
  37280. /** Gets or sets the spinner url to use for the default loading screen */
  37281. static DefaultSpinnerUrl: string;
  37282. /**
  37283. * Creates a new default loading screen
  37284. * @param _renderingCanvas defines the canvas used to render the scene
  37285. * @param _loadingText defines the default text to display
  37286. * @param _loadingDivBackgroundColor defines the default background color
  37287. */
  37288. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37289. /**
  37290. * Function called to display the loading screen
  37291. */
  37292. displayLoadingUI(): void;
  37293. /**
  37294. * Function called to hide the loading screen
  37295. */
  37296. hideLoadingUI(): void;
  37297. /**
  37298. * Gets or sets the text to display while loading
  37299. */
  37300. set loadingUIText(text: string);
  37301. get loadingUIText(): string;
  37302. /**
  37303. * Gets or sets the color to use for the background
  37304. */
  37305. get loadingUIBackgroundColor(): string;
  37306. set loadingUIBackgroundColor(color: string);
  37307. private _resizeLoadingUI;
  37308. }
  37309. }
  37310. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37311. /**
  37312. * Interface for any object that can request an animation frame
  37313. */
  37314. export interface ICustomAnimationFrameRequester {
  37315. /**
  37316. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37317. */
  37318. renderFunction?: Function;
  37319. /**
  37320. * Called to request the next frame to render to
  37321. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37322. */
  37323. requestAnimationFrame: Function;
  37324. /**
  37325. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37326. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37327. */
  37328. requestID?: number;
  37329. }
  37330. }
  37331. declare module "babylonjs/Misc/performanceMonitor" {
  37332. /**
  37333. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37334. */
  37335. export class PerformanceMonitor {
  37336. private _enabled;
  37337. private _rollingFrameTime;
  37338. private _lastFrameTimeMs;
  37339. /**
  37340. * constructor
  37341. * @param frameSampleSize The number of samples required to saturate the sliding window
  37342. */
  37343. constructor(frameSampleSize?: number);
  37344. /**
  37345. * Samples current frame
  37346. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37347. */
  37348. sampleFrame(timeMs?: number): void;
  37349. /**
  37350. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37351. */
  37352. get averageFrameTime(): number;
  37353. /**
  37354. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37355. */
  37356. get averageFrameTimeVariance(): number;
  37357. /**
  37358. * Returns the frame time of the most recent frame
  37359. */
  37360. get instantaneousFrameTime(): number;
  37361. /**
  37362. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37363. */
  37364. get averageFPS(): number;
  37365. /**
  37366. * Returns the average framerate in frames per second using the most recent frame time
  37367. */
  37368. get instantaneousFPS(): number;
  37369. /**
  37370. * Returns true if enough samples have been taken to completely fill the sliding window
  37371. */
  37372. get isSaturated(): boolean;
  37373. /**
  37374. * Enables contributions to the sliding window sample set
  37375. */
  37376. enable(): void;
  37377. /**
  37378. * Disables contributions to the sliding window sample set
  37379. * Samples will not be interpolated over the disabled period
  37380. */
  37381. disable(): void;
  37382. /**
  37383. * Returns true if sampling is enabled
  37384. */
  37385. get isEnabled(): boolean;
  37386. /**
  37387. * Resets performance monitor
  37388. */
  37389. reset(): void;
  37390. }
  37391. /**
  37392. * RollingAverage
  37393. *
  37394. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37395. */
  37396. export class RollingAverage {
  37397. /**
  37398. * Current average
  37399. */
  37400. average: number;
  37401. /**
  37402. * Current variance
  37403. */
  37404. variance: number;
  37405. protected _samples: Array<number>;
  37406. protected _sampleCount: number;
  37407. protected _pos: number;
  37408. protected _m2: number;
  37409. /**
  37410. * constructor
  37411. * @param length The number of samples required to saturate the sliding window
  37412. */
  37413. constructor(length: number);
  37414. /**
  37415. * Adds a sample to the sample set
  37416. * @param v The sample value
  37417. */
  37418. add(v: number): void;
  37419. /**
  37420. * Returns previously added values or null if outside of history or outside the sliding window domain
  37421. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37422. * @return Value previously recorded with add() or null if outside of range
  37423. */
  37424. history(i: number): number;
  37425. /**
  37426. * Returns true if enough samples have been taken to completely fill the sliding window
  37427. * @return true if sample-set saturated
  37428. */
  37429. isSaturated(): boolean;
  37430. /**
  37431. * Resets the rolling average (equivalent to 0 samples taken so far)
  37432. */
  37433. reset(): void;
  37434. /**
  37435. * Wraps a value around the sample range boundaries
  37436. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37437. * @return Wrapped position in sample range
  37438. */
  37439. protected _wrapPosition(i: number): number;
  37440. }
  37441. }
  37442. declare module "babylonjs/Misc/perfCounter" {
  37443. /**
  37444. * This class is used to track a performance counter which is number based.
  37445. * The user has access to many properties which give statistics of different nature.
  37446. *
  37447. * The implementer can track two kinds of Performance Counter: time and count.
  37448. * 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.
  37449. * 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.
  37450. */
  37451. export class PerfCounter {
  37452. /**
  37453. * Gets or sets a global boolean to turn on and off all the counters
  37454. */
  37455. static Enabled: boolean;
  37456. /**
  37457. * Returns the smallest value ever
  37458. */
  37459. get min(): number;
  37460. /**
  37461. * Returns the biggest value ever
  37462. */
  37463. get max(): number;
  37464. /**
  37465. * Returns the average value since the performance counter is running
  37466. */
  37467. get average(): number;
  37468. /**
  37469. * Returns the average value of the last second the counter was monitored
  37470. */
  37471. get lastSecAverage(): number;
  37472. /**
  37473. * Returns the current value
  37474. */
  37475. get current(): number;
  37476. /**
  37477. * Gets the accumulated total
  37478. */
  37479. get total(): number;
  37480. /**
  37481. * Gets the total value count
  37482. */
  37483. get count(): number;
  37484. /**
  37485. * Creates a new counter
  37486. */
  37487. constructor();
  37488. /**
  37489. * Call this method to start monitoring a new frame.
  37490. * 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.
  37491. */
  37492. fetchNewFrame(): void;
  37493. /**
  37494. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37495. * @param newCount the count value to add to the monitored count
  37496. * @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.
  37497. */
  37498. addCount(newCount: number, fetchResult: boolean): void;
  37499. /**
  37500. * Start monitoring this performance counter
  37501. */
  37502. beginMonitoring(): void;
  37503. /**
  37504. * Compute the time lapsed since the previous beginMonitoring() call.
  37505. * @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
  37506. */
  37507. endMonitoring(newFrame?: boolean): void;
  37508. private _fetchResult;
  37509. private _startMonitoringTime;
  37510. private _min;
  37511. private _max;
  37512. private _average;
  37513. private _current;
  37514. private _totalValueCount;
  37515. private _totalAccumulated;
  37516. private _lastSecAverage;
  37517. private _lastSecAccumulated;
  37518. private _lastSecTime;
  37519. private _lastSecValueCount;
  37520. }
  37521. }
  37522. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37523. module "babylonjs/Engines/thinEngine" {
  37524. interface ThinEngine {
  37525. /**
  37526. * Sets alpha constants used by some alpha blending modes
  37527. * @param r defines the red component
  37528. * @param g defines the green component
  37529. * @param b defines the blue component
  37530. * @param a defines the alpha component
  37531. */
  37532. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37533. /**
  37534. * Sets the current alpha mode
  37535. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37536. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37537. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37538. */
  37539. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37540. /**
  37541. * Gets the current alpha mode
  37542. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37543. * @returns the current alpha mode
  37544. */
  37545. getAlphaMode(): number;
  37546. /**
  37547. * Sets the current alpha equation
  37548. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37549. */
  37550. setAlphaEquation(equation: number): void;
  37551. /**
  37552. * Gets the current alpha equation.
  37553. * @returns the current alpha equation
  37554. */
  37555. getAlphaEquation(): number;
  37556. }
  37557. }
  37558. }
  37559. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37561. import { Nullable } from "babylonjs/types";
  37562. module "babylonjs/Engines/thinEngine" {
  37563. interface ThinEngine {
  37564. /** @hidden */
  37565. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37566. }
  37567. }
  37568. }
  37569. declare module "babylonjs/Engines/engine" {
  37570. import { Observable } from "babylonjs/Misc/observable";
  37571. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37572. import { Scene } from "babylonjs/scene";
  37573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37574. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37575. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37576. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37577. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37578. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37579. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37580. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37581. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37583. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37584. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37585. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37586. import "babylonjs/Engines/Extensions/engine.alpha";
  37587. import "babylonjs/Engines/Extensions/engine.readTexture";
  37588. import { Material } from "babylonjs/Materials/material";
  37589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37590. /**
  37591. * Defines the interface used by display changed events
  37592. */
  37593. export interface IDisplayChangedEventArgs {
  37594. /** Gets the vrDisplay object (if any) */
  37595. vrDisplay: Nullable<any>;
  37596. /** Gets a boolean indicating if webVR is supported */
  37597. vrSupported: boolean;
  37598. }
  37599. /**
  37600. * Defines the interface used by objects containing a viewport (like a camera)
  37601. */
  37602. interface IViewportOwnerLike {
  37603. /**
  37604. * Gets or sets the viewport
  37605. */
  37606. viewport: IViewportLike;
  37607. }
  37608. /**
  37609. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37610. */
  37611. export class Engine extends ThinEngine {
  37612. /** Defines that alpha blending is disabled */
  37613. static readonly ALPHA_DISABLE: number;
  37614. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37615. static readonly ALPHA_ADD: number;
  37616. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37617. static readonly ALPHA_COMBINE: number;
  37618. /** Defines that alpha blending to DEST - SRC * DEST */
  37619. static readonly ALPHA_SUBTRACT: number;
  37620. /** Defines that alpha blending to SRC * DEST */
  37621. static readonly ALPHA_MULTIPLY: number;
  37622. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37623. static readonly ALPHA_MAXIMIZED: number;
  37624. /** Defines that alpha blending to SRC + DEST */
  37625. static readonly ALPHA_ONEONE: number;
  37626. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37627. static readonly ALPHA_PREMULTIPLIED: number;
  37628. /**
  37629. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37630. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37631. */
  37632. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37633. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37634. static readonly ALPHA_INTERPOLATE: number;
  37635. /**
  37636. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37637. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37638. */
  37639. static readonly ALPHA_SCREENMODE: number;
  37640. /** Defines that the ressource is not delayed*/
  37641. static readonly DELAYLOADSTATE_NONE: number;
  37642. /** Defines that the ressource was successfully delay loaded */
  37643. static readonly DELAYLOADSTATE_LOADED: number;
  37644. /** Defines that the ressource is currently delay loading */
  37645. static readonly DELAYLOADSTATE_LOADING: number;
  37646. /** Defines that the ressource is delayed and has not started loading */
  37647. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37648. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37649. static readonly NEVER: number;
  37650. /** 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 */
  37651. static readonly ALWAYS: number;
  37652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37653. static readonly LESS: number;
  37654. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37655. static readonly EQUAL: number;
  37656. /** 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 */
  37657. static readonly LEQUAL: number;
  37658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37659. static readonly GREATER: number;
  37660. /** 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 */
  37661. static readonly GEQUAL: number;
  37662. /** 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 */
  37663. static readonly NOTEQUAL: number;
  37664. /** Passed to stencilOperation to specify that stencil value must be kept */
  37665. static readonly KEEP: number;
  37666. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37667. static readonly REPLACE: number;
  37668. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37669. static readonly INCR: number;
  37670. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37671. static readonly DECR: number;
  37672. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37673. static readonly INVERT: number;
  37674. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37675. static readonly INCR_WRAP: number;
  37676. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37677. static readonly DECR_WRAP: number;
  37678. /** Texture is not repeating outside of 0..1 UVs */
  37679. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37680. /** Texture is repeating outside of 0..1 UVs */
  37681. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37682. /** Texture is repeating and mirrored */
  37683. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37684. /** ALPHA */
  37685. static readonly TEXTUREFORMAT_ALPHA: number;
  37686. /** LUMINANCE */
  37687. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37688. /** LUMINANCE_ALPHA */
  37689. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37690. /** RGB */
  37691. static readonly TEXTUREFORMAT_RGB: number;
  37692. /** RGBA */
  37693. static readonly TEXTUREFORMAT_RGBA: number;
  37694. /** RED */
  37695. static readonly TEXTUREFORMAT_RED: number;
  37696. /** RED (2nd reference) */
  37697. static readonly TEXTUREFORMAT_R: number;
  37698. /** RG */
  37699. static readonly TEXTUREFORMAT_RG: number;
  37700. /** RED_INTEGER */
  37701. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37702. /** RED_INTEGER (2nd reference) */
  37703. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37704. /** RG_INTEGER */
  37705. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37706. /** RGB_INTEGER */
  37707. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37708. /** RGBA_INTEGER */
  37709. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37710. /** UNSIGNED_BYTE */
  37711. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37712. /** UNSIGNED_BYTE (2nd reference) */
  37713. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37714. /** FLOAT */
  37715. static readonly TEXTURETYPE_FLOAT: number;
  37716. /** HALF_FLOAT */
  37717. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37718. /** BYTE */
  37719. static readonly TEXTURETYPE_BYTE: number;
  37720. /** SHORT */
  37721. static readonly TEXTURETYPE_SHORT: number;
  37722. /** UNSIGNED_SHORT */
  37723. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37724. /** INT */
  37725. static readonly TEXTURETYPE_INT: number;
  37726. /** UNSIGNED_INT */
  37727. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37728. /** UNSIGNED_SHORT_4_4_4_4 */
  37729. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37730. /** UNSIGNED_SHORT_5_5_5_1 */
  37731. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37732. /** UNSIGNED_SHORT_5_6_5 */
  37733. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37734. /** UNSIGNED_INT_2_10_10_10_REV */
  37735. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37736. /** UNSIGNED_INT_24_8 */
  37737. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37738. /** UNSIGNED_INT_10F_11F_11F_REV */
  37739. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37740. /** UNSIGNED_INT_5_9_9_9_REV */
  37741. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37742. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37743. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37744. /** nearest is mag = nearest and min = nearest and mip = linear */
  37745. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37746. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37747. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37748. /** Trilinear is mag = linear and min = linear and mip = linear */
  37749. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37750. /** nearest is mag = nearest and min = nearest and mip = linear */
  37751. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37752. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37753. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37754. /** Trilinear is mag = linear and min = linear and mip = linear */
  37755. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37756. /** mag = nearest and min = nearest and mip = nearest */
  37757. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37758. /** mag = nearest and min = linear and mip = nearest */
  37759. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37760. /** mag = nearest and min = linear and mip = linear */
  37761. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37762. /** mag = nearest and min = linear and mip = none */
  37763. static readonly TEXTURE_NEAREST_LINEAR: number;
  37764. /** mag = nearest and min = nearest and mip = none */
  37765. static readonly TEXTURE_NEAREST_NEAREST: number;
  37766. /** mag = linear and min = nearest and mip = nearest */
  37767. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37768. /** mag = linear and min = nearest and mip = linear */
  37769. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37770. /** mag = linear and min = linear and mip = none */
  37771. static readonly TEXTURE_LINEAR_LINEAR: number;
  37772. /** mag = linear and min = nearest and mip = none */
  37773. static readonly TEXTURE_LINEAR_NEAREST: number;
  37774. /** Explicit coordinates mode */
  37775. static readonly TEXTURE_EXPLICIT_MODE: number;
  37776. /** Spherical coordinates mode */
  37777. static readonly TEXTURE_SPHERICAL_MODE: number;
  37778. /** Planar coordinates mode */
  37779. static readonly TEXTURE_PLANAR_MODE: number;
  37780. /** Cubic coordinates mode */
  37781. static readonly TEXTURE_CUBIC_MODE: number;
  37782. /** Projection coordinates mode */
  37783. static readonly TEXTURE_PROJECTION_MODE: number;
  37784. /** Skybox coordinates mode */
  37785. static readonly TEXTURE_SKYBOX_MODE: number;
  37786. /** Inverse Cubic coordinates mode */
  37787. static readonly TEXTURE_INVCUBIC_MODE: number;
  37788. /** Equirectangular coordinates mode */
  37789. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37790. /** Equirectangular Fixed coordinates mode */
  37791. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37792. /** Equirectangular Fixed Mirrored coordinates mode */
  37793. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37794. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37795. static readonly SCALEMODE_FLOOR: number;
  37796. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37797. static readonly SCALEMODE_NEAREST: number;
  37798. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37799. static readonly SCALEMODE_CEILING: number;
  37800. /**
  37801. * Returns the current npm package of the sdk
  37802. */
  37803. static get NpmPackage(): string;
  37804. /**
  37805. * Returns the current version of the framework
  37806. */
  37807. static get Version(): string;
  37808. /** Gets the list of created engines */
  37809. static get Instances(): Engine[];
  37810. /**
  37811. * Gets the latest created engine
  37812. */
  37813. static get LastCreatedEngine(): Nullable<Engine>;
  37814. /**
  37815. * Gets the latest created scene
  37816. */
  37817. static get LastCreatedScene(): Nullable<Scene>;
  37818. /**
  37819. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37820. * @param flag defines which part of the materials must be marked as dirty
  37821. * @param predicate defines a predicate used to filter which materials should be affected
  37822. */
  37823. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37824. /**
  37825. * Method called to create the default loading screen.
  37826. * This can be overriden in your own app.
  37827. * @param canvas The rendering canvas element
  37828. * @returns The loading screen
  37829. */
  37830. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37831. /**
  37832. * Method called to create the default rescale post process on each engine.
  37833. */
  37834. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37835. /**
  37836. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37837. **/
  37838. enableOfflineSupport: boolean;
  37839. /**
  37840. * 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)
  37841. **/
  37842. disableManifestCheck: boolean;
  37843. /**
  37844. * Gets the list of created scenes
  37845. */
  37846. scenes: Scene[];
  37847. /**
  37848. * Event raised when a new scene is created
  37849. */
  37850. onNewSceneAddedObservable: Observable<Scene>;
  37851. /**
  37852. * Gets the list of created postprocesses
  37853. */
  37854. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37855. /**
  37856. * Gets a boolean indicating if the pointer is currently locked
  37857. */
  37858. isPointerLock: boolean;
  37859. /**
  37860. * Observable event triggered each time the rendering canvas is resized
  37861. */
  37862. onResizeObservable: Observable<Engine>;
  37863. /**
  37864. * Observable event triggered each time the canvas loses focus
  37865. */
  37866. onCanvasBlurObservable: Observable<Engine>;
  37867. /**
  37868. * Observable event triggered each time the canvas gains focus
  37869. */
  37870. onCanvasFocusObservable: Observable<Engine>;
  37871. /**
  37872. * Observable event triggered each time the canvas receives pointerout event
  37873. */
  37874. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37875. /**
  37876. * Observable raised when the engine begins a new frame
  37877. */
  37878. onBeginFrameObservable: Observable<Engine>;
  37879. /**
  37880. * If set, will be used to request the next animation frame for the render loop
  37881. */
  37882. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37883. /**
  37884. * Observable raised when the engine ends the current frame
  37885. */
  37886. onEndFrameObservable: Observable<Engine>;
  37887. /**
  37888. * Observable raised when the engine is about to compile a shader
  37889. */
  37890. onBeforeShaderCompilationObservable: Observable<Engine>;
  37891. /**
  37892. * Observable raised when the engine has jsut compiled a shader
  37893. */
  37894. onAfterShaderCompilationObservable: Observable<Engine>;
  37895. /**
  37896. * Gets the audio engine
  37897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37898. * @ignorenaming
  37899. */
  37900. static audioEngine: IAudioEngine;
  37901. /**
  37902. * Default AudioEngine factory responsible of creating the Audio Engine.
  37903. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37904. */
  37905. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37906. /**
  37907. * Default offline support factory responsible of creating a tool used to store data locally.
  37908. * By default, this will create a Database object if the workload has been embedded.
  37909. */
  37910. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37911. private _loadingScreen;
  37912. private _pointerLockRequested;
  37913. private _rescalePostProcess;
  37914. private _deterministicLockstep;
  37915. private _lockstepMaxSteps;
  37916. private _timeStep;
  37917. protected get _supportsHardwareTextureRescaling(): boolean;
  37918. private _fps;
  37919. private _deltaTime;
  37920. /** @hidden */
  37921. _drawCalls: PerfCounter;
  37922. /** 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 */
  37923. canvasTabIndex: number;
  37924. /**
  37925. * Turn this value on if you want to pause FPS computation when in background
  37926. */
  37927. disablePerformanceMonitorInBackground: boolean;
  37928. private _performanceMonitor;
  37929. /**
  37930. * Gets the performance monitor attached to this engine
  37931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37932. */
  37933. get performanceMonitor(): PerformanceMonitor;
  37934. private _onFocus;
  37935. private _onBlur;
  37936. private _onCanvasPointerOut;
  37937. private _onCanvasBlur;
  37938. private _onCanvasFocus;
  37939. private _onFullscreenChange;
  37940. private _onPointerLockChange;
  37941. /**
  37942. * Gets the HTML element used to attach event listeners
  37943. * @returns a HTML element
  37944. */
  37945. getInputElement(): Nullable<HTMLElement>;
  37946. /**
  37947. * Creates a new engine
  37948. * @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
  37949. * @param antialias defines enable antialiasing (default: false)
  37950. * @param options defines further options to be sent to the getContext() function
  37951. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37952. */
  37953. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37954. /**
  37955. * Gets current aspect ratio
  37956. * @param viewportOwner defines the camera to use to get the aspect ratio
  37957. * @param useScreen defines if screen size must be used (or the current render target if any)
  37958. * @returns a number defining the aspect ratio
  37959. */
  37960. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37961. /**
  37962. * Gets current screen aspect ratio
  37963. * @returns a number defining the aspect ratio
  37964. */
  37965. getScreenAspectRatio(): number;
  37966. /**
  37967. * Gets the client rect of the HTML canvas attached with the current webGL context
  37968. * @returns a client rectanglee
  37969. */
  37970. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37971. /**
  37972. * Gets the client rect of the HTML element used for events
  37973. * @returns a client rectanglee
  37974. */
  37975. getInputElementClientRect(): Nullable<ClientRect>;
  37976. /**
  37977. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37979. * @returns true if engine is in deterministic lock step mode
  37980. */
  37981. isDeterministicLockStep(): boolean;
  37982. /**
  37983. * Gets the max steps when engine is running in deterministic lock step
  37984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37985. * @returns the max steps
  37986. */
  37987. getLockstepMaxSteps(): number;
  37988. /**
  37989. * Returns the time in ms between steps when using deterministic lock step.
  37990. * @returns time step in (ms)
  37991. */
  37992. getTimeStep(): number;
  37993. /**
  37994. * Force the mipmap generation for the given render target texture
  37995. * @param texture defines the render target texture to use
  37996. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37997. */
  37998. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37999. /** States */
  38000. /**
  38001. * Set various states to the webGL context
  38002. * @param culling defines backface culling state
  38003. * @param zOffset defines the value to apply to zOffset (0 by default)
  38004. * @param force defines if states must be applied even if cache is up to date
  38005. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38006. */
  38007. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38008. /**
  38009. * Set the z offset to apply to current rendering
  38010. * @param value defines the offset to apply
  38011. */
  38012. setZOffset(value: number): void;
  38013. /**
  38014. * Gets the current value of the zOffset
  38015. * @returns the current zOffset state
  38016. */
  38017. getZOffset(): number;
  38018. /**
  38019. * Enable or disable depth buffering
  38020. * @param enable defines the state to set
  38021. */
  38022. setDepthBuffer(enable: boolean): void;
  38023. /**
  38024. * Gets a boolean indicating if depth writing is enabled
  38025. * @returns the current depth writing state
  38026. */
  38027. getDepthWrite(): boolean;
  38028. /**
  38029. * Enable or disable depth writing
  38030. * @param enable defines the state to set
  38031. */
  38032. setDepthWrite(enable: boolean): void;
  38033. /**
  38034. * Gets a boolean indicating if stencil buffer is enabled
  38035. * @returns the current stencil buffer state
  38036. */
  38037. getStencilBuffer(): boolean;
  38038. /**
  38039. * Enable or disable the stencil buffer
  38040. * @param enable defines if the stencil buffer must be enabled or disabled
  38041. */
  38042. setStencilBuffer(enable: boolean): void;
  38043. /**
  38044. * Gets the current stencil mask
  38045. * @returns a number defining the new stencil mask to use
  38046. */
  38047. getStencilMask(): number;
  38048. /**
  38049. * Sets the current stencil mask
  38050. * @param mask defines the new stencil mask to use
  38051. */
  38052. setStencilMask(mask: number): void;
  38053. /**
  38054. * Gets the current stencil function
  38055. * @returns a number defining the stencil function to use
  38056. */
  38057. getStencilFunction(): number;
  38058. /**
  38059. * Gets the current stencil reference value
  38060. * @returns a number defining the stencil reference value to use
  38061. */
  38062. getStencilFunctionReference(): number;
  38063. /**
  38064. * Gets the current stencil mask
  38065. * @returns a number defining the stencil mask to use
  38066. */
  38067. getStencilFunctionMask(): number;
  38068. /**
  38069. * Sets the current stencil function
  38070. * @param stencilFunc defines the new stencil function to use
  38071. */
  38072. setStencilFunction(stencilFunc: number): void;
  38073. /**
  38074. * Sets the current stencil reference
  38075. * @param reference defines the new stencil reference to use
  38076. */
  38077. setStencilFunctionReference(reference: number): void;
  38078. /**
  38079. * Sets the current stencil mask
  38080. * @param mask defines the new stencil mask to use
  38081. */
  38082. setStencilFunctionMask(mask: number): void;
  38083. /**
  38084. * Gets the current stencil operation when stencil fails
  38085. * @returns a number defining stencil operation to use when stencil fails
  38086. */
  38087. getStencilOperationFail(): number;
  38088. /**
  38089. * Gets the current stencil operation when depth fails
  38090. * @returns a number defining stencil operation to use when depth fails
  38091. */
  38092. getStencilOperationDepthFail(): number;
  38093. /**
  38094. * Gets the current stencil operation when stencil passes
  38095. * @returns a number defining stencil operation to use when stencil passes
  38096. */
  38097. getStencilOperationPass(): number;
  38098. /**
  38099. * Sets the stencil operation to use when stencil fails
  38100. * @param operation defines the stencil operation to use when stencil fails
  38101. */
  38102. setStencilOperationFail(operation: number): void;
  38103. /**
  38104. * Sets the stencil operation to use when depth fails
  38105. * @param operation defines the stencil operation to use when depth fails
  38106. */
  38107. setStencilOperationDepthFail(operation: number): void;
  38108. /**
  38109. * Sets the stencil operation to use when stencil passes
  38110. * @param operation defines the stencil operation to use when stencil passes
  38111. */
  38112. setStencilOperationPass(operation: number): void;
  38113. /**
  38114. * Sets a boolean indicating if the dithering state is enabled or disabled
  38115. * @param value defines the dithering state
  38116. */
  38117. setDitheringState(value: boolean): void;
  38118. /**
  38119. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38120. * @param value defines the rasterizer state
  38121. */
  38122. setRasterizerState(value: boolean): void;
  38123. /**
  38124. * Gets the current depth function
  38125. * @returns a number defining the depth function
  38126. */
  38127. getDepthFunction(): Nullable<number>;
  38128. /**
  38129. * Sets the current depth function
  38130. * @param depthFunc defines the function to use
  38131. */
  38132. setDepthFunction(depthFunc: number): void;
  38133. /**
  38134. * Sets the current depth function to GREATER
  38135. */
  38136. setDepthFunctionToGreater(): void;
  38137. /**
  38138. * Sets the current depth function to GEQUAL
  38139. */
  38140. setDepthFunctionToGreaterOrEqual(): void;
  38141. /**
  38142. * Sets the current depth function to LESS
  38143. */
  38144. setDepthFunctionToLess(): void;
  38145. /**
  38146. * Sets the current depth function to LEQUAL
  38147. */
  38148. setDepthFunctionToLessOrEqual(): void;
  38149. private _cachedStencilBuffer;
  38150. private _cachedStencilFunction;
  38151. private _cachedStencilMask;
  38152. private _cachedStencilOperationPass;
  38153. private _cachedStencilOperationFail;
  38154. private _cachedStencilOperationDepthFail;
  38155. private _cachedStencilReference;
  38156. /**
  38157. * Caches the the state of the stencil buffer
  38158. */
  38159. cacheStencilState(): void;
  38160. /**
  38161. * Restores the state of the stencil buffer
  38162. */
  38163. restoreStencilState(): void;
  38164. /**
  38165. * Directly set the WebGL Viewport
  38166. * @param x defines the x coordinate of the viewport (in screen space)
  38167. * @param y defines the y coordinate of the viewport (in screen space)
  38168. * @param width defines the width of the viewport (in screen space)
  38169. * @param height defines the height of the viewport (in screen space)
  38170. * @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
  38171. */
  38172. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38173. /**
  38174. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38175. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38176. * @param y defines the y-coordinate of the corner of the clear rectangle
  38177. * @param width defines the width of the clear rectangle
  38178. * @param height defines the height of the clear rectangle
  38179. * @param clearColor defines the clear color
  38180. */
  38181. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38182. /**
  38183. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38184. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38185. * @param y defines the y-coordinate of the corner of the clear rectangle
  38186. * @param width defines the width of the clear rectangle
  38187. * @param height defines the height of the clear rectangle
  38188. */
  38189. enableScissor(x: number, y: number, width: number, height: number): void;
  38190. /**
  38191. * Disable previously set scissor test rectangle
  38192. */
  38193. disableScissor(): void;
  38194. protected _reportDrawCall(): void;
  38195. /**
  38196. * Initializes a webVR display and starts listening to display change events
  38197. * The onVRDisplayChangedObservable will be notified upon these changes
  38198. * @returns The onVRDisplayChangedObservable
  38199. */
  38200. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38201. /** @hidden */
  38202. _prepareVRComponent(): void;
  38203. /** @hidden */
  38204. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38205. /** @hidden */
  38206. _submitVRFrame(): void;
  38207. /**
  38208. * Call this function to leave webVR mode
  38209. * Will do nothing if webVR is not supported or if there is no webVR device
  38210. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38211. */
  38212. disableVR(): void;
  38213. /**
  38214. * Gets a boolean indicating that the system is in VR mode and is presenting
  38215. * @returns true if VR mode is engaged
  38216. */
  38217. isVRPresenting(): boolean;
  38218. /** @hidden */
  38219. _requestVRFrame(): void;
  38220. /** @hidden */
  38221. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38222. /**
  38223. * Gets the source code of the vertex shader associated with a specific webGL program
  38224. * @param program defines the program to use
  38225. * @returns a string containing the source code of the vertex shader associated with the program
  38226. */
  38227. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38228. /**
  38229. * Gets the source code of the fragment shader associated with a specific webGL program
  38230. * @param program defines the program to use
  38231. * @returns a string containing the source code of the fragment shader associated with the program
  38232. */
  38233. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38234. /**
  38235. * Sets a depth stencil texture from a render target to the according uniform.
  38236. * @param channel The texture channel
  38237. * @param uniform The uniform to set
  38238. * @param texture The render target texture containing the depth stencil texture to apply
  38239. */
  38240. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38241. /**
  38242. * Sets a texture to the webGL context from a postprocess
  38243. * @param channel defines the channel to use
  38244. * @param postProcess defines the source postprocess
  38245. */
  38246. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38247. /**
  38248. * Binds the output of the passed in post process to the texture channel specified
  38249. * @param channel The channel the texture should be bound to
  38250. * @param postProcess The post process which's output should be bound
  38251. */
  38252. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38253. protected _rebuildBuffers(): void;
  38254. /** @hidden */
  38255. _renderFrame(): void;
  38256. _renderLoop(): void;
  38257. /** @hidden */
  38258. _renderViews(): boolean;
  38259. /**
  38260. * Toggle full screen mode
  38261. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38262. */
  38263. switchFullscreen(requestPointerLock: boolean): void;
  38264. /**
  38265. * Enters full screen mode
  38266. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38267. */
  38268. enterFullscreen(requestPointerLock: boolean): void;
  38269. /**
  38270. * Exits full screen mode
  38271. */
  38272. exitFullscreen(): void;
  38273. /**
  38274. * Enters Pointerlock mode
  38275. */
  38276. enterPointerlock(): void;
  38277. /**
  38278. * Exits Pointerlock mode
  38279. */
  38280. exitPointerlock(): void;
  38281. /**
  38282. * Begin a new frame
  38283. */
  38284. beginFrame(): void;
  38285. /**
  38286. * Enf the current frame
  38287. */
  38288. endFrame(): void;
  38289. resize(): void;
  38290. /**
  38291. * Force a specific size of the canvas
  38292. * @param width defines the new canvas' width
  38293. * @param height defines the new canvas' height
  38294. */
  38295. setSize(width: number, height: number): void;
  38296. /**
  38297. * Updates a dynamic vertex buffer.
  38298. * @param vertexBuffer the vertex buffer to update
  38299. * @param data the data used to update the vertex buffer
  38300. * @param byteOffset the byte offset of the data
  38301. * @param byteLength the byte length of the data
  38302. */
  38303. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38304. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38305. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38306. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38307. _releaseTexture(texture: InternalTexture): void;
  38308. /**
  38309. * @hidden
  38310. * Rescales a texture
  38311. * @param source input texutre
  38312. * @param destination destination texture
  38313. * @param scene scene to use to render the resize
  38314. * @param internalFormat format to use when resizing
  38315. * @param onComplete callback to be called when resize has completed
  38316. */
  38317. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38318. /**
  38319. * Gets the current framerate
  38320. * @returns a number representing the framerate
  38321. */
  38322. getFps(): number;
  38323. /**
  38324. * Gets the time spent between current and previous frame
  38325. * @returns a number representing the delta time in ms
  38326. */
  38327. getDeltaTime(): number;
  38328. private _measureFps;
  38329. /** @hidden */
  38330. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38331. /**
  38332. * Update a dynamic index buffer
  38333. * @param indexBuffer defines the target index buffer
  38334. * @param indices defines the data to update
  38335. * @param offset defines the offset in the target index buffer where update should start
  38336. */
  38337. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38338. /**
  38339. * Updates the sample count of a render target texture
  38340. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38341. * @param texture defines the texture to update
  38342. * @param samples defines the sample count to set
  38343. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38344. */
  38345. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38346. /**
  38347. * Updates a depth texture Comparison Mode and Function.
  38348. * If the comparison Function is equal to 0, the mode will be set to none.
  38349. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38350. * @param texture The texture to set the comparison function for
  38351. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38352. */
  38353. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38354. /**
  38355. * Creates a webGL buffer to use with instanciation
  38356. * @param capacity defines the size of the buffer
  38357. * @returns the webGL buffer
  38358. */
  38359. createInstancesBuffer(capacity: number): DataBuffer;
  38360. /**
  38361. * Delete a webGL buffer used with instanciation
  38362. * @param buffer defines the webGL buffer to delete
  38363. */
  38364. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38365. private _clientWaitAsync;
  38366. /** @hidden */
  38367. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38368. dispose(): void;
  38369. private _disableTouchAction;
  38370. /**
  38371. * Display the loading screen
  38372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38373. */
  38374. displayLoadingUI(): void;
  38375. /**
  38376. * Hide the loading screen
  38377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38378. */
  38379. hideLoadingUI(): void;
  38380. /**
  38381. * Gets the current loading screen object
  38382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38383. */
  38384. get loadingScreen(): ILoadingScreen;
  38385. /**
  38386. * Sets the current loading screen object
  38387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38388. */
  38389. set loadingScreen(loadingScreen: ILoadingScreen);
  38390. /**
  38391. * Sets the current loading screen text
  38392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38393. */
  38394. set loadingUIText(text: string);
  38395. /**
  38396. * Sets the current loading screen background color
  38397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38398. */
  38399. set loadingUIBackgroundColor(color: string);
  38400. /** Pointerlock and fullscreen */
  38401. /**
  38402. * Ask the browser to promote the current element to pointerlock mode
  38403. * @param element defines the DOM element to promote
  38404. */
  38405. static _RequestPointerlock(element: HTMLElement): void;
  38406. /**
  38407. * Asks the browser to exit pointerlock mode
  38408. */
  38409. static _ExitPointerlock(): void;
  38410. /**
  38411. * Ask the browser to promote the current element to fullscreen rendering mode
  38412. * @param element defines the DOM element to promote
  38413. */
  38414. static _RequestFullscreen(element: HTMLElement): void;
  38415. /**
  38416. * Asks the browser to exit fullscreen mode
  38417. */
  38418. static _ExitFullscreen(): void;
  38419. }
  38420. }
  38421. declare module "babylonjs/Engines/engineStore" {
  38422. import { Nullable } from "babylonjs/types";
  38423. import { Engine } from "babylonjs/Engines/engine";
  38424. import { Scene } from "babylonjs/scene";
  38425. /**
  38426. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38427. * during the life time of the application.
  38428. */
  38429. export class EngineStore {
  38430. /** Gets the list of created engines */
  38431. static Instances: import("babylonjs/Engines/engine").Engine[];
  38432. /** @hidden */
  38433. static _LastCreatedScene: Nullable<Scene>;
  38434. /**
  38435. * Gets the latest created engine
  38436. */
  38437. static get LastCreatedEngine(): Nullable<Engine>;
  38438. /**
  38439. * Gets the latest created scene
  38440. */
  38441. static get LastCreatedScene(): Nullable<Scene>;
  38442. /**
  38443. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38444. * @ignorenaming
  38445. */
  38446. static UseFallbackTexture: boolean;
  38447. /**
  38448. * Texture content used if a texture cannot loaded
  38449. * @ignorenaming
  38450. */
  38451. static FallbackTexture: string;
  38452. }
  38453. }
  38454. declare module "babylonjs/Misc/promise" {
  38455. /**
  38456. * Helper class that provides a small promise polyfill
  38457. */
  38458. export class PromisePolyfill {
  38459. /**
  38460. * Static function used to check if the polyfill is required
  38461. * If this is the case then the function will inject the polyfill to window.Promise
  38462. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38463. */
  38464. static Apply(force?: boolean): void;
  38465. }
  38466. }
  38467. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38468. /**
  38469. * Interface for screenshot methods with describe argument called `size` as object with options
  38470. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38471. */
  38472. export interface IScreenshotSize {
  38473. /**
  38474. * number in pixels for canvas height
  38475. */
  38476. height?: number;
  38477. /**
  38478. * multiplier allowing render at a higher or lower resolution
  38479. * If value is defined then height and width will be ignored and taken from camera
  38480. */
  38481. precision?: number;
  38482. /**
  38483. * number in pixels for canvas width
  38484. */
  38485. width?: number;
  38486. }
  38487. }
  38488. declare module "babylonjs/Misc/tools" {
  38489. import { Nullable, float } from "babylonjs/types";
  38490. import { DomManagement } from "babylonjs/Misc/domManagement";
  38491. import { WebRequest } from "babylonjs/Misc/webRequest";
  38492. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38493. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38494. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38495. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38496. import { Camera } from "babylonjs/Cameras/camera";
  38497. import { Engine } from "babylonjs/Engines/engine";
  38498. interface IColor4Like {
  38499. r: float;
  38500. g: float;
  38501. b: float;
  38502. a: float;
  38503. }
  38504. /**
  38505. * Class containing a set of static utilities functions
  38506. */
  38507. export class Tools {
  38508. /**
  38509. * Gets or sets the base URL to use to load assets
  38510. */
  38511. static get BaseUrl(): string;
  38512. static set BaseUrl(value: string);
  38513. /**
  38514. * Enable/Disable Custom HTTP Request Headers globally.
  38515. * default = false
  38516. * @see CustomRequestHeaders
  38517. */
  38518. static UseCustomRequestHeaders: boolean;
  38519. /**
  38520. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38521. * i.e. when loading files, where the server/service expects an Authorization header
  38522. */
  38523. static CustomRequestHeaders: {
  38524. [key: string]: string;
  38525. };
  38526. /**
  38527. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38528. */
  38529. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38530. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38531. /**
  38532. * Default behaviour for cors in the application.
  38533. * It can be a string if the expected behavior is identical in the entire app.
  38534. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38535. */
  38536. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38537. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38538. /**
  38539. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38540. * @ignorenaming
  38541. */
  38542. static get UseFallbackTexture(): boolean;
  38543. static set UseFallbackTexture(value: boolean);
  38544. /**
  38545. * Use this object to register external classes like custom textures or material
  38546. * to allow the laoders to instantiate them
  38547. */
  38548. static get RegisteredExternalClasses(): {
  38549. [key: string]: Object;
  38550. };
  38551. static set RegisteredExternalClasses(classes: {
  38552. [key: string]: Object;
  38553. });
  38554. /**
  38555. * Texture content used if a texture cannot loaded
  38556. * @ignorenaming
  38557. */
  38558. static get fallbackTexture(): string;
  38559. static set fallbackTexture(value: string);
  38560. /**
  38561. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38562. * @param u defines the coordinate on X axis
  38563. * @param v defines the coordinate on Y axis
  38564. * @param width defines the width of the source data
  38565. * @param height defines the height of the source data
  38566. * @param pixels defines the source byte array
  38567. * @param color defines the output color
  38568. */
  38569. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38570. /**
  38571. * Interpolates between a and b via alpha
  38572. * @param a The lower value (returned when alpha = 0)
  38573. * @param b The upper value (returned when alpha = 1)
  38574. * @param alpha The interpolation-factor
  38575. * @return The mixed value
  38576. */
  38577. static Mix(a: number, b: number, alpha: number): number;
  38578. /**
  38579. * Tries to instantiate a new object from a given class name
  38580. * @param className defines the class name to instantiate
  38581. * @returns the new object or null if the system was not able to do the instantiation
  38582. */
  38583. static Instantiate(className: string): any;
  38584. /**
  38585. * Provides a slice function that will work even on IE
  38586. * @param data defines the array to slice
  38587. * @param start defines the start of the data (optional)
  38588. * @param end defines the end of the data (optional)
  38589. * @returns the new sliced array
  38590. */
  38591. static Slice<T>(data: T, start?: number, end?: number): T;
  38592. /**
  38593. * Polyfill for setImmediate
  38594. * @param action defines the action to execute after the current execution block
  38595. */
  38596. static SetImmediate(action: () => void): void;
  38597. /**
  38598. * Function indicating if a number is an exponent of 2
  38599. * @param value defines the value to test
  38600. * @returns true if the value is an exponent of 2
  38601. */
  38602. static IsExponentOfTwo(value: number): boolean;
  38603. private static _tmpFloatArray;
  38604. /**
  38605. * Returns the nearest 32-bit single precision float representation of a Number
  38606. * @param value A Number. If the parameter is of a different type, it will get converted
  38607. * to a number or to NaN if it cannot be converted
  38608. * @returns number
  38609. */
  38610. static FloatRound(value: number): number;
  38611. /**
  38612. * Extracts the filename from a path
  38613. * @param path defines the path to use
  38614. * @returns the filename
  38615. */
  38616. static GetFilename(path: string): string;
  38617. /**
  38618. * Extracts the "folder" part of a path (everything before the filename).
  38619. * @param uri The URI to extract the info from
  38620. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38621. * @returns The "folder" part of the path
  38622. */
  38623. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38624. /**
  38625. * Extracts text content from a DOM element hierarchy
  38626. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38627. */
  38628. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38629. /**
  38630. * Convert an angle in radians to degrees
  38631. * @param angle defines the angle to convert
  38632. * @returns the angle in degrees
  38633. */
  38634. static ToDegrees(angle: number): number;
  38635. /**
  38636. * Convert an angle in degrees to radians
  38637. * @param angle defines the angle to convert
  38638. * @returns the angle in radians
  38639. */
  38640. static ToRadians(angle: number): number;
  38641. /**
  38642. * Returns an array if obj is not an array
  38643. * @param obj defines the object to evaluate as an array
  38644. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38645. * @returns either obj directly if obj is an array or a new array containing obj
  38646. */
  38647. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38648. /**
  38649. * Gets the pointer prefix to use
  38650. * @param engine defines the engine we are finding the prefix for
  38651. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38652. */
  38653. static GetPointerPrefix(engine: Engine): string;
  38654. /**
  38655. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38656. * @param url define the url we are trying
  38657. * @param element define the dom element where to configure the cors policy
  38658. */
  38659. static SetCorsBehavior(url: string | string[], element: {
  38660. crossOrigin: string | null;
  38661. }): void;
  38662. /**
  38663. * Removes unwanted characters from an url
  38664. * @param url defines the url to clean
  38665. * @returns the cleaned url
  38666. */
  38667. static CleanUrl(url: string): string;
  38668. /**
  38669. * Gets or sets a function used to pre-process url before using them to load assets
  38670. */
  38671. static get PreprocessUrl(): (url: string) => string;
  38672. static set PreprocessUrl(processor: (url: string) => string);
  38673. /**
  38674. * Loads an image as an HTMLImageElement.
  38675. * @param input url string, ArrayBuffer, or Blob to load
  38676. * @param onLoad callback called when the image successfully loads
  38677. * @param onError callback called when the image fails to load
  38678. * @param offlineProvider offline provider for caching
  38679. * @param mimeType optional mime type
  38680. * @returns the HTMLImageElement of the loaded image
  38681. */
  38682. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38683. /**
  38684. * Loads a file from a url
  38685. * @param url url string, ArrayBuffer, or Blob to load
  38686. * @param onSuccess callback called when the file successfully loads
  38687. * @param onProgress callback called while file is loading (if the server supports this mode)
  38688. * @param offlineProvider defines the offline provider for caching
  38689. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38690. * @param onError callback called when the file fails to load
  38691. * @returns a file request object
  38692. */
  38693. 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;
  38694. /**
  38695. * Loads a file from a url
  38696. * @param url the file url to load
  38697. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38698. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38699. */
  38700. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38701. /**
  38702. * Load a script (identified by an url). When the url returns, the
  38703. * content of this file is added into a new script element, attached to the DOM (body element)
  38704. * @param scriptUrl defines the url of the script to laod
  38705. * @param onSuccess defines the callback called when the script is loaded
  38706. * @param onError defines the callback to call if an error occurs
  38707. * @param scriptId defines the id of the script element
  38708. */
  38709. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38710. /**
  38711. * Load an asynchronous script (identified by an url). When the url returns, the
  38712. * content of this file is added into a new script element, attached to the DOM (body element)
  38713. * @param scriptUrl defines the url of the script to laod
  38714. * @param scriptId defines the id of the script element
  38715. * @returns a promise request object
  38716. */
  38717. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38718. /**
  38719. * Loads a file from a blob
  38720. * @param fileToLoad defines the blob to use
  38721. * @param callback defines the callback to call when data is loaded
  38722. * @param progressCallback defines the callback to call during loading process
  38723. * @returns a file request object
  38724. */
  38725. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38726. /**
  38727. * Reads a file from a File object
  38728. * @param file defines the file to load
  38729. * @param onSuccess defines the callback to call when data is loaded
  38730. * @param onProgress defines the callback to call during loading process
  38731. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38732. * @param onError defines the callback to call when an error occurs
  38733. * @returns a file request object
  38734. */
  38735. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38736. /**
  38737. * Creates a data url from a given string content
  38738. * @param content defines the content to convert
  38739. * @returns the new data url link
  38740. */
  38741. static FileAsURL(content: string): string;
  38742. /**
  38743. * Format the given number to a specific decimal format
  38744. * @param value defines the number to format
  38745. * @param decimals defines the number of decimals to use
  38746. * @returns the formatted string
  38747. */
  38748. static Format(value: number, decimals?: number): string;
  38749. /**
  38750. * Tries to copy an object by duplicating every property
  38751. * @param source defines the source object
  38752. * @param destination defines the target object
  38753. * @param doNotCopyList defines a list of properties to avoid
  38754. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38755. */
  38756. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38757. /**
  38758. * Gets a boolean indicating if the given object has no own property
  38759. * @param obj defines the object to test
  38760. * @returns true if object has no own property
  38761. */
  38762. static IsEmpty(obj: any): boolean;
  38763. /**
  38764. * Function used to register events at window level
  38765. * @param windowElement defines the Window object to use
  38766. * @param events defines the events to register
  38767. */
  38768. static RegisterTopRootEvents(windowElement: Window, events: {
  38769. name: string;
  38770. handler: Nullable<(e: FocusEvent) => any>;
  38771. }[]): void;
  38772. /**
  38773. * Function used to unregister events from window level
  38774. * @param windowElement defines the Window object to use
  38775. * @param events defines the events to unregister
  38776. */
  38777. static UnregisterTopRootEvents(windowElement: Window, events: {
  38778. name: string;
  38779. handler: Nullable<(e: FocusEvent) => any>;
  38780. }[]): void;
  38781. /**
  38782. * @ignore
  38783. */
  38784. static _ScreenshotCanvas: HTMLCanvasElement;
  38785. /**
  38786. * Dumps the current bound framebuffer
  38787. * @param width defines the rendering width
  38788. * @param height defines the rendering height
  38789. * @param engine defines the hosting engine
  38790. * @param successCallback defines the callback triggered once the data are available
  38791. * @param mimeType defines the mime type of the result
  38792. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38793. */
  38794. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38795. /**
  38796. * Converts the canvas data to blob.
  38797. * This acts as a polyfill for browsers not supporting the to blob function.
  38798. * @param canvas Defines the canvas to extract the data from
  38799. * @param successCallback Defines the callback triggered once the data are available
  38800. * @param mimeType Defines the mime type of the result
  38801. */
  38802. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38803. /**
  38804. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38805. * @param successCallback defines the callback triggered once the data are available
  38806. * @param mimeType defines the mime type of the result
  38807. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38808. */
  38809. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38810. /**
  38811. * Downloads a blob in the browser
  38812. * @param blob defines the blob to download
  38813. * @param fileName defines the name of the downloaded file
  38814. */
  38815. static Download(blob: Blob, fileName: string): void;
  38816. /**
  38817. * Captures a screenshot of the current rendering
  38818. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38819. * @param engine defines the rendering engine
  38820. * @param camera defines the source camera
  38821. * @param size This parameter can be set to a single number or to an object with the
  38822. * following (optional) properties: precision, width, height. If a single number is passed,
  38823. * it will be used for both width and height. If an object is passed, the screenshot size
  38824. * will be derived from the parameters. The precision property is a multiplier allowing
  38825. * rendering at a higher or lower resolution
  38826. * @param successCallback defines the callback receives a single parameter which contains the
  38827. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38828. * src parameter of an <img> to display it
  38829. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38830. * Check your browser for supported MIME types
  38831. */
  38832. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38833. /**
  38834. * Captures a screenshot of the current rendering
  38835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38836. * @param engine defines the rendering engine
  38837. * @param camera defines the source camera
  38838. * @param size This parameter can be set to a single number or to an object with the
  38839. * following (optional) properties: precision, width, height. If a single number is passed,
  38840. * it will be used for both width and height. If an object is passed, the screenshot size
  38841. * will be derived from the parameters. The precision property is a multiplier allowing
  38842. * rendering at a higher or lower resolution
  38843. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38844. * Check your browser for supported MIME types
  38845. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38846. * to the src parameter of an <img> to display it
  38847. */
  38848. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38849. /**
  38850. * Generates an image screenshot from the specified camera.
  38851. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38852. * @param engine The engine to use for rendering
  38853. * @param camera The camera to use for rendering
  38854. * @param size This parameter can be set to a single number or to an object with the
  38855. * following (optional) properties: precision, width, height. If a single number is passed,
  38856. * it will be used for both width and height. If an object is passed, the screenshot size
  38857. * will be derived from the parameters. The precision property is a multiplier allowing
  38858. * rendering at a higher or lower resolution
  38859. * @param successCallback The callback receives a single parameter which contains the
  38860. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38861. * src parameter of an <img> to display it
  38862. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38863. * Check your browser for supported MIME types
  38864. * @param samples Texture samples (default: 1)
  38865. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38866. * @param fileName A name for for the downloaded file.
  38867. */
  38868. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38869. /**
  38870. * Generates an image screenshot from the specified camera.
  38871. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38872. * @param engine The engine to use for rendering
  38873. * @param camera The camera to use for rendering
  38874. * @param size This parameter can be set to a single number or to an object with the
  38875. * following (optional) properties: precision, width, height. If a single number is passed,
  38876. * it will be used for both width and height. If an object is passed, the screenshot size
  38877. * will be derived from the parameters. The precision property is a multiplier allowing
  38878. * rendering at a higher or lower resolution
  38879. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38880. * Check your browser for supported MIME types
  38881. * @param samples Texture samples (default: 1)
  38882. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38883. * @param fileName A name for for the downloaded file.
  38884. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38885. * to the src parameter of an <img> to display it
  38886. */
  38887. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38888. /**
  38889. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38890. * Be aware Math.random() could cause collisions, but:
  38891. * "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"
  38892. * @returns a pseudo random id
  38893. */
  38894. static RandomId(): string;
  38895. /**
  38896. * Test if the given uri is a base64 string
  38897. * @param uri The uri to test
  38898. * @return True if the uri is a base64 string or false otherwise
  38899. */
  38900. static IsBase64(uri: string): boolean;
  38901. /**
  38902. * Decode the given base64 uri.
  38903. * @param uri The uri to decode
  38904. * @return The decoded base64 data.
  38905. */
  38906. static DecodeBase64(uri: string): ArrayBuffer;
  38907. /**
  38908. * Gets the absolute url.
  38909. * @param url the input url
  38910. * @return the absolute url
  38911. */
  38912. static GetAbsoluteUrl(url: string): string;
  38913. /**
  38914. * No log
  38915. */
  38916. static readonly NoneLogLevel: number;
  38917. /**
  38918. * Only message logs
  38919. */
  38920. static readonly MessageLogLevel: number;
  38921. /**
  38922. * Only warning logs
  38923. */
  38924. static readonly WarningLogLevel: number;
  38925. /**
  38926. * Only error logs
  38927. */
  38928. static readonly ErrorLogLevel: number;
  38929. /**
  38930. * All logs
  38931. */
  38932. static readonly AllLogLevel: number;
  38933. /**
  38934. * Gets a value indicating the number of loading errors
  38935. * @ignorenaming
  38936. */
  38937. static get errorsCount(): number;
  38938. /**
  38939. * Callback called when a new log is added
  38940. */
  38941. static OnNewCacheEntry: (entry: string) => void;
  38942. /**
  38943. * Log a message to the console
  38944. * @param message defines the message to log
  38945. */
  38946. static Log(message: string): void;
  38947. /**
  38948. * Write a warning message to the console
  38949. * @param message defines the message to log
  38950. */
  38951. static Warn(message: string): void;
  38952. /**
  38953. * Write an error message to the console
  38954. * @param message defines the message to log
  38955. */
  38956. static Error(message: string): void;
  38957. /**
  38958. * Gets current log cache (list of logs)
  38959. */
  38960. static get LogCache(): string;
  38961. /**
  38962. * Clears the log cache
  38963. */
  38964. static ClearLogCache(): void;
  38965. /**
  38966. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38967. */
  38968. static set LogLevels(level: number);
  38969. /**
  38970. * Checks if the window object exists
  38971. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38972. */
  38973. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38974. /**
  38975. * No performance log
  38976. */
  38977. static readonly PerformanceNoneLogLevel: number;
  38978. /**
  38979. * Use user marks to log performance
  38980. */
  38981. static readonly PerformanceUserMarkLogLevel: number;
  38982. /**
  38983. * Log performance to the console
  38984. */
  38985. static readonly PerformanceConsoleLogLevel: number;
  38986. private static _performance;
  38987. /**
  38988. * Sets the current performance log level
  38989. */
  38990. static set PerformanceLogLevel(level: number);
  38991. private static _StartPerformanceCounterDisabled;
  38992. private static _EndPerformanceCounterDisabled;
  38993. private static _StartUserMark;
  38994. private static _EndUserMark;
  38995. private static _StartPerformanceConsole;
  38996. private static _EndPerformanceConsole;
  38997. /**
  38998. * Starts a performance counter
  38999. */
  39000. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39001. /**
  39002. * Ends a specific performance coutner
  39003. */
  39004. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39005. /**
  39006. * Gets either window.performance.now() if supported or Date.now() else
  39007. */
  39008. static get Now(): number;
  39009. /**
  39010. * This method will return the name of the class used to create the instance of the given object.
  39011. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39012. * @param object the object to get the class name from
  39013. * @param isType defines if the object is actually a type
  39014. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39015. */
  39016. static GetClassName(object: any, isType?: boolean): string;
  39017. /**
  39018. * Gets the first element of an array satisfying a given predicate
  39019. * @param array defines the array to browse
  39020. * @param predicate defines the predicate to use
  39021. * @returns null if not found or the element
  39022. */
  39023. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39024. /**
  39025. * This method will return the name of the full name of the class, including its owning module (if any).
  39026. * 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).
  39027. * @param object the object to get the class name from
  39028. * @param isType defines if the object is actually a type
  39029. * @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.
  39030. * @ignorenaming
  39031. */
  39032. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39033. /**
  39034. * Returns a promise that resolves after the given amount of time.
  39035. * @param delay Number of milliseconds to delay
  39036. * @returns Promise that resolves after the given amount of time
  39037. */
  39038. static DelayAsync(delay: number): Promise<void>;
  39039. /**
  39040. * Utility function to detect if the current user agent is Safari
  39041. * @returns whether or not the current user agent is safari
  39042. */
  39043. static IsSafari(): boolean;
  39044. }
  39045. /**
  39046. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39047. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39048. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39049. * @param name The name of the class, case should be preserved
  39050. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39051. */
  39052. export function className(name: string, module?: string): (target: Object) => void;
  39053. /**
  39054. * An implementation of a loop for asynchronous functions.
  39055. */
  39056. export class AsyncLoop {
  39057. /**
  39058. * Defines the number of iterations for the loop
  39059. */
  39060. iterations: number;
  39061. /**
  39062. * Defines the current index of the loop.
  39063. */
  39064. index: number;
  39065. private _done;
  39066. private _fn;
  39067. private _successCallback;
  39068. /**
  39069. * Constructor.
  39070. * @param iterations the number of iterations.
  39071. * @param func the function to run each iteration
  39072. * @param successCallback the callback that will be called upon succesful execution
  39073. * @param offset starting offset.
  39074. */
  39075. constructor(
  39076. /**
  39077. * Defines the number of iterations for the loop
  39078. */
  39079. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39080. /**
  39081. * Execute the next iteration. Must be called after the last iteration was finished.
  39082. */
  39083. executeNext(): void;
  39084. /**
  39085. * Break the loop and run the success callback.
  39086. */
  39087. breakLoop(): void;
  39088. /**
  39089. * Create and run an async loop.
  39090. * @param iterations the number of iterations.
  39091. * @param fn the function to run each iteration
  39092. * @param successCallback the callback that will be called upon succesful execution
  39093. * @param offset starting offset.
  39094. * @returns the created async loop object
  39095. */
  39096. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39097. /**
  39098. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39099. * @param iterations total number of iterations
  39100. * @param syncedIterations number of synchronous iterations in each async iteration.
  39101. * @param fn the function to call each iteration.
  39102. * @param callback a success call back that will be called when iterating stops.
  39103. * @param breakFunction a break condition (optional)
  39104. * @param timeout timeout settings for the setTimeout function. default - 0.
  39105. * @returns the created async loop object
  39106. */
  39107. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39108. }
  39109. }
  39110. declare module "babylonjs/Misc/stringDictionary" {
  39111. import { Nullable } from "babylonjs/types";
  39112. /**
  39113. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39114. * The underlying implementation relies on an associative array to ensure the best performances.
  39115. * The value can be anything including 'null' but except 'undefined'
  39116. */
  39117. export class StringDictionary<T> {
  39118. /**
  39119. * This will clear this dictionary and copy the content from the 'source' one.
  39120. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39121. * @param source the dictionary to take the content from and copy to this dictionary
  39122. */
  39123. copyFrom(source: StringDictionary<T>): void;
  39124. /**
  39125. * Get a value based from its key
  39126. * @param key the given key to get the matching value from
  39127. * @return the value if found, otherwise undefined is returned
  39128. */
  39129. get(key: string): T | undefined;
  39130. /**
  39131. * Get a value from its key or add it if it doesn't exist.
  39132. * This method will ensure you that a given key/data will be present in the dictionary.
  39133. * @param key the given key to get the matching value from
  39134. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39135. * The factory will only be invoked if there's no data for the given key.
  39136. * @return the value corresponding to the key.
  39137. */
  39138. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39139. /**
  39140. * Get a value from its key if present in the dictionary otherwise add it
  39141. * @param key the key to get the value from
  39142. * @param val if there's no such key/value pair in the dictionary add it with this value
  39143. * @return the value corresponding to the key
  39144. */
  39145. getOrAdd(key: string, val: T): T;
  39146. /**
  39147. * Check if there's a given key in the dictionary
  39148. * @param key the key to check for
  39149. * @return true if the key is present, false otherwise
  39150. */
  39151. contains(key: string): boolean;
  39152. /**
  39153. * Add a new key and its corresponding value
  39154. * @param key the key to add
  39155. * @param value the value corresponding to the key
  39156. * @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
  39157. */
  39158. add(key: string, value: T): boolean;
  39159. /**
  39160. * Update a specific value associated to a key
  39161. * @param key defines the key to use
  39162. * @param value defines the value to store
  39163. * @returns true if the value was updated (or false if the key was not found)
  39164. */
  39165. set(key: string, value: T): boolean;
  39166. /**
  39167. * Get the element of the given key and remove it from the dictionary
  39168. * @param key defines the key to search
  39169. * @returns the value associated with the key or null if not found
  39170. */
  39171. getAndRemove(key: string): Nullable<T>;
  39172. /**
  39173. * Remove a key/value from the dictionary.
  39174. * @param key the key to remove
  39175. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39176. */
  39177. remove(key: string): boolean;
  39178. /**
  39179. * Clear the whole content of the dictionary
  39180. */
  39181. clear(): void;
  39182. /**
  39183. * Gets the current count
  39184. */
  39185. get count(): number;
  39186. /**
  39187. * Execute a callback on each key/val of the dictionary.
  39188. * Note that you can remove any element in this dictionary in the callback implementation
  39189. * @param callback the callback to execute on a given key/value pair
  39190. */
  39191. forEach(callback: (key: string, val: T) => void): void;
  39192. /**
  39193. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39194. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39195. * Note that you can remove any element in this dictionary in the callback implementation
  39196. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39197. * @returns the first item
  39198. */
  39199. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39200. private _count;
  39201. private _data;
  39202. }
  39203. }
  39204. declare module "babylonjs/Collisions/collisionCoordinator" {
  39205. import { Nullable } from "babylonjs/types";
  39206. import { Scene } from "babylonjs/scene";
  39207. import { Vector3 } from "babylonjs/Maths/math.vector";
  39208. import { Collider } from "babylonjs/Collisions/collider";
  39209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39210. /** @hidden */
  39211. export interface ICollisionCoordinator {
  39212. createCollider(): Collider;
  39213. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39214. init(scene: Scene): void;
  39215. }
  39216. /** @hidden */
  39217. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39218. private _scene;
  39219. private _scaledPosition;
  39220. private _scaledVelocity;
  39221. private _finalPosition;
  39222. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39223. createCollider(): Collider;
  39224. init(scene: Scene): void;
  39225. private _collideWithWorld;
  39226. }
  39227. }
  39228. declare module "babylonjs/Inputs/scene.inputManager" {
  39229. import { Nullable } from "babylonjs/types";
  39230. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39231. import { Vector2 } from "babylonjs/Maths/math.vector";
  39232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39233. import { Scene } from "babylonjs/scene";
  39234. /**
  39235. * Class used to manage all inputs for the scene.
  39236. */
  39237. export class InputManager {
  39238. /** The distance in pixel that you have to move to prevent some events */
  39239. static DragMovementThreshold: number;
  39240. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39241. static LongPressDelay: number;
  39242. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39243. static DoubleClickDelay: number;
  39244. /** If you need to check double click without raising a single click at first click, enable this flag */
  39245. static ExclusiveDoubleClickMode: boolean;
  39246. private _wheelEventName;
  39247. private _onPointerMove;
  39248. private _onPointerDown;
  39249. private _onPointerUp;
  39250. private _initClickEvent;
  39251. private _initActionManager;
  39252. private _delayedSimpleClick;
  39253. private _delayedSimpleClickTimeout;
  39254. private _previousDelayedSimpleClickTimeout;
  39255. private _meshPickProceed;
  39256. private _previousButtonPressed;
  39257. private _currentPickResult;
  39258. private _previousPickResult;
  39259. private _totalPointersPressed;
  39260. private _doubleClickOccured;
  39261. private _pointerOverMesh;
  39262. private _pickedDownMesh;
  39263. private _pickedUpMesh;
  39264. private _pointerX;
  39265. private _pointerY;
  39266. private _unTranslatedPointerX;
  39267. private _unTranslatedPointerY;
  39268. private _startingPointerPosition;
  39269. private _previousStartingPointerPosition;
  39270. private _startingPointerTime;
  39271. private _previousStartingPointerTime;
  39272. private _pointerCaptures;
  39273. private _onKeyDown;
  39274. private _onKeyUp;
  39275. private _onCanvasFocusObserver;
  39276. private _onCanvasBlurObserver;
  39277. private _scene;
  39278. /**
  39279. * Creates a new InputManager
  39280. * @param scene defines the hosting scene
  39281. */
  39282. constructor(scene: Scene);
  39283. /**
  39284. * Gets the mesh that is currently under the pointer
  39285. */
  39286. get meshUnderPointer(): Nullable<AbstractMesh>;
  39287. /**
  39288. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39289. */
  39290. get unTranslatedPointer(): Vector2;
  39291. /**
  39292. * Gets or sets the current on-screen X position of the pointer
  39293. */
  39294. get pointerX(): number;
  39295. set pointerX(value: number);
  39296. /**
  39297. * Gets or sets the current on-screen Y position of the pointer
  39298. */
  39299. get pointerY(): number;
  39300. set pointerY(value: number);
  39301. private _updatePointerPosition;
  39302. private _processPointerMove;
  39303. private _setRayOnPointerInfo;
  39304. private _checkPrePointerObservable;
  39305. /**
  39306. * Use this method to simulate a pointer move on a mesh
  39307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39310. */
  39311. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39312. /**
  39313. * Use this method to simulate a pointer down on a mesh
  39314. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39315. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39316. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39317. */
  39318. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39319. private _processPointerDown;
  39320. /** @hidden */
  39321. _isPointerSwiping(): boolean;
  39322. /**
  39323. * Use this method to simulate a pointer up on a mesh
  39324. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39325. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39326. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39327. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39328. */
  39329. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39330. private _processPointerUp;
  39331. /**
  39332. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39333. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39334. * @returns true if the pointer was captured
  39335. */
  39336. isPointerCaptured(pointerId?: number): boolean;
  39337. /**
  39338. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39339. * @param attachUp defines if you want to attach events to pointerup
  39340. * @param attachDown defines if you want to attach events to pointerdown
  39341. * @param attachMove defines if you want to attach events to pointermove
  39342. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39343. */
  39344. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39345. /**
  39346. * Detaches all event handlers
  39347. */
  39348. detachControl(): void;
  39349. /**
  39350. * Force the value of meshUnderPointer
  39351. * @param mesh defines the mesh to use
  39352. */
  39353. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39354. /**
  39355. * Gets the mesh under the pointer
  39356. * @returns a Mesh or null if no mesh is under the pointer
  39357. */
  39358. getPointerOverMesh(): Nullable<AbstractMesh>;
  39359. }
  39360. }
  39361. declare module "babylonjs/Animations/animationGroup" {
  39362. import { Animatable } from "babylonjs/Animations/animatable";
  39363. import { Animation } from "babylonjs/Animations/animation";
  39364. import { Scene, IDisposable } from "babylonjs/scene";
  39365. import { Observable } from "babylonjs/Misc/observable";
  39366. import { Nullable } from "babylonjs/types";
  39367. import "babylonjs/Animations/animatable";
  39368. /**
  39369. * This class defines the direct association between an animation and a target
  39370. */
  39371. export class TargetedAnimation {
  39372. /**
  39373. * Animation to perform
  39374. */
  39375. animation: Animation;
  39376. /**
  39377. * Target to animate
  39378. */
  39379. target: any;
  39380. /**
  39381. * Returns the string "TargetedAnimation"
  39382. * @returns "TargetedAnimation"
  39383. */
  39384. getClassName(): string;
  39385. /**
  39386. * Serialize the object
  39387. * @returns the JSON object representing the current entity
  39388. */
  39389. serialize(): any;
  39390. }
  39391. /**
  39392. * Use this class to create coordinated animations on multiple targets
  39393. */
  39394. export class AnimationGroup implements IDisposable {
  39395. /** The name of the animation group */
  39396. name: string;
  39397. private _scene;
  39398. private _targetedAnimations;
  39399. private _animatables;
  39400. private _from;
  39401. private _to;
  39402. private _isStarted;
  39403. private _isPaused;
  39404. private _speedRatio;
  39405. private _loopAnimation;
  39406. private _isAdditive;
  39407. /**
  39408. * Gets or sets the unique id of the node
  39409. */
  39410. uniqueId: number;
  39411. /**
  39412. * This observable will notify when one animation have ended
  39413. */
  39414. onAnimationEndObservable: Observable<TargetedAnimation>;
  39415. /**
  39416. * Observer raised when one animation loops
  39417. */
  39418. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39419. /**
  39420. * Observer raised when all animations have looped
  39421. */
  39422. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39423. /**
  39424. * This observable will notify when all animations have ended.
  39425. */
  39426. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39427. /**
  39428. * This observable will notify when all animations have paused.
  39429. */
  39430. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39431. /**
  39432. * This observable will notify when all animations are playing.
  39433. */
  39434. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39435. /**
  39436. * Gets the first frame
  39437. */
  39438. get from(): number;
  39439. /**
  39440. * Gets the last frame
  39441. */
  39442. get to(): number;
  39443. /**
  39444. * Define if the animations are started
  39445. */
  39446. get isStarted(): boolean;
  39447. /**
  39448. * Gets a value indicating that the current group is playing
  39449. */
  39450. get isPlaying(): boolean;
  39451. /**
  39452. * Gets or sets the speed ratio to use for all animations
  39453. */
  39454. get speedRatio(): number;
  39455. /**
  39456. * Gets or sets the speed ratio to use for all animations
  39457. */
  39458. set speedRatio(value: number);
  39459. /**
  39460. * Gets or sets if all animations should loop or not
  39461. */
  39462. get loopAnimation(): boolean;
  39463. set loopAnimation(value: boolean);
  39464. /**
  39465. * Gets or sets if all animations should be evaluated additively
  39466. */
  39467. get isAdditive(): boolean;
  39468. set isAdditive(value: boolean);
  39469. /**
  39470. * Gets the targeted animations for this animation group
  39471. */
  39472. get targetedAnimations(): Array<TargetedAnimation>;
  39473. /**
  39474. * returning the list of animatables controlled by this animation group.
  39475. */
  39476. get animatables(): Array<Animatable>;
  39477. /**
  39478. * Gets the list of target animations
  39479. */
  39480. get children(): TargetedAnimation[];
  39481. /**
  39482. * Instantiates a new Animation Group.
  39483. * This helps managing several animations at once.
  39484. * @see http://doc.babylonjs.com/how_to/group
  39485. * @param name Defines the name of the group
  39486. * @param scene Defines the scene the group belongs to
  39487. */
  39488. constructor(
  39489. /** The name of the animation group */
  39490. name: string, scene?: Nullable<Scene>);
  39491. /**
  39492. * Add an animation (with its target) in the group
  39493. * @param animation defines the animation we want to add
  39494. * @param target defines the target of the animation
  39495. * @returns the TargetedAnimation object
  39496. */
  39497. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39498. /**
  39499. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39500. * It can add constant keys at begin or end
  39501. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39502. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39503. * @returns the animation group
  39504. */
  39505. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39506. private _animationLoopCount;
  39507. private _animationLoopFlags;
  39508. private _processLoop;
  39509. /**
  39510. * Start all animations on given targets
  39511. * @param loop defines if animations must loop
  39512. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39513. * @param from defines the from key (optional)
  39514. * @param to defines the to key (optional)
  39515. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39516. * @returns the current animation group
  39517. */
  39518. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39519. /**
  39520. * Pause all animations
  39521. * @returns the animation group
  39522. */
  39523. pause(): AnimationGroup;
  39524. /**
  39525. * Play all animations to initial state
  39526. * This function will start() the animations if they were not started or will restart() them if they were paused
  39527. * @param loop defines if animations must loop
  39528. * @returns the animation group
  39529. */
  39530. play(loop?: boolean): AnimationGroup;
  39531. /**
  39532. * Reset all animations to initial state
  39533. * @returns the animation group
  39534. */
  39535. reset(): AnimationGroup;
  39536. /**
  39537. * Restart animations from key 0
  39538. * @returns the animation group
  39539. */
  39540. restart(): AnimationGroup;
  39541. /**
  39542. * Stop all animations
  39543. * @returns the animation group
  39544. */
  39545. stop(): AnimationGroup;
  39546. /**
  39547. * Set animation weight for all animatables
  39548. * @param weight defines the weight to use
  39549. * @return the animationGroup
  39550. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39551. */
  39552. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39553. /**
  39554. * Synchronize and normalize all animatables with a source animatable
  39555. * @param root defines the root animatable to synchronize with
  39556. * @return the animationGroup
  39557. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39558. */
  39559. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39560. /**
  39561. * Goes to a specific frame in this animation group
  39562. * @param frame the frame number to go to
  39563. * @return the animationGroup
  39564. */
  39565. goToFrame(frame: number): AnimationGroup;
  39566. /**
  39567. * Dispose all associated resources
  39568. */
  39569. dispose(): void;
  39570. private _checkAnimationGroupEnded;
  39571. /**
  39572. * Clone the current animation group and returns a copy
  39573. * @param newName defines the name of the new group
  39574. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39575. * @returns the new aniamtion group
  39576. */
  39577. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39578. /**
  39579. * Serializes the animationGroup to an object
  39580. * @returns Serialized object
  39581. */
  39582. serialize(): any;
  39583. /**
  39584. * Returns a new AnimationGroup object parsed from the source provided.
  39585. * @param parsedAnimationGroup defines the source
  39586. * @param scene defines the scene that will receive the animationGroup
  39587. * @returns a new AnimationGroup
  39588. */
  39589. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39590. /**
  39591. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39592. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39593. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39594. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39595. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39596. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39597. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39598. */
  39599. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39600. /**
  39601. * Returns the string "AnimationGroup"
  39602. * @returns "AnimationGroup"
  39603. */
  39604. getClassName(): string;
  39605. /**
  39606. * Creates a detailled string about the object
  39607. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39608. * @returns a string representing the object
  39609. */
  39610. toString(fullDetails?: boolean): string;
  39611. }
  39612. }
  39613. declare module "babylonjs/scene" {
  39614. import { Nullable } from "babylonjs/types";
  39615. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39616. import { Observable } from "babylonjs/Misc/observable";
  39617. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39618. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39619. import { Geometry } from "babylonjs/Meshes/geometry";
  39620. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39623. import { Mesh } from "babylonjs/Meshes/mesh";
  39624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39625. import { Bone } from "babylonjs/Bones/bone";
  39626. import { Skeleton } from "babylonjs/Bones/skeleton";
  39627. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39628. import { Camera } from "babylonjs/Cameras/camera";
  39629. import { AbstractScene } from "babylonjs/abstractScene";
  39630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39632. import { Material } from "babylonjs/Materials/material";
  39633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39634. import { Effect } from "babylonjs/Materials/effect";
  39635. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39636. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39637. import { Light } from "babylonjs/Lights/light";
  39638. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39639. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39640. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39641. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39642. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39643. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39644. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39645. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39646. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39647. import { Engine } from "babylonjs/Engines/engine";
  39648. import { Node } from "babylonjs/node";
  39649. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39650. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39651. import { WebRequest } from "babylonjs/Misc/webRequest";
  39652. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39653. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39654. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39655. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39656. import { Plane } from "babylonjs/Maths/math.plane";
  39657. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39658. import { Ray } from "babylonjs/Culling/ray";
  39659. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39660. import { Animation } from "babylonjs/Animations/animation";
  39661. import { Animatable } from "babylonjs/Animations/animatable";
  39662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39663. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39664. import { Collider } from "babylonjs/Collisions/collider";
  39665. /**
  39666. * Define an interface for all classes that will hold resources
  39667. */
  39668. export interface IDisposable {
  39669. /**
  39670. * Releases all held resources
  39671. */
  39672. dispose(): void;
  39673. }
  39674. /** Interface defining initialization parameters for Scene class */
  39675. export interface SceneOptions {
  39676. /**
  39677. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39678. * It will improve performance when the number of geometries becomes important.
  39679. */
  39680. useGeometryUniqueIdsMap?: boolean;
  39681. /**
  39682. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39683. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39684. */
  39685. useMaterialMeshMap?: boolean;
  39686. /**
  39687. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39688. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39689. */
  39690. useClonedMeshMap?: boolean;
  39691. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39692. virtual?: boolean;
  39693. }
  39694. /**
  39695. * Represents a scene to be rendered by the engine.
  39696. * @see http://doc.babylonjs.com/features/scene
  39697. */
  39698. export class Scene extends AbstractScene implements IAnimatable {
  39699. /** The fog is deactivated */
  39700. static readonly FOGMODE_NONE: number;
  39701. /** The fog density is following an exponential function */
  39702. static readonly FOGMODE_EXP: number;
  39703. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39704. static readonly FOGMODE_EXP2: number;
  39705. /** The fog density is following a linear function. */
  39706. static readonly FOGMODE_LINEAR: number;
  39707. /**
  39708. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39710. */
  39711. static MinDeltaTime: number;
  39712. /**
  39713. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39714. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39715. */
  39716. static MaxDeltaTime: number;
  39717. /**
  39718. * Factory used to create the default material.
  39719. * @param name The name of the material to create
  39720. * @param scene The scene to create the material for
  39721. * @returns The default material
  39722. */
  39723. static DefaultMaterialFactory(scene: Scene): Material;
  39724. /**
  39725. * Factory used to create the a collision coordinator.
  39726. * @returns The collision coordinator
  39727. */
  39728. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39729. /** @hidden */
  39730. _inputManager: InputManager;
  39731. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39732. cameraToUseForPointers: Nullable<Camera>;
  39733. /** @hidden */
  39734. readonly _isScene: boolean;
  39735. /** @hidden */
  39736. _blockEntityCollection: boolean;
  39737. /**
  39738. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39739. */
  39740. autoClear: boolean;
  39741. /**
  39742. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39743. */
  39744. autoClearDepthAndStencil: boolean;
  39745. /**
  39746. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39747. */
  39748. clearColor: Color4;
  39749. /**
  39750. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39751. */
  39752. ambientColor: Color3;
  39753. /**
  39754. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39755. * It should only be one of the following (if not the default embedded one):
  39756. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39757. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39758. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39759. * The material properties need to be setup according to the type of texture in use.
  39760. */
  39761. environmentBRDFTexture: BaseTexture;
  39762. /** @hidden */
  39763. protected _environmentTexture: Nullable<BaseTexture>;
  39764. /**
  39765. * Texture used in all pbr material as the reflection texture.
  39766. * As in the majority of the scene they are the same (exception for multi room and so on),
  39767. * this is easier to reference from here than from all the materials.
  39768. */
  39769. get environmentTexture(): Nullable<BaseTexture>;
  39770. /**
  39771. * Texture used in all pbr material as the reflection texture.
  39772. * As in the majority of the scene they are the same (exception for multi room and so on),
  39773. * this is easier to set here than in all the materials.
  39774. */
  39775. set environmentTexture(value: Nullable<BaseTexture>);
  39776. /** @hidden */
  39777. protected _environmentIntensity: number;
  39778. /**
  39779. * Intensity of the environment in all pbr material.
  39780. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39781. * As in the majority of the scene they are the same (exception for multi room and so on),
  39782. * this is easier to reference from here than from all the materials.
  39783. */
  39784. get environmentIntensity(): number;
  39785. /**
  39786. * Intensity of the environment in all pbr material.
  39787. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39788. * As in the majority of the scene they are the same (exception for multi room and so on),
  39789. * this is easier to set here than in all the materials.
  39790. */
  39791. set environmentIntensity(value: number);
  39792. /** @hidden */
  39793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39794. /**
  39795. * Default image processing configuration used either in the rendering
  39796. * Forward main pass or through the imageProcessingPostProcess if present.
  39797. * As in the majority of the scene they are the same (exception for multi camera),
  39798. * this is easier to reference from here than from all the materials and post process.
  39799. *
  39800. * No setter as we it is a shared configuration, you can set the values instead.
  39801. */
  39802. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39803. private _forceWireframe;
  39804. /**
  39805. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39806. */
  39807. set forceWireframe(value: boolean);
  39808. get forceWireframe(): boolean;
  39809. private _skipFrustumClipping;
  39810. /**
  39811. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39812. */
  39813. set skipFrustumClipping(value: boolean);
  39814. get skipFrustumClipping(): boolean;
  39815. private _forcePointsCloud;
  39816. /**
  39817. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39818. */
  39819. set forcePointsCloud(value: boolean);
  39820. get forcePointsCloud(): boolean;
  39821. /**
  39822. * Gets or sets the active clipplane 1
  39823. */
  39824. clipPlane: Nullable<Plane>;
  39825. /**
  39826. * Gets or sets the active clipplane 2
  39827. */
  39828. clipPlane2: Nullable<Plane>;
  39829. /**
  39830. * Gets or sets the active clipplane 3
  39831. */
  39832. clipPlane3: Nullable<Plane>;
  39833. /**
  39834. * Gets or sets the active clipplane 4
  39835. */
  39836. clipPlane4: Nullable<Plane>;
  39837. /**
  39838. * Gets or sets the active clipplane 5
  39839. */
  39840. clipPlane5: Nullable<Plane>;
  39841. /**
  39842. * Gets or sets the active clipplane 6
  39843. */
  39844. clipPlane6: Nullable<Plane>;
  39845. /**
  39846. * Gets or sets a boolean indicating if animations are enabled
  39847. */
  39848. animationsEnabled: boolean;
  39849. private _animationPropertiesOverride;
  39850. /**
  39851. * Gets or sets the animation properties override
  39852. */
  39853. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39854. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39855. /**
  39856. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39857. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39858. */
  39859. useConstantAnimationDeltaTime: boolean;
  39860. /**
  39861. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39862. * Please note that it requires to run a ray cast through the scene on every frame
  39863. */
  39864. constantlyUpdateMeshUnderPointer: boolean;
  39865. /**
  39866. * Defines the HTML cursor to use when hovering over interactive elements
  39867. */
  39868. hoverCursor: string;
  39869. /**
  39870. * Defines the HTML default cursor to use (empty by default)
  39871. */
  39872. defaultCursor: string;
  39873. /**
  39874. * Defines whether cursors are handled by the scene.
  39875. */
  39876. doNotHandleCursors: boolean;
  39877. /**
  39878. * This is used to call preventDefault() on pointer down
  39879. * in order to block unwanted artifacts like system double clicks
  39880. */
  39881. preventDefaultOnPointerDown: boolean;
  39882. /**
  39883. * This is used to call preventDefault() on pointer up
  39884. * in order to block unwanted artifacts like system double clicks
  39885. */
  39886. preventDefaultOnPointerUp: boolean;
  39887. /**
  39888. * Gets or sets user defined metadata
  39889. */
  39890. metadata: any;
  39891. /**
  39892. * For internal use only. Please do not use.
  39893. */
  39894. reservedDataStore: any;
  39895. /**
  39896. * Gets the name of the plugin used to load this scene (null by default)
  39897. */
  39898. loadingPluginName: string;
  39899. /**
  39900. * Use this array to add regular expressions used to disable offline support for specific urls
  39901. */
  39902. disableOfflineSupportExceptionRules: RegExp[];
  39903. /**
  39904. * An event triggered when the scene is disposed.
  39905. */
  39906. onDisposeObservable: Observable<Scene>;
  39907. private _onDisposeObserver;
  39908. /** Sets a function to be executed when this scene is disposed. */
  39909. set onDispose(callback: () => void);
  39910. /**
  39911. * An event triggered before rendering the scene (right after animations and physics)
  39912. */
  39913. onBeforeRenderObservable: Observable<Scene>;
  39914. private _onBeforeRenderObserver;
  39915. /** Sets a function to be executed before rendering this scene */
  39916. set beforeRender(callback: Nullable<() => void>);
  39917. /**
  39918. * An event triggered after rendering the scene
  39919. */
  39920. onAfterRenderObservable: Observable<Scene>;
  39921. /**
  39922. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39923. */
  39924. onAfterRenderCameraObservable: Observable<Camera>;
  39925. private _onAfterRenderObserver;
  39926. /** Sets a function to be executed after rendering this scene */
  39927. set afterRender(callback: Nullable<() => void>);
  39928. /**
  39929. * An event triggered before animating the scene
  39930. */
  39931. onBeforeAnimationsObservable: Observable<Scene>;
  39932. /**
  39933. * An event triggered after animations processing
  39934. */
  39935. onAfterAnimationsObservable: Observable<Scene>;
  39936. /**
  39937. * An event triggered before draw calls are ready to be sent
  39938. */
  39939. onBeforeDrawPhaseObservable: Observable<Scene>;
  39940. /**
  39941. * An event triggered after draw calls have been sent
  39942. */
  39943. onAfterDrawPhaseObservable: Observable<Scene>;
  39944. /**
  39945. * An event triggered when the scene is ready
  39946. */
  39947. onReadyObservable: Observable<Scene>;
  39948. /**
  39949. * An event triggered before rendering a camera
  39950. */
  39951. onBeforeCameraRenderObservable: Observable<Camera>;
  39952. private _onBeforeCameraRenderObserver;
  39953. /** Sets a function to be executed before rendering a camera*/
  39954. set beforeCameraRender(callback: () => void);
  39955. /**
  39956. * An event triggered after rendering a camera
  39957. */
  39958. onAfterCameraRenderObservable: Observable<Camera>;
  39959. private _onAfterCameraRenderObserver;
  39960. /** Sets a function to be executed after rendering a camera*/
  39961. set afterCameraRender(callback: () => void);
  39962. /**
  39963. * An event triggered when active meshes evaluation is about to start
  39964. */
  39965. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39966. /**
  39967. * An event triggered when active meshes evaluation is done
  39968. */
  39969. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39970. /**
  39971. * An event triggered when particles rendering is about to start
  39972. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39973. */
  39974. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39975. /**
  39976. * An event triggered when particles rendering is done
  39977. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39978. */
  39979. onAfterParticlesRenderingObservable: Observable<Scene>;
  39980. /**
  39981. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39982. */
  39983. onDataLoadedObservable: Observable<Scene>;
  39984. /**
  39985. * An event triggered when a camera is created
  39986. */
  39987. onNewCameraAddedObservable: Observable<Camera>;
  39988. /**
  39989. * An event triggered when a camera is removed
  39990. */
  39991. onCameraRemovedObservable: Observable<Camera>;
  39992. /**
  39993. * An event triggered when a light is created
  39994. */
  39995. onNewLightAddedObservable: Observable<Light>;
  39996. /**
  39997. * An event triggered when a light is removed
  39998. */
  39999. onLightRemovedObservable: Observable<Light>;
  40000. /**
  40001. * An event triggered when a geometry is created
  40002. */
  40003. onNewGeometryAddedObservable: Observable<Geometry>;
  40004. /**
  40005. * An event triggered when a geometry is removed
  40006. */
  40007. onGeometryRemovedObservable: Observable<Geometry>;
  40008. /**
  40009. * An event triggered when a transform node is created
  40010. */
  40011. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40012. /**
  40013. * An event triggered when a transform node is removed
  40014. */
  40015. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40016. /**
  40017. * An event triggered when a mesh is created
  40018. */
  40019. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40020. /**
  40021. * An event triggered when a mesh is removed
  40022. */
  40023. onMeshRemovedObservable: Observable<AbstractMesh>;
  40024. /**
  40025. * An event triggered when a skeleton is created
  40026. */
  40027. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40028. /**
  40029. * An event triggered when a skeleton is removed
  40030. */
  40031. onSkeletonRemovedObservable: Observable<Skeleton>;
  40032. /**
  40033. * An event triggered when a material is created
  40034. */
  40035. onNewMaterialAddedObservable: Observable<Material>;
  40036. /**
  40037. * An event triggered when a material is removed
  40038. */
  40039. onMaterialRemovedObservable: Observable<Material>;
  40040. /**
  40041. * An event triggered when a texture is created
  40042. */
  40043. onNewTextureAddedObservable: Observable<BaseTexture>;
  40044. /**
  40045. * An event triggered when a texture is removed
  40046. */
  40047. onTextureRemovedObservable: Observable<BaseTexture>;
  40048. /**
  40049. * An event triggered when render targets are about to be rendered
  40050. * Can happen multiple times per frame.
  40051. */
  40052. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40053. /**
  40054. * An event triggered when render targets were rendered.
  40055. * Can happen multiple times per frame.
  40056. */
  40057. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40058. /**
  40059. * An event triggered before calculating deterministic simulation step
  40060. */
  40061. onBeforeStepObservable: Observable<Scene>;
  40062. /**
  40063. * An event triggered after calculating deterministic simulation step
  40064. */
  40065. onAfterStepObservable: Observable<Scene>;
  40066. /**
  40067. * An event triggered when the activeCamera property is updated
  40068. */
  40069. onActiveCameraChanged: Observable<Scene>;
  40070. /**
  40071. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40072. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40073. * 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)
  40074. */
  40075. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40076. /**
  40077. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40078. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40079. * 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)
  40080. */
  40081. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40082. /**
  40083. * This Observable will when a mesh has been imported into the scene.
  40084. */
  40085. onMeshImportedObservable: Observable<AbstractMesh>;
  40086. /**
  40087. * This Observable will when an animation file has been imported into the scene.
  40088. */
  40089. onAnimationFileImportedObservable: Observable<Scene>;
  40090. /**
  40091. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40092. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40093. */
  40094. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40095. /** @hidden */
  40096. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40097. /**
  40098. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40099. */
  40100. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40101. /**
  40102. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40103. */
  40104. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40105. /**
  40106. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40107. */
  40108. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40109. /** Callback called when a pointer move is detected */
  40110. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40111. /** Callback called when a pointer down is detected */
  40112. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40113. /** Callback called when a pointer up is detected */
  40114. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40115. /** Callback called when a pointer pick is detected */
  40116. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40117. /**
  40118. * 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).
  40119. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40120. */
  40121. onPrePointerObservable: Observable<PointerInfoPre>;
  40122. /**
  40123. * Observable event triggered each time an input event is received from the rendering canvas
  40124. */
  40125. onPointerObservable: Observable<PointerInfo>;
  40126. /**
  40127. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40128. */
  40129. get unTranslatedPointer(): Vector2;
  40130. /**
  40131. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40132. */
  40133. static get DragMovementThreshold(): number;
  40134. static set DragMovementThreshold(value: number);
  40135. /**
  40136. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40137. */
  40138. static get LongPressDelay(): number;
  40139. static set LongPressDelay(value: number);
  40140. /**
  40141. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40142. */
  40143. static get DoubleClickDelay(): number;
  40144. static set DoubleClickDelay(value: number);
  40145. /** If you need to check double click without raising a single click at first click, enable this flag */
  40146. static get ExclusiveDoubleClickMode(): boolean;
  40147. static set ExclusiveDoubleClickMode(value: boolean);
  40148. /** @hidden */
  40149. _mirroredCameraPosition: Nullable<Vector3>;
  40150. /**
  40151. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40152. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40153. */
  40154. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40155. /**
  40156. * Observable event triggered each time an keyboard event is received from the hosting window
  40157. */
  40158. onKeyboardObservable: Observable<KeyboardInfo>;
  40159. private _useRightHandedSystem;
  40160. /**
  40161. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40162. */
  40163. set useRightHandedSystem(value: boolean);
  40164. get useRightHandedSystem(): boolean;
  40165. private _timeAccumulator;
  40166. private _currentStepId;
  40167. private _currentInternalStep;
  40168. /**
  40169. * Sets the step Id used by deterministic lock step
  40170. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40171. * @param newStepId defines the step Id
  40172. */
  40173. setStepId(newStepId: number): void;
  40174. /**
  40175. * Gets the step Id used by deterministic lock step
  40176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40177. * @returns the step Id
  40178. */
  40179. getStepId(): number;
  40180. /**
  40181. * Gets the internal step used by deterministic lock step
  40182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40183. * @returns the internal step
  40184. */
  40185. getInternalStep(): number;
  40186. private _fogEnabled;
  40187. /**
  40188. * Gets or sets a boolean indicating if fog is enabled on this scene
  40189. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40190. * (Default is true)
  40191. */
  40192. set fogEnabled(value: boolean);
  40193. get fogEnabled(): boolean;
  40194. private _fogMode;
  40195. /**
  40196. * Gets or sets the fog mode to use
  40197. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40198. * | mode | value |
  40199. * | --- | --- |
  40200. * | FOGMODE_NONE | 0 |
  40201. * | FOGMODE_EXP | 1 |
  40202. * | FOGMODE_EXP2 | 2 |
  40203. * | FOGMODE_LINEAR | 3 |
  40204. */
  40205. set fogMode(value: number);
  40206. get fogMode(): number;
  40207. /**
  40208. * Gets or sets the fog color to use
  40209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40210. * (Default is Color3(0.2, 0.2, 0.3))
  40211. */
  40212. fogColor: Color3;
  40213. /**
  40214. * Gets or sets the fog density to use
  40215. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40216. * (Default is 0.1)
  40217. */
  40218. fogDensity: number;
  40219. /**
  40220. * Gets or sets the fog start distance to use
  40221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40222. * (Default is 0)
  40223. */
  40224. fogStart: number;
  40225. /**
  40226. * Gets or sets the fog end distance to use
  40227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40228. * (Default is 1000)
  40229. */
  40230. fogEnd: number;
  40231. private _shadowsEnabled;
  40232. /**
  40233. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40234. */
  40235. set shadowsEnabled(value: boolean);
  40236. get shadowsEnabled(): boolean;
  40237. private _lightsEnabled;
  40238. /**
  40239. * Gets or sets a boolean indicating if lights are enabled on this scene
  40240. */
  40241. set lightsEnabled(value: boolean);
  40242. get lightsEnabled(): boolean;
  40243. /** All of the active cameras added to this scene. */
  40244. activeCameras: Camera[];
  40245. /** @hidden */
  40246. _activeCamera: Nullable<Camera>;
  40247. /** Gets or sets the current active camera */
  40248. get activeCamera(): Nullable<Camera>;
  40249. set activeCamera(value: Nullable<Camera>);
  40250. private _defaultMaterial;
  40251. /** The default material used on meshes when no material is affected */
  40252. get defaultMaterial(): Material;
  40253. /** The default material used on meshes when no material is affected */
  40254. set defaultMaterial(value: Material);
  40255. private _texturesEnabled;
  40256. /**
  40257. * Gets or sets a boolean indicating if textures are enabled on this scene
  40258. */
  40259. set texturesEnabled(value: boolean);
  40260. get texturesEnabled(): boolean;
  40261. /**
  40262. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40263. */
  40264. physicsEnabled: boolean;
  40265. /**
  40266. * Gets or sets a boolean indicating if particles are enabled on this scene
  40267. */
  40268. particlesEnabled: boolean;
  40269. /**
  40270. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40271. */
  40272. spritesEnabled: boolean;
  40273. private _skeletonsEnabled;
  40274. /**
  40275. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40276. */
  40277. set skeletonsEnabled(value: boolean);
  40278. get skeletonsEnabled(): boolean;
  40279. /**
  40280. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40281. */
  40282. lensFlaresEnabled: boolean;
  40283. /**
  40284. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40285. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40286. */
  40287. collisionsEnabled: boolean;
  40288. private _collisionCoordinator;
  40289. /** @hidden */
  40290. get collisionCoordinator(): ICollisionCoordinator;
  40291. /**
  40292. * Defines the gravity applied to this scene (used only for collisions)
  40293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40294. */
  40295. gravity: Vector3;
  40296. /**
  40297. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40298. */
  40299. postProcessesEnabled: boolean;
  40300. /**
  40301. * The list of postprocesses added to the scene
  40302. */
  40303. postProcesses: PostProcess[];
  40304. /**
  40305. * Gets the current postprocess manager
  40306. */
  40307. postProcessManager: PostProcessManager;
  40308. /**
  40309. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40310. */
  40311. renderTargetsEnabled: boolean;
  40312. /**
  40313. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40314. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40315. */
  40316. dumpNextRenderTargets: boolean;
  40317. /**
  40318. * The list of user defined render targets added to the scene
  40319. */
  40320. customRenderTargets: RenderTargetTexture[];
  40321. /**
  40322. * Defines if texture loading must be delayed
  40323. * If true, textures will only be loaded when they need to be rendered
  40324. */
  40325. useDelayedTextureLoading: boolean;
  40326. /**
  40327. * Gets the list of meshes imported to the scene through SceneLoader
  40328. */
  40329. importedMeshesFiles: String[];
  40330. /**
  40331. * Gets or sets a boolean indicating if probes are enabled on this scene
  40332. */
  40333. probesEnabled: boolean;
  40334. /**
  40335. * Gets or sets the current offline provider to use to store scene data
  40336. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40337. */
  40338. offlineProvider: IOfflineProvider;
  40339. /**
  40340. * Gets or sets the action manager associated with the scene
  40341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40342. */
  40343. actionManager: AbstractActionManager;
  40344. private _meshesForIntersections;
  40345. /**
  40346. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40347. */
  40348. proceduralTexturesEnabled: boolean;
  40349. private _engine;
  40350. private _totalVertices;
  40351. /** @hidden */
  40352. _activeIndices: PerfCounter;
  40353. /** @hidden */
  40354. _activeParticles: PerfCounter;
  40355. /** @hidden */
  40356. _activeBones: PerfCounter;
  40357. private _animationRatio;
  40358. /** @hidden */
  40359. _animationTimeLast: number;
  40360. /** @hidden */
  40361. _animationTime: number;
  40362. /**
  40363. * Gets or sets a general scale for animation speed
  40364. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40365. */
  40366. animationTimeScale: number;
  40367. /** @hidden */
  40368. _cachedMaterial: Nullable<Material>;
  40369. /** @hidden */
  40370. _cachedEffect: Nullable<Effect>;
  40371. /** @hidden */
  40372. _cachedVisibility: Nullable<number>;
  40373. private _renderId;
  40374. private _frameId;
  40375. private _executeWhenReadyTimeoutId;
  40376. private _intermediateRendering;
  40377. private _viewUpdateFlag;
  40378. private _projectionUpdateFlag;
  40379. /** @hidden */
  40380. _toBeDisposed: Nullable<IDisposable>[];
  40381. private _activeRequests;
  40382. /** @hidden */
  40383. _pendingData: any[];
  40384. private _isDisposed;
  40385. /**
  40386. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40387. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40388. */
  40389. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40390. private _activeMeshes;
  40391. private _processedMaterials;
  40392. private _renderTargets;
  40393. /** @hidden */
  40394. _activeParticleSystems: SmartArray<IParticleSystem>;
  40395. private _activeSkeletons;
  40396. private _softwareSkinnedMeshes;
  40397. private _renderingManager;
  40398. /** @hidden */
  40399. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40400. private _transformMatrix;
  40401. private _sceneUbo;
  40402. /** @hidden */
  40403. _viewMatrix: Matrix;
  40404. private _projectionMatrix;
  40405. /** @hidden */
  40406. _forcedViewPosition: Nullable<Vector3>;
  40407. /** @hidden */
  40408. _frustumPlanes: Plane[];
  40409. /**
  40410. * Gets the list of frustum planes (built from the active camera)
  40411. */
  40412. get frustumPlanes(): Plane[];
  40413. /**
  40414. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40415. * This is useful if there are more lights that the maximum simulteanous authorized
  40416. */
  40417. requireLightSorting: boolean;
  40418. /** @hidden */
  40419. readonly useMaterialMeshMap: boolean;
  40420. /** @hidden */
  40421. readonly useClonedMeshMap: boolean;
  40422. private _externalData;
  40423. private _uid;
  40424. /**
  40425. * @hidden
  40426. * Backing store of defined scene components.
  40427. */
  40428. _components: ISceneComponent[];
  40429. /**
  40430. * @hidden
  40431. * Backing store of defined scene components.
  40432. */
  40433. _serializableComponents: ISceneSerializableComponent[];
  40434. /**
  40435. * List of components to register on the next registration step.
  40436. */
  40437. private _transientComponents;
  40438. /**
  40439. * Registers the transient components if needed.
  40440. */
  40441. private _registerTransientComponents;
  40442. /**
  40443. * @hidden
  40444. * Add a component to the scene.
  40445. * Note that the ccomponent could be registered on th next frame if this is called after
  40446. * the register component stage.
  40447. * @param component Defines the component to add to the scene
  40448. */
  40449. _addComponent(component: ISceneComponent): void;
  40450. /**
  40451. * @hidden
  40452. * Gets a component from the scene.
  40453. * @param name defines the name of the component to retrieve
  40454. * @returns the component or null if not present
  40455. */
  40456. _getComponent(name: string): Nullable<ISceneComponent>;
  40457. /**
  40458. * @hidden
  40459. * Defines the actions happening before camera updates.
  40460. */
  40461. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40462. /**
  40463. * @hidden
  40464. * Defines the actions happening before clear the canvas.
  40465. */
  40466. _beforeClearStage: Stage<SimpleStageAction>;
  40467. /**
  40468. * @hidden
  40469. * Defines the actions when collecting render targets for the frame.
  40470. */
  40471. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40472. /**
  40473. * @hidden
  40474. * Defines the actions happening for one camera in the frame.
  40475. */
  40476. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40477. /**
  40478. * @hidden
  40479. * Defines the actions happening during the per mesh ready checks.
  40480. */
  40481. _isReadyForMeshStage: Stage<MeshStageAction>;
  40482. /**
  40483. * @hidden
  40484. * Defines the actions happening before evaluate active mesh checks.
  40485. */
  40486. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40487. /**
  40488. * @hidden
  40489. * Defines the actions happening during the evaluate sub mesh checks.
  40490. */
  40491. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40492. /**
  40493. * @hidden
  40494. * Defines the actions happening during the active mesh stage.
  40495. */
  40496. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40497. /**
  40498. * @hidden
  40499. * Defines the actions happening during the per camera render target step.
  40500. */
  40501. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40502. /**
  40503. * @hidden
  40504. * Defines the actions happening just before the active camera is drawing.
  40505. */
  40506. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40507. /**
  40508. * @hidden
  40509. * Defines the actions happening just before a render target is drawing.
  40510. */
  40511. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40512. /**
  40513. * @hidden
  40514. * Defines the actions happening just before a rendering group is drawing.
  40515. */
  40516. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40517. /**
  40518. * @hidden
  40519. * Defines the actions happening just before a mesh is drawing.
  40520. */
  40521. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40522. /**
  40523. * @hidden
  40524. * Defines the actions happening just after a mesh has been drawn.
  40525. */
  40526. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40527. /**
  40528. * @hidden
  40529. * Defines the actions happening just after a rendering group has been drawn.
  40530. */
  40531. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40532. /**
  40533. * @hidden
  40534. * Defines the actions happening just after the active camera has been drawn.
  40535. */
  40536. _afterCameraDrawStage: Stage<CameraStageAction>;
  40537. /**
  40538. * @hidden
  40539. * Defines the actions happening just after a render target has been drawn.
  40540. */
  40541. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40542. /**
  40543. * @hidden
  40544. * Defines the actions happening just after rendering all cameras and computing intersections.
  40545. */
  40546. _afterRenderStage: Stage<SimpleStageAction>;
  40547. /**
  40548. * @hidden
  40549. * Defines the actions happening when a pointer move event happens.
  40550. */
  40551. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40552. /**
  40553. * @hidden
  40554. * Defines the actions happening when a pointer down event happens.
  40555. */
  40556. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40557. /**
  40558. * @hidden
  40559. * Defines the actions happening when a pointer up event happens.
  40560. */
  40561. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40562. /**
  40563. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40564. */
  40565. private geometriesByUniqueId;
  40566. /**
  40567. * Creates a new Scene
  40568. * @param engine defines the engine to use to render this scene
  40569. * @param options defines the scene options
  40570. */
  40571. constructor(engine: Engine, options?: SceneOptions);
  40572. /**
  40573. * Gets a string idenfifying the name of the class
  40574. * @returns "Scene" string
  40575. */
  40576. getClassName(): string;
  40577. private _defaultMeshCandidates;
  40578. /**
  40579. * @hidden
  40580. */
  40581. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40582. private _defaultSubMeshCandidates;
  40583. /**
  40584. * @hidden
  40585. */
  40586. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40587. /**
  40588. * Sets the default candidate providers for the scene.
  40589. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40590. * and getCollidingSubMeshCandidates to their default function
  40591. */
  40592. setDefaultCandidateProviders(): void;
  40593. /**
  40594. * Gets the mesh that is currently under the pointer
  40595. */
  40596. get meshUnderPointer(): Nullable<AbstractMesh>;
  40597. /**
  40598. * Gets or sets the current on-screen X position of the pointer
  40599. */
  40600. get pointerX(): number;
  40601. set pointerX(value: number);
  40602. /**
  40603. * Gets or sets the current on-screen Y position of the pointer
  40604. */
  40605. get pointerY(): number;
  40606. set pointerY(value: number);
  40607. /**
  40608. * Gets the cached material (ie. the latest rendered one)
  40609. * @returns the cached material
  40610. */
  40611. getCachedMaterial(): Nullable<Material>;
  40612. /**
  40613. * Gets the cached effect (ie. the latest rendered one)
  40614. * @returns the cached effect
  40615. */
  40616. getCachedEffect(): Nullable<Effect>;
  40617. /**
  40618. * Gets the cached visibility state (ie. the latest rendered one)
  40619. * @returns the cached visibility state
  40620. */
  40621. getCachedVisibility(): Nullable<number>;
  40622. /**
  40623. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40624. * @param material defines the current material
  40625. * @param effect defines the current effect
  40626. * @param visibility defines the current visibility state
  40627. * @returns true if one parameter is not cached
  40628. */
  40629. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40630. /**
  40631. * Gets the engine associated with the scene
  40632. * @returns an Engine
  40633. */
  40634. getEngine(): Engine;
  40635. /**
  40636. * Gets the total number of vertices rendered per frame
  40637. * @returns the total number of vertices rendered per frame
  40638. */
  40639. getTotalVertices(): number;
  40640. /**
  40641. * Gets the performance counter for total vertices
  40642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40643. */
  40644. get totalVerticesPerfCounter(): PerfCounter;
  40645. /**
  40646. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40647. * @returns the total number of active indices rendered per frame
  40648. */
  40649. getActiveIndices(): number;
  40650. /**
  40651. * Gets the performance counter for active indices
  40652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40653. */
  40654. get totalActiveIndicesPerfCounter(): PerfCounter;
  40655. /**
  40656. * Gets the total number of active particles rendered per frame
  40657. * @returns the total number of active particles rendered per frame
  40658. */
  40659. getActiveParticles(): number;
  40660. /**
  40661. * Gets the performance counter for active particles
  40662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40663. */
  40664. get activeParticlesPerfCounter(): PerfCounter;
  40665. /**
  40666. * Gets the total number of active bones rendered per frame
  40667. * @returns the total number of active bones rendered per frame
  40668. */
  40669. getActiveBones(): number;
  40670. /**
  40671. * Gets the performance counter for active bones
  40672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40673. */
  40674. get activeBonesPerfCounter(): PerfCounter;
  40675. /**
  40676. * Gets the array of active meshes
  40677. * @returns an array of AbstractMesh
  40678. */
  40679. getActiveMeshes(): SmartArray<AbstractMesh>;
  40680. /**
  40681. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40682. * @returns a number
  40683. */
  40684. getAnimationRatio(): number;
  40685. /**
  40686. * Gets an unique Id for the current render phase
  40687. * @returns a number
  40688. */
  40689. getRenderId(): number;
  40690. /**
  40691. * Gets an unique Id for the current frame
  40692. * @returns a number
  40693. */
  40694. getFrameId(): number;
  40695. /** Call this function if you want to manually increment the render Id*/
  40696. incrementRenderId(): void;
  40697. private _createUbo;
  40698. /**
  40699. * Use this method to simulate a pointer move on a mesh
  40700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40703. * @returns the current scene
  40704. */
  40705. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40706. /**
  40707. * Use this method to simulate a pointer down on a mesh
  40708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40711. * @returns the current scene
  40712. */
  40713. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40714. /**
  40715. * Use this method to simulate a pointer up on a mesh
  40716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40719. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40720. * @returns the current scene
  40721. */
  40722. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40723. /**
  40724. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40725. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40726. * @returns true if the pointer was captured
  40727. */
  40728. isPointerCaptured(pointerId?: number): boolean;
  40729. /**
  40730. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40731. * @param attachUp defines if you want to attach events to pointerup
  40732. * @param attachDown defines if you want to attach events to pointerdown
  40733. * @param attachMove defines if you want to attach events to pointermove
  40734. */
  40735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40736. /** Detaches all event handlers*/
  40737. detachControl(): void;
  40738. /**
  40739. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40740. * Delay loaded resources are not taking in account
  40741. * @return true if all required resources are ready
  40742. */
  40743. isReady(): boolean;
  40744. /** Resets all cached information relative to material (including effect and visibility) */
  40745. resetCachedMaterial(): void;
  40746. /**
  40747. * Registers a function to be called before every frame render
  40748. * @param func defines the function to register
  40749. */
  40750. registerBeforeRender(func: () => void): void;
  40751. /**
  40752. * Unregisters a function called before every frame render
  40753. * @param func defines the function to unregister
  40754. */
  40755. unregisterBeforeRender(func: () => void): void;
  40756. /**
  40757. * Registers a function to be called after every frame render
  40758. * @param func defines the function to register
  40759. */
  40760. registerAfterRender(func: () => void): void;
  40761. /**
  40762. * Unregisters a function called after every frame render
  40763. * @param func defines the function to unregister
  40764. */
  40765. unregisterAfterRender(func: () => void): void;
  40766. private _executeOnceBeforeRender;
  40767. /**
  40768. * The provided function will run before render once and will be disposed afterwards.
  40769. * A timeout delay can be provided so that the function will be executed in N ms.
  40770. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40771. * @param func The function to be executed.
  40772. * @param timeout optional delay in ms
  40773. */
  40774. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40775. /** @hidden */
  40776. _addPendingData(data: any): void;
  40777. /** @hidden */
  40778. _removePendingData(data: any): void;
  40779. /**
  40780. * Returns the number of items waiting to be loaded
  40781. * @returns the number of items waiting to be loaded
  40782. */
  40783. getWaitingItemsCount(): number;
  40784. /**
  40785. * Returns a boolean indicating if the scene is still loading data
  40786. */
  40787. get isLoading(): boolean;
  40788. /**
  40789. * Registers a function to be executed when the scene is ready
  40790. * @param {Function} func - the function to be executed
  40791. */
  40792. executeWhenReady(func: () => void): void;
  40793. /**
  40794. * Returns a promise that resolves when the scene is ready
  40795. * @returns A promise that resolves when the scene is ready
  40796. */
  40797. whenReadyAsync(): Promise<void>;
  40798. /** @hidden */
  40799. _checkIsReady(): void;
  40800. /**
  40801. * Gets all animatable attached to the scene
  40802. */
  40803. get animatables(): Animatable[];
  40804. /**
  40805. * Resets the last animation time frame.
  40806. * Useful to override when animations start running when loading a scene for the first time.
  40807. */
  40808. resetLastAnimationTimeFrame(): void;
  40809. /**
  40810. * Gets the current view matrix
  40811. * @returns a Matrix
  40812. */
  40813. getViewMatrix(): Matrix;
  40814. /**
  40815. * Gets the current projection matrix
  40816. * @returns a Matrix
  40817. */
  40818. getProjectionMatrix(): Matrix;
  40819. /**
  40820. * Gets the current transform matrix
  40821. * @returns a Matrix made of View * Projection
  40822. */
  40823. getTransformMatrix(): Matrix;
  40824. /**
  40825. * Sets the current transform matrix
  40826. * @param viewL defines the View matrix to use
  40827. * @param projectionL defines the Projection matrix to use
  40828. * @param viewR defines the right View matrix to use (if provided)
  40829. * @param projectionR defines the right Projection matrix to use (if provided)
  40830. */
  40831. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40832. /**
  40833. * Gets the uniform buffer used to store scene data
  40834. * @returns a UniformBuffer
  40835. */
  40836. getSceneUniformBuffer(): UniformBuffer;
  40837. /**
  40838. * Gets an unique (relatively to the current scene) Id
  40839. * @returns an unique number for the scene
  40840. */
  40841. getUniqueId(): number;
  40842. /**
  40843. * Add a mesh to the list of scene's meshes
  40844. * @param newMesh defines the mesh to add
  40845. * @param recursive if all child meshes should also be added to the scene
  40846. */
  40847. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40848. /**
  40849. * Remove a mesh for the list of scene's meshes
  40850. * @param toRemove defines the mesh to remove
  40851. * @param recursive if all child meshes should also be removed from the scene
  40852. * @returns the index where the mesh was in the mesh list
  40853. */
  40854. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40855. /**
  40856. * Add a transform node to the list of scene's transform nodes
  40857. * @param newTransformNode defines the transform node to add
  40858. */
  40859. addTransformNode(newTransformNode: TransformNode): void;
  40860. /**
  40861. * Remove a transform node for the list of scene's transform nodes
  40862. * @param toRemove defines the transform node to remove
  40863. * @returns the index where the transform node was in the transform node list
  40864. */
  40865. removeTransformNode(toRemove: TransformNode): number;
  40866. /**
  40867. * Remove a skeleton for the list of scene's skeletons
  40868. * @param toRemove defines the skeleton to remove
  40869. * @returns the index where the skeleton was in the skeleton list
  40870. */
  40871. removeSkeleton(toRemove: Skeleton): number;
  40872. /**
  40873. * Remove a morph target for the list of scene's morph targets
  40874. * @param toRemove defines the morph target to remove
  40875. * @returns the index where the morph target was in the morph target list
  40876. */
  40877. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40878. /**
  40879. * Remove a light for the list of scene's lights
  40880. * @param toRemove defines the light to remove
  40881. * @returns the index where the light was in the light list
  40882. */
  40883. removeLight(toRemove: Light): number;
  40884. /**
  40885. * Remove a camera for the list of scene's cameras
  40886. * @param toRemove defines the camera to remove
  40887. * @returns the index where the camera was in the camera list
  40888. */
  40889. removeCamera(toRemove: Camera): number;
  40890. /**
  40891. * Remove a particle system for the list of scene's particle systems
  40892. * @param toRemove defines the particle system to remove
  40893. * @returns the index where the particle system was in the particle system list
  40894. */
  40895. removeParticleSystem(toRemove: IParticleSystem): number;
  40896. /**
  40897. * Remove a animation for the list of scene's animations
  40898. * @param toRemove defines the animation to remove
  40899. * @returns the index where the animation was in the animation list
  40900. */
  40901. removeAnimation(toRemove: Animation): number;
  40902. /**
  40903. * Will stop the animation of the given target
  40904. * @param target - the target
  40905. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40906. * @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)
  40907. */
  40908. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40909. /**
  40910. * Removes the given animation group from this scene.
  40911. * @param toRemove The animation group to remove
  40912. * @returns The index of the removed animation group
  40913. */
  40914. removeAnimationGroup(toRemove: AnimationGroup): number;
  40915. /**
  40916. * Removes the given multi-material from this scene.
  40917. * @param toRemove The multi-material to remove
  40918. * @returns The index of the removed multi-material
  40919. */
  40920. removeMultiMaterial(toRemove: MultiMaterial): number;
  40921. /**
  40922. * Removes the given material from this scene.
  40923. * @param toRemove The material to remove
  40924. * @returns The index of the removed material
  40925. */
  40926. removeMaterial(toRemove: Material): number;
  40927. /**
  40928. * Removes the given action manager from this scene.
  40929. * @param toRemove The action manager to remove
  40930. * @returns The index of the removed action manager
  40931. */
  40932. removeActionManager(toRemove: AbstractActionManager): number;
  40933. /**
  40934. * Removes the given texture from this scene.
  40935. * @param toRemove The texture to remove
  40936. * @returns The index of the removed texture
  40937. */
  40938. removeTexture(toRemove: BaseTexture): number;
  40939. /**
  40940. * Adds the given light to this scene
  40941. * @param newLight The light to add
  40942. */
  40943. addLight(newLight: Light): void;
  40944. /**
  40945. * Sorts the list list based on light priorities
  40946. */
  40947. sortLightsByPriority(): void;
  40948. /**
  40949. * Adds the given camera to this scene
  40950. * @param newCamera The camera to add
  40951. */
  40952. addCamera(newCamera: Camera): void;
  40953. /**
  40954. * Adds the given skeleton to this scene
  40955. * @param newSkeleton The skeleton to add
  40956. */
  40957. addSkeleton(newSkeleton: Skeleton): void;
  40958. /**
  40959. * Adds the given particle system to this scene
  40960. * @param newParticleSystem The particle system to add
  40961. */
  40962. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40963. /**
  40964. * Adds the given animation to this scene
  40965. * @param newAnimation The animation to add
  40966. */
  40967. addAnimation(newAnimation: Animation): void;
  40968. /**
  40969. * Adds the given animation group to this scene.
  40970. * @param newAnimationGroup The animation group to add
  40971. */
  40972. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40973. /**
  40974. * Adds the given multi-material to this scene
  40975. * @param newMultiMaterial The multi-material to add
  40976. */
  40977. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40978. /**
  40979. * Adds the given material to this scene
  40980. * @param newMaterial The material to add
  40981. */
  40982. addMaterial(newMaterial: Material): void;
  40983. /**
  40984. * Adds the given morph target to this scene
  40985. * @param newMorphTargetManager The morph target to add
  40986. */
  40987. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40988. /**
  40989. * Adds the given geometry to this scene
  40990. * @param newGeometry The geometry to add
  40991. */
  40992. addGeometry(newGeometry: Geometry): void;
  40993. /**
  40994. * Adds the given action manager to this scene
  40995. * @param newActionManager The action manager to add
  40996. */
  40997. addActionManager(newActionManager: AbstractActionManager): void;
  40998. /**
  40999. * Adds the given texture to this scene.
  41000. * @param newTexture The texture to add
  41001. */
  41002. addTexture(newTexture: BaseTexture): void;
  41003. /**
  41004. * Switch active camera
  41005. * @param newCamera defines the new active camera
  41006. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41007. */
  41008. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41009. /**
  41010. * sets the active camera of the scene using its ID
  41011. * @param id defines the camera's ID
  41012. * @return the new active camera or null if none found.
  41013. */
  41014. setActiveCameraByID(id: string): Nullable<Camera>;
  41015. /**
  41016. * sets the active camera of the scene using its name
  41017. * @param name defines the camera's name
  41018. * @returns the new active camera or null if none found.
  41019. */
  41020. setActiveCameraByName(name: string): Nullable<Camera>;
  41021. /**
  41022. * get an animation group using its name
  41023. * @param name defines the material's name
  41024. * @return the animation group or null if none found.
  41025. */
  41026. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41027. /**
  41028. * Get a material using its unique id
  41029. * @param uniqueId defines the material's unique id
  41030. * @return the material or null if none found.
  41031. */
  41032. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41033. /**
  41034. * get a material using its id
  41035. * @param id defines the material's ID
  41036. * @return the material or null if none found.
  41037. */
  41038. getMaterialByID(id: string): Nullable<Material>;
  41039. /**
  41040. * Gets a the last added material using a given id
  41041. * @param id defines the material's ID
  41042. * @return the last material with the given id or null if none found.
  41043. */
  41044. getLastMaterialByID(id: string): Nullable<Material>;
  41045. /**
  41046. * Gets a material using its name
  41047. * @param name defines the material's name
  41048. * @return the material or null if none found.
  41049. */
  41050. getMaterialByName(name: string): Nullable<Material>;
  41051. /**
  41052. * Get a texture using its unique id
  41053. * @param uniqueId defines the texture's unique id
  41054. * @return the texture or null if none found.
  41055. */
  41056. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41057. /**
  41058. * Gets a camera using its id
  41059. * @param id defines the id to look for
  41060. * @returns the camera or null if not found
  41061. */
  41062. getCameraByID(id: string): Nullable<Camera>;
  41063. /**
  41064. * Gets a camera using its unique id
  41065. * @param uniqueId defines the unique id to look for
  41066. * @returns the camera or null if not found
  41067. */
  41068. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41069. /**
  41070. * Gets a camera using its name
  41071. * @param name defines the camera's name
  41072. * @return the camera or null if none found.
  41073. */
  41074. getCameraByName(name: string): Nullable<Camera>;
  41075. /**
  41076. * Gets a bone using its id
  41077. * @param id defines the bone's id
  41078. * @return the bone or null if not found
  41079. */
  41080. getBoneByID(id: string): Nullable<Bone>;
  41081. /**
  41082. * Gets a bone using its id
  41083. * @param name defines the bone's name
  41084. * @return the bone or null if not found
  41085. */
  41086. getBoneByName(name: string): Nullable<Bone>;
  41087. /**
  41088. * Gets a light node using its name
  41089. * @param name defines the the light's name
  41090. * @return the light or null if none found.
  41091. */
  41092. getLightByName(name: string): Nullable<Light>;
  41093. /**
  41094. * Gets a light node using its id
  41095. * @param id defines the light's id
  41096. * @return the light or null if none found.
  41097. */
  41098. getLightByID(id: string): Nullable<Light>;
  41099. /**
  41100. * Gets a light node using its scene-generated unique ID
  41101. * @param uniqueId defines the light's unique id
  41102. * @return the light or null if none found.
  41103. */
  41104. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41105. /**
  41106. * Gets a particle system by id
  41107. * @param id defines the particle system id
  41108. * @return the corresponding system or null if none found
  41109. */
  41110. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41111. /**
  41112. * Gets a geometry using its ID
  41113. * @param id defines the geometry's id
  41114. * @return the geometry or null if none found.
  41115. */
  41116. getGeometryByID(id: string): Nullable<Geometry>;
  41117. private _getGeometryByUniqueID;
  41118. /**
  41119. * Add a new geometry to this scene
  41120. * @param geometry defines the geometry to be added to the scene.
  41121. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41122. * @return a boolean defining if the geometry was added or not
  41123. */
  41124. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41125. /**
  41126. * Removes an existing geometry
  41127. * @param geometry defines the geometry to be removed from the scene
  41128. * @return a boolean defining if the geometry was removed or not
  41129. */
  41130. removeGeometry(geometry: Geometry): boolean;
  41131. /**
  41132. * Gets the list of geometries attached to the scene
  41133. * @returns an array of Geometry
  41134. */
  41135. getGeometries(): Geometry[];
  41136. /**
  41137. * Gets the first added mesh found of a given ID
  41138. * @param id defines the id to search for
  41139. * @return the mesh found or null if not found at all
  41140. */
  41141. getMeshByID(id: string): Nullable<AbstractMesh>;
  41142. /**
  41143. * Gets a list of meshes using their id
  41144. * @param id defines the id to search for
  41145. * @returns a list of meshes
  41146. */
  41147. getMeshesByID(id: string): Array<AbstractMesh>;
  41148. /**
  41149. * Gets the first added transform node found of a given ID
  41150. * @param id defines the id to search for
  41151. * @return the found transform node or null if not found at all.
  41152. */
  41153. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41154. /**
  41155. * Gets a transform node with its auto-generated unique id
  41156. * @param uniqueId efines the unique id to search for
  41157. * @return the found transform node or null if not found at all.
  41158. */
  41159. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41160. /**
  41161. * Gets a list of transform nodes using their id
  41162. * @param id defines the id to search for
  41163. * @returns a list of transform nodes
  41164. */
  41165. getTransformNodesByID(id: string): Array<TransformNode>;
  41166. /**
  41167. * Gets a mesh with its auto-generated unique id
  41168. * @param uniqueId defines the unique id to search for
  41169. * @return the found mesh or null if not found at all.
  41170. */
  41171. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41172. /**
  41173. * Gets a the last added mesh using a given id
  41174. * @param id defines the id to search for
  41175. * @return the found mesh or null if not found at all.
  41176. */
  41177. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41178. /**
  41179. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41180. * @param id defines the id to search for
  41181. * @return the found node or null if not found at all
  41182. */
  41183. getLastEntryByID(id: string): Nullable<Node>;
  41184. /**
  41185. * Gets a node (Mesh, Camera, Light) using a given id
  41186. * @param id defines the id to search for
  41187. * @return the found node or null if not found at all
  41188. */
  41189. getNodeByID(id: string): Nullable<Node>;
  41190. /**
  41191. * Gets a node (Mesh, Camera, Light) using a given name
  41192. * @param name defines the name to search for
  41193. * @return the found node or null if not found at all.
  41194. */
  41195. getNodeByName(name: string): Nullable<Node>;
  41196. /**
  41197. * Gets a mesh using a given name
  41198. * @param name defines the name to search for
  41199. * @return the found mesh or null if not found at all.
  41200. */
  41201. getMeshByName(name: string): Nullable<AbstractMesh>;
  41202. /**
  41203. * Gets a transform node using a given name
  41204. * @param name defines the name to search for
  41205. * @return the found transform node or null if not found at all.
  41206. */
  41207. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41208. /**
  41209. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41210. * @param id defines the id to search for
  41211. * @return the found skeleton or null if not found at all.
  41212. */
  41213. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41214. /**
  41215. * Gets a skeleton using a given auto generated unique id
  41216. * @param uniqueId defines the unique id to search for
  41217. * @return the found skeleton or null if not found at all.
  41218. */
  41219. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41220. /**
  41221. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41222. * @param id defines the id to search for
  41223. * @return the found skeleton or null if not found at all.
  41224. */
  41225. getSkeletonById(id: string): Nullable<Skeleton>;
  41226. /**
  41227. * Gets a skeleton using a given name
  41228. * @param name defines the name to search for
  41229. * @return the found skeleton or null if not found at all.
  41230. */
  41231. getSkeletonByName(name: string): Nullable<Skeleton>;
  41232. /**
  41233. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41234. * @param id defines the id to search for
  41235. * @return the found morph target manager or null if not found at all.
  41236. */
  41237. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41238. /**
  41239. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41240. * @param id defines the id to search for
  41241. * @return the found morph target or null if not found at all.
  41242. */
  41243. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41244. /**
  41245. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41246. * @param name defines the name to search for
  41247. * @return the found morph target or null if not found at all.
  41248. */
  41249. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41250. /**
  41251. * Gets a boolean indicating if the given mesh is active
  41252. * @param mesh defines the mesh to look for
  41253. * @returns true if the mesh is in the active list
  41254. */
  41255. isActiveMesh(mesh: AbstractMesh): boolean;
  41256. /**
  41257. * Return a unique id as a string which can serve as an identifier for the scene
  41258. */
  41259. get uid(): string;
  41260. /**
  41261. * Add an externaly attached data from its key.
  41262. * This method call will fail and return false, if such key already exists.
  41263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41264. * @param key the unique key that identifies the data
  41265. * @param data the data object to associate to the key for this Engine instance
  41266. * @return true if no such key were already present and the data was added successfully, false otherwise
  41267. */
  41268. addExternalData<T>(key: string, data: T): boolean;
  41269. /**
  41270. * Get an externaly attached data from its key
  41271. * @param key the unique key that identifies the data
  41272. * @return the associated data, if present (can be null), or undefined if not present
  41273. */
  41274. getExternalData<T>(key: string): Nullable<T>;
  41275. /**
  41276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41277. * @param key the unique key that identifies the data
  41278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41279. * @return the associated data, can be null if the factory returned null.
  41280. */
  41281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41282. /**
  41283. * Remove an externaly attached data from the Engine instance
  41284. * @param key the unique key that identifies the data
  41285. * @return true if the data was successfully removed, false if it doesn't exist
  41286. */
  41287. removeExternalData(key: string): boolean;
  41288. private _evaluateSubMesh;
  41289. /**
  41290. * Clear the processed materials smart array preventing retention point in material dispose.
  41291. */
  41292. freeProcessedMaterials(): void;
  41293. private _preventFreeActiveMeshesAndRenderingGroups;
  41294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41296. * when disposing several meshes in a row or a hierarchy of meshes.
  41297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41298. */
  41299. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41300. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41301. /**
  41302. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41303. */
  41304. freeActiveMeshes(): void;
  41305. /**
  41306. * Clear the info related to rendering groups preventing retention points during dispose.
  41307. */
  41308. freeRenderingGroups(): void;
  41309. /** @hidden */
  41310. _isInIntermediateRendering(): boolean;
  41311. /**
  41312. * Lambda returning the list of potentially active meshes.
  41313. */
  41314. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41315. /**
  41316. * Lambda returning the list of potentially active sub meshes.
  41317. */
  41318. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41319. /**
  41320. * Lambda returning the list of potentially intersecting sub meshes.
  41321. */
  41322. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41323. /**
  41324. * Lambda returning the list of potentially colliding sub meshes.
  41325. */
  41326. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41327. private _activeMeshesFrozen;
  41328. private _skipEvaluateActiveMeshesCompletely;
  41329. /**
  41330. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41331. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41332. * @returns the current scene
  41333. */
  41334. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41335. /**
  41336. * Use this function to restart evaluating active meshes on every frame
  41337. * @returns the current scene
  41338. */
  41339. unfreezeActiveMeshes(): Scene;
  41340. private _evaluateActiveMeshes;
  41341. private _activeMesh;
  41342. /**
  41343. * Update the transform matrix to update from the current active camera
  41344. * @param force defines a boolean used to force the update even if cache is up to date
  41345. */
  41346. updateTransformMatrix(force?: boolean): void;
  41347. private _bindFrameBuffer;
  41348. /** @hidden */
  41349. _allowPostProcessClearColor: boolean;
  41350. /** @hidden */
  41351. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41352. private _processSubCameras;
  41353. private _checkIntersections;
  41354. /** @hidden */
  41355. _advancePhysicsEngineStep(step: number): void;
  41356. /**
  41357. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41358. */
  41359. getDeterministicFrameTime: () => number;
  41360. /** @hidden */
  41361. _animate(): void;
  41362. /** Execute all animations (for a frame) */
  41363. animate(): void;
  41364. /**
  41365. * Render the scene
  41366. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41367. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41368. */
  41369. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41370. /**
  41371. * Freeze all materials
  41372. * A frozen material will not be updatable but should be faster to render
  41373. */
  41374. freezeMaterials(): void;
  41375. /**
  41376. * Unfreeze all materials
  41377. * A frozen material will not be updatable but should be faster to render
  41378. */
  41379. unfreezeMaterials(): void;
  41380. /**
  41381. * Releases all held ressources
  41382. */
  41383. dispose(): void;
  41384. /**
  41385. * Gets if the scene is already disposed
  41386. */
  41387. get isDisposed(): boolean;
  41388. /**
  41389. * Call this function to reduce memory footprint of the scene.
  41390. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41391. */
  41392. clearCachedVertexData(): void;
  41393. /**
  41394. * This function will remove the local cached buffer data from texture.
  41395. * It will save memory but will prevent the texture from being rebuilt
  41396. */
  41397. cleanCachedTextureBuffer(): void;
  41398. /**
  41399. * Get the world extend vectors with an optional filter
  41400. *
  41401. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41402. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41403. */
  41404. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41405. min: Vector3;
  41406. max: Vector3;
  41407. };
  41408. /**
  41409. * Creates a ray that can be used to pick in the scene
  41410. * @param x defines the x coordinate of the origin (on-screen)
  41411. * @param y defines the y coordinate of the origin (on-screen)
  41412. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41413. * @param camera defines the camera to use for the picking
  41414. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41415. * @returns a Ray
  41416. */
  41417. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41418. /**
  41419. * Creates a ray that can be used to pick in the scene
  41420. * @param x defines the x coordinate of the origin (on-screen)
  41421. * @param y defines the y coordinate of the origin (on-screen)
  41422. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41423. * @param result defines the ray where to store the picking ray
  41424. * @param camera defines the camera to use for the picking
  41425. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41426. * @returns the current scene
  41427. */
  41428. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41429. /**
  41430. * Creates a ray that can be used to pick in the scene
  41431. * @param x defines the x coordinate of the origin (on-screen)
  41432. * @param y defines the y coordinate of the origin (on-screen)
  41433. * @param camera defines the camera to use for the picking
  41434. * @returns a Ray
  41435. */
  41436. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41437. /**
  41438. * Creates a ray that can be used to pick in the scene
  41439. * @param x defines the x coordinate of the origin (on-screen)
  41440. * @param y defines the y coordinate of the origin (on-screen)
  41441. * @param result defines the ray where to store the picking ray
  41442. * @param camera defines the camera to use for the picking
  41443. * @returns the current scene
  41444. */
  41445. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41446. /** Launch a ray to try to pick a mesh in the scene
  41447. * @param x position on screen
  41448. * @param y position on screen
  41449. * @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
  41450. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41451. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41453. * @returns a PickingInfo
  41454. */
  41455. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41456. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41457. * @param x position on screen
  41458. * @param y position on screen
  41459. * @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
  41460. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41461. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41462. * @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)
  41463. */
  41464. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41465. /** Use the given ray to pick a mesh in the scene
  41466. * @param ray The ray to use to pick meshes
  41467. * @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
  41468. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41470. * @returns a PickingInfo
  41471. */
  41472. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41473. /**
  41474. * Launch a ray to try to pick a mesh in the scene
  41475. * @param x X position on screen
  41476. * @param y Y position on screen
  41477. * @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
  41478. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41480. * @returns an array of PickingInfo
  41481. */
  41482. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41483. /**
  41484. * Launch a ray to try to pick a mesh in the scene
  41485. * @param ray Ray to use
  41486. * @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
  41487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41488. * @returns an array of PickingInfo
  41489. */
  41490. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41491. /**
  41492. * Force the value of meshUnderPointer
  41493. * @param mesh defines the mesh to use
  41494. */
  41495. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41496. /**
  41497. * Gets the mesh under the pointer
  41498. * @returns a Mesh or null if no mesh is under the pointer
  41499. */
  41500. getPointerOverMesh(): Nullable<AbstractMesh>;
  41501. /** @hidden */
  41502. _rebuildGeometries(): void;
  41503. /** @hidden */
  41504. _rebuildTextures(): void;
  41505. private _getByTags;
  41506. /**
  41507. * Get a list of meshes by tags
  41508. * @param tagsQuery defines the tags query to use
  41509. * @param forEach defines a predicate used to filter results
  41510. * @returns an array of Mesh
  41511. */
  41512. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41513. /**
  41514. * Get a list of cameras by tags
  41515. * @param tagsQuery defines the tags query to use
  41516. * @param forEach defines a predicate used to filter results
  41517. * @returns an array of Camera
  41518. */
  41519. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41520. /**
  41521. * Get a list of lights by tags
  41522. * @param tagsQuery defines the tags query to use
  41523. * @param forEach defines a predicate used to filter results
  41524. * @returns an array of Light
  41525. */
  41526. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41527. /**
  41528. * Get a list of materials by tags
  41529. * @param tagsQuery defines the tags query to use
  41530. * @param forEach defines a predicate used to filter results
  41531. * @returns an array of Material
  41532. */
  41533. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41534. /**
  41535. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41536. * This allowed control for front to back rendering or reversly depending of the special needs.
  41537. *
  41538. * @param renderingGroupId The rendering group id corresponding to its index
  41539. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41540. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41541. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41542. */
  41543. 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;
  41544. /**
  41545. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41546. *
  41547. * @param renderingGroupId The rendering group id corresponding to its index
  41548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41549. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41550. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41551. */
  41552. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41553. /**
  41554. * Gets the current auto clear configuration for one rendering group of the rendering
  41555. * manager.
  41556. * @param index the rendering group index to get the information for
  41557. * @returns The auto clear setup for the requested rendering group
  41558. */
  41559. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41560. private _blockMaterialDirtyMechanism;
  41561. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41562. get blockMaterialDirtyMechanism(): boolean;
  41563. set blockMaterialDirtyMechanism(value: boolean);
  41564. /**
  41565. * Will flag all materials as dirty to trigger new shader compilation
  41566. * @param flag defines the flag used to specify which material part must be marked as dirty
  41567. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41568. */
  41569. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41570. /** @hidden */
  41571. _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;
  41572. /** @hidden */
  41573. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41574. /** @hidden */
  41575. _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;
  41576. /** @hidden */
  41577. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41578. /** @hidden */
  41579. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41580. /** @hidden */
  41581. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41582. }
  41583. }
  41584. declare module "babylonjs/assetContainer" {
  41585. import { AbstractScene } from "babylonjs/abstractScene";
  41586. import { Scene } from "babylonjs/scene";
  41587. import { Mesh } from "babylonjs/Meshes/mesh";
  41588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41589. import { Skeleton } from "babylonjs/Bones/skeleton";
  41590. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41591. import { Animatable } from "babylonjs/Animations/animatable";
  41592. import { Nullable } from "babylonjs/types";
  41593. import { Node } from "babylonjs/node";
  41594. /**
  41595. * Set of assets to keep when moving a scene into an asset container.
  41596. */
  41597. export class KeepAssets extends AbstractScene {
  41598. }
  41599. /**
  41600. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41601. */
  41602. export class InstantiatedEntries {
  41603. /**
  41604. * List of new root nodes (eg. nodes with no parent)
  41605. */
  41606. rootNodes: TransformNode[];
  41607. /**
  41608. * List of new skeletons
  41609. */
  41610. skeletons: Skeleton[];
  41611. /**
  41612. * List of new animation groups
  41613. */
  41614. animationGroups: AnimationGroup[];
  41615. }
  41616. /**
  41617. * Container with a set of assets that can be added or removed from a scene.
  41618. */
  41619. export class AssetContainer extends AbstractScene {
  41620. private _wasAddedToScene;
  41621. /**
  41622. * The scene the AssetContainer belongs to.
  41623. */
  41624. scene: Scene;
  41625. /**
  41626. * Instantiates an AssetContainer.
  41627. * @param scene The scene the AssetContainer belongs to.
  41628. */
  41629. constructor(scene: Scene);
  41630. /**
  41631. * Instantiate or clone all meshes and add the new ones to the scene.
  41632. * Skeletons and animation groups will all be cloned
  41633. * @param nameFunction defines an optional function used to get new names for clones
  41634. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41635. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41636. */
  41637. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41638. /**
  41639. * Adds all the assets from the container to the scene.
  41640. */
  41641. addAllToScene(): void;
  41642. /**
  41643. * Removes all the assets in the container from the scene
  41644. */
  41645. removeAllFromScene(): void;
  41646. /**
  41647. * Disposes all the assets in the container
  41648. */
  41649. dispose(): void;
  41650. private _moveAssets;
  41651. /**
  41652. * Removes all the assets contained in the scene and adds them to the container.
  41653. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41654. */
  41655. moveAllFromScene(keepAssets?: KeepAssets): void;
  41656. /**
  41657. * 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.
  41658. * @returns the root mesh
  41659. */
  41660. createRootMesh(): Mesh;
  41661. /**
  41662. * Merge animations (direct and animation groups) from this asset container into a scene
  41663. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41664. * @param animatables set of animatables to retarget to a node from the scene
  41665. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41666. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41667. */
  41668. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41669. }
  41670. }
  41671. declare module "babylonjs/abstractScene" {
  41672. import { Scene } from "babylonjs/scene";
  41673. import { Nullable } from "babylonjs/types";
  41674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41676. import { Geometry } from "babylonjs/Meshes/geometry";
  41677. import { Skeleton } from "babylonjs/Bones/skeleton";
  41678. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41679. import { AssetContainer } from "babylonjs/assetContainer";
  41680. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41681. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41683. import { Material } from "babylonjs/Materials/material";
  41684. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41685. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41686. import { Camera } from "babylonjs/Cameras/camera";
  41687. import { Light } from "babylonjs/Lights/light";
  41688. import { Node } from "babylonjs/node";
  41689. import { Animation } from "babylonjs/Animations/animation";
  41690. /**
  41691. * Defines how the parser contract is defined.
  41692. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41693. */
  41694. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41695. /**
  41696. * Defines how the individual parser contract is defined.
  41697. * These parser can parse an individual asset
  41698. */
  41699. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41700. /**
  41701. * Base class of the scene acting as a container for the different elements composing a scene.
  41702. * This class is dynamically extended by the different components of the scene increasing
  41703. * flexibility and reducing coupling
  41704. */
  41705. export abstract class AbstractScene {
  41706. /**
  41707. * Stores the list of available parsers in the application.
  41708. */
  41709. private static _BabylonFileParsers;
  41710. /**
  41711. * Stores the list of available individual parsers in the application.
  41712. */
  41713. private static _IndividualBabylonFileParsers;
  41714. /**
  41715. * Adds a parser in the list of available ones
  41716. * @param name Defines the name of the parser
  41717. * @param parser Defines the parser to add
  41718. */
  41719. static AddParser(name: string, parser: BabylonFileParser): void;
  41720. /**
  41721. * Gets a general parser from the list of avaialble ones
  41722. * @param name Defines the name of the parser
  41723. * @returns the requested parser or null
  41724. */
  41725. static GetParser(name: string): Nullable<BabylonFileParser>;
  41726. /**
  41727. * Adds n individual parser in the list of available ones
  41728. * @param name Defines the name of the parser
  41729. * @param parser Defines the parser to add
  41730. */
  41731. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41732. /**
  41733. * Gets an individual parser from the list of avaialble ones
  41734. * @param name Defines the name of the parser
  41735. * @returns the requested parser or null
  41736. */
  41737. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41738. /**
  41739. * Parser json data and populate both a scene and its associated container object
  41740. * @param jsonData Defines the data to parse
  41741. * @param scene Defines the scene to parse the data for
  41742. * @param container Defines the container attached to the parsing sequence
  41743. * @param rootUrl Defines the root url of the data
  41744. */
  41745. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41746. /**
  41747. * Gets the list of root nodes (ie. nodes with no parent)
  41748. */
  41749. rootNodes: Node[];
  41750. /** All of the cameras added to this scene
  41751. * @see http://doc.babylonjs.com/babylon101/cameras
  41752. */
  41753. cameras: Camera[];
  41754. /**
  41755. * All of the lights added to this scene
  41756. * @see http://doc.babylonjs.com/babylon101/lights
  41757. */
  41758. lights: Light[];
  41759. /**
  41760. * All of the (abstract) meshes added to this scene
  41761. */
  41762. meshes: AbstractMesh[];
  41763. /**
  41764. * The list of skeletons added to the scene
  41765. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41766. */
  41767. skeletons: Skeleton[];
  41768. /**
  41769. * All of the particle systems added to this scene
  41770. * @see http://doc.babylonjs.com/babylon101/particles
  41771. */
  41772. particleSystems: IParticleSystem[];
  41773. /**
  41774. * Gets a list of Animations associated with the scene
  41775. */
  41776. animations: Animation[];
  41777. /**
  41778. * All of the animation groups added to this scene
  41779. * @see http://doc.babylonjs.com/how_to/group
  41780. */
  41781. animationGroups: AnimationGroup[];
  41782. /**
  41783. * All of the multi-materials added to this scene
  41784. * @see http://doc.babylonjs.com/how_to/multi_materials
  41785. */
  41786. multiMaterials: MultiMaterial[];
  41787. /**
  41788. * All of the materials added to this scene
  41789. * In the context of a Scene, it is not supposed to be modified manually.
  41790. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41791. * Note also that the order of the Material within the array is not significant and might change.
  41792. * @see http://doc.babylonjs.com/babylon101/materials
  41793. */
  41794. materials: Material[];
  41795. /**
  41796. * The list of morph target managers added to the scene
  41797. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41798. */
  41799. morphTargetManagers: MorphTargetManager[];
  41800. /**
  41801. * The list of geometries used in the scene.
  41802. */
  41803. geometries: Geometry[];
  41804. /**
  41805. * All of the tranform nodes added to this scene
  41806. * In the context of a Scene, it is not supposed to be modified manually.
  41807. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41808. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41809. * @see http://doc.babylonjs.com/how_to/transformnode
  41810. */
  41811. transformNodes: TransformNode[];
  41812. /**
  41813. * ActionManagers available on the scene.
  41814. */
  41815. actionManagers: AbstractActionManager[];
  41816. /**
  41817. * Textures to keep.
  41818. */
  41819. textures: BaseTexture[];
  41820. /**
  41821. * Environment texture for the scene
  41822. */
  41823. environmentTexture: Nullable<BaseTexture>;
  41824. /**
  41825. * @returns all meshes, lights, cameras, transformNodes and bones
  41826. */
  41827. getNodes(): Array<Node>;
  41828. }
  41829. }
  41830. declare module "babylonjs/Audio/sound" {
  41831. import { Observable } from "babylonjs/Misc/observable";
  41832. import { Vector3 } from "babylonjs/Maths/math.vector";
  41833. import { Nullable } from "babylonjs/types";
  41834. import { Scene } from "babylonjs/scene";
  41835. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41836. /**
  41837. * Interface used to define options for Sound class
  41838. */
  41839. export interface ISoundOptions {
  41840. /**
  41841. * Does the sound autoplay once loaded.
  41842. */
  41843. autoplay?: boolean;
  41844. /**
  41845. * Does the sound loop after it finishes playing once.
  41846. */
  41847. loop?: boolean;
  41848. /**
  41849. * Sound's volume
  41850. */
  41851. volume?: number;
  41852. /**
  41853. * Is it a spatial sound?
  41854. */
  41855. spatialSound?: boolean;
  41856. /**
  41857. * Maximum distance to hear that sound
  41858. */
  41859. maxDistance?: number;
  41860. /**
  41861. * Uses user defined attenuation function
  41862. */
  41863. useCustomAttenuation?: boolean;
  41864. /**
  41865. * Define the roll off factor of spatial sounds.
  41866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41867. */
  41868. rolloffFactor?: number;
  41869. /**
  41870. * Define the reference distance the sound should be heard perfectly.
  41871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41872. */
  41873. refDistance?: number;
  41874. /**
  41875. * Define the distance attenuation model the sound will follow.
  41876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41877. */
  41878. distanceModel?: string;
  41879. /**
  41880. * Defines the playback speed (1 by default)
  41881. */
  41882. playbackRate?: number;
  41883. /**
  41884. * Defines if the sound is from a streaming source
  41885. */
  41886. streaming?: boolean;
  41887. /**
  41888. * Defines an optional length (in seconds) inside the sound file
  41889. */
  41890. length?: number;
  41891. /**
  41892. * Defines an optional offset (in seconds) inside the sound file
  41893. */
  41894. offset?: number;
  41895. /**
  41896. * If true, URLs will not be required to state the audio file codec to use.
  41897. */
  41898. skipCodecCheck?: boolean;
  41899. }
  41900. /**
  41901. * Defines a sound that can be played in the application.
  41902. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41904. */
  41905. export class Sound {
  41906. /**
  41907. * The name of the sound in the scene.
  41908. */
  41909. name: string;
  41910. /**
  41911. * Does the sound autoplay once loaded.
  41912. */
  41913. autoplay: boolean;
  41914. /**
  41915. * Does the sound loop after it finishes playing once.
  41916. */
  41917. loop: boolean;
  41918. /**
  41919. * Does the sound use a custom attenuation curve to simulate the falloff
  41920. * happening when the source gets further away from the camera.
  41921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41922. */
  41923. useCustomAttenuation: boolean;
  41924. /**
  41925. * The sound track id this sound belongs to.
  41926. */
  41927. soundTrackId: number;
  41928. /**
  41929. * Is this sound currently played.
  41930. */
  41931. isPlaying: boolean;
  41932. /**
  41933. * Is this sound currently paused.
  41934. */
  41935. isPaused: boolean;
  41936. /**
  41937. * Does this sound enables spatial sound.
  41938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41939. */
  41940. spatialSound: boolean;
  41941. /**
  41942. * Define the reference distance the sound should be heard perfectly.
  41943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41944. */
  41945. refDistance: number;
  41946. /**
  41947. * Define the roll off factor of spatial sounds.
  41948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41949. */
  41950. rolloffFactor: number;
  41951. /**
  41952. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41954. */
  41955. maxDistance: number;
  41956. /**
  41957. * Define the distance attenuation model the sound will follow.
  41958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41959. */
  41960. distanceModel: string;
  41961. /**
  41962. * @hidden
  41963. * Back Compat
  41964. **/
  41965. onended: () => any;
  41966. /**
  41967. * Gets or sets an object used to store user defined information for the sound.
  41968. */
  41969. metadata: any;
  41970. /**
  41971. * Observable event when the current playing sound finishes.
  41972. */
  41973. onEndedObservable: Observable<Sound>;
  41974. private _panningModel;
  41975. private _playbackRate;
  41976. private _streaming;
  41977. private _startTime;
  41978. private _startOffset;
  41979. private _position;
  41980. /** @hidden */
  41981. _positionInEmitterSpace: boolean;
  41982. private _localDirection;
  41983. private _volume;
  41984. private _isReadyToPlay;
  41985. private _isDirectional;
  41986. private _readyToPlayCallback;
  41987. private _audioBuffer;
  41988. private _soundSource;
  41989. private _streamingSource;
  41990. private _soundPanner;
  41991. private _soundGain;
  41992. private _inputAudioNode;
  41993. private _outputAudioNode;
  41994. private _coneInnerAngle;
  41995. private _coneOuterAngle;
  41996. private _coneOuterGain;
  41997. private _scene;
  41998. private _connectedTransformNode;
  41999. private _customAttenuationFunction;
  42000. private _registerFunc;
  42001. private _isOutputConnected;
  42002. private _htmlAudioElement;
  42003. private _urlType;
  42004. private _length?;
  42005. private _offset?;
  42006. /** @hidden */
  42007. static _SceneComponentInitialization: (scene: Scene) => void;
  42008. /**
  42009. * Create a sound and attach it to a scene
  42010. * @param name Name of your sound
  42011. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42012. * @param scene defines the scene the sound belongs to
  42013. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42014. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42015. */
  42016. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42017. /**
  42018. * Release the sound and its associated resources
  42019. */
  42020. dispose(): void;
  42021. /**
  42022. * Gets if the sounds is ready to be played or not.
  42023. * @returns true if ready, otherwise false
  42024. */
  42025. isReady(): boolean;
  42026. private _soundLoaded;
  42027. /**
  42028. * Sets the data of the sound from an audiobuffer
  42029. * @param audioBuffer The audioBuffer containing the data
  42030. */
  42031. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42032. /**
  42033. * Updates the current sounds options such as maxdistance, loop...
  42034. * @param options A JSON object containing values named as the object properties
  42035. */
  42036. updateOptions(options: ISoundOptions): void;
  42037. private _createSpatialParameters;
  42038. private _updateSpatialParameters;
  42039. /**
  42040. * Switch the panning model to HRTF:
  42041. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42043. */
  42044. switchPanningModelToHRTF(): void;
  42045. /**
  42046. * Switch the panning model to Equal Power:
  42047. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42049. */
  42050. switchPanningModelToEqualPower(): void;
  42051. private _switchPanningModel;
  42052. /**
  42053. * Connect this sound to a sound track audio node like gain...
  42054. * @param soundTrackAudioNode the sound track audio node to connect to
  42055. */
  42056. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42057. /**
  42058. * Transform this sound into a directional source
  42059. * @param coneInnerAngle Size of the inner cone in degree
  42060. * @param coneOuterAngle Size of the outer cone in degree
  42061. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42062. */
  42063. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42064. /**
  42065. * Gets or sets the inner angle for the directional cone.
  42066. */
  42067. get directionalConeInnerAngle(): number;
  42068. /**
  42069. * Gets or sets the inner angle for the directional cone.
  42070. */
  42071. set directionalConeInnerAngle(value: number);
  42072. /**
  42073. * Gets or sets the outer angle for the directional cone.
  42074. */
  42075. get directionalConeOuterAngle(): number;
  42076. /**
  42077. * Gets or sets the outer angle for the directional cone.
  42078. */
  42079. set directionalConeOuterAngle(value: number);
  42080. /**
  42081. * Sets the position of the emitter if spatial sound is enabled
  42082. * @param newPosition Defines the new posisiton
  42083. */
  42084. setPosition(newPosition: Vector3): void;
  42085. /**
  42086. * Sets the local direction of the emitter if spatial sound is enabled
  42087. * @param newLocalDirection Defines the new local direction
  42088. */
  42089. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42090. private _updateDirection;
  42091. /** @hidden */
  42092. updateDistanceFromListener(): void;
  42093. /**
  42094. * Sets a new custom attenuation function for the sound.
  42095. * @param callback Defines the function used for the attenuation
  42096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42097. */
  42098. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42099. /**
  42100. * Play the sound
  42101. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42102. * @param offset (optional) Start the sound at a specific time in seconds
  42103. * @param length (optional) Sound duration (in seconds)
  42104. */
  42105. play(time?: number, offset?: number, length?: number): void;
  42106. private _onended;
  42107. /**
  42108. * Stop the sound
  42109. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42110. */
  42111. stop(time?: number): void;
  42112. /**
  42113. * Put the sound in pause
  42114. */
  42115. pause(): void;
  42116. /**
  42117. * Sets a dedicated volume for this sounds
  42118. * @param newVolume Define the new volume of the sound
  42119. * @param time Define time for gradual change to new volume
  42120. */
  42121. setVolume(newVolume: number, time?: number): void;
  42122. /**
  42123. * Set the sound play back rate
  42124. * @param newPlaybackRate Define the playback rate the sound should be played at
  42125. */
  42126. setPlaybackRate(newPlaybackRate: number): void;
  42127. /**
  42128. * Gets the volume of the sound.
  42129. * @returns the volume of the sound
  42130. */
  42131. getVolume(): number;
  42132. /**
  42133. * Attach the sound to a dedicated mesh
  42134. * @param transformNode The transform node to connect the sound with
  42135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42136. */
  42137. attachToMesh(transformNode: TransformNode): void;
  42138. /**
  42139. * Detach the sound from the previously attached mesh
  42140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42141. */
  42142. detachFromMesh(): void;
  42143. private _onRegisterAfterWorldMatrixUpdate;
  42144. /**
  42145. * Clone the current sound in the scene.
  42146. * @returns the new sound clone
  42147. */
  42148. clone(): Nullable<Sound>;
  42149. /**
  42150. * Gets the current underlying audio buffer containing the data
  42151. * @returns the audio buffer
  42152. */
  42153. getAudioBuffer(): Nullable<AudioBuffer>;
  42154. /**
  42155. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42156. * @returns the source node
  42157. */
  42158. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42159. /**
  42160. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42161. * @returns the gain node
  42162. */
  42163. getSoundGain(): Nullable<GainNode>;
  42164. /**
  42165. * Serializes the Sound in a JSON representation
  42166. * @returns the JSON representation of the sound
  42167. */
  42168. serialize(): any;
  42169. /**
  42170. * Parse a JSON representation of a sound to innstantiate in a given scene
  42171. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42172. * @param scene Define the scene the new parsed sound should be created in
  42173. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42174. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42175. * @returns the newly parsed sound
  42176. */
  42177. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42178. }
  42179. }
  42180. declare module "babylonjs/Actions/directAudioActions" {
  42181. import { Action } from "babylonjs/Actions/action";
  42182. import { Condition } from "babylonjs/Actions/condition";
  42183. import { Sound } from "babylonjs/Audio/sound";
  42184. /**
  42185. * This defines an action helpful to play a defined sound on a triggered action.
  42186. */
  42187. export class PlaySoundAction extends Action {
  42188. private _sound;
  42189. /**
  42190. * Instantiate the action
  42191. * @param triggerOptions defines the trigger options
  42192. * @param sound defines the sound to play
  42193. * @param condition defines the trigger related conditions
  42194. */
  42195. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42196. /** @hidden */
  42197. _prepare(): void;
  42198. /**
  42199. * Execute the action and play the sound.
  42200. */
  42201. execute(): void;
  42202. /**
  42203. * Serializes the actions and its related information.
  42204. * @param parent defines the object to serialize in
  42205. * @returns the serialized object
  42206. */
  42207. serialize(parent: any): any;
  42208. }
  42209. /**
  42210. * This defines an action helpful to stop a defined sound on a triggered action.
  42211. */
  42212. export class StopSoundAction extends Action {
  42213. private _sound;
  42214. /**
  42215. * Instantiate the action
  42216. * @param triggerOptions defines the trigger options
  42217. * @param sound defines the sound to stop
  42218. * @param condition defines the trigger related conditions
  42219. */
  42220. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42221. /** @hidden */
  42222. _prepare(): void;
  42223. /**
  42224. * Execute the action and stop the sound.
  42225. */
  42226. execute(): void;
  42227. /**
  42228. * Serializes the actions and its related information.
  42229. * @param parent defines the object to serialize in
  42230. * @returns the serialized object
  42231. */
  42232. serialize(parent: any): any;
  42233. }
  42234. }
  42235. declare module "babylonjs/Actions/interpolateValueAction" {
  42236. import { Action } from "babylonjs/Actions/action";
  42237. import { Condition } from "babylonjs/Actions/condition";
  42238. import { Observable } from "babylonjs/Misc/observable";
  42239. /**
  42240. * This defines an action responsible to change the value of a property
  42241. * by interpolating between its current value and the newly set one once triggered.
  42242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42243. */
  42244. export class InterpolateValueAction extends Action {
  42245. /**
  42246. * Defines the path of the property where the value should be interpolated
  42247. */
  42248. propertyPath: string;
  42249. /**
  42250. * Defines the target value at the end of the interpolation.
  42251. */
  42252. value: any;
  42253. /**
  42254. * Defines the time it will take for the property to interpolate to the value.
  42255. */
  42256. duration: number;
  42257. /**
  42258. * Defines if the other scene animations should be stopped when the action has been triggered
  42259. */
  42260. stopOtherAnimations?: boolean;
  42261. /**
  42262. * Defines a callback raised once the interpolation animation has been done.
  42263. */
  42264. onInterpolationDone?: () => void;
  42265. /**
  42266. * Observable triggered once the interpolation animation has been done.
  42267. */
  42268. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42269. private _target;
  42270. private _effectiveTarget;
  42271. private _property;
  42272. /**
  42273. * Instantiate the action
  42274. * @param triggerOptions defines the trigger options
  42275. * @param target defines the object containing the value to interpolate
  42276. * @param propertyPath defines the path to the property in the target object
  42277. * @param value defines the target value at the end of the interpolation
  42278. * @param duration deines the time it will take for the property to interpolate to the value.
  42279. * @param condition defines the trigger related conditions
  42280. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42281. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42282. */
  42283. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42284. /** @hidden */
  42285. _prepare(): void;
  42286. /**
  42287. * Execute the action starts the value interpolation.
  42288. */
  42289. execute(): void;
  42290. /**
  42291. * Serializes the actions and its related information.
  42292. * @param parent defines the object to serialize in
  42293. * @returns the serialized object
  42294. */
  42295. serialize(parent: any): any;
  42296. }
  42297. }
  42298. declare module "babylonjs/Actions/index" {
  42299. export * from "babylonjs/Actions/abstractActionManager";
  42300. export * from "babylonjs/Actions/action";
  42301. export * from "babylonjs/Actions/actionEvent";
  42302. export * from "babylonjs/Actions/actionManager";
  42303. export * from "babylonjs/Actions/condition";
  42304. export * from "babylonjs/Actions/directActions";
  42305. export * from "babylonjs/Actions/directAudioActions";
  42306. export * from "babylonjs/Actions/interpolateValueAction";
  42307. }
  42308. declare module "babylonjs/Animations/index" {
  42309. export * from "babylonjs/Animations/animatable";
  42310. export * from "babylonjs/Animations/animation";
  42311. export * from "babylonjs/Animations/animationGroup";
  42312. export * from "babylonjs/Animations/animationPropertiesOverride";
  42313. export * from "babylonjs/Animations/easing";
  42314. export * from "babylonjs/Animations/runtimeAnimation";
  42315. export * from "babylonjs/Animations/animationEvent";
  42316. export * from "babylonjs/Animations/animationGroup";
  42317. export * from "babylonjs/Animations/animationKey";
  42318. export * from "babylonjs/Animations/animationRange";
  42319. export * from "babylonjs/Animations/animatable.interface";
  42320. }
  42321. declare module "babylonjs/Audio/soundTrack" {
  42322. import { Sound } from "babylonjs/Audio/sound";
  42323. import { Analyser } from "babylonjs/Audio/analyser";
  42324. import { Scene } from "babylonjs/scene";
  42325. /**
  42326. * Options allowed during the creation of a sound track.
  42327. */
  42328. export interface ISoundTrackOptions {
  42329. /**
  42330. * The volume the sound track should take during creation
  42331. */
  42332. volume?: number;
  42333. /**
  42334. * Define if the sound track is the main sound track of the scene
  42335. */
  42336. mainTrack?: boolean;
  42337. }
  42338. /**
  42339. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42340. * It will be also used in a future release to apply effects on a specific track.
  42341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42342. */
  42343. export class SoundTrack {
  42344. /**
  42345. * The unique identifier of the sound track in the scene.
  42346. */
  42347. id: number;
  42348. /**
  42349. * The list of sounds included in the sound track.
  42350. */
  42351. soundCollection: Array<Sound>;
  42352. private _outputAudioNode;
  42353. private _scene;
  42354. private _connectedAnalyser;
  42355. private _options;
  42356. private _isInitialized;
  42357. /**
  42358. * Creates a new sound track.
  42359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42360. * @param scene Define the scene the sound track belongs to
  42361. * @param options
  42362. */
  42363. constructor(scene: Scene, options?: ISoundTrackOptions);
  42364. private _initializeSoundTrackAudioGraph;
  42365. /**
  42366. * Release the sound track and its associated resources
  42367. */
  42368. dispose(): void;
  42369. /**
  42370. * Adds a sound to this sound track
  42371. * @param sound define the cound to add
  42372. * @ignoreNaming
  42373. */
  42374. AddSound(sound: Sound): void;
  42375. /**
  42376. * Removes a sound to this sound track
  42377. * @param sound define the cound to remove
  42378. * @ignoreNaming
  42379. */
  42380. RemoveSound(sound: Sound): void;
  42381. /**
  42382. * Set a global volume for the full sound track.
  42383. * @param newVolume Define the new volume of the sound track
  42384. */
  42385. setVolume(newVolume: number): void;
  42386. /**
  42387. * Switch the panning model to HRTF:
  42388. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42390. */
  42391. switchPanningModelToHRTF(): void;
  42392. /**
  42393. * Switch the panning model to Equal Power:
  42394. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42396. */
  42397. switchPanningModelToEqualPower(): void;
  42398. /**
  42399. * Connect the sound track to an audio analyser allowing some amazing
  42400. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42402. * @param analyser The analyser to connect to the engine
  42403. */
  42404. connectToAnalyser(analyser: Analyser): void;
  42405. }
  42406. }
  42407. declare module "babylonjs/Audio/audioSceneComponent" {
  42408. import { Sound } from "babylonjs/Audio/sound";
  42409. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42410. import { Nullable } from "babylonjs/types";
  42411. import { Vector3 } from "babylonjs/Maths/math.vector";
  42412. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42413. import { Scene } from "babylonjs/scene";
  42414. import { AbstractScene } from "babylonjs/abstractScene";
  42415. import "babylonjs/Audio/audioEngine";
  42416. module "babylonjs/abstractScene" {
  42417. interface AbstractScene {
  42418. /**
  42419. * The list of sounds used in the scene.
  42420. */
  42421. sounds: Nullable<Array<Sound>>;
  42422. }
  42423. }
  42424. module "babylonjs/scene" {
  42425. interface Scene {
  42426. /**
  42427. * @hidden
  42428. * Backing field
  42429. */
  42430. _mainSoundTrack: SoundTrack;
  42431. /**
  42432. * The main sound track played by the scene.
  42433. * It cotains your primary collection of sounds.
  42434. */
  42435. mainSoundTrack: SoundTrack;
  42436. /**
  42437. * The list of sound tracks added to the scene
  42438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42439. */
  42440. soundTracks: Nullable<Array<SoundTrack>>;
  42441. /**
  42442. * Gets a sound using a given name
  42443. * @param name defines the name to search for
  42444. * @return the found sound or null if not found at all.
  42445. */
  42446. getSoundByName(name: string): Nullable<Sound>;
  42447. /**
  42448. * Gets or sets if audio support is enabled
  42449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42450. */
  42451. audioEnabled: boolean;
  42452. /**
  42453. * Gets or sets if audio will be output to headphones
  42454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42455. */
  42456. headphone: boolean;
  42457. /**
  42458. * Gets or sets custom audio listener position provider
  42459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42460. */
  42461. audioListenerPositionProvider: Nullable<() => Vector3>;
  42462. /**
  42463. * Gets or sets a refresh rate when using 3D audio positioning
  42464. */
  42465. audioPositioningRefreshRate: number;
  42466. }
  42467. }
  42468. /**
  42469. * Defines the sound scene component responsible to manage any sounds
  42470. * in a given scene.
  42471. */
  42472. export class AudioSceneComponent implements ISceneSerializableComponent {
  42473. /**
  42474. * The component name helpfull to identify the component in the list of scene components.
  42475. */
  42476. readonly name: string;
  42477. /**
  42478. * The scene the component belongs to.
  42479. */
  42480. scene: Scene;
  42481. private _audioEnabled;
  42482. /**
  42483. * Gets whether audio is enabled or not.
  42484. * Please use related enable/disable method to switch state.
  42485. */
  42486. get audioEnabled(): boolean;
  42487. private _headphone;
  42488. /**
  42489. * Gets whether audio is outputing to headphone or not.
  42490. * Please use the according Switch methods to change output.
  42491. */
  42492. get headphone(): boolean;
  42493. /**
  42494. * Gets or sets a refresh rate when using 3D audio positioning
  42495. */
  42496. audioPositioningRefreshRate: number;
  42497. private _audioListenerPositionProvider;
  42498. /**
  42499. * Gets the current audio listener position provider
  42500. */
  42501. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42502. /**
  42503. * Sets a custom listener position for all sounds in the scene
  42504. * By default, this is the position of the first active camera
  42505. */
  42506. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42507. /**
  42508. * Creates a new instance of the component for the given scene
  42509. * @param scene Defines the scene to register the component in
  42510. */
  42511. constructor(scene: Scene);
  42512. /**
  42513. * Registers the component in a given scene
  42514. */
  42515. register(): void;
  42516. /**
  42517. * Rebuilds the elements related to this component in case of
  42518. * context lost for instance.
  42519. */
  42520. rebuild(): void;
  42521. /**
  42522. * Serializes the component data to the specified json object
  42523. * @param serializationObject The object to serialize to
  42524. */
  42525. serialize(serializationObject: any): void;
  42526. /**
  42527. * Adds all the elements from the container to the scene
  42528. * @param container the container holding the elements
  42529. */
  42530. addFromContainer(container: AbstractScene): void;
  42531. /**
  42532. * Removes all the elements in the container from the scene
  42533. * @param container contains the elements to remove
  42534. * @param dispose if the removed element should be disposed (default: false)
  42535. */
  42536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42537. /**
  42538. * Disposes the component and the associated ressources.
  42539. */
  42540. dispose(): void;
  42541. /**
  42542. * Disables audio in the associated scene.
  42543. */
  42544. disableAudio(): void;
  42545. /**
  42546. * Enables audio in the associated scene.
  42547. */
  42548. enableAudio(): void;
  42549. /**
  42550. * Switch audio to headphone output.
  42551. */
  42552. switchAudioModeForHeadphones(): void;
  42553. /**
  42554. * Switch audio to normal speakers.
  42555. */
  42556. switchAudioModeForNormalSpeakers(): void;
  42557. private _cachedCameraDirection;
  42558. private _cachedCameraPosition;
  42559. private _lastCheck;
  42560. private _afterRender;
  42561. }
  42562. }
  42563. declare module "babylonjs/Audio/weightedsound" {
  42564. import { Sound } from "babylonjs/Audio/sound";
  42565. /**
  42566. * Wraps one or more Sound objects and selects one with random weight for playback.
  42567. */
  42568. export class WeightedSound {
  42569. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42570. loop: boolean;
  42571. private _coneInnerAngle;
  42572. private _coneOuterAngle;
  42573. private _volume;
  42574. /** A Sound is currently playing. */
  42575. isPlaying: boolean;
  42576. /** A Sound is currently paused. */
  42577. isPaused: boolean;
  42578. private _sounds;
  42579. private _weights;
  42580. private _currentIndex?;
  42581. /**
  42582. * Creates a new WeightedSound from the list of sounds given.
  42583. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42584. * @param sounds Array of Sounds that will be selected from.
  42585. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42586. */
  42587. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42588. /**
  42589. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42590. */
  42591. get directionalConeInnerAngle(): number;
  42592. /**
  42593. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42594. */
  42595. set directionalConeInnerAngle(value: number);
  42596. /**
  42597. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42598. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42599. */
  42600. get directionalConeOuterAngle(): number;
  42601. /**
  42602. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42603. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42604. */
  42605. set directionalConeOuterAngle(value: number);
  42606. /**
  42607. * Playback volume.
  42608. */
  42609. get volume(): number;
  42610. /**
  42611. * Playback volume.
  42612. */
  42613. set volume(value: number);
  42614. private _onended;
  42615. /**
  42616. * Suspend playback
  42617. */
  42618. pause(): void;
  42619. /**
  42620. * Stop playback
  42621. */
  42622. stop(): void;
  42623. /**
  42624. * Start playback.
  42625. * @param startOffset Position the clip head at a specific time in seconds.
  42626. */
  42627. play(startOffset?: number): void;
  42628. }
  42629. }
  42630. declare module "babylonjs/Audio/index" {
  42631. export * from "babylonjs/Audio/analyser";
  42632. export * from "babylonjs/Audio/audioEngine";
  42633. export * from "babylonjs/Audio/audioSceneComponent";
  42634. export * from "babylonjs/Audio/sound";
  42635. export * from "babylonjs/Audio/soundTrack";
  42636. export * from "babylonjs/Audio/weightedsound";
  42637. }
  42638. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42639. import { Behavior } from "babylonjs/Behaviors/behavior";
  42640. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42641. import { BackEase } from "babylonjs/Animations/easing";
  42642. /**
  42643. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42645. */
  42646. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42647. /**
  42648. * Gets the name of the behavior.
  42649. */
  42650. get name(): string;
  42651. /**
  42652. * The easing function used by animations
  42653. */
  42654. static EasingFunction: BackEase;
  42655. /**
  42656. * The easing mode used by animations
  42657. */
  42658. static EasingMode: number;
  42659. /**
  42660. * The duration of the animation, in milliseconds
  42661. */
  42662. transitionDuration: number;
  42663. /**
  42664. * Length of the distance animated by the transition when lower radius is reached
  42665. */
  42666. lowerRadiusTransitionRange: number;
  42667. /**
  42668. * Length of the distance animated by the transition when upper radius is reached
  42669. */
  42670. upperRadiusTransitionRange: number;
  42671. private _autoTransitionRange;
  42672. /**
  42673. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42674. */
  42675. get autoTransitionRange(): boolean;
  42676. /**
  42677. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42678. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42679. */
  42680. set autoTransitionRange(value: boolean);
  42681. private _attachedCamera;
  42682. private _onAfterCheckInputsObserver;
  42683. private _onMeshTargetChangedObserver;
  42684. /**
  42685. * Initializes the behavior.
  42686. */
  42687. init(): void;
  42688. /**
  42689. * Attaches the behavior to its arc rotate camera.
  42690. * @param camera Defines the camera to attach the behavior to
  42691. */
  42692. attach(camera: ArcRotateCamera): void;
  42693. /**
  42694. * Detaches the behavior from its current arc rotate camera.
  42695. */
  42696. detach(): void;
  42697. private _radiusIsAnimating;
  42698. private _radiusBounceTransition;
  42699. private _animatables;
  42700. private _cachedWheelPrecision;
  42701. /**
  42702. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42703. * @param radiusLimit The limit to check against.
  42704. * @return Bool to indicate if at limit.
  42705. */
  42706. private _isRadiusAtLimit;
  42707. /**
  42708. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42709. * @param radiusDelta The delta by which to animate to. Can be negative.
  42710. */
  42711. private _applyBoundRadiusAnimation;
  42712. /**
  42713. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42714. */
  42715. protected _clearAnimationLocks(): void;
  42716. /**
  42717. * Stops and removes all animations that have been applied to the camera
  42718. */
  42719. stopAllAnimations(): void;
  42720. }
  42721. }
  42722. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42723. import { Behavior } from "babylonjs/Behaviors/behavior";
  42724. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42725. import { ExponentialEase } from "babylonjs/Animations/easing";
  42726. import { Nullable } from "babylonjs/types";
  42727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42728. import { Vector3 } from "babylonjs/Maths/math.vector";
  42729. /**
  42730. * 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.
  42731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42732. */
  42733. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42734. /**
  42735. * Gets the name of the behavior.
  42736. */
  42737. get name(): string;
  42738. private _mode;
  42739. private _radiusScale;
  42740. private _positionScale;
  42741. private _defaultElevation;
  42742. private _elevationReturnTime;
  42743. private _elevationReturnWaitTime;
  42744. private _zoomStopsAnimation;
  42745. private _framingTime;
  42746. /**
  42747. * The easing function used by animations
  42748. */
  42749. static EasingFunction: ExponentialEase;
  42750. /**
  42751. * The easing mode used by animations
  42752. */
  42753. static EasingMode: number;
  42754. /**
  42755. * Sets the current mode used by the behavior
  42756. */
  42757. set mode(mode: number);
  42758. /**
  42759. * Gets current mode used by the behavior.
  42760. */
  42761. get mode(): number;
  42762. /**
  42763. * Sets the scale applied to the radius (1 by default)
  42764. */
  42765. set radiusScale(radius: number);
  42766. /**
  42767. * Gets the scale applied to the radius
  42768. */
  42769. get radiusScale(): number;
  42770. /**
  42771. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42772. */
  42773. set positionScale(scale: number);
  42774. /**
  42775. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42776. */
  42777. get positionScale(): number;
  42778. /**
  42779. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42780. * behaviour is triggered, in radians.
  42781. */
  42782. set defaultElevation(elevation: number);
  42783. /**
  42784. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42785. * behaviour is triggered, in radians.
  42786. */
  42787. get defaultElevation(): number;
  42788. /**
  42789. * Sets the time (in milliseconds) taken to return to the default beta position.
  42790. * Negative value indicates camera should not return to default.
  42791. */
  42792. set elevationReturnTime(speed: number);
  42793. /**
  42794. * Gets the time (in milliseconds) taken to return to the default beta position.
  42795. * Negative value indicates camera should not return to default.
  42796. */
  42797. get elevationReturnTime(): number;
  42798. /**
  42799. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42800. */
  42801. set elevationReturnWaitTime(time: number);
  42802. /**
  42803. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42804. */
  42805. get elevationReturnWaitTime(): number;
  42806. /**
  42807. * Sets the flag that indicates if user zooming should stop animation.
  42808. */
  42809. set zoomStopsAnimation(flag: boolean);
  42810. /**
  42811. * Gets the flag that indicates if user zooming should stop animation.
  42812. */
  42813. get zoomStopsAnimation(): boolean;
  42814. /**
  42815. * Sets the transition time when framing the mesh, in milliseconds
  42816. */
  42817. set framingTime(time: number);
  42818. /**
  42819. * Gets the transition time when framing the mesh, in milliseconds
  42820. */
  42821. get framingTime(): number;
  42822. /**
  42823. * Define if the behavior should automatically change the configured
  42824. * camera limits and sensibilities.
  42825. */
  42826. autoCorrectCameraLimitsAndSensibility: boolean;
  42827. private _onPrePointerObservableObserver;
  42828. private _onAfterCheckInputsObserver;
  42829. private _onMeshTargetChangedObserver;
  42830. private _attachedCamera;
  42831. private _isPointerDown;
  42832. private _lastInteractionTime;
  42833. /**
  42834. * Initializes the behavior.
  42835. */
  42836. init(): void;
  42837. /**
  42838. * Attaches the behavior to its arc rotate camera.
  42839. * @param camera Defines the camera to attach the behavior to
  42840. */
  42841. attach(camera: ArcRotateCamera): void;
  42842. /**
  42843. * Detaches the behavior from its current arc rotate camera.
  42844. */
  42845. detach(): void;
  42846. private _animatables;
  42847. private _betaIsAnimating;
  42848. private _betaTransition;
  42849. private _radiusTransition;
  42850. private _vectorTransition;
  42851. /**
  42852. * Targets the given mesh and updates zoom level accordingly.
  42853. * @param mesh The mesh to target.
  42854. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42855. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42856. */
  42857. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42858. /**
  42859. * Targets the given mesh with its children and updates zoom level accordingly.
  42860. * @param mesh The mesh to target.
  42861. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42862. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42863. */
  42864. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42865. /**
  42866. * Targets the given meshes with their children and updates zoom level accordingly.
  42867. * @param meshes The mesh to target.
  42868. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42869. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42870. */
  42871. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42872. /**
  42873. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42874. * @param minimumWorld Determines the smaller position of the bounding box extend
  42875. * @param maximumWorld Determines the bigger position of the bounding box extend
  42876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42878. */
  42879. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42880. /**
  42881. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42882. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42883. * frustum width.
  42884. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42885. * to fully enclose the mesh in the viewing frustum.
  42886. */
  42887. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42888. /**
  42889. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42890. * is automatically returned to its default position (expected to be above ground plane).
  42891. */
  42892. private _maintainCameraAboveGround;
  42893. /**
  42894. * Returns the frustum slope based on the canvas ratio and camera FOV
  42895. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42896. */
  42897. private _getFrustumSlope;
  42898. /**
  42899. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42900. */
  42901. private _clearAnimationLocks;
  42902. /**
  42903. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42904. */
  42905. private _applyUserInteraction;
  42906. /**
  42907. * Stops and removes all animations that have been applied to the camera
  42908. */
  42909. stopAllAnimations(): void;
  42910. /**
  42911. * Gets a value indicating if the user is moving the camera
  42912. */
  42913. get isUserIsMoving(): boolean;
  42914. /**
  42915. * The camera can move all the way towards the mesh.
  42916. */
  42917. static IgnoreBoundsSizeMode: number;
  42918. /**
  42919. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42920. */
  42921. static FitFrustumSidesMode: number;
  42922. }
  42923. }
  42924. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42925. import { Nullable } from "babylonjs/types";
  42926. import { Camera } from "babylonjs/Cameras/camera";
  42927. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42928. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42929. /**
  42930. * Base class for Camera Pointer Inputs.
  42931. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42932. * for example usage.
  42933. */
  42934. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42935. /**
  42936. * Defines the camera the input is attached to.
  42937. */
  42938. abstract camera: Camera;
  42939. /**
  42940. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42941. */
  42942. protected _altKey: boolean;
  42943. protected _ctrlKey: boolean;
  42944. protected _metaKey: boolean;
  42945. protected _shiftKey: boolean;
  42946. /**
  42947. * Which mouse buttons were pressed at time of last mouse event.
  42948. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42949. */
  42950. protected _buttonsPressed: number;
  42951. /**
  42952. * Defines the buttons associated with the input to handle camera move.
  42953. */
  42954. buttons: number[];
  42955. /**
  42956. * Attach the input controls to a specific dom element to get the input from.
  42957. * @param element Defines the element the controls should be listened from
  42958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42959. */
  42960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42961. /**
  42962. * Detach the current controls from the specified dom element.
  42963. * @param element Defines the element to stop listening the inputs from
  42964. */
  42965. detachControl(element: Nullable<HTMLElement>): void;
  42966. /**
  42967. * Gets the class name of the current input.
  42968. * @returns the class name
  42969. */
  42970. getClassName(): string;
  42971. /**
  42972. * Get the friendly name associated with the input class.
  42973. * @returns the input friendly name
  42974. */
  42975. getSimpleName(): string;
  42976. /**
  42977. * Called on pointer POINTERDOUBLETAP event.
  42978. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42979. */
  42980. protected onDoubleTap(type: string): void;
  42981. /**
  42982. * Called on pointer POINTERMOVE event if only a single touch is active.
  42983. * Override this method to provide functionality.
  42984. */
  42985. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42986. /**
  42987. * Called on pointer POINTERMOVE event if multiple touches are active.
  42988. * Override this method to provide functionality.
  42989. */
  42990. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42991. /**
  42992. * Called on JS contextmenu event.
  42993. * Override this method to provide functionality.
  42994. */
  42995. protected onContextMenu(evt: PointerEvent): void;
  42996. /**
  42997. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42998. * press.
  42999. * Override this method to provide functionality.
  43000. */
  43001. protected onButtonDown(evt: PointerEvent): void;
  43002. /**
  43003. * Called each time a new POINTERUP event occurs. Ie, for each button
  43004. * release.
  43005. * Override this method to provide functionality.
  43006. */
  43007. protected onButtonUp(evt: PointerEvent): void;
  43008. /**
  43009. * Called when window becomes inactive.
  43010. * Override this method to provide functionality.
  43011. */
  43012. protected onLostFocus(): void;
  43013. private _pointerInput;
  43014. private _observer;
  43015. private _onLostFocus;
  43016. private pointA;
  43017. private pointB;
  43018. }
  43019. }
  43020. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43021. import { Nullable } from "babylonjs/types";
  43022. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43023. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43024. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43025. /**
  43026. * Manage the pointers inputs to control an arc rotate camera.
  43027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43028. */
  43029. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43030. /**
  43031. * Defines the camera the input is attached to.
  43032. */
  43033. camera: ArcRotateCamera;
  43034. /**
  43035. * Gets the class name of the current input.
  43036. * @returns the class name
  43037. */
  43038. getClassName(): string;
  43039. /**
  43040. * Defines the buttons associated with the input to handle camera move.
  43041. */
  43042. buttons: number[];
  43043. /**
  43044. * Defines the pointer angular sensibility along the X axis or how fast is
  43045. * the camera rotating.
  43046. */
  43047. angularSensibilityX: number;
  43048. /**
  43049. * Defines the pointer angular sensibility along the Y axis or how fast is
  43050. * the camera rotating.
  43051. */
  43052. angularSensibilityY: number;
  43053. /**
  43054. * Defines the pointer pinch precision or how fast is the camera zooming.
  43055. */
  43056. pinchPrecision: number;
  43057. /**
  43058. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43059. * from 0.
  43060. * It defines the percentage of current camera.radius to use as delta when
  43061. * pinch zoom is used.
  43062. */
  43063. pinchDeltaPercentage: number;
  43064. /**
  43065. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43066. * that any object in the plane at the camera's target point will scale
  43067. * perfectly with finger motion.
  43068. * Overrides pinchDeltaPercentage and pinchPrecision.
  43069. */
  43070. useNaturalPinchZoom: boolean;
  43071. /**
  43072. * Defines the pointer panning sensibility or how fast is the camera moving.
  43073. */
  43074. panningSensibility: number;
  43075. /**
  43076. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43077. */
  43078. multiTouchPanning: boolean;
  43079. /**
  43080. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43081. * zoom (pinch) through multitouch.
  43082. */
  43083. multiTouchPanAndZoom: boolean;
  43084. /**
  43085. * Revers pinch action direction.
  43086. */
  43087. pinchInwards: boolean;
  43088. private _isPanClick;
  43089. private _twoFingerActivityCount;
  43090. private _isPinching;
  43091. /**
  43092. * Called on pointer POINTERMOVE event if only a single touch is active.
  43093. */
  43094. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43095. /**
  43096. * Called on pointer POINTERDOUBLETAP event.
  43097. */
  43098. protected onDoubleTap(type: string): void;
  43099. /**
  43100. * Called on pointer POINTERMOVE event if multiple touches are active.
  43101. */
  43102. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43103. /**
  43104. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43105. * press.
  43106. */
  43107. protected onButtonDown(evt: PointerEvent): void;
  43108. /**
  43109. * Called each time a new POINTERUP event occurs. Ie, for each button
  43110. * release.
  43111. */
  43112. protected onButtonUp(evt: PointerEvent): void;
  43113. /**
  43114. * Called when window becomes inactive.
  43115. */
  43116. protected onLostFocus(): void;
  43117. }
  43118. }
  43119. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43120. import { Nullable } from "babylonjs/types";
  43121. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43123. /**
  43124. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43126. */
  43127. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43128. /**
  43129. * Defines the camera the input is attached to.
  43130. */
  43131. camera: ArcRotateCamera;
  43132. /**
  43133. * Defines the list of key codes associated with the up action (increase alpha)
  43134. */
  43135. keysUp: number[];
  43136. /**
  43137. * Defines the list of key codes associated with the down action (decrease alpha)
  43138. */
  43139. keysDown: number[];
  43140. /**
  43141. * Defines the list of key codes associated with the left action (increase beta)
  43142. */
  43143. keysLeft: number[];
  43144. /**
  43145. * Defines the list of key codes associated with the right action (decrease beta)
  43146. */
  43147. keysRight: number[];
  43148. /**
  43149. * Defines the list of key codes associated with the reset action.
  43150. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43151. */
  43152. keysReset: number[];
  43153. /**
  43154. * Defines the panning sensibility of the inputs.
  43155. * (How fast is the camera panning)
  43156. */
  43157. panningSensibility: number;
  43158. /**
  43159. * Defines the zooming sensibility of the inputs.
  43160. * (How fast is the camera zooming)
  43161. */
  43162. zoomingSensibility: number;
  43163. /**
  43164. * Defines whether maintaining the alt key down switch the movement mode from
  43165. * orientation to zoom.
  43166. */
  43167. useAltToZoom: boolean;
  43168. /**
  43169. * Rotation speed of the camera
  43170. */
  43171. angularSpeed: number;
  43172. private _keys;
  43173. private _ctrlPressed;
  43174. private _altPressed;
  43175. private _onCanvasBlurObserver;
  43176. private _onKeyboardObserver;
  43177. private _engine;
  43178. private _scene;
  43179. /**
  43180. * Attach the input controls to a specific dom element to get the input from.
  43181. * @param element Defines the element the controls should be listened from
  43182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43183. */
  43184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43185. /**
  43186. * Detach the current controls from the specified dom element.
  43187. * @param element Defines the element to stop listening the inputs from
  43188. */
  43189. detachControl(element: Nullable<HTMLElement>): void;
  43190. /**
  43191. * Update the current camera state depending on the inputs that have been used this frame.
  43192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43193. */
  43194. checkInputs(): void;
  43195. /**
  43196. * Gets the class name of the current intput.
  43197. * @returns the class name
  43198. */
  43199. getClassName(): string;
  43200. /**
  43201. * Get the friendly name associated with the input class.
  43202. * @returns the input friendly name
  43203. */
  43204. getSimpleName(): string;
  43205. }
  43206. }
  43207. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43208. import { Nullable } from "babylonjs/types";
  43209. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43210. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43211. /**
  43212. * Manage the mouse wheel inputs to control an arc rotate camera.
  43213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43214. */
  43215. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43216. /**
  43217. * Defines the camera the input is attached to.
  43218. */
  43219. camera: ArcRotateCamera;
  43220. /**
  43221. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43222. */
  43223. wheelPrecision: number;
  43224. /**
  43225. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43226. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43227. */
  43228. wheelDeltaPercentage: number;
  43229. private _wheel;
  43230. private _observer;
  43231. private computeDeltaFromMouseWheelLegacyEvent;
  43232. /**
  43233. * Attach the input controls to a specific dom element to get the input from.
  43234. * @param element Defines the element the controls should be listened from
  43235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43236. */
  43237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43238. /**
  43239. * Detach the current controls from the specified dom element.
  43240. * @param element Defines the element to stop listening the inputs from
  43241. */
  43242. detachControl(element: Nullable<HTMLElement>): void;
  43243. /**
  43244. * Gets the class name of the current intput.
  43245. * @returns the class name
  43246. */
  43247. getClassName(): string;
  43248. /**
  43249. * Get the friendly name associated with the input class.
  43250. * @returns the input friendly name
  43251. */
  43252. getSimpleName(): string;
  43253. }
  43254. }
  43255. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43256. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43257. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43258. /**
  43259. * Default Inputs manager for the ArcRotateCamera.
  43260. * It groups all the default supported inputs for ease of use.
  43261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43262. */
  43263. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43264. /**
  43265. * Instantiates a new ArcRotateCameraInputsManager.
  43266. * @param camera Defines the camera the inputs belong to
  43267. */
  43268. constructor(camera: ArcRotateCamera);
  43269. /**
  43270. * Add mouse wheel input support to the input manager.
  43271. * @returns the current input manager
  43272. */
  43273. addMouseWheel(): ArcRotateCameraInputsManager;
  43274. /**
  43275. * Add pointers input support to the input manager.
  43276. * @returns the current input manager
  43277. */
  43278. addPointers(): ArcRotateCameraInputsManager;
  43279. /**
  43280. * Add keyboard input support to the input manager.
  43281. * @returns the current input manager
  43282. */
  43283. addKeyboard(): ArcRotateCameraInputsManager;
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/arcRotateCamera" {
  43287. import { Observable } from "babylonjs/Misc/observable";
  43288. import { Nullable } from "babylonjs/types";
  43289. import { Scene } from "babylonjs/scene";
  43290. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43292. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43293. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43294. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43295. import { Camera } from "babylonjs/Cameras/camera";
  43296. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43297. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43298. import { Collider } from "babylonjs/Collisions/collider";
  43299. /**
  43300. * This represents an orbital type of camera.
  43301. *
  43302. * 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.
  43303. * 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.
  43304. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43305. */
  43306. export class ArcRotateCamera extends TargetCamera {
  43307. /**
  43308. * Defines the rotation angle of the camera along the longitudinal axis.
  43309. */
  43310. alpha: number;
  43311. /**
  43312. * Defines the rotation angle of the camera along the latitudinal axis.
  43313. */
  43314. beta: number;
  43315. /**
  43316. * Defines the radius of the camera from it s target point.
  43317. */
  43318. radius: number;
  43319. protected _target: Vector3;
  43320. protected _targetHost: Nullable<AbstractMesh>;
  43321. /**
  43322. * Defines the target point of the camera.
  43323. * The camera looks towards it form the radius distance.
  43324. */
  43325. get target(): Vector3;
  43326. set target(value: Vector3);
  43327. /**
  43328. * Define the current local position of the camera in the scene
  43329. */
  43330. get position(): Vector3;
  43331. set position(newPosition: Vector3);
  43332. protected _upVector: Vector3;
  43333. protected _upToYMatrix: Matrix;
  43334. protected _YToUpMatrix: Matrix;
  43335. /**
  43336. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43337. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43338. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43339. */
  43340. set upVector(vec: Vector3);
  43341. get upVector(): Vector3;
  43342. /**
  43343. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43344. */
  43345. setMatUp(): void;
  43346. /**
  43347. * Current inertia value on the longitudinal axis.
  43348. * The bigger this number the longer it will take for the camera to stop.
  43349. */
  43350. inertialAlphaOffset: number;
  43351. /**
  43352. * Current inertia value on the latitudinal axis.
  43353. * The bigger this number the longer it will take for the camera to stop.
  43354. */
  43355. inertialBetaOffset: number;
  43356. /**
  43357. * Current inertia value on the radius axis.
  43358. * The bigger this number the longer it will take for the camera to stop.
  43359. */
  43360. inertialRadiusOffset: number;
  43361. /**
  43362. * Minimum allowed angle on the longitudinal axis.
  43363. * This can help limiting how the Camera is able to move in the scene.
  43364. */
  43365. lowerAlphaLimit: Nullable<number>;
  43366. /**
  43367. * Maximum allowed angle on the longitudinal axis.
  43368. * This can help limiting how the Camera is able to move in the scene.
  43369. */
  43370. upperAlphaLimit: Nullable<number>;
  43371. /**
  43372. * Minimum allowed angle on the latitudinal axis.
  43373. * This can help limiting how the Camera is able to move in the scene.
  43374. */
  43375. lowerBetaLimit: number;
  43376. /**
  43377. * Maximum allowed angle on the latitudinal axis.
  43378. * This can help limiting how the Camera is able to move in the scene.
  43379. */
  43380. upperBetaLimit: number;
  43381. /**
  43382. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43383. * This can help limiting how the Camera is able to move in the scene.
  43384. */
  43385. lowerRadiusLimit: Nullable<number>;
  43386. /**
  43387. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43388. * This can help limiting how the Camera is able to move in the scene.
  43389. */
  43390. upperRadiusLimit: Nullable<number>;
  43391. /**
  43392. * Defines the current inertia value used during panning of the camera along the X axis.
  43393. */
  43394. inertialPanningX: number;
  43395. /**
  43396. * Defines the current inertia value used during panning of the camera along the Y axis.
  43397. */
  43398. inertialPanningY: number;
  43399. /**
  43400. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43401. * Basically if your fingers moves away from more than this distance you will be considered
  43402. * in pinch mode.
  43403. */
  43404. pinchToPanMaxDistance: number;
  43405. /**
  43406. * Defines the maximum distance the camera can pan.
  43407. * This could help keeping the cammera always in your scene.
  43408. */
  43409. panningDistanceLimit: Nullable<number>;
  43410. /**
  43411. * Defines the target of the camera before paning.
  43412. */
  43413. panningOriginTarget: Vector3;
  43414. /**
  43415. * Defines the value of the inertia used during panning.
  43416. * 0 would mean stop inertia and one would mean no decelleration at all.
  43417. */
  43418. panningInertia: number;
  43419. /**
  43420. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43421. */
  43422. get angularSensibilityX(): number;
  43423. set angularSensibilityX(value: number);
  43424. /**
  43425. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43426. */
  43427. get angularSensibilityY(): number;
  43428. set angularSensibilityY(value: number);
  43429. /**
  43430. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43431. */
  43432. get pinchPrecision(): number;
  43433. set pinchPrecision(value: number);
  43434. /**
  43435. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43436. * It will be used instead of pinchDeltaPrecision if different from 0.
  43437. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43438. */
  43439. get pinchDeltaPercentage(): number;
  43440. set pinchDeltaPercentage(value: number);
  43441. /**
  43442. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43443. * and pinch delta percentage.
  43444. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43445. * that any object in the plane at the camera's target point will scale
  43446. * perfectly with finger motion.
  43447. */
  43448. get useNaturalPinchZoom(): boolean;
  43449. set useNaturalPinchZoom(value: boolean);
  43450. /**
  43451. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43452. */
  43453. get panningSensibility(): number;
  43454. set panningSensibility(value: number);
  43455. /**
  43456. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43457. */
  43458. get keysUp(): number[];
  43459. set keysUp(value: number[]);
  43460. /**
  43461. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43462. */
  43463. get keysDown(): number[];
  43464. set keysDown(value: number[]);
  43465. /**
  43466. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43467. */
  43468. get keysLeft(): number[];
  43469. set keysLeft(value: number[]);
  43470. /**
  43471. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43472. */
  43473. get keysRight(): number[];
  43474. set keysRight(value: number[]);
  43475. /**
  43476. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43477. */
  43478. get wheelPrecision(): number;
  43479. set wheelPrecision(value: number);
  43480. /**
  43481. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43482. * It will be used instead of pinchDeltaPrecision if different from 0.
  43483. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43484. */
  43485. get wheelDeltaPercentage(): number;
  43486. set wheelDeltaPercentage(value: number);
  43487. /**
  43488. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43489. */
  43490. zoomOnFactor: number;
  43491. /**
  43492. * Defines a screen offset for the camera position.
  43493. */
  43494. targetScreenOffset: Vector2;
  43495. /**
  43496. * Allows the camera to be completely reversed.
  43497. * If false the camera can not arrive upside down.
  43498. */
  43499. allowUpsideDown: boolean;
  43500. /**
  43501. * Define if double tap/click is used to restore the previously saved state of the camera.
  43502. */
  43503. useInputToRestoreState: boolean;
  43504. /** @hidden */
  43505. _viewMatrix: Matrix;
  43506. /** @hidden */
  43507. _useCtrlForPanning: boolean;
  43508. /** @hidden */
  43509. _panningMouseButton: number;
  43510. /**
  43511. * Defines the input associated to the camera.
  43512. */
  43513. inputs: ArcRotateCameraInputsManager;
  43514. /** @hidden */
  43515. _reset: () => void;
  43516. /**
  43517. * Defines the allowed panning axis.
  43518. */
  43519. panningAxis: Vector3;
  43520. protected _localDirection: Vector3;
  43521. protected _transformedDirection: Vector3;
  43522. private _bouncingBehavior;
  43523. /**
  43524. * Gets the bouncing behavior of the camera if it has been enabled.
  43525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43526. */
  43527. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43528. /**
  43529. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43530. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43531. */
  43532. get useBouncingBehavior(): boolean;
  43533. set useBouncingBehavior(value: boolean);
  43534. private _framingBehavior;
  43535. /**
  43536. * Gets the framing behavior of the camera if it has been enabled.
  43537. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43538. */
  43539. get framingBehavior(): Nullable<FramingBehavior>;
  43540. /**
  43541. * Defines if the framing behavior of the camera is enabled on the camera.
  43542. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43543. */
  43544. get useFramingBehavior(): boolean;
  43545. set useFramingBehavior(value: boolean);
  43546. private _autoRotationBehavior;
  43547. /**
  43548. * Gets the auto rotation behavior of the camera if it has been enabled.
  43549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43550. */
  43551. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43552. /**
  43553. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43554. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43555. */
  43556. get useAutoRotationBehavior(): boolean;
  43557. set useAutoRotationBehavior(value: boolean);
  43558. /**
  43559. * Observable triggered when the mesh target has been changed on the camera.
  43560. */
  43561. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43562. /**
  43563. * Event raised when the camera is colliding with a mesh.
  43564. */
  43565. onCollide: (collidedMesh: AbstractMesh) => void;
  43566. /**
  43567. * Defines whether the camera should check collision with the objects oh the scene.
  43568. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43569. */
  43570. checkCollisions: boolean;
  43571. /**
  43572. * Defines the collision radius of the camera.
  43573. * This simulates a sphere around the camera.
  43574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43575. */
  43576. collisionRadius: Vector3;
  43577. protected _collider: Collider;
  43578. protected _previousPosition: Vector3;
  43579. protected _collisionVelocity: Vector3;
  43580. protected _newPosition: Vector3;
  43581. protected _previousAlpha: number;
  43582. protected _previousBeta: number;
  43583. protected _previousRadius: number;
  43584. protected _collisionTriggered: boolean;
  43585. protected _targetBoundingCenter: Nullable<Vector3>;
  43586. private _computationVector;
  43587. /**
  43588. * Instantiates a new ArcRotateCamera in a given scene
  43589. * @param name Defines the name of the camera
  43590. * @param alpha Defines the camera rotation along the logitudinal axis
  43591. * @param beta Defines the camera rotation along the latitudinal axis
  43592. * @param radius Defines the camera distance from its target
  43593. * @param target Defines the camera target
  43594. * @param scene Defines the scene the camera belongs to
  43595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43596. */
  43597. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43598. /** @hidden */
  43599. _initCache(): void;
  43600. /** @hidden */
  43601. _updateCache(ignoreParentClass?: boolean): void;
  43602. protected _getTargetPosition(): Vector3;
  43603. private _storedAlpha;
  43604. private _storedBeta;
  43605. private _storedRadius;
  43606. private _storedTarget;
  43607. private _storedTargetScreenOffset;
  43608. /**
  43609. * Stores the current state of the camera (alpha, beta, radius and target)
  43610. * @returns the camera itself
  43611. */
  43612. storeState(): Camera;
  43613. /**
  43614. * @hidden
  43615. * Restored camera state. You must call storeState() first
  43616. */
  43617. _restoreStateValues(): boolean;
  43618. /** @hidden */
  43619. _isSynchronizedViewMatrix(): boolean;
  43620. /**
  43621. * Attached controls to the current camera.
  43622. * @param element Defines the element the controls should be listened from
  43623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43624. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43625. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43626. */
  43627. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43628. /**
  43629. * Detach the current controls from the camera.
  43630. * The camera will stop reacting to inputs.
  43631. * @param element Defines the element to stop listening the inputs from
  43632. */
  43633. detachControl(element: HTMLElement): void;
  43634. /** @hidden */
  43635. _checkInputs(): void;
  43636. protected _checkLimits(): void;
  43637. /**
  43638. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43639. */
  43640. rebuildAnglesAndRadius(): void;
  43641. /**
  43642. * Use a position to define the current camera related information like alpha, beta and radius
  43643. * @param position Defines the position to set the camera at
  43644. */
  43645. setPosition(position: Vector3): void;
  43646. /**
  43647. * Defines the target the camera should look at.
  43648. * This will automatically adapt alpha beta and radius to fit within the new target.
  43649. * @param target Defines the new target as a Vector or a mesh
  43650. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43651. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43652. */
  43653. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43654. /** @hidden */
  43655. _getViewMatrix(): Matrix;
  43656. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43657. /**
  43658. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43659. * @param meshes Defines the mesh to zoom on
  43660. * @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)
  43661. */
  43662. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43663. /**
  43664. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43665. * The target will be changed but the radius
  43666. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43667. * @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)
  43668. */
  43669. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43670. min: Vector3;
  43671. max: Vector3;
  43672. distance: number;
  43673. }, doNotUpdateMaxZ?: boolean): void;
  43674. /**
  43675. * @override
  43676. * Override Camera.createRigCamera
  43677. */
  43678. createRigCamera(name: string, cameraIndex: number): Camera;
  43679. /**
  43680. * @hidden
  43681. * @override
  43682. * Override Camera._updateRigCameras
  43683. */
  43684. _updateRigCameras(): void;
  43685. /**
  43686. * Destroy the camera and release the current resources hold by it.
  43687. */
  43688. dispose(): void;
  43689. /**
  43690. * Gets the current object class name.
  43691. * @return the class name
  43692. */
  43693. getClassName(): string;
  43694. }
  43695. }
  43696. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43697. import { Behavior } from "babylonjs/Behaviors/behavior";
  43698. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43699. /**
  43700. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43701. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43702. */
  43703. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43704. /**
  43705. * Gets the name of the behavior.
  43706. */
  43707. get name(): string;
  43708. private _zoomStopsAnimation;
  43709. private _idleRotationSpeed;
  43710. private _idleRotationWaitTime;
  43711. private _idleRotationSpinupTime;
  43712. /**
  43713. * Sets the flag that indicates if user zooming should stop animation.
  43714. */
  43715. set zoomStopsAnimation(flag: boolean);
  43716. /**
  43717. * Gets the flag that indicates if user zooming should stop animation.
  43718. */
  43719. get zoomStopsAnimation(): boolean;
  43720. /**
  43721. * Sets the default speed at which the camera rotates around the model.
  43722. */
  43723. set idleRotationSpeed(speed: number);
  43724. /**
  43725. * Gets the default speed at which the camera rotates around the model.
  43726. */
  43727. get idleRotationSpeed(): number;
  43728. /**
  43729. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43730. */
  43731. set idleRotationWaitTime(time: number);
  43732. /**
  43733. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43734. */
  43735. get idleRotationWaitTime(): number;
  43736. /**
  43737. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43738. */
  43739. set idleRotationSpinupTime(time: number);
  43740. /**
  43741. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43742. */
  43743. get idleRotationSpinupTime(): number;
  43744. /**
  43745. * Gets a value indicating if the camera is currently rotating because of this behavior
  43746. */
  43747. get rotationInProgress(): boolean;
  43748. private _onPrePointerObservableObserver;
  43749. private _onAfterCheckInputsObserver;
  43750. private _attachedCamera;
  43751. private _isPointerDown;
  43752. private _lastFrameTime;
  43753. private _lastInteractionTime;
  43754. private _cameraRotationSpeed;
  43755. /**
  43756. * Initializes the behavior.
  43757. */
  43758. init(): void;
  43759. /**
  43760. * Attaches the behavior to its arc rotate camera.
  43761. * @param camera Defines the camera to attach the behavior to
  43762. */
  43763. attach(camera: ArcRotateCamera): void;
  43764. /**
  43765. * Detaches the behavior from its current arc rotate camera.
  43766. */
  43767. detach(): void;
  43768. /**
  43769. * Returns true if user is scrolling.
  43770. * @return true if user is scrolling.
  43771. */
  43772. private _userIsZooming;
  43773. private _lastFrameRadius;
  43774. private _shouldAnimationStopForInteraction;
  43775. /**
  43776. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43777. */
  43778. private _applyUserInteraction;
  43779. private _userIsMoving;
  43780. }
  43781. }
  43782. declare module "babylonjs/Behaviors/Cameras/index" {
  43783. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43784. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43785. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43786. }
  43787. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43788. import { Mesh } from "babylonjs/Meshes/mesh";
  43789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43790. import { Behavior } from "babylonjs/Behaviors/behavior";
  43791. /**
  43792. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43793. */
  43794. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43795. private ui;
  43796. /**
  43797. * The name of the behavior
  43798. */
  43799. name: string;
  43800. /**
  43801. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43802. */
  43803. distanceAwayFromFace: number;
  43804. /**
  43805. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43806. */
  43807. distanceAwayFromBottomOfFace: number;
  43808. private _faceVectors;
  43809. private _target;
  43810. private _scene;
  43811. private _onRenderObserver;
  43812. private _tmpMatrix;
  43813. private _tmpVector;
  43814. /**
  43815. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43816. * @param ui The transform node that should be attched to the mesh
  43817. */
  43818. constructor(ui: TransformNode);
  43819. /**
  43820. * Initializes the behavior
  43821. */
  43822. init(): void;
  43823. private _closestFace;
  43824. private _zeroVector;
  43825. private _lookAtTmpMatrix;
  43826. private _lookAtToRef;
  43827. /**
  43828. * Attaches the AttachToBoxBehavior to the passed in mesh
  43829. * @param target The mesh that the specified node will be attached to
  43830. */
  43831. attach(target: Mesh): void;
  43832. /**
  43833. * Detaches the behavior from the mesh
  43834. */
  43835. detach(): void;
  43836. }
  43837. }
  43838. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43839. import { Behavior } from "babylonjs/Behaviors/behavior";
  43840. import { Mesh } from "babylonjs/Meshes/mesh";
  43841. /**
  43842. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43843. */
  43844. export class FadeInOutBehavior implements Behavior<Mesh> {
  43845. /**
  43846. * Time in milliseconds to delay before fading in (Default: 0)
  43847. */
  43848. delay: number;
  43849. /**
  43850. * Time in milliseconds for the mesh to fade in (Default: 300)
  43851. */
  43852. fadeInTime: number;
  43853. private _millisecondsPerFrame;
  43854. private _hovered;
  43855. private _hoverValue;
  43856. private _ownerNode;
  43857. /**
  43858. * Instatiates the FadeInOutBehavior
  43859. */
  43860. constructor();
  43861. /**
  43862. * The name of the behavior
  43863. */
  43864. get name(): string;
  43865. /**
  43866. * Initializes the behavior
  43867. */
  43868. init(): void;
  43869. /**
  43870. * Attaches the fade behavior on the passed in mesh
  43871. * @param ownerNode The mesh that will be faded in/out once attached
  43872. */
  43873. attach(ownerNode: Mesh): void;
  43874. /**
  43875. * Detaches the behavior from the mesh
  43876. */
  43877. detach(): void;
  43878. /**
  43879. * Triggers the mesh to begin fading in or out
  43880. * @param value if the object should fade in or out (true to fade in)
  43881. */
  43882. fadeIn(value: boolean): void;
  43883. private _update;
  43884. private _setAllVisibility;
  43885. }
  43886. }
  43887. declare module "babylonjs/Misc/pivotTools" {
  43888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43889. /**
  43890. * Class containing a set of static utilities functions for managing Pivots
  43891. * @hidden
  43892. */
  43893. export class PivotTools {
  43894. private static _PivotCached;
  43895. private static _OldPivotPoint;
  43896. private static _PivotTranslation;
  43897. private static _PivotTmpVector;
  43898. /** @hidden */
  43899. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43900. /** @hidden */
  43901. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43902. }
  43903. }
  43904. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43905. import { Scene } from "babylonjs/scene";
  43906. import { Vector4 } from "babylonjs/Maths/math.vector";
  43907. import { Mesh } from "babylonjs/Meshes/mesh";
  43908. import { Nullable } from "babylonjs/types";
  43909. import { Plane } from "babylonjs/Maths/math.plane";
  43910. /**
  43911. * Class containing static functions to help procedurally build meshes
  43912. */
  43913. export class PlaneBuilder {
  43914. /**
  43915. * Creates a plane mesh
  43916. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43917. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43918. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43922. * @param name defines the name of the mesh
  43923. * @param options defines the options used to create the mesh
  43924. * @param scene defines the hosting scene
  43925. * @returns the plane mesh
  43926. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43927. */
  43928. static CreatePlane(name: string, options: {
  43929. size?: number;
  43930. width?: number;
  43931. height?: number;
  43932. sideOrientation?: number;
  43933. frontUVs?: Vector4;
  43934. backUVs?: Vector4;
  43935. updatable?: boolean;
  43936. sourcePlane?: Plane;
  43937. }, scene?: Nullable<Scene>): Mesh;
  43938. }
  43939. }
  43940. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43941. import { Behavior } from "babylonjs/Behaviors/behavior";
  43942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43943. import { Observable } from "babylonjs/Misc/observable";
  43944. import { Vector3 } from "babylonjs/Maths/math.vector";
  43945. import { Ray } from "babylonjs/Culling/ray";
  43946. import "babylonjs/Meshes/Builders/planeBuilder";
  43947. /**
  43948. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43949. */
  43950. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43951. private static _AnyMouseID;
  43952. /**
  43953. * Abstract mesh the behavior is set on
  43954. */
  43955. attachedNode: AbstractMesh;
  43956. private _dragPlane;
  43957. private _scene;
  43958. private _pointerObserver;
  43959. private _beforeRenderObserver;
  43960. private static _planeScene;
  43961. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43962. /**
  43963. * 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)
  43964. */
  43965. maxDragAngle: number;
  43966. /**
  43967. * @hidden
  43968. */
  43969. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43970. /**
  43971. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43972. */
  43973. currentDraggingPointerID: number;
  43974. /**
  43975. * The last position where the pointer hit the drag plane in world space
  43976. */
  43977. lastDragPosition: Vector3;
  43978. /**
  43979. * If the behavior is currently in a dragging state
  43980. */
  43981. dragging: boolean;
  43982. /**
  43983. * 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)
  43984. */
  43985. dragDeltaRatio: number;
  43986. /**
  43987. * If the drag plane orientation should be updated during the dragging (Default: true)
  43988. */
  43989. updateDragPlane: boolean;
  43990. private _debugMode;
  43991. private _moving;
  43992. /**
  43993. * Fires each time the attached mesh is dragged with the pointer
  43994. * * delta between last drag position and current drag position in world space
  43995. * * dragDistance along the drag axis
  43996. * * dragPlaneNormal normal of the current drag plane used during the drag
  43997. * * dragPlanePoint in world space where the drag intersects the drag plane
  43998. */
  43999. onDragObservable: Observable<{
  44000. delta: Vector3;
  44001. dragPlanePoint: Vector3;
  44002. dragPlaneNormal: Vector3;
  44003. dragDistance: number;
  44004. pointerId: number;
  44005. }>;
  44006. /**
  44007. * Fires each time a drag begins (eg. mouse down on mesh)
  44008. */
  44009. onDragStartObservable: Observable<{
  44010. dragPlanePoint: Vector3;
  44011. pointerId: number;
  44012. }>;
  44013. /**
  44014. * Fires each time a drag ends (eg. mouse release after drag)
  44015. */
  44016. onDragEndObservable: Observable<{
  44017. dragPlanePoint: Vector3;
  44018. pointerId: number;
  44019. }>;
  44020. /**
  44021. * If the attached mesh should be moved when dragged
  44022. */
  44023. moveAttached: boolean;
  44024. /**
  44025. * If the drag behavior will react to drag events (Default: true)
  44026. */
  44027. enabled: boolean;
  44028. /**
  44029. * If pointer events should start and release the drag (Default: true)
  44030. */
  44031. startAndReleaseDragOnPointerEvents: boolean;
  44032. /**
  44033. * If camera controls should be detached during the drag
  44034. */
  44035. detachCameraControls: boolean;
  44036. /**
  44037. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44038. */
  44039. useObjectOrientationForDragging: boolean;
  44040. private _options;
  44041. /**
  44042. * Gets the options used by the behavior
  44043. */
  44044. get options(): {
  44045. dragAxis?: Vector3;
  44046. dragPlaneNormal?: Vector3;
  44047. };
  44048. /**
  44049. * Sets the options used by the behavior
  44050. */
  44051. set options(options: {
  44052. dragAxis?: Vector3;
  44053. dragPlaneNormal?: Vector3;
  44054. });
  44055. /**
  44056. * Creates a pointer drag behavior that can be attached to a mesh
  44057. * @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)
  44058. */
  44059. constructor(options?: {
  44060. dragAxis?: Vector3;
  44061. dragPlaneNormal?: Vector3;
  44062. });
  44063. /**
  44064. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44065. */
  44066. validateDrag: (targetPosition: Vector3) => boolean;
  44067. /**
  44068. * The name of the behavior
  44069. */
  44070. get name(): string;
  44071. /**
  44072. * Initializes the behavior
  44073. */
  44074. init(): void;
  44075. private _tmpVector;
  44076. private _alternatePickedPoint;
  44077. private _worldDragAxis;
  44078. private _targetPosition;
  44079. private _attachedElement;
  44080. /**
  44081. * Attaches the drag behavior the passed in mesh
  44082. * @param ownerNode The mesh that will be dragged around once attached
  44083. * @param predicate Predicate to use for pick filtering
  44084. */
  44085. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44086. /**
  44087. * Force relase the drag action by code.
  44088. */
  44089. releaseDrag(): void;
  44090. private _startDragRay;
  44091. private _lastPointerRay;
  44092. /**
  44093. * Simulates the start of a pointer drag event on the behavior
  44094. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44095. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44096. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44097. */
  44098. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44099. private _startDrag;
  44100. private _dragDelta;
  44101. private _moveDrag;
  44102. private _pickWithRayOnDragPlane;
  44103. private _pointA;
  44104. private _pointB;
  44105. private _pointC;
  44106. private _lineA;
  44107. private _lineB;
  44108. private _localAxis;
  44109. private _lookAt;
  44110. private _updateDragPlanePosition;
  44111. /**
  44112. * Detaches the behavior from the mesh
  44113. */
  44114. detach(): void;
  44115. }
  44116. }
  44117. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44118. import { Mesh } from "babylonjs/Meshes/mesh";
  44119. import { Behavior } from "babylonjs/Behaviors/behavior";
  44120. /**
  44121. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44122. */
  44123. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44124. private _dragBehaviorA;
  44125. private _dragBehaviorB;
  44126. private _startDistance;
  44127. private _initialScale;
  44128. private _targetScale;
  44129. private _ownerNode;
  44130. private _sceneRenderObserver;
  44131. /**
  44132. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44133. */
  44134. constructor();
  44135. /**
  44136. * The name of the behavior
  44137. */
  44138. get name(): string;
  44139. /**
  44140. * Initializes the behavior
  44141. */
  44142. init(): void;
  44143. private _getCurrentDistance;
  44144. /**
  44145. * Attaches the scale behavior the passed in mesh
  44146. * @param ownerNode The mesh that will be scaled around once attached
  44147. */
  44148. attach(ownerNode: Mesh): void;
  44149. /**
  44150. * Detaches the behavior from the mesh
  44151. */
  44152. detach(): void;
  44153. }
  44154. }
  44155. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44156. import { Behavior } from "babylonjs/Behaviors/behavior";
  44157. import { Mesh } from "babylonjs/Meshes/mesh";
  44158. import { Observable } from "babylonjs/Misc/observable";
  44159. /**
  44160. * 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
  44161. */
  44162. export class SixDofDragBehavior implements Behavior<Mesh> {
  44163. private static _virtualScene;
  44164. private _ownerNode;
  44165. private _sceneRenderObserver;
  44166. private _scene;
  44167. private _targetPosition;
  44168. private _virtualOriginMesh;
  44169. private _virtualDragMesh;
  44170. private _pointerObserver;
  44171. private _moving;
  44172. private _startingOrientation;
  44173. private _attachedElement;
  44174. /**
  44175. * 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)
  44176. */
  44177. private zDragFactor;
  44178. /**
  44179. * If the object should rotate to face the drag origin
  44180. */
  44181. rotateDraggedObject: boolean;
  44182. /**
  44183. * If the behavior is currently in a dragging state
  44184. */
  44185. dragging: boolean;
  44186. /**
  44187. * 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)
  44188. */
  44189. dragDeltaRatio: number;
  44190. /**
  44191. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44192. */
  44193. currentDraggingPointerID: number;
  44194. /**
  44195. * If camera controls should be detached during the drag
  44196. */
  44197. detachCameraControls: boolean;
  44198. /**
  44199. * Fires each time a drag starts
  44200. */
  44201. onDragStartObservable: Observable<{}>;
  44202. /**
  44203. * Fires each time a drag ends (eg. mouse release after drag)
  44204. */
  44205. onDragEndObservable: Observable<{}>;
  44206. /**
  44207. * 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
  44208. */
  44209. constructor();
  44210. /**
  44211. * The name of the behavior
  44212. */
  44213. get name(): string;
  44214. /**
  44215. * Initializes the behavior
  44216. */
  44217. init(): void;
  44218. /**
  44219. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44220. */
  44221. private get _pointerCamera();
  44222. /**
  44223. * Attaches the scale behavior the passed in mesh
  44224. * @param ownerNode The mesh that will be scaled around once attached
  44225. */
  44226. attach(ownerNode: Mesh): void;
  44227. /**
  44228. * Detaches the behavior from the mesh
  44229. */
  44230. detach(): void;
  44231. }
  44232. }
  44233. declare module "babylonjs/Behaviors/Meshes/index" {
  44234. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44235. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44236. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44237. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44238. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44239. }
  44240. declare module "babylonjs/Behaviors/index" {
  44241. export * from "babylonjs/Behaviors/behavior";
  44242. export * from "babylonjs/Behaviors/Cameras/index";
  44243. export * from "babylonjs/Behaviors/Meshes/index";
  44244. }
  44245. declare module "babylonjs/Bones/boneIKController" {
  44246. import { Bone } from "babylonjs/Bones/bone";
  44247. import { Vector3 } from "babylonjs/Maths/math.vector";
  44248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44249. import { Nullable } from "babylonjs/types";
  44250. /**
  44251. * Class used to apply inverse kinematics to bones
  44252. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44253. */
  44254. export class BoneIKController {
  44255. private static _tmpVecs;
  44256. private static _tmpQuat;
  44257. private static _tmpMats;
  44258. /**
  44259. * Gets or sets the target mesh
  44260. */
  44261. targetMesh: AbstractMesh;
  44262. /** Gets or sets the mesh used as pole */
  44263. poleTargetMesh: AbstractMesh;
  44264. /**
  44265. * Gets or sets the bone used as pole
  44266. */
  44267. poleTargetBone: Nullable<Bone>;
  44268. /**
  44269. * Gets or sets the target position
  44270. */
  44271. targetPosition: Vector3;
  44272. /**
  44273. * Gets or sets the pole target position
  44274. */
  44275. poleTargetPosition: Vector3;
  44276. /**
  44277. * Gets or sets the pole target local offset
  44278. */
  44279. poleTargetLocalOffset: Vector3;
  44280. /**
  44281. * Gets or sets the pole angle
  44282. */
  44283. poleAngle: number;
  44284. /**
  44285. * Gets or sets the mesh associated with the controller
  44286. */
  44287. mesh: AbstractMesh;
  44288. /**
  44289. * 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)
  44290. */
  44291. slerpAmount: number;
  44292. private _bone1Quat;
  44293. private _bone1Mat;
  44294. private _bone2Ang;
  44295. private _bone1;
  44296. private _bone2;
  44297. private _bone1Length;
  44298. private _bone2Length;
  44299. private _maxAngle;
  44300. private _maxReach;
  44301. private _rightHandedSystem;
  44302. private _bendAxis;
  44303. private _slerping;
  44304. private _adjustRoll;
  44305. /**
  44306. * Gets or sets maximum allowed angle
  44307. */
  44308. get maxAngle(): number;
  44309. set maxAngle(value: number);
  44310. /**
  44311. * Creates a new BoneIKController
  44312. * @param mesh defines the mesh to control
  44313. * @param bone defines the bone to control
  44314. * @param options defines options to set up the controller
  44315. */
  44316. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44317. targetMesh?: AbstractMesh;
  44318. poleTargetMesh?: AbstractMesh;
  44319. poleTargetBone?: Bone;
  44320. poleTargetLocalOffset?: Vector3;
  44321. poleAngle?: number;
  44322. bendAxis?: Vector3;
  44323. maxAngle?: number;
  44324. slerpAmount?: number;
  44325. });
  44326. private _setMaxAngle;
  44327. /**
  44328. * Force the controller to update the bones
  44329. */
  44330. update(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Bones/boneLookController" {
  44334. import { Vector3 } from "babylonjs/Maths/math.vector";
  44335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44336. import { Bone } from "babylonjs/Bones/bone";
  44337. import { Space } from "babylonjs/Maths/math.axis";
  44338. /**
  44339. * Class used to make a bone look toward a point in space
  44340. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44341. */
  44342. export class BoneLookController {
  44343. private static _tmpVecs;
  44344. private static _tmpQuat;
  44345. private static _tmpMats;
  44346. /**
  44347. * The target Vector3 that the bone will look at
  44348. */
  44349. target: Vector3;
  44350. /**
  44351. * The mesh that the bone is attached to
  44352. */
  44353. mesh: AbstractMesh;
  44354. /**
  44355. * The bone that will be looking to the target
  44356. */
  44357. bone: Bone;
  44358. /**
  44359. * The up axis of the coordinate system that is used when the bone is rotated
  44360. */
  44361. upAxis: Vector3;
  44362. /**
  44363. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44364. */
  44365. upAxisSpace: Space;
  44366. /**
  44367. * Used to make an adjustment to the yaw of the bone
  44368. */
  44369. adjustYaw: number;
  44370. /**
  44371. * Used to make an adjustment to the pitch of the bone
  44372. */
  44373. adjustPitch: number;
  44374. /**
  44375. * Used to make an adjustment to the roll of the bone
  44376. */
  44377. adjustRoll: number;
  44378. /**
  44379. * 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)
  44380. */
  44381. slerpAmount: number;
  44382. private _minYaw;
  44383. private _maxYaw;
  44384. private _minPitch;
  44385. private _maxPitch;
  44386. private _minYawSin;
  44387. private _minYawCos;
  44388. private _maxYawSin;
  44389. private _maxYawCos;
  44390. private _midYawConstraint;
  44391. private _minPitchTan;
  44392. private _maxPitchTan;
  44393. private _boneQuat;
  44394. private _slerping;
  44395. private _transformYawPitch;
  44396. private _transformYawPitchInv;
  44397. private _firstFrameSkipped;
  44398. private _yawRange;
  44399. private _fowardAxis;
  44400. /**
  44401. * Gets or sets the minimum yaw angle that the bone can look to
  44402. */
  44403. get minYaw(): number;
  44404. set minYaw(value: number);
  44405. /**
  44406. * Gets or sets the maximum yaw angle that the bone can look to
  44407. */
  44408. get maxYaw(): number;
  44409. set maxYaw(value: number);
  44410. /**
  44411. * Gets or sets the minimum pitch angle that the bone can look to
  44412. */
  44413. get minPitch(): number;
  44414. set minPitch(value: number);
  44415. /**
  44416. * Gets or sets the maximum pitch angle that the bone can look to
  44417. */
  44418. get maxPitch(): number;
  44419. set maxPitch(value: number);
  44420. /**
  44421. * Create a BoneLookController
  44422. * @param mesh the mesh that the bone belongs to
  44423. * @param bone the bone that will be looking to the target
  44424. * @param target the target Vector3 to look at
  44425. * @param options optional settings:
  44426. * * maxYaw: the maximum angle the bone will yaw to
  44427. * * minYaw: the minimum angle the bone will yaw to
  44428. * * maxPitch: the maximum angle the bone will pitch to
  44429. * * minPitch: the minimum angle the bone will yaw to
  44430. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44431. * * upAxis: the up axis of the coordinate system
  44432. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44433. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44434. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44435. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44436. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44437. * * adjustRoll: used to make an adjustment to the roll of the bone
  44438. **/
  44439. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44440. maxYaw?: number;
  44441. minYaw?: number;
  44442. maxPitch?: number;
  44443. minPitch?: number;
  44444. slerpAmount?: number;
  44445. upAxis?: Vector3;
  44446. upAxisSpace?: Space;
  44447. yawAxis?: Vector3;
  44448. pitchAxis?: Vector3;
  44449. adjustYaw?: number;
  44450. adjustPitch?: number;
  44451. adjustRoll?: number;
  44452. });
  44453. /**
  44454. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44455. */
  44456. update(): void;
  44457. private _getAngleDiff;
  44458. private _getAngleBetween;
  44459. private _isAngleBetween;
  44460. }
  44461. }
  44462. declare module "babylonjs/Bones/index" {
  44463. export * from "babylonjs/Bones/bone";
  44464. export * from "babylonjs/Bones/boneIKController";
  44465. export * from "babylonjs/Bones/boneLookController";
  44466. export * from "babylonjs/Bones/skeleton";
  44467. }
  44468. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44469. import { Nullable } from "babylonjs/types";
  44470. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44471. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44472. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44473. /**
  44474. * Manage the gamepad inputs to control an arc rotate camera.
  44475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44476. */
  44477. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44478. /**
  44479. * Defines the camera the input is attached to.
  44480. */
  44481. camera: ArcRotateCamera;
  44482. /**
  44483. * Defines the gamepad the input is gathering event from.
  44484. */
  44485. gamepad: Nullable<Gamepad>;
  44486. /**
  44487. * Defines the gamepad rotation sensiblity.
  44488. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44489. */
  44490. gamepadRotationSensibility: number;
  44491. /**
  44492. * Defines the gamepad move sensiblity.
  44493. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44494. */
  44495. gamepadMoveSensibility: number;
  44496. private _yAxisScale;
  44497. /**
  44498. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44499. */
  44500. get invertYAxis(): boolean;
  44501. set invertYAxis(value: boolean);
  44502. private _onGamepadConnectedObserver;
  44503. private _onGamepadDisconnectedObserver;
  44504. /**
  44505. * Attach the input controls to a specific dom element to get the input from.
  44506. * @param element Defines the element the controls should be listened from
  44507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44508. */
  44509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44510. /**
  44511. * Detach the current controls from the specified dom element.
  44512. * @param element Defines the element to stop listening the inputs from
  44513. */
  44514. detachControl(element: Nullable<HTMLElement>): void;
  44515. /**
  44516. * Update the current camera state depending on the inputs that have been used this frame.
  44517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44518. */
  44519. checkInputs(): void;
  44520. /**
  44521. * Gets the class name of the current intput.
  44522. * @returns the class name
  44523. */
  44524. getClassName(): string;
  44525. /**
  44526. * Get the friendly name associated with the input class.
  44527. * @returns the input friendly name
  44528. */
  44529. getSimpleName(): string;
  44530. }
  44531. }
  44532. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44536. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44537. interface ArcRotateCameraInputsManager {
  44538. /**
  44539. * Add orientation input support to the input manager.
  44540. * @returns the current input manager
  44541. */
  44542. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44543. }
  44544. }
  44545. /**
  44546. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44548. */
  44549. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44550. /**
  44551. * Defines the camera the input is attached to.
  44552. */
  44553. camera: ArcRotateCamera;
  44554. /**
  44555. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44556. */
  44557. alphaCorrection: number;
  44558. /**
  44559. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44560. */
  44561. gammaCorrection: number;
  44562. private _alpha;
  44563. private _gamma;
  44564. private _dirty;
  44565. private _deviceOrientationHandler;
  44566. /**
  44567. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44568. */
  44569. constructor();
  44570. /**
  44571. * Attach the input controls to a specific dom element to get the input from.
  44572. * @param element Defines the element the controls should be listened from
  44573. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44574. */
  44575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44576. /** @hidden */
  44577. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44578. /**
  44579. * Update the current camera state depending on the inputs that have been used this frame.
  44580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44581. */
  44582. checkInputs(): void;
  44583. /**
  44584. * Detach the current controls from the specified dom element.
  44585. * @param element Defines the element to stop listening the inputs from
  44586. */
  44587. detachControl(element: Nullable<HTMLElement>): void;
  44588. /**
  44589. * Gets the class name of the current intput.
  44590. * @returns the class name
  44591. */
  44592. getClassName(): string;
  44593. /**
  44594. * Get the friendly name associated with the input class.
  44595. * @returns the input friendly name
  44596. */
  44597. getSimpleName(): string;
  44598. }
  44599. }
  44600. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44601. import { Nullable } from "babylonjs/types";
  44602. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44603. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44604. /**
  44605. * Listen to mouse events to control the camera.
  44606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44607. */
  44608. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44609. /**
  44610. * Defines the camera the input is attached to.
  44611. */
  44612. camera: FlyCamera;
  44613. /**
  44614. * Defines if touch is enabled. (Default is true.)
  44615. */
  44616. touchEnabled: boolean;
  44617. /**
  44618. * Defines the buttons associated with the input to handle camera rotation.
  44619. */
  44620. buttons: number[];
  44621. /**
  44622. * Assign buttons for Yaw control.
  44623. */
  44624. buttonsYaw: number[];
  44625. /**
  44626. * Assign buttons for Pitch control.
  44627. */
  44628. buttonsPitch: number[];
  44629. /**
  44630. * Assign buttons for Roll control.
  44631. */
  44632. buttonsRoll: number[];
  44633. /**
  44634. * Detect if any button is being pressed while mouse is moved.
  44635. * -1 = Mouse locked.
  44636. * 0 = Left button.
  44637. * 1 = Middle Button.
  44638. * 2 = Right Button.
  44639. */
  44640. activeButton: number;
  44641. /**
  44642. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44643. * Higher values reduce its sensitivity.
  44644. */
  44645. angularSensibility: number;
  44646. private _mousemoveCallback;
  44647. private _observer;
  44648. private _rollObserver;
  44649. private previousPosition;
  44650. private noPreventDefault;
  44651. private element;
  44652. /**
  44653. * Listen to mouse events to control the camera.
  44654. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44656. */
  44657. constructor(touchEnabled?: boolean);
  44658. /**
  44659. * Attach the mouse control to the HTML DOM element.
  44660. * @param element Defines the element that listens to the input events.
  44661. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44662. */
  44663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44664. /**
  44665. * Detach the current controls from the specified dom element.
  44666. * @param element Defines the element to stop listening the inputs from
  44667. */
  44668. detachControl(element: Nullable<HTMLElement>): void;
  44669. /**
  44670. * Gets the class name of the current input.
  44671. * @returns the class name.
  44672. */
  44673. getClassName(): string;
  44674. /**
  44675. * Get the friendly name associated with the input class.
  44676. * @returns the input's friendly name.
  44677. */
  44678. getSimpleName(): string;
  44679. private _pointerInput;
  44680. private _onMouseMove;
  44681. /**
  44682. * Rotate camera by mouse offset.
  44683. */
  44684. private rotateCamera;
  44685. }
  44686. }
  44687. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44688. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44689. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44690. /**
  44691. * Default Inputs manager for the FlyCamera.
  44692. * It groups all the default supported inputs for ease of use.
  44693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44694. */
  44695. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44696. /**
  44697. * Instantiates a new FlyCameraInputsManager.
  44698. * @param camera Defines the camera the inputs belong to.
  44699. */
  44700. constructor(camera: FlyCamera);
  44701. /**
  44702. * Add keyboard input support to the input manager.
  44703. * @returns the new FlyCameraKeyboardMoveInput().
  44704. */
  44705. addKeyboard(): FlyCameraInputsManager;
  44706. /**
  44707. * Add mouse input support to the input manager.
  44708. * @param touchEnabled Enable touch screen support.
  44709. * @returns the new FlyCameraMouseInput().
  44710. */
  44711. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44712. }
  44713. }
  44714. declare module "babylonjs/Cameras/flyCamera" {
  44715. import { Scene } from "babylonjs/scene";
  44716. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44718. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44719. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44720. /**
  44721. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44722. * such as in a 3D Space Shooter or a Flight Simulator.
  44723. */
  44724. export class FlyCamera extends TargetCamera {
  44725. /**
  44726. * Define the collision ellipsoid of the camera.
  44727. * This is helpful for simulating a camera body, like a player's body.
  44728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44729. */
  44730. ellipsoid: Vector3;
  44731. /**
  44732. * Define an offset for the position of the ellipsoid around the camera.
  44733. * This can be helpful if the camera is attached away from the player's body center,
  44734. * such as at its head.
  44735. */
  44736. ellipsoidOffset: Vector3;
  44737. /**
  44738. * Enable or disable collisions of the camera with the rest of the scene objects.
  44739. */
  44740. checkCollisions: boolean;
  44741. /**
  44742. * Enable or disable gravity on the camera.
  44743. */
  44744. applyGravity: boolean;
  44745. /**
  44746. * Define the current direction the camera is moving to.
  44747. */
  44748. cameraDirection: Vector3;
  44749. /**
  44750. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44751. * This overrides and empties cameraRotation.
  44752. */
  44753. rotationQuaternion: Quaternion;
  44754. /**
  44755. * Track Roll to maintain the wanted Rolling when looking around.
  44756. */
  44757. _trackRoll: number;
  44758. /**
  44759. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44760. */
  44761. rollCorrect: number;
  44762. /**
  44763. * Mimic a banked turn, Rolling the camera when Yawing.
  44764. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44765. */
  44766. bankedTurn: boolean;
  44767. /**
  44768. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44769. */
  44770. bankedTurnLimit: number;
  44771. /**
  44772. * Value of 0 disables the banked Roll.
  44773. * Value of 1 is equal to the Yaw angle in radians.
  44774. */
  44775. bankedTurnMultiplier: number;
  44776. /**
  44777. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44778. */
  44779. inputs: FlyCameraInputsManager;
  44780. /**
  44781. * Gets the input sensibility for mouse input.
  44782. * Higher values reduce sensitivity.
  44783. */
  44784. get angularSensibility(): number;
  44785. /**
  44786. * Sets the input sensibility for a mouse input.
  44787. * Higher values reduce sensitivity.
  44788. */
  44789. set angularSensibility(value: number);
  44790. /**
  44791. * Get the keys for camera movement forward.
  44792. */
  44793. get keysForward(): number[];
  44794. /**
  44795. * Set the keys for camera movement forward.
  44796. */
  44797. set keysForward(value: number[]);
  44798. /**
  44799. * Get the keys for camera movement backward.
  44800. */
  44801. get keysBackward(): number[];
  44802. set keysBackward(value: number[]);
  44803. /**
  44804. * Get the keys for camera movement up.
  44805. */
  44806. get keysUp(): number[];
  44807. /**
  44808. * Set the keys for camera movement up.
  44809. */
  44810. set keysUp(value: number[]);
  44811. /**
  44812. * Get the keys for camera movement down.
  44813. */
  44814. get keysDown(): number[];
  44815. /**
  44816. * Set the keys for camera movement down.
  44817. */
  44818. set keysDown(value: number[]);
  44819. /**
  44820. * Get the keys for camera movement left.
  44821. */
  44822. get keysLeft(): number[];
  44823. /**
  44824. * Set the keys for camera movement left.
  44825. */
  44826. set keysLeft(value: number[]);
  44827. /**
  44828. * Set the keys for camera movement right.
  44829. */
  44830. get keysRight(): number[];
  44831. /**
  44832. * Set the keys for camera movement right.
  44833. */
  44834. set keysRight(value: number[]);
  44835. /**
  44836. * Event raised when the camera collides with a mesh in the scene.
  44837. */
  44838. onCollide: (collidedMesh: AbstractMesh) => void;
  44839. private _collider;
  44840. private _needMoveForGravity;
  44841. private _oldPosition;
  44842. private _diffPosition;
  44843. private _newPosition;
  44844. /** @hidden */
  44845. _localDirection: Vector3;
  44846. /** @hidden */
  44847. _transformedDirection: Vector3;
  44848. /**
  44849. * Instantiates a FlyCamera.
  44850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44851. * such as in a 3D Space Shooter or a Flight Simulator.
  44852. * @param name Define the name of the camera in the scene.
  44853. * @param position Define the starting position of the camera in the scene.
  44854. * @param scene Define the scene the camera belongs to.
  44855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44856. */
  44857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44858. /**
  44859. * Attach a control to the HTML DOM element.
  44860. * @param element Defines the element that listens to the input events.
  44861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44862. */
  44863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44864. /**
  44865. * Detach a control from the HTML DOM element.
  44866. * The camera will stop reacting to that input.
  44867. * @param element Defines the element that listens to the input events.
  44868. */
  44869. detachControl(element: HTMLElement): void;
  44870. private _collisionMask;
  44871. /**
  44872. * Get the mask that the camera ignores in collision events.
  44873. */
  44874. get collisionMask(): number;
  44875. /**
  44876. * Set the mask that the camera ignores in collision events.
  44877. */
  44878. set collisionMask(mask: number);
  44879. /** @hidden */
  44880. _collideWithWorld(displacement: Vector3): void;
  44881. /** @hidden */
  44882. private _onCollisionPositionChange;
  44883. /** @hidden */
  44884. _checkInputs(): void;
  44885. /** @hidden */
  44886. _decideIfNeedsToMove(): boolean;
  44887. /** @hidden */
  44888. _updatePosition(): void;
  44889. /**
  44890. * Restore the Roll to its target value at the rate specified.
  44891. * @param rate - Higher means slower restoring.
  44892. * @hidden
  44893. */
  44894. restoreRoll(rate: number): void;
  44895. /**
  44896. * Destroy the camera and release the current resources held by it.
  44897. */
  44898. dispose(): void;
  44899. /**
  44900. * Get the current object class name.
  44901. * @returns the class name.
  44902. */
  44903. getClassName(): string;
  44904. }
  44905. }
  44906. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44907. import { Nullable } from "babylonjs/types";
  44908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44909. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44910. /**
  44911. * Listen to keyboard events to control the camera.
  44912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44913. */
  44914. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44915. /**
  44916. * Defines the camera the input is attached to.
  44917. */
  44918. camera: FlyCamera;
  44919. /**
  44920. * The list of keyboard keys used to control the forward move of the camera.
  44921. */
  44922. keysForward: number[];
  44923. /**
  44924. * The list of keyboard keys used to control the backward move of the camera.
  44925. */
  44926. keysBackward: number[];
  44927. /**
  44928. * The list of keyboard keys used to control the forward move of the camera.
  44929. */
  44930. keysUp: number[];
  44931. /**
  44932. * The list of keyboard keys used to control the backward move of the camera.
  44933. */
  44934. keysDown: number[];
  44935. /**
  44936. * The list of keyboard keys used to control the right strafe move of the camera.
  44937. */
  44938. keysRight: number[];
  44939. /**
  44940. * The list of keyboard keys used to control the left strafe move of the camera.
  44941. */
  44942. keysLeft: number[];
  44943. private _keys;
  44944. private _onCanvasBlurObserver;
  44945. private _onKeyboardObserver;
  44946. private _engine;
  44947. private _scene;
  44948. /**
  44949. * Attach the input controls to a specific dom element to get the input from.
  44950. * @param element Defines the element the controls should be listened from
  44951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44952. */
  44953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44954. /**
  44955. * Detach the current controls from the specified dom element.
  44956. * @param element Defines the element to stop listening the inputs from
  44957. */
  44958. detachControl(element: Nullable<HTMLElement>): void;
  44959. /**
  44960. * Gets the class name of the current intput.
  44961. * @returns the class name
  44962. */
  44963. getClassName(): string;
  44964. /** @hidden */
  44965. _onLostFocus(e: FocusEvent): void;
  44966. /**
  44967. * Get the friendly name associated with the input class.
  44968. * @returns the input friendly name
  44969. */
  44970. getSimpleName(): string;
  44971. /**
  44972. * Update the current camera state depending on the inputs that have been used this frame.
  44973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44974. */
  44975. checkInputs(): void;
  44976. }
  44977. }
  44978. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44979. import { Nullable } from "babylonjs/types";
  44980. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44982. /**
  44983. * Manage the mouse wheel inputs to control a follow camera.
  44984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44985. */
  44986. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44987. /**
  44988. * Defines the camera the input is attached to.
  44989. */
  44990. camera: FollowCamera;
  44991. /**
  44992. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44993. */
  44994. axisControlRadius: boolean;
  44995. /**
  44996. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44997. */
  44998. axisControlHeight: boolean;
  44999. /**
  45000. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45001. */
  45002. axisControlRotation: boolean;
  45003. /**
  45004. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45005. * relation to mouseWheel events.
  45006. */
  45007. wheelPrecision: number;
  45008. /**
  45009. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45010. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45011. */
  45012. wheelDeltaPercentage: number;
  45013. private _wheel;
  45014. private _observer;
  45015. /**
  45016. * Attach the input controls to a specific dom element to get the input from.
  45017. * @param element Defines the element the controls should be listened from
  45018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45019. */
  45020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45021. /**
  45022. * Detach the current controls from the specified dom element.
  45023. * @param element Defines the element to stop listening the inputs from
  45024. */
  45025. detachControl(element: Nullable<HTMLElement>): void;
  45026. /**
  45027. * Gets the class name of the current intput.
  45028. * @returns the class name
  45029. */
  45030. getClassName(): string;
  45031. /**
  45032. * Get the friendly name associated with the input class.
  45033. * @returns the input friendly name
  45034. */
  45035. getSimpleName(): string;
  45036. }
  45037. }
  45038. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45039. import { Nullable } from "babylonjs/types";
  45040. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45041. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45042. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45043. /**
  45044. * Manage the pointers inputs to control an follow camera.
  45045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45046. */
  45047. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45048. /**
  45049. * Defines the camera the input is attached to.
  45050. */
  45051. camera: FollowCamera;
  45052. /**
  45053. * Gets the class name of the current input.
  45054. * @returns the class name
  45055. */
  45056. getClassName(): string;
  45057. /**
  45058. * Defines the pointer angular sensibility along the X axis or how fast is
  45059. * the camera rotating.
  45060. * A negative number will reverse the axis direction.
  45061. */
  45062. angularSensibilityX: number;
  45063. /**
  45064. * Defines the pointer angular sensibility along the Y axis or how fast is
  45065. * the camera rotating.
  45066. * A negative number will reverse the axis direction.
  45067. */
  45068. angularSensibilityY: number;
  45069. /**
  45070. * Defines the pointer pinch precision or how fast is the camera zooming.
  45071. * A negative number will reverse the axis direction.
  45072. */
  45073. pinchPrecision: number;
  45074. /**
  45075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45076. * from 0.
  45077. * It defines the percentage of current camera.radius to use as delta when
  45078. * pinch zoom is used.
  45079. */
  45080. pinchDeltaPercentage: number;
  45081. /**
  45082. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45083. */
  45084. axisXControlRadius: boolean;
  45085. /**
  45086. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45087. */
  45088. axisXControlHeight: boolean;
  45089. /**
  45090. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45091. */
  45092. axisXControlRotation: boolean;
  45093. /**
  45094. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45095. */
  45096. axisYControlRadius: boolean;
  45097. /**
  45098. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45099. */
  45100. axisYControlHeight: boolean;
  45101. /**
  45102. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45103. */
  45104. axisYControlRotation: boolean;
  45105. /**
  45106. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45107. */
  45108. axisPinchControlRadius: boolean;
  45109. /**
  45110. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45111. */
  45112. axisPinchControlHeight: boolean;
  45113. /**
  45114. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45115. */
  45116. axisPinchControlRotation: boolean;
  45117. /**
  45118. * Log error messages if basic misconfiguration has occurred.
  45119. */
  45120. warningEnable: boolean;
  45121. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45122. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45123. private _warningCounter;
  45124. private _warning;
  45125. }
  45126. }
  45127. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45128. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45129. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45130. /**
  45131. * Default Inputs manager for the FollowCamera.
  45132. * It groups all the default supported inputs for ease of use.
  45133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45134. */
  45135. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45136. /**
  45137. * Instantiates a new FollowCameraInputsManager.
  45138. * @param camera Defines the camera the inputs belong to
  45139. */
  45140. constructor(camera: FollowCamera);
  45141. /**
  45142. * Add keyboard input support to the input manager.
  45143. * @returns the current input manager
  45144. */
  45145. addKeyboard(): FollowCameraInputsManager;
  45146. /**
  45147. * Add mouse wheel input support to the input manager.
  45148. * @returns the current input manager
  45149. */
  45150. addMouseWheel(): FollowCameraInputsManager;
  45151. /**
  45152. * Add pointers input support to the input manager.
  45153. * @returns the current input manager
  45154. */
  45155. addPointers(): FollowCameraInputsManager;
  45156. /**
  45157. * Add orientation input support to the input manager.
  45158. * @returns the current input manager
  45159. */
  45160. addVRDeviceOrientation(): FollowCameraInputsManager;
  45161. }
  45162. }
  45163. declare module "babylonjs/Cameras/followCamera" {
  45164. import { Nullable } from "babylonjs/types";
  45165. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45166. import { Scene } from "babylonjs/scene";
  45167. import { Vector3 } from "babylonjs/Maths/math.vector";
  45168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45169. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45170. /**
  45171. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45172. * an arc rotate version arcFollowCamera are available.
  45173. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45174. */
  45175. export class FollowCamera extends TargetCamera {
  45176. /**
  45177. * Distance the follow camera should follow an object at
  45178. */
  45179. radius: number;
  45180. /**
  45181. * Minimum allowed distance of the camera to the axis of rotation
  45182. * (The camera can not get closer).
  45183. * This can help limiting how the Camera is able to move in the scene.
  45184. */
  45185. lowerRadiusLimit: Nullable<number>;
  45186. /**
  45187. * Maximum allowed distance of the camera to the axis of rotation
  45188. * (The camera can not get further).
  45189. * This can help limiting how the Camera is able to move in the scene.
  45190. */
  45191. upperRadiusLimit: Nullable<number>;
  45192. /**
  45193. * Define a rotation offset between the camera and the object it follows
  45194. */
  45195. rotationOffset: number;
  45196. /**
  45197. * Minimum allowed angle to camera position relative to target object.
  45198. * This can help limiting how the Camera is able to move in the scene.
  45199. */
  45200. lowerRotationOffsetLimit: Nullable<number>;
  45201. /**
  45202. * Maximum allowed angle to camera position relative to target object.
  45203. * This can help limiting how the Camera is able to move in the scene.
  45204. */
  45205. upperRotationOffsetLimit: Nullable<number>;
  45206. /**
  45207. * Define a height offset between the camera and the object it follows.
  45208. * It can help following an object from the top (like a car chaing a plane)
  45209. */
  45210. heightOffset: number;
  45211. /**
  45212. * Minimum allowed height of camera position relative to target object.
  45213. * This can help limiting how the Camera is able to move in the scene.
  45214. */
  45215. lowerHeightOffsetLimit: Nullable<number>;
  45216. /**
  45217. * Maximum allowed height of camera position relative to target object.
  45218. * This can help limiting how the Camera is able to move in the scene.
  45219. */
  45220. upperHeightOffsetLimit: Nullable<number>;
  45221. /**
  45222. * Define how fast the camera can accelerate to follow it s target.
  45223. */
  45224. cameraAcceleration: number;
  45225. /**
  45226. * Define the speed limit of the camera following an object.
  45227. */
  45228. maxCameraSpeed: number;
  45229. /**
  45230. * Define the target of the camera.
  45231. */
  45232. lockedTarget: Nullable<AbstractMesh>;
  45233. /**
  45234. * Defines the input associated with the camera.
  45235. */
  45236. inputs: FollowCameraInputsManager;
  45237. /**
  45238. * Instantiates the follow camera.
  45239. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45240. * @param name Define the name of the camera in the scene
  45241. * @param position Define the position of the camera
  45242. * @param scene Define the scene the camera belong to
  45243. * @param lockedTarget Define the target of the camera
  45244. */
  45245. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45246. private _follow;
  45247. /**
  45248. * Attached controls to the current camera.
  45249. * @param element Defines the element the controls should be listened from
  45250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45251. */
  45252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45253. /**
  45254. * Detach the current controls from the camera.
  45255. * The camera will stop reacting to inputs.
  45256. * @param element Defines the element to stop listening the inputs from
  45257. */
  45258. detachControl(element: HTMLElement): void;
  45259. /** @hidden */
  45260. _checkInputs(): void;
  45261. private _checkLimits;
  45262. /**
  45263. * Gets the camera class name.
  45264. * @returns the class name
  45265. */
  45266. getClassName(): string;
  45267. }
  45268. /**
  45269. * Arc Rotate version of the follow camera.
  45270. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45272. */
  45273. export class ArcFollowCamera extends TargetCamera {
  45274. /** The longitudinal angle of the camera */
  45275. alpha: number;
  45276. /** The latitudinal angle of the camera */
  45277. beta: number;
  45278. /** The radius of the camera from its target */
  45279. radius: number;
  45280. /** Define the camera target (the mesh it should follow) */
  45281. target: Nullable<AbstractMesh>;
  45282. private _cartesianCoordinates;
  45283. /**
  45284. * Instantiates a new ArcFollowCamera
  45285. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45286. * @param name Define the name of the camera
  45287. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45288. * @param beta Define the rotation angle of the camera around the elevation axis
  45289. * @param radius Define the radius of the camera from its target point
  45290. * @param target Define the target of the camera
  45291. * @param scene Define the scene the camera belongs to
  45292. */
  45293. constructor(name: string,
  45294. /** The longitudinal angle of the camera */
  45295. alpha: number,
  45296. /** The latitudinal angle of the camera */
  45297. beta: number,
  45298. /** The radius of the camera from its target */
  45299. radius: number,
  45300. /** Define the camera target (the mesh it should follow) */
  45301. target: Nullable<AbstractMesh>, scene: Scene);
  45302. private _follow;
  45303. /** @hidden */
  45304. _checkInputs(): void;
  45305. /**
  45306. * Returns the class name of the object.
  45307. * It is mostly used internally for serialization purposes.
  45308. */
  45309. getClassName(): string;
  45310. }
  45311. }
  45312. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45313. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45314. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45315. import { Nullable } from "babylonjs/types";
  45316. /**
  45317. * Manage the keyboard inputs to control the movement of a follow camera.
  45318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45319. */
  45320. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45321. /**
  45322. * Defines the camera the input is attached to.
  45323. */
  45324. camera: FollowCamera;
  45325. /**
  45326. * Defines the list of key codes associated with the up action (increase heightOffset)
  45327. */
  45328. keysHeightOffsetIncr: number[];
  45329. /**
  45330. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45331. */
  45332. keysHeightOffsetDecr: number[];
  45333. /**
  45334. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45335. */
  45336. keysHeightOffsetModifierAlt: boolean;
  45337. /**
  45338. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45339. */
  45340. keysHeightOffsetModifierCtrl: boolean;
  45341. /**
  45342. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45343. */
  45344. keysHeightOffsetModifierShift: boolean;
  45345. /**
  45346. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45347. */
  45348. keysRotationOffsetIncr: number[];
  45349. /**
  45350. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45351. */
  45352. keysRotationOffsetDecr: number[];
  45353. /**
  45354. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45355. */
  45356. keysRotationOffsetModifierAlt: boolean;
  45357. /**
  45358. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45359. */
  45360. keysRotationOffsetModifierCtrl: boolean;
  45361. /**
  45362. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45363. */
  45364. keysRotationOffsetModifierShift: boolean;
  45365. /**
  45366. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45367. */
  45368. keysRadiusIncr: number[];
  45369. /**
  45370. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45371. */
  45372. keysRadiusDecr: number[];
  45373. /**
  45374. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45375. */
  45376. keysRadiusModifierAlt: boolean;
  45377. /**
  45378. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45379. */
  45380. keysRadiusModifierCtrl: boolean;
  45381. /**
  45382. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45383. */
  45384. keysRadiusModifierShift: boolean;
  45385. /**
  45386. * Defines the rate of change of heightOffset.
  45387. */
  45388. heightSensibility: number;
  45389. /**
  45390. * Defines the rate of change of rotationOffset.
  45391. */
  45392. rotationSensibility: number;
  45393. /**
  45394. * Defines the rate of change of radius.
  45395. */
  45396. radiusSensibility: number;
  45397. private _keys;
  45398. private _ctrlPressed;
  45399. private _altPressed;
  45400. private _shiftPressed;
  45401. private _onCanvasBlurObserver;
  45402. private _onKeyboardObserver;
  45403. private _engine;
  45404. private _scene;
  45405. /**
  45406. * Attach the input controls to a specific dom element to get the input from.
  45407. * @param element Defines the element the controls should be listened from
  45408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45409. */
  45410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45411. /**
  45412. * Detach the current controls from the specified dom element.
  45413. * @param element Defines the element to stop listening the inputs from
  45414. */
  45415. detachControl(element: Nullable<HTMLElement>): void;
  45416. /**
  45417. * Update the current camera state depending on the inputs that have been used this frame.
  45418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45419. */
  45420. checkInputs(): void;
  45421. /**
  45422. * Gets the class name of the current input.
  45423. * @returns the class name
  45424. */
  45425. getClassName(): string;
  45426. /**
  45427. * Get the friendly name associated with the input class.
  45428. * @returns the input friendly name
  45429. */
  45430. getSimpleName(): string;
  45431. /**
  45432. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45433. * allow modification of the heightOffset value.
  45434. */
  45435. private _modifierHeightOffset;
  45436. /**
  45437. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45438. * allow modification of the rotationOffset value.
  45439. */
  45440. private _modifierRotationOffset;
  45441. /**
  45442. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45443. * allow modification of the radius value.
  45444. */
  45445. private _modifierRadius;
  45446. }
  45447. }
  45448. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45449. import { Nullable } from "babylonjs/types";
  45450. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45451. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45452. import { Observable } from "babylonjs/Misc/observable";
  45453. module "babylonjs/Cameras/freeCameraInputsManager" {
  45454. interface FreeCameraInputsManager {
  45455. /**
  45456. * @hidden
  45457. */
  45458. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45459. /**
  45460. * Add orientation input support to the input manager.
  45461. * @returns the current input manager
  45462. */
  45463. addDeviceOrientation(): FreeCameraInputsManager;
  45464. }
  45465. }
  45466. /**
  45467. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45468. * Screen rotation is taken into account.
  45469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45470. */
  45471. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45472. private _camera;
  45473. private _screenOrientationAngle;
  45474. private _constantTranform;
  45475. private _screenQuaternion;
  45476. private _alpha;
  45477. private _beta;
  45478. private _gamma;
  45479. /**
  45480. * Can be used to detect if a device orientation sensor is available on a device
  45481. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45482. * @returns a promise that will resolve on orientation change
  45483. */
  45484. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45485. /**
  45486. * @hidden
  45487. */
  45488. _onDeviceOrientationChangedObservable: Observable<void>;
  45489. /**
  45490. * Instantiates a new input
  45491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45492. */
  45493. constructor();
  45494. /**
  45495. * Define the camera controlled by the input.
  45496. */
  45497. get camera(): FreeCamera;
  45498. set camera(camera: FreeCamera);
  45499. /**
  45500. * Attach the input controls to a specific dom element to get the input from.
  45501. * @param element Defines the element the controls should be listened from
  45502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45503. */
  45504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45505. private _orientationChanged;
  45506. private _deviceOrientation;
  45507. /**
  45508. * Detach the current controls from the specified dom element.
  45509. * @param element Defines the element to stop listening the inputs from
  45510. */
  45511. detachControl(element: Nullable<HTMLElement>): void;
  45512. /**
  45513. * Update the current camera state depending on the inputs that have been used this frame.
  45514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45515. */
  45516. checkInputs(): void;
  45517. /**
  45518. * Gets the class name of the current intput.
  45519. * @returns the class name
  45520. */
  45521. getClassName(): string;
  45522. /**
  45523. * Get the friendly name associated with the input class.
  45524. * @returns the input friendly name
  45525. */
  45526. getSimpleName(): string;
  45527. }
  45528. }
  45529. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45530. import { Nullable } from "babylonjs/types";
  45531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45533. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45534. /**
  45535. * Manage the gamepad inputs to control a free camera.
  45536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45537. */
  45538. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45539. /**
  45540. * Define the camera the input is attached to.
  45541. */
  45542. camera: FreeCamera;
  45543. /**
  45544. * Define the Gamepad controlling the input
  45545. */
  45546. gamepad: Nullable<Gamepad>;
  45547. /**
  45548. * Defines the gamepad rotation sensiblity.
  45549. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45550. */
  45551. gamepadAngularSensibility: number;
  45552. /**
  45553. * Defines the gamepad move sensiblity.
  45554. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45555. */
  45556. gamepadMoveSensibility: number;
  45557. private _yAxisScale;
  45558. /**
  45559. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45560. */
  45561. get invertYAxis(): boolean;
  45562. set invertYAxis(value: boolean);
  45563. private _onGamepadConnectedObserver;
  45564. private _onGamepadDisconnectedObserver;
  45565. private _cameraTransform;
  45566. private _deltaTransform;
  45567. private _vector3;
  45568. private _vector2;
  45569. /**
  45570. * Attach the input controls to a specific dom element to get the input from.
  45571. * @param element Defines the element the controls should be listened from
  45572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45573. */
  45574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45575. /**
  45576. * Detach the current controls from the specified dom element.
  45577. * @param element Defines the element to stop listening the inputs from
  45578. */
  45579. detachControl(element: Nullable<HTMLElement>): void;
  45580. /**
  45581. * Update the current camera state depending on the inputs that have been used this frame.
  45582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45583. */
  45584. checkInputs(): void;
  45585. /**
  45586. * Gets the class name of the current intput.
  45587. * @returns the class name
  45588. */
  45589. getClassName(): string;
  45590. /**
  45591. * Get the friendly name associated with the input class.
  45592. * @returns the input friendly name
  45593. */
  45594. getSimpleName(): string;
  45595. }
  45596. }
  45597. declare module "babylonjs/Misc/virtualJoystick" {
  45598. import { Nullable } from "babylonjs/types";
  45599. import { Vector3 } from "babylonjs/Maths/math.vector";
  45600. /**
  45601. * Defines the potential axis of a Joystick
  45602. */
  45603. export enum JoystickAxis {
  45604. /** X axis */
  45605. X = 0,
  45606. /** Y axis */
  45607. Y = 1,
  45608. /** Z axis */
  45609. Z = 2
  45610. }
  45611. /**
  45612. * Class used to define virtual joystick (used in touch mode)
  45613. */
  45614. export class VirtualJoystick {
  45615. /**
  45616. * Gets or sets a boolean indicating that left and right values must be inverted
  45617. */
  45618. reverseLeftRight: boolean;
  45619. /**
  45620. * Gets or sets a boolean indicating that up and down values must be inverted
  45621. */
  45622. reverseUpDown: boolean;
  45623. /**
  45624. * Gets the offset value for the position (ie. the change of the position value)
  45625. */
  45626. deltaPosition: Vector3;
  45627. /**
  45628. * Gets a boolean indicating if the virtual joystick was pressed
  45629. */
  45630. pressed: boolean;
  45631. /**
  45632. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45633. */
  45634. static Canvas: Nullable<HTMLCanvasElement>;
  45635. private static _globalJoystickIndex;
  45636. private static vjCanvasContext;
  45637. private static vjCanvasWidth;
  45638. private static vjCanvasHeight;
  45639. private static halfWidth;
  45640. private _action;
  45641. private _axisTargetedByLeftAndRight;
  45642. private _axisTargetedByUpAndDown;
  45643. private _joystickSensibility;
  45644. private _inversedSensibility;
  45645. private _joystickPointerID;
  45646. private _joystickColor;
  45647. private _joystickPointerPos;
  45648. private _joystickPreviousPointerPos;
  45649. private _joystickPointerStartPos;
  45650. private _deltaJoystickVector;
  45651. private _leftJoystick;
  45652. private _touches;
  45653. private _onPointerDownHandlerRef;
  45654. private _onPointerMoveHandlerRef;
  45655. private _onPointerUpHandlerRef;
  45656. private _onResize;
  45657. /**
  45658. * Creates a new virtual joystick
  45659. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45660. */
  45661. constructor(leftJoystick?: boolean);
  45662. /**
  45663. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45664. * @param newJoystickSensibility defines the new sensibility
  45665. */
  45666. setJoystickSensibility(newJoystickSensibility: number): void;
  45667. private _onPointerDown;
  45668. private _onPointerMove;
  45669. private _onPointerUp;
  45670. /**
  45671. * Change the color of the virtual joystick
  45672. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45673. */
  45674. setJoystickColor(newColor: string): void;
  45675. /**
  45676. * Defines a callback to call when the joystick is touched
  45677. * @param action defines the callback
  45678. */
  45679. setActionOnTouch(action: () => any): void;
  45680. /**
  45681. * Defines which axis you'd like to control for left & right
  45682. * @param axis defines the axis to use
  45683. */
  45684. setAxisForLeftRight(axis: JoystickAxis): void;
  45685. /**
  45686. * Defines which axis you'd like to control for up & down
  45687. * @param axis defines the axis to use
  45688. */
  45689. setAxisForUpDown(axis: JoystickAxis): void;
  45690. private _drawVirtualJoystick;
  45691. /**
  45692. * Release internal HTML canvas
  45693. */
  45694. releaseCanvas(): void;
  45695. }
  45696. }
  45697. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45698. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45699. import { Nullable } from "babylonjs/types";
  45700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45702. module "babylonjs/Cameras/freeCameraInputsManager" {
  45703. interface FreeCameraInputsManager {
  45704. /**
  45705. * Add virtual joystick input support to the input manager.
  45706. * @returns the current input manager
  45707. */
  45708. addVirtualJoystick(): FreeCameraInputsManager;
  45709. }
  45710. }
  45711. /**
  45712. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45714. */
  45715. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45716. /**
  45717. * Defines the camera the input is attached to.
  45718. */
  45719. camera: FreeCamera;
  45720. private _leftjoystick;
  45721. private _rightjoystick;
  45722. /**
  45723. * Gets the left stick of the virtual joystick.
  45724. * @returns The virtual Joystick
  45725. */
  45726. getLeftJoystick(): VirtualJoystick;
  45727. /**
  45728. * Gets the right stick of the virtual joystick.
  45729. * @returns The virtual Joystick
  45730. */
  45731. getRightJoystick(): VirtualJoystick;
  45732. /**
  45733. * Update the current camera state depending on the inputs that have been used this frame.
  45734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45735. */
  45736. checkInputs(): void;
  45737. /**
  45738. * Attach the input controls to a specific dom element to get the input from.
  45739. * @param element Defines the element the controls should be listened from
  45740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45741. */
  45742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45743. /**
  45744. * Detach the current controls from the specified dom element.
  45745. * @param element Defines the element to stop listening the inputs from
  45746. */
  45747. detachControl(element: Nullable<HTMLElement>): void;
  45748. /**
  45749. * Gets the class name of the current intput.
  45750. * @returns the class name
  45751. */
  45752. getClassName(): string;
  45753. /**
  45754. * Get the friendly name associated with the input class.
  45755. * @returns the input friendly name
  45756. */
  45757. getSimpleName(): string;
  45758. }
  45759. }
  45760. declare module "babylonjs/Cameras/Inputs/index" {
  45761. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45762. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45763. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45765. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45766. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45767. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45768. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45769. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45770. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45771. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45772. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45773. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45774. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45775. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45776. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45777. }
  45778. declare module "babylonjs/Cameras/touchCamera" {
  45779. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45780. import { Scene } from "babylonjs/scene";
  45781. import { Vector3 } from "babylonjs/Maths/math.vector";
  45782. /**
  45783. * This represents a FPS type of camera controlled by touch.
  45784. * This is like a universal camera minus the Gamepad controls.
  45785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45786. */
  45787. export class TouchCamera extends FreeCamera {
  45788. /**
  45789. * Defines the touch sensibility for rotation.
  45790. * The higher the faster.
  45791. */
  45792. get touchAngularSensibility(): number;
  45793. set touchAngularSensibility(value: number);
  45794. /**
  45795. * Defines the touch sensibility for move.
  45796. * The higher the faster.
  45797. */
  45798. get touchMoveSensibility(): number;
  45799. set touchMoveSensibility(value: number);
  45800. /**
  45801. * Instantiates a new touch camera.
  45802. * This represents a FPS type of camera controlled by touch.
  45803. * This is like a universal camera minus the Gamepad controls.
  45804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45805. * @param name Define the name of the camera in the scene
  45806. * @param position Define the start position of the camera in the scene
  45807. * @param scene Define the scene the camera belongs to
  45808. */
  45809. constructor(name: string, position: Vector3, scene: Scene);
  45810. /**
  45811. * Gets the current object class name.
  45812. * @return the class name
  45813. */
  45814. getClassName(): string;
  45815. /** @hidden */
  45816. _setupInputs(): void;
  45817. }
  45818. }
  45819. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45821. import { Scene } from "babylonjs/scene";
  45822. import { Vector3 } from "babylonjs/Maths/math.vector";
  45823. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45824. import { Axis } from "babylonjs/Maths/math.axis";
  45825. /**
  45826. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45827. * being tilted forward or back and left or right.
  45828. */
  45829. export class DeviceOrientationCamera extends FreeCamera {
  45830. private _initialQuaternion;
  45831. private _quaternionCache;
  45832. private _tmpDragQuaternion;
  45833. private _disablePointerInputWhenUsingDeviceOrientation;
  45834. /**
  45835. * Creates a new device orientation camera
  45836. * @param name The name of the camera
  45837. * @param position The start position camera
  45838. * @param scene The scene the camera belongs to
  45839. */
  45840. constructor(name: string, position: Vector3, scene: Scene);
  45841. /**
  45842. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45843. */
  45844. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45845. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45846. private _dragFactor;
  45847. /**
  45848. * Enabled turning on the y axis when the orientation sensor is active
  45849. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45850. */
  45851. enableHorizontalDragging(dragFactor?: number): void;
  45852. /**
  45853. * Gets the current instance class name ("DeviceOrientationCamera").
  45854. * This helps avoiding instanceof at run time.
  45855. * @returns the class name
  45856. */
  45857. getClassName(): string;
  45858. /**
  45859. * @hidden
  45860. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45861. */
  45862. _checkInputs(): void;
  45863. /**
  45864. * Reset the camera to its default orientation on the specified axis only.
  45865. * @param axis The axis to reset
  45866. */
  45867. resetToCurrentRotation(axis?: Axis): void;
  45868. }
  45869. }
  45870. declare module "babylonjs/Gamepads/xboxGamepad" {
  45871. import { Observable } from "babylonjs/Misc/observable";
  45872. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45873. /**
  45874. * Defines supported buttons for XBox360 compatible gamepads
  45875. */
  45876. export enum Xbox360Button {
  45877. /** A */
  45878. A = 0,
  45879. /** B */
  45880. B = 1,
  45881. /** X */
  45882. X = 2,
  45883. /** Y */
  45884. Y = 3,
  45885. /** Left button */
  45886. LB = 4,
  45887. /** Right button */
  45888. RB = 5,
  45889. /** Back */
  45890. Back = 8,
  45891. /** Start */
  45892. Start = 9,
  45893. /** Left stick */
  45894. LeftStick = 10,
  45895. /** Right stick */
  45896. RightStick = 11
  45897. }
  45898. /** Defines values for XBox360 DPad */
  45899. export enum Xbox360Dpad {
  45900. /** Up */
  45901. Up = 12,
  45902. /** Down */
  45903. Down = 13,
  45904. /** Left */
  45905. Left = 14,
  45906. /** Right */
  45907. Right = 15
  45908. }
  45909. /**
  45910. * Defines a XBox360 gamepad
  45911. */
  45912. export class Xbox360Pad extends Gamepad {
  45913. private _leftTrigger;
  45914. private _rightTrigger;
  45915. private _onlefttriggerchanged;
  45916. private _onrighttriggerchanged;
  45917. private _onbuttondown;
  45918. private _onbuttonup;
  45919. private _ondpaddown;
  45920. private _ondpadup;
  45921. /** Observable raised when a button is pressed */
  45922. onButtonDownObservable: Observable<Xbox360Button>;
  45923. /** Observable raised when a button is released */
  45924. onButtonUpObservable: Observable<Xbox360Button>;
  45925. /** Observable raised when a pad is pressed */
  45926. onPadDownObservable: Observable<Xbox360Dpad>;
  45927. /** Observable raised when a pad is released */
  45928. onPadUpObservable: Observable<Xbox360Dpad>;
  45929. private _buttonA;
  45930. private _buttonB;
  45931. private _buttonX;
  45932. private _buttonY;
  45933. private _buttonBack;
  45934. private _buttonStart;
  45935. private _buttonLB;
  45936. private _buttonRB;
  45937. private _buttonLeftStick;
  45938. private _buttonRightStick;
  45939. private _dPadUp;
  45940. private _dPadDown;
  45941. private _dPadLeft;
  45942. private _dPadRight;
  45943. private _isXboxOnePad;
  45944. /**
  45945. * Creates a new XBox360 gamepad object
  45946. * @param id defines the id of this gamepad
  45947. * @param index defines its index
  45948. * @param gamepad defines the internal HTML gamepad object
  45949. * @param xboxOne defines if it is a XBox One gamepad
  45950. */
  45951. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45952. /**
  45953. * Defines the callback to call when left trigger is pressed
  45954. * @param callback defines the callback to use
  45955. */
  45956. onlefttriggerchanged(callback: (value: number) => void): void;
  45957. /**
  45958. * Defines the callback to call when right trigger is pressed
  45959. * @param callback defines the callback to use
  45960. */
  45961. onrighttriggerchanged(callback: (value: number) => void): void;
  45962. /**
  45963. * Gets the left trigger value
  45964. */
  45965. get leftTrigger(): number;
  45966. /**
  45967. * Sets the left trigger value
  45968. */
  45969. set leftTrigger(newValue: number);
  45970. /**
  45971. * Gets the right trigger value
  45972. */
  45973. get rightTrigger(): number;
  45974. /**
  45975. * Sets the right trigger value
  45976. */
  45977. set rightTrigger(newValue: number);
  45978. /**
  45979. * Defines the callback to call when a button is pressed
  45980. * @param callback defines the callback to use
  45981. */
  45982. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45983. /**
  45984. * Defines the callback to call when a button is released
  45985. * @param callback defines the callback to use
  45986. */
  45987. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45988. /**
  45989. * Defines the callback to call when a pad is pressed
  45990. * @param callback defines the callback to use
  45991. */
  45992. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45993. /**
  45994. * Defines the callback to call when a pad is released
  45995. * @param callback defines the callback to use
  45996. */
  45997. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45998. private _setButtonValue;
  45999. private _setDPadValue;
  46000. /**
  46001. * Gets the value of the `A` button
  46002. */
  46003. get buttonA(): number;
  46004. /**
  46005. * Sets the value of the `A` button
  46006. */
  46007. set buttonA(value: number);
  46008. /**
  46009. * Gets the value of the `B` button
  46010. */
  46011. get buttonB(): number;
  46012. /**
  46013. * Sets the value of the `B` button
  46014. */
  46015. set buttonB(value: number);
  46016. /**
  46017. * Gets the value of the `X` button
  46018. */
  46019. get buttonX(): number;
  46020. /**
  46021. * Sets the value of the `X` button
  46022. */
  46023. set buttonX(value: number);
  46024. /**
  46025. * Gets the value of the `Y` button
  46026. */
  46027. get buttonY(): number;
  46028. /**
  46029. * Sets the value of the `Y` button
  46030. */
  46031. set buttonY(value: number);
  46032. /**
  46033. * Gets the value of the `Start` button
  46034. */
  46035. get buttonStart(): number;
  46036. /**
  46037. * Sets the value of the `Start` button
  46038. */
  46039. set buttonStart(value: number);
  46040. /**
  46041. * Gets the value of the `Back` button
  46042. */
  46043. get buttonBack(): number;
  46044. /**
  46045. * Sets the value of the `Back` button
  46046. */
  46047. set buttonBack(value: number);
  46048. /**
  46049. * Gets the value of the `Left` button
  46050. */
  46051. get buttonLB(): number;
  46052. /**
  46053. * Sets the value of the `Left` button
  46054. */
  46055. set buttonLB(value: number);
  46056. /**
  46057. * Gets the value of the `Right` button
  46058. */
  46059. get buttonRB(): number;
  46060. /**
  46061. * Sets the value of the `Right` button
  46062. */
  46063. set buttonRB(value: number);
  46064. /**
  46065. * Gets the value of the Left joystick
  46066. */
  46067. get buttonLeftStick(): number;
  46068. /**
  46069. * Sets the value of the Left joystick
  46070. */
  46071. set buttonLeftStick(value: number);
  46072. /**
  46073. * Gets the value of the Right joystick
  46074. */
  46075. get buttonRightStick(): number;
  46076. /**
  46077. * Sets the value of the Right joystick
  46078. */
  46079. set buttonRightStick(value: number);
  46080. /**
  46081. * Gets the value of D-pad up
  46082. */
  46083. get dPadUp(): number;
  46084. /**
  46085. * Sets the value of D-pad up
  46086. */
  46087. set dPadUp(value: number);
  46088. /**
  46089. * Gets the value of D-pad down
  46090. */
  46091. get dPadDown(): number;
  46092. /**
  46093. * Sets the value of D-pad down
  46094. */
  46095. set dPadDown(value: number);
  46096. /**
  46097. * Gets the value of D-pad left
  46098. */
  46099. get dPadLeft(): number;
  46100. /**
  46101. * Sets the value of D-pad left
  46102. */
  46103. set dPadLeft(value: number);
  46104. /**
  46105. * Gets the value of D-pad right
  46106. */
  46107. get dPadRight(): number;
  46108. /**
  46109. * Sets the value of D-pad right
  46110. */
  46111. set dPadRight(value: number);
  46112. /**
  46113. * Force the gamepad to synchronize with device values
  46114. */
  46115. update(): void;
  46116. /**
  46117. * Disposes the gamepad
  46118. */
  46119. dispose(): void;
  46120. }
  46121. }
  46122. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46123. import { Observable } from "babylonjs/Misc/observable";
  46124. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46125. /**
  46126. * Defines supported buttons for DualShock compatible gamepads
  46127. */
  46128. export enum DualShockButton {
  46129. /** Cross */
  46130. Cross = 0,
  46131. /** Circle */
  46132. Circle = 1,
  46133. /** Square */
  46134. Square = 2,
  46135. /** Triangle */
  46136. Triangle = 3,
  46137. /** L1 */
  46138. L1 = 4,
  46139. /** R1 */
  46140. R1 = 5,
  46141. /** Share */
  46142. Share = 8,
  46143. /** Options */
  46144. Options = 9,
  46145. /** Left stick */
  46146. LeftStick = 10,
  46147. /** Right stick */
  46148. RightStick = 11
  46149. }
  46150. /** Defines values for DualShock DPad */
  46151. export enum DualShockDpad {
  46152. /** Up */
  46153. Up = 12,
  46154. /** Down */
  46155. Down = 13,
  46156. /** Left */
  46157. Left = 14,
  46158. /** Right */
  46159. Right = 15
  46160. }
  46161. /**
  46162. * Defines a DualShock gamepad
  46163. */
  46164. export class DualShockPad extends Gamepad {
  46165. private _leftTrigger;
  46166. private _rightTrigger;
  46167. private _onlefttriggerchanged;
  46168. private _onrighttriggerchanged;
  46169. private _onbuttondown;
  46170. private _onbuttonup;
  46171. private _ondpaddown;
  46172. private _ondpadup;
  46173. /** Observable raised when a button is pressed */
  46174. onButtonDownObservable: Observable<DualShockButton>;
  46175. /** Observable raised when a button is released */
  46176. onButtonUpObservable: Observable<DualShockButton>;
  46177. /** Observable raised when a pad is pressed */
  46178. onPadDownObservable: Observable<DualShockDpad>;
  46179. /** Observable raised when a pad is released */
  46180. onPadUpObservable: Observable<DualShockDpad>;
  46181. private _buttonCross;
  46182. private _buttonCircle;
  46183. private _buttonSquare;
  46184. private _buttonTriangle;
  46185. private _buttonShare;
  46186. private _buttonOptions;
  46187. private _buttonL1;
  46188. private _buttonR1;
  46189. private _buttonLeftStick;
  46190. private _buttonRightStick;
  46191. private _dPadUp;
  46192. private _dPadDown;
  46193. private _dPadLeft;
  46194. private _dPadRight;
  46195. /**
  46196. * Creates a new DualShock gamepad object
  46197. * @param id defines the id of this gamepad
  46198. * @param index defines its index
  46199. * @param gamepad defines the internal HTML gamepad object
  46200. */
  46201. constructor(id: string, index: number, gamepad: any);
  46202. /**
  46203. * Defines the callback to call when left trigger is pressed
  46204. * @param callback defines the callback to use
  46205. */
  46206. onlefttriggerchanged(callback: (value: number) => void): void;
  46207. /**
  46208. * Defines the callback to call when right trigger is pressed
  46209. * @param callback defines the callback to use
  46210. */
  46211. onrighttriggerchanged(callback: (value: number) => void): void;
  46212. /**
  46213. * Gets the left trigger value
  46214. */
  46215. get leftTrigger(): number;
  46216. /**
  46217. * Sets the left trigger value
  46218. */
  46219. set leftTrigger(newValue: number);
  46220. /**
  46221. * Gets the right trigger value
  46222. */
  46223. get rightTrigger(): number;
  46224. /**
  46225. * Sets the right trigger value
  46226. */
  46227. set rightTrigger(newValue: number);
  46228. /**
  46229. * Defines the callback to call when a button is pressed
  46230. * @param callback defines the callback to use
  46231. */
  46232. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46233. /**
  46234. * Defines the callback to call when a button is released
  46235. * @param callback defines the callback to use
  46236. */
  46237. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46238. /**
  46239. * Defines the callback to call when a pad is pressed
  46240. * @param callback defines the callback to use
  46241. */
  46242. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46243. /**
  46244. * Defines the callback to call when a pad is released
  46245. * @param callback defines the callback to use
  46246. */
  46247. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46248. private _setButtonValue;
  46249. private _setDPadValue;
  46250. /**
  46251. * Gets the value of the `Cross` button
  46252. */
  46253. get buttonCross(): number;
  46254. /**
  46255. * Sets the value of the `Cross` button
  46256. */
  46257. set buttonCross(value: number);
  46258. /**
  46259. * Gets the value of the `Circle` button
  46260. */
  46261. get buttonCircle(): number;
  46262. /**
  46263. * Sets the value of the `Circle` button
  46264. */
  46265. set buttonCircle(value: number);
  46266. /**
  46267. * Gets the value of the `Square` button
  46268. */
  46269. get buttonSquare(): number;
  46270. /**
  46271. * Sets the value of the `Square` button
  46272. */
  46273. set buttonSquare(value: number);
  46274. /**
  46275. * Gets the value of the `Triangle` button
  46276. */
  46277. get buttonTriangle(): number;
  46278. /**
  46279. * Sets the value of the `Triangle` button
  46280. */
  46281. set buttonTriangle(value: number);
  46282. /**
  46283. * Gets the value of the `Options` button
  46284. */
  46285. get buttonOptions(): number;
  46286. /**
  46287. * Sets the value of the `Options` button
  46288. */
  46289. set buttonOptions(value: number);
  46290. /**
  46291. * Gets the value of the `Share` button
  46292. */
  46293. get buttonShare(): number;
  46294. /**
  46295. * Sets the value of the `Share` button
  46296. */
  46297. set buttonShare(value: number);
  46298. /**
  46299. * Gets the value of the `L1` button
  46300. */
  46301. get buttonL1(): number;
  46302. /**
  46303. * Sets the value of the `L1` button
  46304. */
  46305. set buttonL1(value: number);
  46306. /**
  46307. * Gets the value of the `R1` button
  46308. */
  46309. get buttonR1(): number;
  46310. /**
  46311. * Sets the value of the `R1` button
  46312. */
  46313. set buttonR1(value: number);
  46314. /**
  46315. * Gets the value of the Left joystick
  46316. */
  46317. get buttonLeftStick(): number;
  46318. /**
  46319. * Sets the value of the Left joystick
  46320. */
  46321. set buttonLeftStick(value: number);
  46322. /**
  46323. * Gets the value of the Right joystick
  46324. */
  46325. get buttonRightStick(): number;
  46326. /**
  46327. * Sets the value of the Right joystick
  46328. */
  46329. set buttonRightStick(value: number);
  46330. /**
  46331. * Gets the value of D-pad up
  46332. */
  46333. get dPadUp(): number;
  46334. /**
  46335. * Sets the value of D-pad up
  46336. */
  46337. set dPadUp(value: number);
  46338. /**
  46339. * Gets the value of D-pad down
  46340. */
  46341. get dPadDown(): number;
  46342. /**
  46343. * Sets the value of D-pad down
  46344. */
  46345. set dPadDown(value: number);
  46346. /**
  46347. * Gets the value of D-pad left
  46348. */
  46349. get dPadLeft(): number;
  46350. /**
  46351. * Sets the value of D-pad left
  46352. */
  46353. set dPadLeft(value: number);
  46354. /**
  46355. * Gets the value of D-pad right
  46356. */
  46357. get dPadRight(): number;
  46358. /**
  46359. * Sets the value of D-pad right
  46360. */
  46361. set dPadRight(value: number);
  46362. /**
  46363. * Force the gamepad to synchronize with device values
  46364. */
  46365. update(): void;
  46366. /**
  46367. * Disposes the gamepad
  46368. */
  46369. dispose(): void;
  46370. }
  46371. }
  46372. declare module "babylonjs/Gamepads/gamepadManager" {
  46373. import { Observable } from "babylonjs/Misc/observable";
  46374. import { Nullable } from "babylonjs/types";
  46375. import { Scene } from "babylonjs/scene";
  46376. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46377. /**
  46378. * Manager for handling gamepads
  46379. */
  46380. export class GamepadManager {
  46381. private _scene?;
  46382. private _babylonGamepads;
  46383. private _oneGamepadConnected;
  46384. /** @hidden */
  46385. _isMonitoring: boolean;
  46386. private _gamepadEventSupported;
  46387. private _gamepadSupport?;
  46388. /**
  46389. * observable to be triggered when the gamepad controller has been connected
  46390. */
  46391. onGamepadConnectedObservable: Observable<Gamepad>;
  46392. /**
  46393. * observable to be triggered when the gamepad controller has been disconnected
  46394. */
  46395. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46396. private _onGamepadConnectedEvent;
  46397. private _onGamepadDisconnectedEvent;
  46398. /**
  46399. * Initializes the gamepad manager
  46400. * @param _scene BabylonJS scene
  46401. */
  46402. constructor(_scene?: Scene | undefined);
  46403. /**
  46404. * The gamepads in the game pad manager
  46405. */
  46406. get gamepads(): Gamepad[];
  46407. /**
  46408. * Get the gamepad controllers based on type
  46409. * @param type The type of gamepad controller
  46410. * @returns Nullable gamepad
  46411. */
  46412. getGamepadByType(type?: number): Nullable<Gamepad>;
  46413. /**
  46414. * Disposes the gamepad manager
  46415. */
  46416. dispose(): void;
  46417. private _addNewGamepad;
  46418. private _startMonitoringGamepads;
  46419. private _stopMonitoringGamepads;
  46420. /** @hidden */
  46421. _checkGamepadsStatus(): void;
  46422. private _updateGamepadObjects;
  46423. }
  46424. }
  46425. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46426. import { Nullable } from "babylonjs/types";
  46427. import { Scene } from "babylonjs/scene";
  46428. import { ISceneComponent } from "babylonjs/sceneComponent";
  46429. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46430. module "babylonjs/scene" {
  46431. interface Scene {
  46432. /** @hidden */
  46433. _gamepadManager: Nullable<GamepadManager>;
  46434. /**
  46435. * Gets the gamepad manager associated with the scene
  46436. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46437. */
  46438. gamepadManager: GamepadManager;
  46439. }
  46440. }
  46441. module "babylonjs/Cameras/freeCameraInputsManager" {
  46442. /**
  46443. * Interface representing a free camera inputs manager
  46444. */
  46445. interface FreeCameraInputsManager {
  46446. /**
  46447. * Adds gamepad input support to the FreeCameraInputsManager.
  46448. * @returns the FreeCameraInputsManager
  46449. */
  46450. addGamepad(): FreeCameraInputsManager;
  46451. }
  46452. }
  46453. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46454. /**
  46455. * Interface representing an arc rotate camera inputs manager
  46456. */
  46457. interface ArcRotateCameraInputsManager {
  46458. /**
  46459. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46460. * @returns the camera inputs manager
  46461. */
  46462. addGamepad(): ArcRotateCameraInputsManager;
  46463. }
  46464. }
  46465. /**
  46466. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46467. */
  46468. export class GamepadSystemSceneComponent implements ISceneComponent {
  46469. /**
  46470. * The component name helpfull to identify the component in the list of scene components.
  46471. */
  46472. readonly name: string;
  46473. /**
  46474. * The scene the component belongs to.
  46475. */
  46476. scene: Scene;
  46477. /**
  46478. * Creates a new instance of the component for the given scene
  46479. * @param scene Defines the scene to register the component in
  46480. */
  46481. constructor(scene: Scene);
  46482. /**
  46483. * Registers the component in a given scene
  46484. */
  46485. register(): void;
  46486. /**
  46487. * Rebuilds the elements related to this component in case of
  46488. * context lost for instance.
  46489. */
  46490. rebuild(): void;
  46491. /**
  46492. * Disposes the component and the associated ressources
  46493. */
  46494. dispose(): void;
  46495. private _beforeCameraUpdate;
  46496. }
  46497. }
  46498. declare module "babylonjs/Cameras/universalCamera" {
  46499. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46500. import { Scene } from "babylonjs/scene";
  46501. import { Vector3 } from "babylonjs/Maths/math.vector";
  46502. import "babylonjs/Gamepads/gamepadSceneComponent";
  46503. /**
  46504. * 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,
  46505. * which still works and will still be found in many Playgrounds.
  46506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46507. */
  46508. export class UniversalCamera extends TouchCamera {
  46509. /**
  46510. * Defines the gamepad rotation sensiblity.
  46511. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46512. */
  46513. get gamepadAngularSensibility(): number;
  46514. set gamepadAngularSensibility(value: number);
  46515. /**
  46516. * Defines the gamepad move sensiblity.
  46517. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46518. */
  46519. get gamepadMoveSensibility(): number;
  46520. set gamepadMoveSensibility(value: number);
  46521. /**
  46522. * 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,
  46523. * which still works and will still be found in many Playgrounds.
  46524. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46525. * @param name Define the name of the camera in the scene
  46526. * @param position Define the start position of the camera in the scene
  46527. * @param scene Define the scene the camera belongs to
  46528. */
  46529. constructor(name: string, position: Vector3, scene: Scene);
  46530. /**
  46531. * Gets the current object class name.
  46532. * @return the class name
  46533. */
  46534. getClassName(): string;
  46535. }
  46536. }
  46537. declare module "babylonjs/Cameras/gamepadCamera" {
  46538. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46539. import { Scene } from "babylonjs/scene";
  46540. import { Vector3 } from "babylonjs/Maths/math.vector";
  46541. /**
  46542. * This represents a FPS type of camera. This is only here for back compat purpose.
  46543. * Please use the UniversalCamera instead as both are identical.
  46544. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46545. */
  46546. export class GamepadCamera extends UniversalCamera {
  46547. /**
  46548. * Instantiates a new Gamepad Camera
  46549. * This represents a FPS type of camera. This is only here for back compat purpose.
  46550. * Please use the UniversalCamera instead as both are identical.
  46551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46552. * @param name Define the name of the camera in the scene
  46553. * @param position Define the start position of the camera in the scene
  46554. * @param scene Define the scene the camera belongs to
  46555. */
  46556. constructor(name: string, position: Vector3, scene: Scene);
  46557. /**
  46558. * Gets the current object class name.
  46559. * @return the class name
  46560. */
  46561. getClassName(): string;
  46562. }
  46563. }
  46564. declare module "babylonjs/Shaders/pass.fragment" {
  46565. /** @hidden */
  46566. export var passPixelShader: {
  46567. name: string;
  46568. shader: string;
  46569. };
  46570. }
  46571. declare module "babylonjs/Shaders/passCube.fragment" {
  46572. /** @hidden */
  46573. export var passCubePixelShader: {
  46574. name: string;
  46575. shader: string;
  46576. };
  46577. }
  46578. declare module "babylonjs/PostProcesses/passPostProcess" {
  46579. import { Nullable } from "babylonjs/types";
  46580. import { Camera } from "babylonjs/Cameras/camera";
  46581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46582. import { Engine } from "babylonjs/Engines/engine";
  46583. import "babylonjs/Shaders/pass.fragment";
  46584. import "babylonjs/Shaders/passCube.fragment";
  46585. /**
  46586. * PassPostProcess which produces an output the same as it's input
  46587. */
  46588. export class PassPostProcess extends PostProcess {
  46589. /**
  46590. * Creates the PassPostProcess
  46591. * @param name The name of the effect.
  46592. * @param options The required width/height ratio to downsize to before computing the render pass.
  46593. * @param camera The camera to apply the render pass to.
  46594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46595. * @param engine The engine which the post process will be applied. (default: current engine)
  46596. * @param reusable If the post process can be reused on the same frame. (default: false)
  46597. * @param textureType The type of texture to be used when performing the post processing.
  46598. * @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)
  46599. */
  46600. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46601. }
  46602. /**
  46603. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46604. */
  46605. export class PassCubePostProcess extends PostProcess {
  46606. private _face;
  46607. /**
  46608. * Gets or sets the cube face to display.
  46609. * * 0 is +X
  46610. * * 1 is -X
  46611. * * 2 is +Y
  46612. * * 3 is -Y
  46613. * * 4 is +Z
  46614. * * 5 is -Z
  46615. */
  46616. get face(): number;
  46617. set face(value: number);
  46618. /**
  46619. * Creates the PassCubePostProcess
  46620. * @param name The name of the effect.
  46621. * @param options The required width/height ratio to downsize to before computing the render pass.
  46622. * @param camera The camera to apply the render pass to.
  46623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46624. * @param engine The engine which the post process will be applied. (default: current engine)
  46625. * @param reusable If the post process can be reused on the same frame. (default: false)
  46626. * @param textureType The type of texture to be used when performing the post processing.
  46627. * @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)
  46628. */
  46629. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46630. }
  46631. }
  46632. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46633. /** @hidden */
  46634. export var anaglyphPixelShader: {
  46635. name: string;
  46636. shader: string;
  46637. };
  46638. }
  46639. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46640. import { Engine } from "babylonjs/Engines/engine";
  46641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46642. import { Camera } from "babylonjs/Cameras/camera";
  46643. import "babylonjs/Shaders/anaglyph.fragment";
  46644. /**
  46645. * Postprocess used to generate anaglyphic rendering
  46646. */
  46647. export class AnaglyphPostProcess extends PostProcess {
  46648. private _passedProcess;
  46649. /**
  46650. * Creates a new AnaglyphPostProcess
  46651. * @param name defines postprocess name
  46652. * @param options defines creation options or target ratio scale
  46653. * @param rigCameras defines cameras using this postprocess
  46654. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46655. * @param engine defines hosting engine
  46656. * @param reusable defines if the postprocess will be reused multiple times per frame
  46657. */
  46658. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46659. }
  46660. }
  46661. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46662. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46663. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46664. import { Scene } from "babylonjs/scene";
  46665. import { Vector3 } from "babylonjs/Maths/math.vector";
  46666. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46667. /**
  46668. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46669. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46670. */
  46671. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46672. /**
  46673. * Creates a new AnaglyphArcRotateCamera
  46674. * @param name defines camera name
  46675. * @param alpha defines alpha angle (in radians)
  46676. * @param beta defines beta angle (in radians)
  46677. * @param radius defines radius
  46678. * @param target defines camera target
  46679. * @param interaxialDistance defines distance between each color axis
  46680. * @param scene defines the hosting scene
  46681. */
  46682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46683. /**
  46684. * Gets camera class name
  46685. * @returns AnaglyphArcRotateCamera
  46686. */
  46687. getClassName(): string;
  46688. }
  46689. }
  46690. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46691. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46692. import { Scene } from "babylonjs/scene";
  46693. import { Vector3 } from "babylonjs/Maths/math.vector";
  46694. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46695. /**
  46696. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46697. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46698. */
  46699. export class AnaglyphFreeCamera extends FreeCamera {
  46700. /**
  46701. * Creates a new AnaglyphFreeCamera
  46702. * @param name defines camera name
  46703. * @param position defines initial position
  46704. * @param interaxialDistance defines distance between each color axis
  46705. * @param scene defines the hosting scene
  46706. */
  46707. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46708. /**
  46709. * Gets camera class name
  46710. * @returns AnaglyphFreeCamera
  46711. */
  46712. getClassName(): string;
  46713. }
  46714. }
  46715. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46716. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46717. import { Scene } from "babylonjs/scene";
  46718. import { Vector3 } from "babylonjs/Maths/math.vector";
  46719. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46720. /**
  46721. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46722. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46723. */
  46724. export class AnaglyphGamepadCamera extends GamepadCamera {
  46725. /**
  46726. * Creates a new AnaglyphGamepadCamera
  46727. * @param name defines camera name
  46728. * @param position defines initial position
  46729. * @param interaxialDistance defines distance between each color axis
  46730. * @param scene defines the hosting scene
  46731. */
  46732. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46733. /**
  46734. * Gets camera class name
  46735. * @returns AnaglyphGamepadCamera
  46736. */
  46737. getClassName(): string;
  46738. }
  46739. }
  46740. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46741. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46742. import { Scene } from "babylonjs/scene";
  46743. import { Vector3 } from "babylonjs/Maths/math.vector";
  46744. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46745. /**
  46746. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46748. */
  46749. export class AnaglyphUniversalCamera extends UniversalCamera {
  46750. /**
  46751. * Creates a new AnaglyphUniversalCamera
  46752. * @param name defines camera name
  46753. * @param position defines initial position
  46754. * @param interaxialDistance defines distance between each color axis
  46755. * @param scene defines the hosting scene
  46756. */
  46757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46758. /**
  46759. * Gets camera class name
  46760. * @returns AnaglyphUniversalCamera
  46761. */
  46762. getClassName(): string;
  46763. }
  46764. }
  46765. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46766. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46767. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46768. import { Scene } from "babylonjs/scene";
  46769. import { Vector3 } from "babylonjs/Maths/math.vector";
  46770. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46771. /**
  46772. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46773. * @see http://doc.babylonjs.com/features/cameras
  46774. */
  46775. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46776. /**
  46777. * Creates a new StereoscopicArcRotateCamera
  46778. * @param name defines camera name
  46779. * @param alpha defines alpha angle (in radians)
  46780. * @param beta defines beta angle (in radians)
  46781. * @param radius defines radius
  46782. * @param target defines camera target
  46783. * @param interaxialDistance defines distance between each color axis
  46784. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46785. * @param scene defines the hosting scene
  46786. */
  46787. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46788. /**
  46789. * Gets camera class name
  46790. * @returns StereoscopicArcRotateCamera
  46791. */
  46792. getClassName(): string;
  46793. }
  46794. }
  46795. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46796. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46797. import { Scene } from "babylonjs/scene";
  46798. import { Vector3 } from "babylonjs/Maths/math.vector";
  46799. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46800. /**
  46801. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46802. * @see http://doc.babylonjs.com/features/cameras
  46803. */
  46804. export class StereoscopicFreeCamera extends FreeCamera {
  46805. /**
  46806. * Creates a new StereoscopicFreeCamera
  46807. * @param name defines camera name
  46808. * @param position defines initial position
  46809. * @param interaxialDistance defines distance between each color axis
  46810. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46811. * @param scene defines the hosting scene
  46812. */
  46813. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46814. /**
  46815. * Gets camera class name
  46816. * @returns StereoscopicFreeCamera
  46817. */
  46818. getClassName(): string;
  46819. }
  46820. }
  46821. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46822. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46823. import { Scene } from "babylonjs/scene";
  46824. import { Vector3 } from "babylonjs/Maths/math.vector";
  46825. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46826. /**
  46827. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46828. * @see http://doc.babylonjs.com/features/cameras
  46829. */
  46830. export class StereoscopicGamepadCamera extends GamepadCamera {
  46831. /**
  46832. * Creates a new StereoscopicGamepadCamera
  46833. * @param name defines camera name
  46834. * @param position defines initial position
  46835. * @param interaxialDistance defines distance between each color axis
  46836. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46837. * @param scene defines the hosting scene
  46838. */
  46839. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46840. /**
  46841. * Gets camera class name
  46842. * @returns StereoscopicGamepadCamera
  46843. */
  46844. getClassName(): string;
  46845. }
  46846. }
  46847. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46848. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46849. import { Scene } from "babylonjs/scene";
  46850. import { Vector3 } from "babylonjs/Maths/math.vector";
  46851. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46852. /**
  46853. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46854. * @see http://doc.babylonjs.com/features/cameras
  46855. */
  46856. export class StereoscopicUniversalCamera extends UniversalCamera {
  46857. /**
  46858. * Creates a new StereoscopicUniversalCamera
  46859. * @param name defines camera name
  46860. * @param position defines initial position
  46861. * @param interaxialDistance defines distance between each color axis
  46862. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46863. * @param scene defines the hosting scene
  46864. */
  46865. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46866. /**
  46867. * Gets camera class name
  46868. * @returns StereoscopicUniversalCamera
  46869. */
  46870. getClassName(): string;
  46871. }
  46872. }
  46873. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46874. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46875. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46876. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46877. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46878. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46879. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46880. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46881. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46882. }
  46883. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46885. import { Scene } from "babylonjs/scene";
  46886. import { Vector3 } from "babylonjs/Maths/math.vector";
  46887. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46888. /**
  46889. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46890. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46891. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46892. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46893. */
  46894. export class VirtualJoysticksCamera extends FreeCamera {
  46895. /**
  46896. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46897. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46898. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46899. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46900. * @param name Define the name of the camera in the scene
  46901. * @param position Define the start position of the camera in the scene
  46902. * @param scene Define the scene the camera belongs to
  46903. */
  46904. constructor(name: string, position: Vector3, scene: Scene);
  46905. /**
  46906. * Gets the current object class name.
  46907. * @return the class name
  46908. */
  46909. getClassName(): string;
  46910. }
  46911. }
  46912. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46913. import { Matrix } from "babylonjs/Maths/math.vector";
  46914. /**
  46915. * This represents all the required metrics to create a VR camera.
  46916. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46917. */
  46918. export class VRCameraMetrics {
  46919. /**
  46920. * Define the horizontal resolution off the screen.
  46921. */
  46922. hResolution: number;
  46923. /**
  46924. * Define the vertical resolution off the screen.
  46925. */
  46926. vResolution: number;
  46927. /**
  46928. * Define the horizontal screen size.
  46929. */
  46930. hScreenSize: number;
  46931. /**
  46932. * Define the vertical screen size.
  46933. */
  46934. vScreenSize: number;
  46935. /**
  46936. * Define the vertical screen center position.
  46937. */
  46938. vScreenCenter: number;
  46939. /**
  46940. * Define the distance of the eyes to the screen.
  46941. */
  46942. eyeToScreenDistance: number;
  46943. /**
  46944. * Define the distance between both lenses
  46945. */
  46946. lensSeparationDistance: number;
  46947. /**
  46948. * Define the distance between both viewer's eyes.
  46949. */
  46950. interpupillaryDistance: number;
  46951. /**
  46952. * Define the distortion factor of the VR postprocess.
  46953. * Please, touch with care.
  46954. */
  46955. distortionK: number[];
  46956. /**
  46957. * Define the chromatic aberration correction factors for the VR post process.
  46958. */
  46959. chromaAbCorrection: number[];
  46960. /**
  46961. * Define the scale factor of the post process.
  46962. * The smaller the better but the slower.
  46963. */
  46964. postProcessScaleFactor: number;
  46965. /**
  46966. * Define an offset for the lens center.
  46967. */
  46968. lensCenterOffset: number;
  46969. /**
  46970. * Define if the current vr camera should compensate the distortion of the lense or not.
  46971. */
  46972. compensateDistortion: boolean;
  46973. /**
  46974. * Defines if multiview should be enabled when rendering (Default: false)
  46975. */
  46976. multiviewEnabled: boolean;
  46977. /**
  46978. * Gets the rendering aspect ratio based on the provided resolutions.
  46979. */
  46980. get aspectRatio(): number;
  46981. /**
  46982. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46983. */
  46984. get aspectRatioFov(): number;
  46985. /**
  46986. * @hidden
  46987. */
  46988. get leftHMatrix(): Matrix;
  46989. /**
  46990. * @hidden
  46991. */
  46992. get rightHMatrix(): Matrix;
  46993. /**
  46994. * @hidden
  46995. */
  46996. get leftPreViewMatrix(): Matrix;
  46997. /**
  46998. * @hidden
  46999. */
  47000. get rightPreViewMatrix(): Matrix;
  47001. /**
  47002. * Get the default VRMetrics based on the most generic setup.
  47003. * @returns the default vr metrics
  47004. */
  47005. static GetDefault(): VRCameraMetrics;
  47006. }
  47007. }
  47008. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47009. /** @hidden */
  47010. export var vrDistortionCorrectionPixelShader: {
  47011. name: string;
  47012. shader: string;
  47013. };
  47014. }
  47015. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47016. import { Camera } from "babylonjs/Cameras/camera";
  47017. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47018. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47019. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47020. /**
  47021. * VRDistortionCorrectionPostProcess used for mobile VR
  47022. */
  47023. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47024. private _isRightEye;
  47025. private _distortionFactors;
  47026. private _postProcessScaleFactor;
  47027. private _lensCenterOffset;
  47028. private _scaleIn;
  47029. private _scaleFactor;
  47030. private _lensCenter;
  47031. /**
  47032. * Initializes the VRDistortionCorrectionPostProcess
  47033. * @param name The name of the effect.
  47034. * @param camera The camera to apply the render pass to.
  47035. * @param isRightEye If this is for the right eye distortion
  47036. * @param vrMetrics All the required metrics for the VR camera
  47037. */
  47038. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47039. }
  47040. }
  47041. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47042. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47043. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47044. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47045. import { Scene } from "babylonjs/scene";
  47046. import { Vector3 } from "babylonjs/Maths/math.vector";
  47047. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47048. import "babylonjs/Cameras/RigModes/vrRigMode";
  47049. /**
  47050. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47051. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47052. */
  47053. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47054. /**
  47055. * Creates a new VRDeviceOrientationArcRotateCamera
  47056. * @param name defines camera name
  47057. * @param alpha defines the camera rotation along the logitudinal axis
  47058. * @param beta defines the camera rotation along the latitudinal axis
  47059. * @param radius defines the camera distance from its target
  47060. * @param target defines the camera target
  47061. * @param scene defines the scene the camera belongs to
  47062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47064. */
  47065. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47066. /**
  47067. * Gets camera class name
  47068. * @returns VRDeviceOrientationArcRotateCamera
  47069. */
  47070. getClassName(): string;
  47071. }
  47072. }
  47073. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47074. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47075. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47076. import { Scene } from "babylonjs/scene";
  47077. import { Vector3 } from "babylonjs/Maths/math.vector";
  47078. import "babylonjs/Cameras/RigModes/vrRigMode";
  47079. /**
  47080. * Camera used to simulate VR rendering (based on FreeCamera)
  47081. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47082. */
  47083. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47084. /**
  47085. * Creates a new VRDeviceOrientationFreeCamera
  47086. * @param name defines camera name
  47087. * @param position defines the start position of the camera
  47088. * @param scene defines the scene the camera belongs to
  47089. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47090. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47091. */
  47092. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47093. /**
  47094. * Gets camera class name
  47095. * @returns VRDeviceOrientationFreeCamera
  47096. */
  47097. getClassName(): string;
  47098. }
  47099. }
  47100. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47101. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47103. import { Scene } from "babylonjs/scene";
  47104. import { Vector3 } from "babylonjs/Maths/math.vector";
  47105. import "babylonjs/Gamepads/gamepadSceneComponent";
  47106. /**
  47107. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47108. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47109. */
  47110. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47111. /**
  47112. * Creates a new VRDeviceOrientationGamepadCamera
  47113. * @param name defines camera name
  47114. * @param position defines the start position of the camera
  47115. * @param scene defines the scene the camera belongs to
  47116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47118. */
  47119. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47120. /**
  47121. * Gets camera class name
  47122. * @returns VRDeviceOrientationGamepadCamera
  47123. */
  47124. getClassName(): string;
  47125. }
  47126. }
  47127. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47128. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47130. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47131. /** @hidden */
  47132. export var imageProcessingPixelShader: {
  47133. name: string;
  47134. shader: string;
  47135. };
  47136. }
  47137. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47138. import { Nullable } from "babylonjs/types";
  47139. import { Color4 } from "babylonjs/Maths/math.color";
  47140. import { Camera } from "babylonjs/Cameras/camera";
  47141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47142. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47143. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47145. import { Engine } from "babylonjs/Engines/engine";
  47146. import "babylonjs/Shaders/imageProcessing.fragment";
  47147. import "babylonjs/Shaders/postprocess.vertex";
  47148. /**
  47149. * ImageProcessingPostProcess
  47150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47151. */
  47152. export class ImageProcessingPostProcess extends PostProcess {
  47153. /**
  47154. * Default configuration related to image processing available in the PBR Material.
  47155. */
  47156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47157. /**
  47158. * Gets the image processing configuration used either in this material.
  47159. */
  47160. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47161. /**
  47162. * Sets the Default image processing configuration used either in the this material.
  47163. *
  47164. * If sets to null, the scene one is in use.
  47165. */
  47166. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47167. /**
  47168. * Keep track of the image processing observer to allow dispose and replace.
  47169. */
  47170. private _imageProcessingObserver;
  47171. /**
  47172. * Attaches a new image processing configuration to the PBR Material.
  47173. * @param configuration
  47174. */
  47175. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47176. /**
  47177. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47178. */
  47179. get colorCurves(): Nullable<ColorCurves>;
  47180. /**
  47181. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47182. */
  47183. set colorCurves(value: Nullable<ColorCurves>);
  47184. /**
  47185. * Gets wether the color curves effect is enabled.
  47186. */
  47187. get colorCurvesEnabled(): boolean;
  47188. /**
  47189. * Sets wether the color curves effect is enabled.
  47190. */
  47191. set colorCurvesEnabled(value: boolean);
  47192. /**
  47193. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47194. */
  47195. get colorGradingTexture(): Nullable<BaseTexture>;
  47196. /**
  47197. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47198. */
  47199. set colorGradingTexture(value: Nullable<BaseTexture>);
  47200. /**
  47201. * Gets wether the color grading effect is enabled.
  47202. */
  47203. get colorGradingEnabled(): boolean;
  47204. /**
  47205. * Gets wether the color grading effect is enabled.
  47206. */
  47207. set colorGradingEnabled(value: boolean);
  47208. /**
  47209. * Gets exposure used in the effect.
  47210. */
  47211. get exposure(): number;
  47212. /**
  47213. * Sets exposure used in the effect.
  47214. */
  47215. set exposure(value: number);
  47216. /**
  47217. * Gets wether tonemapping is enabled or not.
  47218. */
  47219. get toneMappingEnabled(): boolean;
  47220. /**
  47221. * Sets wether tonemapping is enabled or not
  47222. */
  47223. set toneMappingEnabled(value: boolean);
  47224. /**
  47225. * Gets the type of tone mapping effect.
  47226. */
  47227. get toneMappingType(): number;
  47228. /**
  47229. * Sets the type of tone mapping effect.
  47230. */
  47231. set toneMappingType(value: number);
  47232. /**
  47233. * Gets contrast used in the effect.
  47234. */
  47235. get contrast(): number;
  47236. /**
  47237. * Sets contrast used in the effect.
  47238. */
  47239. set contrast(value: number);
  47240. /**
  47241. * Gets Vignette stretch size.
  47242. */
  47243. get vignetteStretch(): number;
  47244. /**
  47245. * Sets Vignette stretch size.
  47246. */
  47247. set vignetteStretch(value: number);
  47248. /**
  47249. * Gets Vignette centre X Offset.
  47250. */
  47251. get vignetteCentreX(): number;
  47252. /**
  47253. * Sets Vignette centre X Offset.
  47254. */
  47255. set vignetteCentreX(value: number);
  47256. /**
  47257. * Gets Vignette centre Y Offset.
  47258. */
  47259. get vignetteCentreY(): number;
  47260. /**
  47261. * Sets Vignette centre Y Offset.
  47262. */
  47263. set vignetteCentreY(value: number);
  47264. /**
  47265. * Gets Vignette weight or intensity of the vignette effect.
  47266. */
  47267. get vignetteWeight(): number;
  47268. /**
  47269. * Sets Vignette weight or intensity of the vignette effect.
  47270. */
  47271. set vignetteWeight(value: number);
  47272. /**
  47273. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47274. * if vignetteEnabled is set to true.
  47275. */
  47276. get vignetteColor(): Color4;
  47277. /**
  47278. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47279. * if vignetteEnabled is set to true.
  47280. */
  47281. set vignetteColor(value: Color4);
  47282. /**
  47283. * Gets Camera field of view used by the Vignette effect.
  47284. */
  47285. get vignetteCameraFov(): number;
  47286. /**
  47287. * Sets Camera field of view used by the Vignette effect.
  47288. */
  47289. set vignetteCameraFov(value: number);
  47290. /**
  47291. * Gets the vignette blend mode allowing different kind of effect.
  47292. */
  47293. get vignetteBlendMode(): number;
  47294. /**
  47295. * Sets the vignette blend mode allowing different kind of effect.
  47296. */
  47297. set vignetteBlendMode(value: number);
  47298. /**
  47299. * Gets wether the vignette effect is enabled.
  47300. */
  47301. get vignetteEnabled(): boolean;
  47302. /**
  47303. * Sets wether the vignette effect is enabled.
  47304. */
  47305. set vignetteEnabled(value: boolean);
  47306. private _fromLinearSpace;
  47307. /**
  47308. * Gets wether the input of the processing is in Gamma or Linear Space.
  47309. */
  47310. get fromLinearSpace(): boolean;
  47311. /**
  47312. * Sets wether the input of the processing is in Gamma or Linear Space.
  47313. */
  47314. set fromLinearSpace(value: boolean);
  47315. /**
  47316. * Defines cache preventing GC.
  47317. */
  47318. private _defines;
  47319. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47320. /**
  47321. * "ImageProcessingPostProcess"
  47322. * @returns "ImageProcessingPostProcess"
  47323. */
  47324. getClassName(): string;
  47325. protected _updateParameters(): void;
  47326. dispose(camera?: Camera): void;
  47327. }
  47328. }
  47329. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47330. import { Scene } from "babylonjs/scene";
  47331. import { Color3 } from "babylonjs/Maths/math.color";
  47332. import { Mesh } from "babylonjs/Meshes/mesh";
  47333. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47334. import { Nullable } from "babylonjs/types";
  47335. /**
  47336. * Class containing static functions to help procedurally build meshes
  47337. */
  47338. export class GroundBuilder {
  47339. /**
  47340. * Creates a ground mesh
  47341. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47342. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47344. * @param name defines the name of the mesh
  47345. * @param options defines the options used to create the mesh
  47346. * @param scene defines the hosting scene
  47347. * @returns the ground mesh
  47348. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47349. */
  47350. static CreateGround(name: string, options: {
  47351. width?: number;
  47352. height?: number;
  47353. subdivisions?: number;
  47354. subdivisionsX?: number;
  47355. subdivisionsY?: number;
  47356. updatable?: boolean;
  47357. }, scene: any): Mesh;
  47358. /**
  47359. * Creates a tiled ground mesh
  47360. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47361. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47362. * * 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
  47363. * * 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
  47364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47365. * @param name defines the name of the mesh
  47366. * @param options defines the options used to create the mesh
  47367. * @param scene defines the hosting scene
  47368. * @returns the tiled ground mesh
  47369. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47370. */
  47371. static CreateTiledGround(name: string, options: {
  47372. xmin: number;
  47373. zmin: number;
  47374. xmax: number;
  47375. zmax: number;
  47376. subdivisions?: {
  47377. w: number;
  47378. h: number;
  47379. };
  47380. precision?: {
  47381. w: number;
  47382. h: number;
  47383. };
  47384. updatable?: boolean;
  47385. }, scene?: Nullable<Scene>): Mesh;
  47386. /**
  47387. * Creates a ground mesh from a height map
  47388. * * The parameter `url` sets the URL of the height map image resource.
  47389. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47390. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47391. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47392. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47393. * * 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.
  47394. * * 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).
  47395. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47397. * @param name defines the name of the mesh
  47398. * @param url defines the url to the height map
  47399. * @param options defines the options used to create the mesh
  47400. * @param scene defines the hosting scene
  47401. * @returns the ground mesh
  47402. * @see https://doc.babylonjs.com/babylon101/height_map
  47403. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47404. */
  47405. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47406. width?: number;
  47407. height?: number;
  47408. subdivisions?: number;
  47409. minHeight?: number;
  47410. maxHeight?: number;
  47411. colorFilter?: Color3;
  47412. alphaFilter?: number;
  47413. updatable?: boolean;
  47414. onReady?: (mesh: GroundMesh) => void;
  47415. }, scene?: Nullable<Scene>): GroundMesh;
  47416. }
  47417. }
  47418. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47419. import { Vector4 } from "babylonjs/Maths/math.vector";
  47420. import { Mesh } from "babylonjs/Meshes/mesh";
  47421. /**
  47422. * Class containing static functions to help procedurally build meshes
  47423. */
  47424. export class TorusBuilder {
  47425. /**
  47426. * Creates a torus mesh
  47427. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47428. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47429. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47433. * @param name defines the name of the mesh
  47434. * @param options defines the options used to create the mesh
  47435. * @param scene defines the hosting scene
  47436. * @returns the torus mesh
  47437. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47438. */
  47439. static CreateTorus(name: string, options: {
  47440. diameter?: number;
  47441. thickness?: number;
  47442. tessellation?: number;
  47443. updatable?: boolean;
  47444. sideOrientation?: number;
  47445. frontUVs?: Vector4;
  47446. backUVs?: Vector4;
  47447. }, scene: any): Mesh;
  47448. }
  47449. }
  47450. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47451. import { Vector4 } from "babylonjs/Maths/math.vector";
  47452. import { Color4 } from "babylonjs/Maths/math.color";
  47453. import { Mesh } from "babylonjs/Meshes/mesh";
  47454. /**
  47455. * Class containing static functions to help procedurally build meshes
  47456. */
  47457. export class CylinderBuilder {
  47458. /**
  47459. * Creates a cylinder or a cone mesh
  47460. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47461. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47462. * * 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.
  47463. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47464. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47465. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47466. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47467. * * 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).
  47468. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47469. * * 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).
  47470. * * 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
  47471. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47472. * * 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
  47473. * * 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.
  47474. * * If `enclose` is false, a ring surface is one element.
  47475. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47476. * * 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
  47477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47480. * @param name defines the name of the mesh
  47481. * @param options defines the options used to create the mesh
  47482. * @param scene defines the hosting scene
  47483. * @returns the cylinder mesh
  47484. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47485. */
  47486. static CreateCylinder(name: string, options: {
  47487. height?: number;
  47488. diameterTop?: number;
  47489. diameterBottom?: number;
  47490. diameter?: number;
  47491. tessellation?: number;
  47492. subdivisions?: number;
  47493. arc?: number;
  47494. faceColors?: Color4[];
  47495. faceUV?: Vector4[];
  47496. updatable?: boolean;
  47497. hasRings?: boolean;
  47498. enclose?: boolean;
  47499. cap?: number;
  47500. sideOrientation?: number;
  47501. frontUVs?: Vector4;
  47502. backUVs?: Vector4;
  47503. }, scene: any): Mesh;
  47504. }
  47505. }
  47506. declare module "babylonjs/XR/webXRTypes" {
  47507. import { Nullable } from "babylonjs/types";
  47508. import { IDisposable } from "babylonjs/scene";
  47509. /**
  47510. * States of the webXR experience
  47511. */
  47512. export enum WebXRState {
  47513. /**
  47514. * Transitioning to being in XR mode
  47515. */
  47516. ENTERING_XR = 0,
  47517. /**
  47518. * Transitioning to non XR mode
  47519. */
  47520. EXITING_XR = 1,
  47521. /**
  47522. * In XR mode and presenting
  47523. */
  47524. IN_XR = 2,
  47525. /**
  47526. * Not entered XR mode
  47527. */
  47528. NOT_IN_XR = 3
  47529. }
  47530. /**
  47531. * Abstraction of the XR render target
  47532. */
  47533. export interface WebXRRenderTarget extends IDisposable {
  47534. /**
  47535. * xrpresent context of the canvas which can be used to display/mirror xr content
  47536. */
  47537. canvasContext: WebGLRenderingContext;
  47538. /**
  47539. * xr layer for the canvas
  47540. */
  47541. xrLayer: Nullable<XRWebGLLayer>;
  47542. /**
  47543. * Initializes the xr layer for the session
  47544. * @param xrSession xr session
  47545. * @returns a promise that will resolve once the XR Layer has been created
  47546. */
  47547. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47548. }
  47549. }
  47550. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47551. import { Nullable } from "babylonjs/types";
  47552. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47553. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47554. /**
  47555. * COnfiguration object for WebXR output canvas
  47556. */
  47557. export class WebXRManagedOutputCanvasOptions {
  47558. /**
  47559. * An optional canvas in case you wish to create it yourself and provide it here.
  47560. * If not provided, a new canvas will be created
  47561. */
  47562. canvasElement?: HTMLCanvasElement;
  47563. /**
  47564. * Options for this XR Layer output
  47565. */
  47566. canvasOptions?: XRWebGLLayerOptions;
  47567. /**
  47568. * CSS styling for a newly created canvas (if not provided)
  47569. */
  47570. newCanvasCssStyle?: string;
  47571. /**
  47572. * Get the default values of the configuration object
  47573. * @returns default values of this configuration object
  47574. */
  47575. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47576. }
  47577. /**
  47578. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47579. */
  47580. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47581. private _options;
  47582. private _canvas;
  47583. private _engine;
  47584. /**
  47585. * Rendering context of the canvas which can be used to display/mirror xr content
  47586. */
  47587. canvasContext: WebGLRenderingContext;
  47588. /**
  47589. * xr layer for the canvas
  47590. */
  47591. xrLayer: Nullable<XRWebGLLayer>;
  47592. /**
  47593. * Initializes the canvas to be added/removed upon entering/exiting xr
  47594. * @param _xrSessionManager The XR Session manager
  47595. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47596. */
  47597. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47598. /**
  47599. * Disposes of the object
  47600. */
  47601. dispose(): void;
  47602. /**
  47603. * Initializes the xr layer for the session
  47604. * @param xrSession xr session
  47605. * @returns a promise that will resolve once the XR Layer has been created
  47606. */
  47607. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47608. private _addCanvas;
  47609. private _removeCanvas;
  47610. private _setManagedOutputCanvas;
  47611. }
  47612. }
  47613. declare module "babylonjs/XR/webXRSessionManager" {
  47614. import { Observable } from "babylonjs/Misc/observable";
  47615. import { Nullable } from "babylonjs/types";
  47616. import { IDisposable, Scene } from "babylonjs/scene";
  47617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47618. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47619. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47620. /**
  47621. * Manages an XRSession to work with Babylon's engine
  47622. * @see https://doc.babylonjs.com/how_to/webxr
  47623. */
  47624. export class WebXRSessionManager implements IDisposable {
  47625. /** The scene which the session should be created for */
  47626. scene: Scene;
  47627. private _referenceSpace;
  47628. private _rttProvider;
  47629. private _sessionEnded;
  47630. private _xrNavigator;
  47631. private baseLayer;
  47632. /**
  47633. * The base reference space from which the session started. good if you want to reset your
  47634. * reference space
  47635. */
  47636. baseReferenceSpace: XRReferenceSpace;
  47637. /**
  47638. * Current XR frame
  47639. */
  47640. currentFrame: Nullable<XRFrame>;
  47641. /** WebXR timestamp updated every frame */
  47642. currentTimestamp: number;
  47643. /**
  47644. * Used just in case of a failure to initialize an immersive session.
  47645. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47646. */
  47647. defaultHeightCompensation: number;
  47648. /**
  47649. * Fires every time a new xrFrame arrives which can be used to update the camera
  47650. */
  47651. onXRFrameObservable: Observable<XRFrame>;
  47652. /**
  47653. * Fires when the reference space changed
  47654. */
  47655. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47656. /**
  47657. * Fires when the xr session is ended either by the device or manually done
  47658. */
  47659. onXRSessionEnded: Observable<any>;
  47660. /**
  47661. * Fires when the xr session is ended either by the device or manually done
  47662. */
  47663. onXRSessionInit: Observable<XRSession>;
  47664. /**
  47665. * Underlying xr session
  47666. */
  47667. session: XRSession;
  47668. /**
  47669. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47670. * or get the offset the player is currently at.
  47671. */
  47672. viewerReferenceSpace: XRReferenceSpace;
  47673. /**
  47674. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47675. * @param scene The scene which the session should be created for
  47676. */
  47677. constructor(
  47678. /** The scene which the session should be created for */
  47679. scene: Scene);
  47680. /**
  47681. * The current reference space used in this session. This reference space can constantly change!
  47682. * It is mainly used to offset the camera's position.
  47683. */
  47684. get referenceSpace(): XRReferenceSpace;
  47685. /**
  47686. * Set a new reference space and triggers the observable
  47687. */
  47688. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47689. /**
  47690. * Disposes of the session manager
  47691. */
  47692. dispose(): void;
  47693. /**
  47694. * Stops the xrSession and restores the render loop
  47695. * @returns Promise which resolves after it exits XR
  47696. */
  47697. exitXRAsync(): Promise<void>;
  47698. /**
  47699. * Gets the correct render target texture to be rendered this frame for this eye
  47700. * @param eye the eye for which to get the render target
  47701. * @returns the render target for the specified eye
  47702. */
  47703. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47704. /**
  47705. * Creates a WebXRRenderTarget object for the XR session
  47706. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47707. * @param options optional options to provide when creating a new render target
  47708. * @returns a WebXR render target to which the session can render
  47709. */
  47710. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47711. /**
  47712. * Initializes the manager
  47713. * After initialization enterXR can be called to start an XR session
  47714. * @returns Promise which resolves after it is initialized
  47715. */
  47716. initializeAsync(): Promise<void>;
  47717. /**
  47718. * Initializes an xr session
  47719. * @param xrSessionMode mode to initialize
  47720. * @param xrSessionInit defines optional and required values to pass to the session builder
  47721. * @returns a promise which will resolve once the session has been initialized
  47722. */
  47723. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47724. /**
  47725. * Checks if a session would be supported for the creation options specified
  47726. * @param sessionMode session mode to check if supported eg. immersive-vr
  47727. * @returns A Promise that resolves to true if supported and false if not
  47728. */
  47729. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47730. /**
  47731. * Resets the reference space to the one started the session
  47732. */
  47733. resetReferenceSpace(): void;
  47734. /**
  47735. * Starts rendering to the xr layer
  47736. */
  47737. runXRRenderLoop(): void;
  47738. /**
  47739. * Sets the reference space on the xr session
  47740. * @param referenceSpaceType space to set
  47741. * @returns a promise that will resolve once the reference space has been set
  47742. */
  47743. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47744. /**
  47745. * Updates the render state of the session
  47746. * @param state state to set
  47747. * @returns a promise that resolves once the render state has been updated
  47748. */
  47749. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47750. /**
  47751. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47752. * @param sessionMode defines the session to test
  47753. * @returns a promise with boolean as final value
  47754. */
  47755. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47756. private _createRenderTargetTexture;
  47757. }
  47758. }
  47759. declare module "babylonjs/XR/webXRCamera" {
  47760. import { Matrix } from "babylonjs/Maths/math.vector";
  47761. import { Scene } from "babylonjs/scene";
  47762. import { Camera } from "babylonjs/Cameras/camera";
  47763. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47764. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47765. /**
  47766. * WebXR Camera which holds the views for the xrSession
  47767. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47768. */
  47769. export class WebXRCamera extends FreeCamera {
  47770. private _xrSessionManager;
  47771. private _firstFrame;
  47772. private _referenceQuaternion;
  47773. private _referencedPosition;
  47774. private _xrInvPositionCache;
  47775. private _xrInvQuaternionCache;
  47776. /**
  47777. * Should position compensation execute on first frame.
  47778. * This is used when copying the position from a native (non XR) camera
  47779. */
  47780. compensateOnFirstFrame: boolean;
  47781. /**
  47782. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47783. * @param name the name of the camera
  47784. * @param scene the scene to add the camera to
  47785. * @param _xrSessionManager a constructed xr session manager
  47786. */
  47787. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47788. /**
  47789. * Return the user's height, unrelated to the current ground.
  47790. * This will be the y position of this camera, when ground level is 0.
  47791. */
  47792. get realWorldHeight(): number;
  47793. /** @hidden */
  47794. _updateForDualEyeDebugging(): void;
  47795. /**
  47796. * Sets this camera's transformation based on a non-vr camera
  47797. * @param otherCamera the non-vr camera to copy the transformation from
  47798. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47799. */
  47800. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47801. /**
  47802. * Gets the current instance class name ("WebXRCamera").
  47803. * @returns the class name
  47804. */
  47805. getClassName(): string;
  47806. /**
  47807. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47808. */
  47809. _getViewMatrix(): Matrix;
  47810. private _updateFromXRSession;
  47811. private _updateNumberOfRigCameras;
  47812. private _updateReferenceSpace;
  47813. private _updateReferenceSpaceOffset;
  47814. }
  47815. }
  47816. declare module "babylonjs/XR/webXRFeaturesManager" {
  47817. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47818. import { IDisposable } from "babylonjs/scene";
  47819. /**
  47820. * Defining the interface required for a (webxr) feature
  47821. */
  47822. export interface IWebXRFeature extends IDisposable {
  47823. /**
  47824. * Is this feature attached
  47825. */
  47826. attached: boolean;
  47827. /**
  47828. * Should auto-attach be disabled?
  47829. */
  47830. disableAutoAttach: boolean;
  47831. /**
  47832. * Attach the feature to the session
  47833. * Will usually be called by the features manager
  47834. *
  47835. * @param force should attachment be forced (even when already attached)
  47836. * @returns true if successful.
  47837. */
  47838. attach(force?: boolean): boolean;
  47839. /**
  47840. * Detach the feature from the session
  47841. * Will usually be called by the features manager
  47842. *
  47843. * @returns true if successful.
  47844. */
  47845. detach(): boolean;
  47846. }
  47847. /**
  47848. * A list of the currently available features without referencing them
  47849. */
  47850. export class WebXRFeatureName {
  47851. /**
  47852. * The name of the anchor system feature
  47853. */
  47854. static ANCHOR_SYSTEM: string;
  47855. /**
  47856. * The name of the background remover feature
  47857. */
  47858. static BACKGROUND_REMOVER: string;
  47859. /**
  47860. * The name of the hit test feature
  47861. */
  47862. static HIT_TEST: string;
  47863. /**
  47864. * physics impostors for xr controllers feature
  47865. */
  47866. static PHYSICS_CONTROLLERS: string;
  47867. /**
  47868. * The name of the plane detection feature
  47869. */
  47870. static PLANE_DETECTION: string;
  47871. /**
  47872. * The name of the pointer selection feature
  47873. */
  47874. static POINTER_SELECTION: string;
  47875. /**
  47876. * The name of the teleportation feature
  47877. */
  47878. static TELEPORTATION: string;
  47879. }
  47880. /**
  47881. * Defining the constructor of a feature. Used to register the modules.
  47882. */
  47883. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47884. /**
  47885. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47886. * It is mainly used in AR sessions.
  47887. *
  47888. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47889. */
  47890. export class WebXRFeaturesManager implements IDisposable {
  47891. private _xrSessionManager;
  47892. private static readonly _AvailableFeatures;
  47893. private _features;
  47894. /**
  47895. * constructs a new features manages.
  47896. *
  47897. * @param _xrSessionManager an instance of WebXRSessionManager
  47898. */
  47899. constructor(_xrSessionManager: WebXRSessionManager);
  47900. /**
  47901. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47902. * Mainly used internally.
  47903. *
  47904. * @param featureName the name of the feature to register
  47905. * @param constructorFunction the function used to construct the module
  47906. * @param version the (babylon) version of the module
  47907. * @param stable is that a stable version of this module
  47908. */
  47909. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47910. /**
  47911. * Returns a constructor of a specific feature.
  47912. *
  47913. * @param featureName the name of the feature to construct
  47914. * @param version the version of the feature to load
  47915. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47916. * @param options optional options provided to the module.
  47917. * @returns a function that, when called, will return a new instance of this feature
  47918. */
  47919. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47920. /**
  47921. * Can be used to return the list of features currently registered
  47922. *
  47923. * @returns an Array of available features
  47924. */
  47925. static GetAvailableFeatures(): string[];
  47926. /**
  47927. * Gets the versions available for a specific feature
  47928. * @param featureName the name of the feature
  47929. * @returns an array with the available versions
  47930. */
  47931. static GetAvailableVersions(featureName: string): string[];
  47932. /**
  47933. * Return the latest unstable version of this feature
  47934. * @param featureName the name of the feature to search
  47935. * @returns the version number. if not found will return -1
  47936. */
  47937. static GetLatestVersionOfFeature(featureName: string): number;
  47938. /**
  47939. * Return the latest stable version of this feature
  47940. * @param featureName the name of the feature to search
  47941. * @returns the version number. if not found will return -1
  47942. */
  47943. static GetStableVersionOfFeature(featureName: string): number;
  47944. /**
  47945. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47946. * Can be used during a session to start a feature
  47947. * @param featureName the name of feature to attach
  47948. */
  47949. attachFeature(featureName: string): void;
  47950. /**
  47951. * Can be used inside a session or when the session ends to detach a specific feature
  47952. * @param featureName the name of the feature to detach
  47953. */
  47954. detachFeature(featureName: string): void;
  47955. /**
  47956. * Used to disable an already-enabled feature
  47957. * The feature will be disposed and will be recreated once enabled.
  47958. * @param featureName the feature to disable
  47959. * @returns true if disable was successful
  47960. */
  47961. disableFeature(featureName: string | {
  47962. Name: string;
  47963. }): boolean;
  47964. /**
  47965. * dispose this features manager
  47966. */
  47967. dispose(): void;
  47968. /**
  47969. * 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.
  47970. * 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.
  47971. *
  47972. * @param featureName the name of the feature to load or the class of the feature
  47973. * @param version optional version to load. if not provided the latest version will be enabled
  47974. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47975. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47976. * @returns a new constructed feature or throws an error if feature not found.
  47977. */
  47978. enableFeature(featureName: string | {
  47979. Name: string;
  47980. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47981. /**
  47982. * get the implementation of an enabled feature.
  47983. * @param featureName the name of the feature to load
  47984. * @returns the feature class, if found
  47985. */
  47986. getEnabledFeature(featureName: string): IWebXRFeature;
  47987. /**
  47988. * Get the list of enabled features
  47989. * @returns an array of enabled features
  47990. */
  47991. getEnabledFeatures(): string[];
  47992. }
  47993. }
  47994. declare module "babylonjs/XR/webXRExperienceHelper" {
  47995. import { Observable } from "babylonjs/Misc/observable";
  47996. import { IDisposable, Scene } from "babylonjs/scene";
  47997. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47998. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47999. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48000. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48001. /**
  48002. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48003. * @see https://doc.babylonjs.com/how_to/webxr
  48004. */
  48005. export class WebXRExperienceHelper implements IDisposable {
  48006. private scene;
  48007. private _nonVRCamera;
  48008. private _originalSceneAutoClear;
  48009. private _supported;
  48010. /**
  48011. * Camera used to render xr content
  48012. */
  48013. camera: WebXRCamera;
  48014. /** A features manager for this xr session */
  48015. featuresManager: WebXRFeaturesManager;
  48016. /**
  48017. * Observers registered here will be triggered after the camera's initial transformation is set
  48018. * This can be used to set a different ground level or an extra rotation.
  48019. *
  48020. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48021. * to the position set after this observable is done executing.
  48022. */
  48023. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48024. /**
  48025. * Fires when the state of the experience helper has changed
  48026. */
  48027. onStateChangedObservable: Observable<WebXRState>;
  48028. /** Session manager used to keep track of xr session */
  48029. sessionManager: WebXRSessionManager;
  48030. /**
  48031. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48032. */
  48033. state: WebXRState;
  48034. /**
  48035. * Creates a WebXRExperienceHelper
  48036. * @param scene The scene the helper should be created in
  48037. */
  48038. private constructor();
  48039. /**
  48040. * Creates the experience helper
  48041. * @param scene the scene to attach the experience helper to
  48042. * @returns a promise for the experience helper
  48043. */
  48044. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48045. /**
  48046. * Disposes of the experience helper
  48047. */
  48048. dispose(): void;
  48049. /**
  48050. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48051. * @param sessionMode options for the XR session
  48052. * @param referenceSpaceType frame of reference of the XR session
  48053. * @param renderTarget the output canvas that will be used to enter XR mode
  48054. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48055. * @returns promise that resolves after xr mode has entered
  48056. */
  48057. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48058. /**
  48059. * Exits XR mode and returns the scene to its original state
  48060. * @returns promise that resolves after xr mode has exited
  48061. */
  48062. exitXRAsync(): Promise<void>;
  48063. private _nonXRToXRCamera;
  48064. private _setState;
  48065. }
  48066. }
  48067. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48068. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48069. import { Observable } from "babylonjs/Misc/observable";
  48070. import { IDisposable } from "babylonjs/scene";
  48071. /**
  48072. * X-Y values for axes in WebXR
  48073. */
  48074. export interface IWebXRMotionControllerAxesValue {
  48075. /**
  48076. * The value of the x axis
  48077. */
  48078. x: number;
  48079. /**
  48080. * The value of the y-axis
  48081. */
  48082. y: number;
  48083. }
  48084. /**
  48085. * changed / previous values for the values of this component
  48086. */
  48087. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48088. /**
  48089. * current (this frame) value
  48090. */
  48091. current: T;
  48092. /**
  48093. * previous (last change) value
  48094. */
  48095. previous: T;
  48096. }
  48097. /**
  48098. * Represents changes in the component between current frame and last values recorded
  48099. */
  48100. export interface IWebXRMotionControllerComponentChanges {
  48101. /**
  48102. * will be populated with previous and current values if axes changed
  48103. */
  48104. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48105. /**
  48106. * will be populated with previous and current values if pressed changed
  48107. */
  48108. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48109. /**
  48110. * will be populated with previous and current values if touched changed
  48111. */
  48112. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48113. /**
  48114. * will be populated with previous and current values if value changed
  48115. */
  48116. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48117. }
  48118. /**
  48119. * This class represents a single component (for example button or thumbstick) of a motion controller
  48120. */
  48121. export class WebXRControllerComponent implements IDisposable {
  48122. /**
  48123. * the id of this component
  48124. */
  48125. id: string;
  48126. /**
  48127. * the type of the component
  48128. */
  48129. type: MotionControllerComponentType;
  48130. private _buttonIndex;
  48131. private _axesIndices;
  48132. private _axes;
  48133. private _changes;
  48134. private _currentValue;
  48135. private _hasChanges;
  48136. private _pressed;
  48137. private _touched;
  48138. /**
  48139. * button component type
  48140. */
  48141. static BUTTON_TYPE: MotionControllerComponentType;
  48142. /**
  48143. * squeeze component type
  48144. */
  48145. static SQUEEZE_TYPE: MotionControllerComponentType;
  48146. /**
  48147. * Thumbstick component type
  48148. */
  48149. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48150. /**
  48151. * Touchpad component type
  48152. */
  48153. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48154. /**
  48155. * trigger component type
  48156. */
  48157. static TRIGGER_TYPE: MotionControllerComponentType;
  48158. /**
  48159. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48160. * the axes data changes
  48161. */
  48162. onAxisValueChangedObservable: Observable<{
  48163. x: number;
  48164. y: number;
  48165. }>;
  48166. /**
  48167. * Observers registered here will be triggered when the state of a button changes
  48168. * State change is either pressed / touched / value
  48169. */
  48170. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48171. /**
  48172. * Creates a new component for a motion controller.
  48173. * It is created by the motion controller itself
  48174. *
  48175. * @param id the id of this component
  48176. * @param type the type of the component
  48177. * @param _buttonIndex index in the buttons array of the gamepad
  48178. * @param _axesIndices indices of the values in the axes array of the gamepad
  48179. */
  48180. constructor(
  48181. /**
  48182. * the id of this component
  48183. */
  48184. id: string,
  48185. /**
  48186. * the type of the component
  48187. */
  48188. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48189. /**
  48190. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48191. */
  48192. get axes(): IWebXRMotionControllerAxesValue;
  48193. /**
  48194. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48195. */
  48196. get changes(): IWebXRMotionControllerComponentChanges;
  48197. /**
  48198. * Return whether or not the component changed the last frame
  48199. */
  48200. get hasChanges(): boolean;
  48201. /**
  48202. * is the button currently pressed
  48203. */
  48204. get pressed(): boolean;
  48205. /**
  48206. * is the button currently touched
  48207. */
  48208. get touched(): boolean;
  48209. /**
  48210. * Get the current value of this component
  48211. */
  48212. get value(): number;
  48213. /**
  48214. * Dispose this component
  48215. */
  48216. dispose(): void;
  48217. /**
  48218. * Are there axes correlating to this component
  48219. * @return true is axes data is available
  48220. */
  48221. isAxes(): boolean;
  48222. /**
  48223. * Is this component a button (hence - pressable)
  48224. * @returns true if can be pressed
  48225. */
  48226. isButton(): boolean;
  48227. /**
  48228. * update this component using the gamepad object it is in. Called on every frame
  48229. * @param nativeController the native gamepad controller object
  48230. */
  48231. update(nativeController: IMinimalMotionControllerObject): void;
  48232. }
  48233. }
  48234. declare module "babylonjs/Loading/sceneLoader" {
  48235. import { Observable } from "babylonjs/Misc/observable";
  48236. import { Nullable } from "babylonjs/types";
  48237. import { Scene } from "babylonjs/scene";
  48238. import { Engine } from "babylonjs/Engines/engine";
  48239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48240. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48241. import { AssetContainer } from "babylonjs/assetContainer";
  48242. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48243. import { Skeleton } from "babylonjs/Bones/skeleton";
  48244. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48245. import { WebRequest } from "babylonjs/Misc/webRequest";
  48246. /**
  48247. * Class used to represent data loading progression
  48248. */
  48249. export class SceneLoaderProgressEvent {
  48250. /** defines if data length to load can be evaluated */
  48251. readonly lengthComputable: boolean;
  48252. /** defines the loaded data length */
  48253. readonly loaded: number;
  48254. /** defines the data length to load */
  48255. readonly total: number;
  48256. /**
  48257. * Create a new progress event
  48258. * @param lengthComputable defines if data length to load can be evaluated
  48259. * @param loaded defines the loaded data length
  48260. * @param total defines the data length to load
  48261. */
  48262. constructor(
  48263. /** defines if data length to load can be evaluated */
  48264. lengthComputable: boolean,
  48265. /** defines the loaded data length */
  48266. loaded: number,
  48267. /** defines the data length to load */
  48268. total: number);
  48269. /**
  48270. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48271. * @param event defines the source event
  48272. * @returns a new SceneLoaderProgressEvent
  48273. */
  48274. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48275. }
  48276. /**
  48277. * Interface used by SceneLoader plugins to define supported file extensions
  48278. */
  48279. export interface ISceneLoaderPluginExtensions {
  48280. /**
  48281. * Defines the list of supported extensions
  48282. */
  48283. [extension: string]: {
  48284. isBinary: boolean;
  48285. };
  48286. }
  48287. /**
  48288. * Interface used by SceneLoader plugin factory
  48289. */
  48290. export interface ISceneLoaderPluginFactory {
  48291. /**
  48292. * Defines the name of the factory
  48293. */
  48294. name: string;
  48295. /**
  48296. * Function called to create a new plugin
  48297. * @return the new plugin
  48298. */
  48299. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48300. /**
  48301. * The callback that returns true if the data can be directly loaded.
  48302. * @param data string containing the file data
  48303. * @returns if the data can be loaded directly
  48304. */
  48305. canDirectLoad?(data: string): boolean;
  48306. }
  48307. /**
  48308. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48309. */
  48310. export interface ISceneLoaderPluginBase {
  48311. /**
  48312. * The friendly name of this plugin.
  48313. */
  48314. name: string;
  48315. /**
  48316. * The file extensions supported by this plugin.
  48317. */
  48318. extensions: string | ISceneLoaderPluginExtensions;
  48319. /**
  48320. * The callback called when loading from a url.
  48321. * @param scene scene loading this url
  48322. * @param url url to load
  48323. * @param onSuccess callback called when the file successfully loads
  48324. * @param onProgress callback called while file is loading (if the server supports this mode)
  48325. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48326. * @param onError callback called when the file fails to load
  48327. * @returns a file request object
  48328. */
  48329. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48330. /**
  48331. * The callback called when loading from a file object.
  48332. * @param scene scene loading this file
  48333. * @param file defines the file to load
  48334. * @param onSuccess defines the callback to call when data is loaded
  48335. * @param onProgress defines the callback to call during loading process
  48336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48337. * @param onError defines the callback to call when an error occurs
  48338. * @returns a file request object
  48339. */
  48340. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48341. /**
  48342. * The callback that returns true if the data can be directly loaded.
  48343. * @param data string containing the file data
  48344. * @returns if the data can be loaded directly
  48345. */
  48346. canDirectLoad?(data: string): boolean;
  48347. /**
  48348. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48349. * @param scene scene loading this data
  48350. * @param data string containing the data
  48351. * @returns data to pass to the plugin
  48352. */
  48353. directLoad?(scene: Scene, data: string): any;
  48354. /**
  48355. * The callback that allows custom handling of the root url based on the response url.
  48356. * @param rootUrl the original root url
  48357. * @param responseURL the response url if available
  48358. * @returns the new root url
  48359. */
  48360. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48361. }
  48362. /**
  48363. * Interface used to define a SceneLoader plugin
  48364. */
  48365. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48366. /**
  48367. * Import meshes into a scene.
  48368. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48369. * @param scene The scene to import into
  48370. * @param data The data to import
  48371. * @param rootUrl The root url for scene and resources
  48372. * @param meshes The meshes array to import into
  48373. * @param particleSystems The particle systems array to import into
  48374. * @param skeletons The skeletons array to import into
  48375. * @param onError The callback when import fails
  48376. * @returns True if successful or false otherwise
  48377. */
  48378. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48379. /**
  48380. * Load into a scene.
  48381. * @param scene The scene to load into
  48382. * @param data The data to import
  48383. * @param rootUrl The root url for scene and resources
  48384. * @param onError The callback when import fails
  48385. * @returns True if successful or false otherwise
  48386. */
  48387. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48388. /**
  48389. * Load into an asset container.
  48390. * @param scene The scene to load into
  48391. * @param data The data to import
  48392. * @param rootUrl The root url for scene and resources
  48393. * @param onError The callback when import fails
  48394. * @returns The loaded asset container
  48395. */
  48396. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48397. }
  48398. /**
  48399. * Interface used to define an async SceneLoader plugin
  48400. */
  48401. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48402. /**
  48403. * Import meshes into a scene.
  48404. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48405. * @param scene The scene to import into
  48406. * @param data The data to import
  48407. * @param rootUrl The root url for scene and resources
  48408. * @param onProgress The callback when the load progresses
  48409. * @param fileName Defines the name of the file to load
  48410. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48411. */
  48412. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48413. meshes: AbstractMesh[];
  48414. particleSystems: IParticleSystem[];
  48415. skeletons: Skeleton[];
  48416. animationGroups: AnimationGroup[];
  48417. }>;
  48418. /**
  48419. * Load into a scene.
  48420. * @param scene The scene to load into
  48421. * @param data The data to import
  48422. * @param rootUrl The root url for scene and resources
  48423. * @param onProgress The callback when the load progresses
  48424. * @param fileName Defines the name of the file to load
  48425. * @returns Nothing
  48426. */
  48427. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48428. /**
  48429. * Load into an asset container.
  48430. * @param scene The scene to load into
  48431. * @param data The data to import
  48432. * @param rootUrl The root url for scene and resources
  48433. * @param onProgress The callback when the load progresses
  48434. * @param fileName Defines the name of the file to load
  48435. * @returns The loaded asset container
  48436. */
  48437. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48438. }
  48439. /**
  48440. * Mode that determines how to handle old animation groups before loading new ones.
  48441. */
  48442. export enum SceneLoaderAnimationGroupLoadingMode {
  48443. /**
  48444. * Reset all old animations to initial state then dispose them.
  48445. */
  48446. Clean = 0,
  48447. /**
  48448. * Stop all old animations.
  48449. */
  48450. Stop = 1,
  48451. /**
  48452. * Restart old animations from first frame.
  48453. */
  48454. Sync = 2,
  48455. /**
  48456. * Old animations remains untouched.
  48457. */
  48458. NoSync = 3
  48459. }
  48460. /**
  48461. * Class used to load scene from various file formats using registered plugins
  48462. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48463. */
  48464. export class SceneLoader {
  48465. /**
  48466. * No logging while loading
  48467. */
  48468. static readonly NO_LOGGING: number;
  48469. /**
  48470. * Minimal logging while loading
  48471. */
  48472. static readonly MINIMAL_LOGGING: number;
  48473. /**
  48474. * Summary logging while loading
  48475. */
  48476. static readonly SUMMARY_LOGGING: number;
  48477. /**
  48478. * Detailled logging while loading
  48479. */
  48480. static readonly DETAILED_LOGGING: number;
  48481. /**
  48482. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48483. */
  48484. static get ForceFullSceneLoadingForIncremental(): boolean;
  48485. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48486. /**
  48487. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48488. */
  48489. static get ShowLoadingScreen(): boolean;
  48490. static set ShowLoadingScreen(value: boolean);
  48491. /**
  48492. * Defines the current logging level (while loading the scene)
  48493. * @ignorenaming
  48494. */
  48495. static get loggingLevel(): number;
  48496. static set loggingLevel(value: number);
  48497. /**
  48498. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48499. */
  48500. static get CleanBoneMatrixWeights(): boolean;
  48501. static set CleanBoneMatrixWeights(value: boolean);
  48502. /**
  48503. * Event raised when a plugin is used to load a scene
  48504. */
  48505. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48506. private static _registeredPlugins;
  48507. private static _getDefaultPlugin;
  48508. private static _getPluginForExtension;
  48509. private static _getPluginForDirectLoad;
  48510. private static _getPluginForFilename;
  48511. private static _getDirectLoad;
  48512. private static _loadData;
  48513. private static _getFileInfo;
  48514. /**
  48515. * Gets a plugin that can load the given extension
  48516. * @param extension defines the extension to load
  48517. * @returns a plugin or null if none works
  48518. */
  48519. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48520. /**
  48521. * Gets a boolean indicating that the given extension can be loaded
  48522. * @param extension defines the extension to load
  48523. * @returns true if the extension is supported
  48524. */
  48525. static IsPluginForExtensionAvailable(extension: string): boolean;
  48526. /**
  48527. * Adds a new plugin to the list of registered plugins
  48528. * @param plugin defines the plugin to add
  48529. */
  48530. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48531. /**
  48532. * Import meshes into a scene
  48533. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48534. * @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)
  48535. * @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)
  48536. * @param scene the instance of BABYLON.Scene to append to
  48537. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48538. * @param onProgress a callback with a progress event for each file being loaded
  48539. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48540. * @param pluginExtension the extension used to determine the plugin
  48541. * @returns The loaded plugin
  48542. */
  48543. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48544. /**
  48545. * Import meshes into a scene
  48546. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48547. * @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)
  48548. * @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)
  48549. * @param scene the instance of BABYLON.Scene to append to
  48550. * @param onProgress a callback with a progress event for each file being loaded
  48551. * @param pluginExtension the extension used to determine the plugin
  48552. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48553. */
  48554. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48555. meshes: AbstractMesh[];
  48556. particleSystems: IParticleSystem[];
  48557. skeletons: Skeleton[];
  48558. animationGroups: AnimationGroup[];
  48559. }>;
  48560. /**
  48561. * Load a scene
  48562. * @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)
  48563. * @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)
  48564. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48565. * @param onSuccess a callback with the scene when import succeeds
  48566. * @param onProgress a callback with a progress event for each file being loaded
  48567. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48568. * @param pluginExtension the extension used to determine the plugin
  48569. * @returns The loaded plugin
  48570. */
  48571. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48572. /**
  48573. * Load a scene
  48574. * @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)
  48575. * @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)
  48576. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48577. * @param onProgress a callback with a progress event for each file being loaded
  48578. * @param pluginExtension the extension used to determine the plugin
  48579. * @returns The loaded scene
  48580. */
  48581. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48582. /**
  48583. * Append a scene
  48584. * @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)
  48585. * @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)
  48586. * @param scene is the instance of BABYLON.Scene to append to
  48587. * @param onSuccess a callback with the scene when import succeeds
  48588. * @param onProgress a callback with a progress event for each file being loaded
  48589. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48590. * @param pluginExtension the extension used to determine the plugin
  48591. * @returns The loaded plugin
  48592. */
  48593. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48594. /**
  48595. * Append a scene
  48596. * @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)
  48597. * @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)
  48598. * @param scene is the instance of BABYLON.Scene to append to
  48599. * @param onProgress a callback with a progress event for each file being loaded
  48600. * @param pluginExtension the extension used to determine the plugin
  48601. * @returns The given scene
  48602. */
  48603. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48604. /**
  48605. * Load a scene into an asset container
  48606. * @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)
  48607. * @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)
  48608. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48609. * @param onSuccess a callback with the scene when import succeeds
  48610. * @param onProgress a callback with a progress event for each file being loaded
  48611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48612. * @param pluginExtension the extension used to determine the plugin
  48613. * @returns The loaded plugin
  48614. */
  48615. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48616. /**
  48617. * Load a scene into an asset container
  48618. * @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)
  48619. * @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)
  48620. * @param scene is the instance of Scene to append to
  48621. * @param onProgress a callback with a progress event for each file being loaded
  48622. * @param pluginExtension the extension used to determine the plugin
  48623. * @returns The loaded asset container
  48624. */
  48625. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48626. /**
  48627. * Import animations from a file into a scene
  48628. * @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)
  48629. * @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)
  48630. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48631. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48632. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48633. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48634. * @param onSuccess a callback with the scene when import succeeds
  48635. * @param onProgress a callback with a progress event for each file being loaded
  48636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48637. */
  48638. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  48639. /**
  48640. * Import animations from a file into a scene
  48641. * @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)
  48642. * @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)
  48643. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48644. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48645. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48646. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48647. * @param onSuccess a callback with the scene when import succeeds
  48648. * @param onProgress a callback with a progress event for each file being loaded
  48649. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48650. * @returns the updated scene with imported animations
  48651. */
  48652. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  48653. }
  48654. }
  48655. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48656. import { IDisposable, Scene } from "babylonjs/scene";
  48657. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48658. import { Observable } from "babylonjs/Misc/observable";
  48659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48660. import { Nullable } from "babylonjs/types";
  48661. /**
  48662. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48663. */
  48664. export type MotionControllerHandedness = "none" | "left" | "right";
  48665. /**
  48666. * The type of components available in motion controllers.
  48667. * This is not the name of the component.
  48668. */
  48669. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48670. /**
  48671. * The state of a controller component
  48672. */
  48673. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48674. /**
  48675. * The schema of motion controller layout.
  48676. * No object will be initialized using this interface
  48677. * This is used just to define the profile.
  48678. */
  48679. export interface IMotionControllerLayout {
  48680. /**
  48681. * Path to load the assets. Usually relative to the base path
  48682. */
  48683. assetPath: string;
  48684. /**
  48685. * Available components (unsorted)
  48686. */
  48687. components: {
  48688. /**
  48689. * A map of component Ids
  48690. */
  48691. [componentId: string]: {
  48692. /**
  48693. * The type of input the component outputs
  48694. */
  48695. type: MotionControllerComponentType;
  48696. /**
  48697. * The indices of this component in the gamepad object
  48698. */
  48699. gamepadIndices: {
  48700. /**
  48701. * Index of button
  48702. */
  48703. button?: number;
  48704. /**
  48705. * If available, index of x-axis
  48706. */
  48707. xAxis?: number;
  48708. /**
  48709. * If available, index of y-axis
  48710. */
  48711. yAxis?: number;
  48712. };
  48713. /**
  48714. * The mesh's root node name
  48715. */
  48716. rootNodeName: string;
  48717. /**
  48718. * Animation definitions for this model
  48719. */
  48720. visualResponses: {
  48721. [stateKey: string]: {
  48722. /**
  48723. * What property will be animated
  48724. */
  48725. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48726. /**
  48727. * What states influence this visual response
  48728. */
  48729. states: MotionControllerComponentStateType[];
  48730. /**
  48731. * Type of animation - movement or visibility
  48732. */
  48733. valueNodeProperty: "transform" | "visibility";
  48734. /**
  48735. * Base node name to move. Its position will be calculated according to the min and max nodes
  48736. */
  48737. valueNodeName?: string;
  48738. /**
  48739. * Minimum movement node
  48740. */
  48741. minNodeName?: string;
  48742. /**
  48743. * Max movement node
  48744. */
  48745. maxNodeName?: string;
  48746. };
  48747. };
  48748. /**
  48749. * If touch enabled, what is the name of node to display user feedback
  48750. */
  48751. touchPointNodeName?: string;
  48752. };
  48753. };
  48754. /**
  48755. * Is it xr standard mapping or not
  48756. */
  48757. gamepadMapping: "" | "xr-standard";
  48758. /**
  48759. * Base root node of this entire model
  48760. */
  48761. rootNodeName: string;
  48762. /**
  48763. * Defines the main button component id
  48764. */
  48765. selectComponentId: string;
  48766. }
  48767. /**
  48768. * A definition for the layout map in the input profile
  48769. */
  48770. export interface IMotionControllerLayoutMap {
  48771. /**
  48772. * Layouts with handedness type as a key
  48773. */
  48774. [handedness: string]: IMotionControllerLayout;
  48775. }
  48776. /**
  48777. * The XR Input profile schema
  48778. * Profiles can be found here:
  48779. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48780. */
  48781. export interface IMotionControllerProfile {
  48782. /**
  48783. * fallback profiles for this profileId
  48784. */
  48785. fallbackProfileIds: string[];
  48786. /**
  48787. * The layout map, with handedness as key
  48788. */
  48789. layouts: IMotionControllerLayoutMap;
  48790. /**
  48791. * The id of this profile
  48792. * correlates to the profile(s) in the xrInput.profiles array
  48793. */
  48794. profileId: string;
  48795. }
  48796. /**
  48797. * A helper-interface for the 3 meshes needed for controller button animation
  48798. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48799. */
  48800. export interface IMotionControllerButtonMeshMap {
  48801. /**
  48802. * the mesh that defines the pressed value mesh position.
  48803. * This is used to find the max-position of this button
  48804. */
  48805. pressedMesh: AbstractMesh;
  48806. /**
  48807. * the mesh that defines the unpressed value mesh position.
  48808. * This is used to find the min (or initial) position of this button
  48809. */
  48810. unpressedMesh: AbstractMesh;
  48811. /**
  48812. * The mesh that will be changed when value changes
  48813. */
  48814. valueMesh: AbstractMesh;
  48815. }
  48816. /**
  48817. * A helper-interface for the 3 meshes needed for controller axis animation.
  48818. * This will be expanded when touchpad animations are fully supported
  48819. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48820. */
  48821. export interface IMotionControllerMeshMap {
  48822. /**
  48823. * the mesh that defines the maximum value mesh position.
  48824. */
  48825. maxMesh?: AbstractMesh;
  48826. /**
  48827. * the mesh that defines the minimum value mesh position.
  48828. */
  48829. minMesh?: AbstractMesh;
  48830. /**
  48831. * The mesh that will be changed when axis value changes
  48832. */
  48833. valueMesh: AbstractMesh;
  48834. }
  48835. /**
  48836. * The elements needed for change-detection of the gamepad objects in motion controllers
  48837. */
  48838. export interface IMinimalMotionControllerObject {
  48839. /**
  48840. * Available axes of this controller
  48841. */
  48842. axes: number[];
  48843. /**
  48844. * An array of available buttons
  48845. */
  48846. buttons: Array<{
  48847. /**
  48848. * Value of the button/trigger
  48849. */
  48850. value: number;
  48851. /**
  48852. * If the button/trigger is currently touched
  48853. */
  48854. touched: boolean;
  48855. /**
  48856. * If the button/trigger is currently pressed
  48857. */
  48858. pressed: boolean;
  48859. }>;
  48860. /**
  48861. * EXPERIMENTAL haptic support.
  48862. */
  48863. hapticActuators?: Array<{
  48864. pulse: (value: number, duration: number) => Promise<boolean>;
  48865. }>;
  48866. }
  48867. /**
  48868. * An Abstract Motion controller
  48869. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48870. * Each component has an observable to check for changes in value and state
  48871. */
  48872. export abstract class WebXRAbstractMotionController implements IDisposable {
  48873. protected scene: Scene;
  48874. protected layout: IMotionControllerLayout;
  48875. /**
  48876. * The gamepad object correlating to this controller
  48877. */
  48878. gamepadObject: IMinimalMotionControllerObject;
  48879. /**
  48880. * handedness (left/right/none) of this controller
  48881. */
  48882. handedness: MotionControllerHandedness;
  48883. private _initComponent;
  48884. private _modelReady;
  48885. /**
  48886. * A map of components (WebXRControllerComponent) in this motion controller
  48887. * Components have a ComponentType and can also have both button and axis definitions
  48888. */
  48889. readonly components: {
  48890. [id: string]: WebXRControllerComponent;
  48891. };
  48892. /**
  48893. * Disable the model's animation. Can be set at any time.
  48894. */
  48895. disableAnimation: boolean;
  48896. /**
  48897. * Observers registered here will be triggered when the model of this controller is done loading
  48898. */
  48899. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48900. /**
  48901. * The profile id of this motion controller
  48902. */
  48903. abstract profileId: string;
  48904. /**
  48905. * The root mesh of the model. It is null if the model was not yet initialized
  48906. */
  48907. rootMesh: Nullable<AbstractMesh>;
  48908. /**
  48909. * constructs a new abstract motion controller
  48910. * @param scene the scene to which the model of the controller will be added
  48911. * @param layout The profile layout to load
  48912. * @param gamepadObject The gamepad object correlating to this controller
  48913. * @param handedness handedness (left/right/none) of this controller
  48914. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48915. */
  48916. constructor(scene: Scene, layout: IMotionControllerLayout,
  48917. /**
  48918. * The gamepad object correlating to this controller
  48919. */
  48920. gamepadObject: IMinimalMotionControllerObject,
  48921. /**
  48922. * handedness (left/right/none) of this controller
  48923. */
  48924. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48925. /**
  48926. * Dispose this controller, the model mesh and all its components
  48927. */
  48928. dispose(): void;
  48929. /**
  48930. * Returns all components of specific type
  48931. * @param type the type to search for
  48932. * @return an array of components with this type
  48933. */
  48934. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48935. /**
  48936. * get a component based an its component id as defined in layout.components
  48937. * @param id the id of the component
  48938. * @returns the component correlates to the id or undefined if not found
  48939. */
  48940. getComponent(id: string): WebXRControllerComponent;
  48941. /**
  48942. * Get the list of components available in this motion controller
  48943. * @returns an array of strings correlating to available components
  48944. */
  48945. getComponentIds(): string[];
  48946. /**
  48947. * Get the first component of specific type
  48948. * @param type type of component to find
  48949. * @return a controller component or null if not found
  48950. */
  48951. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48952. /**
  48953. * Get the main (Select) component of this controller as defined in the layout
  48954. * @returns the main component of this controller
  48955. */
  48956. getMainComponent(): WebXRControllerComponent;
  48957. /**
  48958. * Loads the model correlating to this controller
  48959. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48960. * @returns A promise fulfilled with the result of the model loading
  48961. */
  48962. loadModel(): Promise<boolean>;
  48963. /**
  48964. * Update this model using the current XRFrame
  48965. * @param xrFrame the current xr frame to use and update the model
  48966. */
  48967. updateFromXRFrame(xrFrame: XRFrame): void;
  48968. /**
  48969. * Backwards compatibility due to a deeply-integrated typo
  48970. */
  48971. get handness(): XREye;
  48972. /**
  48973. * Pulse (vibrate) this controller
  48974. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48975. * Consecutive calls to this function will cancel the last pulse call
  48976. *
  48977. * @param value the strength of the pulse in 0.0...1.0 range
  48978. * @param duration Duration of the pulse in milliseconds
  48979. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48980. * @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
  48981. */
  48982. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48983. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48984. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48985. /**
  48986. * Moves the axis on the controller mesh based on its current state
  48987. * @param axis the index of the axis
  48988. * @param axisValue the value of the axis which determines the meshes new position
  48989. * @hidden
  48990. */
  48991. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48992. /**
  48993. * Update the model itself with the current frame data
  48994. * @param xrFrame the frame to use for updating the model mesh
  48995. */
  48996. protected updateModel(xrFrame: XRFrame): void;
  48997. /**
  48998. * Get the filename and path for this controller's model
  48999. * @returns a map of filename and path
  49000. */
  49001. protected abstract _getFilenameAndPath(): {
  49002. filename: string;
  49003. path: string;
  49004. };
  49005. /**
  49006. * This function is called before the mesh is loaded. It checks for loading constraints.
  49007. * For example, this function can check if the GLB loader is available
  49008. * If this function returns false, the generic controller will be loaded instead
  49009. * @returns Is the client ready to load the mesh
  49010. */
  49011. protected abstract _getModelLoadingConstraints(): boolean;
  49012. /**
  49013. * This function will be called after the model was successfully loaded and can be used
  49014. * for mesh transformations before it is available for the user
  49015. * @param meshes the loaded meshes
  49016. */
  49017. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49018. /**
  49019. * Set the root mesh for this controller. Important for the WebXR controller class
  49020. * @param meshes the loaded meshes
  49021. */
  49022. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49023. /**
  49024. * A function executed each frame that updates the mesh (if needed)
  49025. * @param xrFrame the current xrFrame
  49026. */
  49027. protected abstract _updateModel(xrFrame: XRFrame): void;
  49028. private _getGenericFilenameAndPath;
  49029. private _getGenericParentMesh;
  49030. }
  49031. }
  49032. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49033. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49035. import { Scene } from "babylonjs/scene";
  49036. /**
  49037. * A generic trigger-only motion controller for WebXR
  49038. */
  49039. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49040. /**
  49041. * Static version of the profile id of this controller
  49042. */
  49043. static ProfileId: string;
  49044. profileId: string;
  49045. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49046. protected _getFilenameAndPath(): {
  49047. filename: string;
  49048. path: string;
  49049. };
  49050. protected _getModelLoadingConstraints(): boolean;
  49051. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49053. protected _updateModel(): void;
  49054. }
  49055. }
  49056. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49057. import { Vector4 } from "babylonjs/Maths/math.vector";
  49058. import { Mesh } from "babylonjs/Meshes/mesh";
  49059. import { Scene } from "babylonjs/scene";
  49060. import { Nullable } from "babylonjs/types";
  49061. /**
  49062. * Class containing static functions to help procedurally build meshes
  49063. */
  49064. export class SphereBuilder {
  49065. /**
  49066. * Creates a sphere mesh
  49067. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49068. * * 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`)
  49069. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49070. * * 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
  49071. * * 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)
  49072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49075. * @param name defines the name of the mesh
  49076. * @param options defines the options used to create the mesh
  49077. * @param scene defines the hosting scene
  49078. * @returns the sphere mesh
  49079. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49080. */
  49081. static CreateSphere(name: string, options: {
  49082. segments?: number;
  49083. diameter?: number;
  49084. diameterX?: number;
  49085. diameterY?: number;
  49086. diameterZ?: number;
  49087. arc?: number;
  49088. slice?: number;
  49089. sideOrientation?: number;
  49090. frontUVs?: Vector4;
  49091. backUVs?: Vector4;
  49092. updatable?: boolean;
  49093. }, scene?: Nullable<Scene>): Mesh;
  49094. }
  49095. }
  49096. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49098. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49099. import { Scene } from "babylonjs/scene";
  49100. /**
  49101. * A profiled motion controller has its profile loaded from an online repository.
  49102. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49103. */
  49104. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49105. private _repositoryUrl;
  49106. private _buttonMeshMapping;
  49107. private _touchDots;
  49108. /**
  49109. * The profile ID of this controller. Will be populated when the controller initializes.
  49110. */
  49111. profileId: string;
  49112. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49113. dispose(): void;
  49114. protected _getFilenameAndPath(): {
  49115. filename: string;
  49116. path: string;
  49117. };
  49118. protected _getModelLoadingConstraints(): boolean;
  49119. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49120. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49121. protected _updateModel(_xrFrame: XRFrame): void;
  49122. }
  49123. }
  49124. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49125. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49126. import { Scene } from "babylonjs/scene";
  49127. /**
  49128. * A construction function type to create a new controller based on an xrInput object
  49129. */
  49130. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49131. /**
  49132. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49133. *
  49134. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49135. * it should be replaced with auto-loaded controllers.
  49136. *
  49137. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49138. */
  49139. export class WebXRMotionControllerManager {
  49140. private static _AvailableControllers;
  49141. private static _Fallbacks;
  49142. private static _ProfileLoadingPromises;
  49143. private static _ProfilesList;
  49144. /**
  49145. * The base URL of the online controller repository. Can be changed at any time.
  49146. */
  49147. static BaseRepositoryUrl: string;
  49148. /**
  49149. * Which repository gets priority - local or online
  49150. */
  49151. static PrioritizeOnlineRepository: boolean;
  49152. /**
  49153. * Use the online repository, or use only locally-defined controllers
  49154. */
  49155. static UseOnlineRepository: boolean;
  49156. /**
  49157. * Clear the cache used for profile loading and reload when requested again
  49158. */
  49159. static ClearProfilesCache(): void;
  49160. /**
  49161. * Register the default fallbacks.
  49162. * This function is called automatically when this file is imported.
  49163. */
  49164. static DefaultFallbacks(): void;
  49165. /**
  49166. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49167. * @param profileId the profile to which a fallback needs to be found
  49168. * @return an array with corresponding fallback profiles
  49169. */
  49170. static FindFallbackWithProfileId(profileId: string): string[];
  49171. /**
  49172. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49173. * The order of search:
  49174. *
  49175. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49176. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49177. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49178. * 4) return the generic trigger controller if none were found
  49179. *
  49180. * @param xrInput the xrInput to which a new controller is initialized
  49181. * @param scene the scene to which the model will be added
  49182. * @param forceProfile force a certain profile for this controller
  49183. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49184. */
  49185. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49186. /**
  49187. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49188. *
  49189. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49190. *
  49191. * @param type the profile type to register
  49192. * @param constructFunction the function to be called when loading this profile
  49193. */
  49194. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49195. /**
  49196. * Register a fallback to a specific profile.
  49197. * @param profileId the profileId that will receive the fallbacks
  49198. * @param fallbacks A list of fallback profiles
  49199. */
  49200. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49201. /**
  49202. * Will update the list of profiles available in the repository
  49203. * @return a promise that resolves to a map of profiles available online
  49204. */
  49205. static UpdateProfilesList(): Promise<{
  49206. [profile: string]: string;
  49207. }>;
  49208. private static _LoadProfileFromRepository;
  49209. private static _LoadProfilesFromAvailableControllers;
  49210. }
  49211. }
  49212. declare module "babylonjs/XR/webXRInputSource" {
  49213. import { Observable } from "babylonjs/Misc/observable";
  49214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49215. import { Ray } from "babylonjs/Culling/ray";
  49216. import { Scene } from "babylonjs/scene";
  49217. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49218. /**
  49219. * Configuration options for the WebXR controller creation
  49220. */
  49221. export interface IWebXRControllerOptions {
  49222. /**
  49223. * Should the controller mesh be animated when a user interacts with it
  49224. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49225. */
  49226. disableMotionControllerAnimation?: boolean;
  49227. /**
  49228. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49229. */
  49230. doNotLoadControllerMesh?: boolean;
  49231. /**
  49232. * Force a specific controller type for this controller.
  49233. * This can be used when creating your own profile or when testing different controllers
  49234. */
  49235. forceControllerProfile?: string;
  49236. /**
  49237. * Defines a rendering group ID for meshes that will be loaded.
  49238. * This is for the default controllers only.
  49239. */
  49240. renderingGroupId?: number;
  49241. }
  49242. /**
  49243. * Represents an XR controller
  49244. */
  49245. export class WebXRInputSource {
  49246. private _scene;
  49247. /** The underlying input source for the controller */
  49248. inputSource: XRInputSource;
  49249. private _options;
  49250. private _tmpVector;
  49251. private _uniqueId;
  49252. /**
  49253. * 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
  49254. */
  49255. grip?: AbstractMesh;
  49256. /**
  49257. * If available, this is the gamepad object related to this controller.
  49258. * Using this object it is possible to get click events and trackpad changes of the
  49259. * webxr controller that is currently being used.
  49260. */
  49261. motionController?: WebXRAbstractMotionController;
  49262. /**
  49263. * Event that fires when the controller is removed/disposed.
  49264. * The object provided as event data is this controller, after associated assets were disposed.
  49265. * uniqueId is still available.
  49266. */
  49267. onDisposeObservable: Observable<WebXRInputSource>;
  49268. /**
  49269. * Will be triggered when the mesh associated with the motion controller is done loading.
  49270. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49271. * A shortened version of controller -> motion controller -> on mesh loaded.
  49272. */
  49273. onMeshLoadedObservable: Observable<AbstractMesh>;
  49274. /**
  49275. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49276. */
  49277. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49278. /**
  49279. * Pointer which can be used to select objects or attach a visible laser to
  49280. */
  49281. pointer: AbstractMesh;
  49282. /**
  49283. * Creates the controller
  49284. * @see https://doc.babylonjs.com/how_to/webxr
  49285. * @param _scene the scene which the controller should be associated to
  49286. * @param inputSource the underlying input source for the controller
  49287. * @param _options options for this controller creation
  49288. */
  49289. constructor(_scene: Scene,
  49290. /** The underlying input source for the controller */
  49291. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49292. /**
  49293. * Get this controllers unique id
  49294. */
  49295. get uniqueId(): string;
  49296. /**
  49297. * Disposes of the object
  49298. */
  49299. dispose(): void;
  49300. /**
  49301. * Gets a world space ray coming from the pointer or grip
  49302. * @param result the resulting ray
  49303. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49304. */
  49305. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49306. /**
  49307. * Updates the controller pose based on the given XRFrame
  49308. * @param xrFrame xr frame to update the pose with
  49309. * @param referenceSpace reference space to use
  49310. */
  49311. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49312. }
  49313. }
  49314. declare module "babylonjs/XR/webXRInput" {
  49315. import { Observable } from "babylonjs/Misc/observable";
  49316. import { IDisposable } from "babylonjs/scene";
  49317. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49318. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49319. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49320. /**
  49321. * The schema for initialization options of the XR Input class
  49322. */
  49323. export interface IWebXRInputOptions {
  49324. /**
  49325. * If set to true no model will be automatically loaded
  49326. */
  49327. doNotLoadControllerMeshes?: boolean;
  49328. /**
  49329. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49330. * If not found, the xr input profile data will be used.
  49331. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49332. */
  49333. forceInputProfile?: string;
  49334. /**
  49335. * Do not send a request to the controller repository to load the profile.
  49336. *
  49337. * Instead, use the controllers available in babylon itself.
  49338. */
  49339. disableOnlineControllerRepository?: boolean;
  49340. /**
  49341. * A custom URL for the controllers repository
  49342. */
  49343. customControllersRepositoryURL?: string;
  49344. /**
  49345. * Should the controller model's components not move according to the user input
  49346. */
  49347. disableControllerAnimation?: boolean;
  49348. /**
  49349. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49350. */
  49351. controllerOptions?: IWebXRControllerOptions;
  49352. }
  49353. /**
  49354. * XR input used to track XR inputs such as controllers/rays
  49355. */
  49356. export class WebXRInput implements IDisposable {
  49357. /**
  49358. * the xr session manager for this session
  49359. */
  49360. xrSessionManager: WebXRSessionManager;
  49361. /**
  49362. * the WebXR camera for this session. Mainly used for teleportation
  49363. */
  49364. xrCamera: WebXRCamera;
  49365. private readonly options;
  49366. /**
  49367. * XR controllers being tracked
  49368. */
  49369. controllers: Array<WebXRInputSource>;
  49370. private _frameObserver;
  49371. private _sessionEndedObserver;
  49372. private _sessionInitObserver;
  49373. /**
  49374. * Event when a controller has been connected/added
  49375. */
  49376. onControllerAddedObservable: Observable<WebXRInputSource>;
  49377. /**
  49378. * Event when a controller has been removed/disconnected
  49379. */
  49380. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49381. /**
  49382. * Initializes the WebXRInput
  49383. * @param xrSessionManager the xr session manager for this session
  49384. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49385. * @param options = initialization options for this xr input
  49386. */
  49387. constructor(
  49388. /**
  49389. * the xr session manager for this session
  49390. */
  49391. xrSessionManager: WebXRSessionManager,
  49392. /**
  49393. * the WebXR camera for this session. Mainly used for teleportation
  49394. */
  49395. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49396. private _onInputSourcesChange;
  49397. private _addAndRemoveControllers;
  49398. /**
  49399. * Disposes of the object
  49400. */
  49401. dispose(): void;
  49402. }
  49403. }
  49404. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49405. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49406. import { Observable, EventState } from "babylonjs/Misc/observable";
  49407. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49408. /**
  49409. * This is the base class for all WebXR features.
  49410. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49411. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49412. */
  49413. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49414. protected _xrSessionManager: WebXRSessionManager;
  49415. private _attached;
  49416. private _removeOnDetach;
  49417. /**
  49418. * Should auto-attach be disabled?
  49419. */
  49420. disableAutoAttach: boolean;
  49421. /**
  49422. * Construct a new (abstract) WebXR feature
  49423. * @param _xrSessionManager the xr session manager for this feature
  49424. */
  49425. constructor(_xrSessionManager: WebXRSessionManager);
  49426. /**
  49427. * Is this feature attached
  49428. */
  49429. get attached(): boolean;
  49430. /**
  49431. * attach this feature
  49432. *
  49433. * @param force should attachment be forced (even when already attached)
  49434. * @returns true if successful, false is failed or already attached
  49435. */
  49436. attach(force?: boolean): boolean;
  49437. /**
  49438. * detach this feature.
  49439. *
  49440. * @returns true if successful, false if failed or already detached
  49441. */
  49442. detach(): boolean;
  49443. /**
  49444. * Dispose this feature and all of the resources attached
  49445. */
  49446. dispose(): void;
  49447. /**
  49448. * This is used to register callbacks that will automatically be removed when detach is called.
  49449. * @param observable the observable to which the observer will be attached
  49450. * @param callback the callback to register
  49451. */
  49452. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49453. /**
  49454. * Code in this function will be executed on each xrFrame received from the browser.
  49455. * This function will not execute after the feature is detached.
  49456. * @param _xrFrame the current frame
  49457. */
  49458. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49459. }
  49460. }
  49461. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49462. import { IDisposable, Scene } from "babylonjs/scene";
  49463. import { Nullable } from "babylonjs/types";
  49464. import { Observable } from "babylonjs/Misc/observable";
  49465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49466. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49467. import { Camera } from "babylonjs/Cameras/camera";
  49468. /**
  49469. * Renders a layer on top of an existing scene
  49470. */
  49471. export class UtilityLayerRenderer implements IDisposable {
  49472. /** the original scene that will be rendered on top of */
  49473. originalScene: Scene;
  49474. private _pointerCaptures;
  49475. private _lastPointerEvents;
  49476. private static _DefaultUtilityLayer;
  49477. private static _DefaultKeepDepthUtilityLayer;
  49478. private _sharedGizmoLight;
  49479. private _renderCamera;
  49480. /**
  49481. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49482. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49483. * @returns the camera that is used when rendering the utility layer
  49484. */
  49485. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49486. /**
  49487. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49488. * @param cam the camera that should be used when rendering the utility layer
  49489. */
  49490. setRenderCamera(cam: Nullable<Camera>): void;
  49491. /**
  49492. * @hidden
  49493. * Light which used by gizmos to get light shading
  49494. */
  49495. _getSharedGizmoLight(): HemisphericLight;
  49496. /**
  49497. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49498. */
  49499. pickUtilitySceneFirst: boolean;
  49500. /**
  49501. * 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)
  49502. */
  49503. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49504. /**
  49505. * 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)
  49506. */
  49507. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49508. /**
  49509. * The scene that is rendered on top of the original scene
  49510. */
  49511. utilityLayerScene: Scene;
  49512. /**
  49513. * If the utility layer should automatically be rendered on top of existing scene
  49514. */
  49515. shouldRender: boolean;
  49516. /**
  49517. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49518. */
  49519. onlyCheckPointerDownEvents: boolean;
  49520. /**
  49521. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49522. */
  49523. processAllEvents: boolean;
  49524. /**
  49525. * Observable raised when the pointer move from the utility layer scene to the main scene
  49526. */
  49527. onPointerOutObservable: Observable<number>;
  49528. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49529. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49530. private _afterRenderObserver;
  49531. private _sceneDisposeObserver;
  49532. private _originalPointerObserver;
  49533. /**
  49534. * Instantiates a UtilityLayerRenderer
  49535. * @param originalScene the original scene that will be rendered on top of
  49536. * @param handleEvents boolean indicating if the utility layer should handle events
  49537. */
  49538. constructor(
  49539. /** the original scene that will be rendered on top of */
  49540. originalScene: Scene, handleEvents?: boolean);
  49541. private _notifyObservers;
  49542. /**
  49543. * Renders the utility layers scene on top of the original scene
  49544. */
  49545. render(): void;
  49546. /**
  49547. * Disposes of the renderer
  49548. */
  49549. dispose(): void;
  49550. private _updateCamera;
  49551. }
  49552. }
  49553. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49554. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49556. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49557. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49558. import { Scene } from "babylonjs/scene";
  49559. import { Nullable } from "babylonjs/types";
  49560. import { Color3 } from "babylonjs/Maths/math.color";
  49561. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49562. /**
  49563. * Options interface for the pointer selection module
  49564. */
  49565. export interface IWebXRControllerPointerSelectionOptions {
  49566. /**
  49567. * if provided, this scene will be used to render meshes.
  49568. */
  49569. customUtilityLayerScene?: Scene;
  49570. /**
  49571. * 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)
  49572. * If not disabled, the last picked point will be used to execute a pointer up event
  49573. * If disabled, pointer up event will be triggered right after the pointer down event.
  49574. * Used in screen and gaze target ray mode only
  49575. */
  49576. disablePointerUpOnTouchOut: boolean;
  49577. /**
  49578. * For gaze mode (time to select instead of press)
  49579. */
  49580. forceGazeMode: boolean;
  49581. /**
  49582. * 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
  49583. * to start a new countdown to the pointer down event.
  49584. * Defaults to 1.
  49585. */
  49586. gazeModePointerMovedFactor?: number;
  49587. /**
  49588. * Different button type to use instead of the main component
  49589. */
  49590. overrideButtonId?: string;
  49591. /**
  49592. * use this rendering group id for the meshes (optional)
  49593. */
  49594. renderingGroupId?: number;
  49595. /**
  49596. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49597. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49598. * 3000 means 3 seconds between pointing at something and selecting it
  49599. */
  49600. timeToSelect?: number;
  49601. /**
  49602. * Should meshes created here be added to a utility layer or the main scene
  49603. */
  49604. useUtilityLayer?: boolean;
  49605. /**
  49606. * the xr input to use with this pointer selection
  49607. */
  49608. xrInput: WebXRInput;
  49609. }
  49610. /**
  49611. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49612. */
  49613. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49614. private readonly _options;
  49615. private static _idCounter;
  49616. private _attachController;
  49617. private _controllers;
  49618. private _scene;
  49619. private _tmpVectorForPickCompare;
  49620. /**
  49621. * The module's name
  49622. */
  49623. static readonly Name: string;
  49624. /**
  49625. * The (Babylon) version of this module.
  49626. * This is an integer representing the implementation version.
  49627. * This number does not correspond to the WebXR specs version
  49628. */
  49629. static readonly Version: number;
  49630. /**
  49631. * Disable lighting on the laser pointer (so it will always be visible)
  49632. */
  49633. disablePointerLighting: boolean;
  49634. /**
  49635. * Disable lighting on the selection mesh (so it will always be visible)
  49636. */
  49637. disableSelectionMeshLighting: boolean;
  49638. /**
  49639. * Should the laser pointer be displayed
  49640. */
  49641. displayLaserPointer: boolean;
  49642. /**
  49643. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49644. */
  49645. displaySelectionMesh: boolean;
  49646. /**
  49647. * This color will be set to the laser pointer when selection is triggered
  49648. */
  49649. laserPointerPickedColor: Color3;
  49650. /**
  49651. * Default color of the laser pointer
  49652. */
  49653. laserPointerDefaultColor: Color3;
  49654. /**
  49655. * default color of the selection ring
  49656. */
  49657. selectionMeshDefaultColor: Color3;
  49658. /**
  49659. * This color will be applied to the selection ring when selection is triggered
  49660. */
  49661. selectionMeshPickedColor: Color3;
  49662. /**
  49663. * Optional filter to be used for ray selection. This predicate shares behavior with
  49664. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49665. */
  49666. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49667. /**
  49668. * constructs a new background remover module
  49669. * @param _xrSessionManager the session manager for this module
  49670. * @param _options read-only options to be used in this module
  49671. */
  49672. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49673. /**
  49674. * attach this feature
  49675. * Will usually be called by the features manager
  49676. *
  49677. * @returns true if successful.
  49678. */
  49679. attach(): boolean;
  49680. /**
  49681. * detach this feature.
  49682. * Will usually be called by the features manager
  49683. *
  49684. * @returns true if successful.
  49685. */
  49686. detach(): boolean;
  49687. /**
  49688. * Will get the mesh under a specific pointer.
  49689. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49690. * @param controllerId the controllerId to check
  49691. * @returns The mesh under pointer or null if no mesh is under the pointer
  49692. */
  49693. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49694. /**
  49695. * Get the xr controller that correlates to the pointer id in the pointer event
  49696. *
  49697. * @param id the pointer id to search for
  49698. * @returns the controller that correlates to this id or null if not found
  49699. */
  49700. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49701. protected _onXRFrame(_xrFrame: XRFrame): void;
  49702. private _attachGazeMode;
  49703. private _attachScreenRayMode;
  49704. private _attachTrackedPointerRayMode;
  49705. private _convertNormalToDirectionOfRay;
  49706. private _detachController;
  49707. private _generateNewMeshPair;
  49708. private _pickingMoved;
  49709. private _updatePointerDistance;
  49710. /** @hidden */
  49711. get lasterPointerDefaultColor(): Color3;
  49712. }
  49713. }
  49714. declare module "babylonjs/XR/webXREnterExitUI" {
  49715. import { Nullable } from "babylonjs/types";
  49716. import { Observable } from "babylonjs/Misc/observable";
  49717. import { IDisposable, Scene } from "babylonjs/scene";
  49718. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49719. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49720. /**
  49721. * Button which can be used to enter a different mode of XR
  49722. */
  49723. export class WebXREnterExitUIButton {
  49724. /** button element */
  49725. element: HTMLElement;
  49726. /** XR initialization options for the button */
  49727. sessionMode: XRSessionMode;
  49728. /** Reference space type */
  49729. referenceSpaceType: XRReferenceSpaceType;
  49730. /**
  49731. * Creates a WebXREnterExitUIButton
  49732. * @param element button element
  49733. * @param sessionMode XR initialization session mode
  49734. * @param referenceSpaceType the type of reference space to be used
  49735. */
  49736. constructor(
  49737. /** button element */
  49738. element: HTMLElement,
  49739. /** XR initialization options for the button */
  49740. sessionMode: XRSessionMode,
  49741. /** Reference space type */
  49742. referenceSpaceType: XRReferenceSpaceType);
  49743. /**
  49744. * Extendable function which can be used to update the button's visuals when the state changes
  49745. * @param activeButton the current active button in the UI
  49746. */
  49747. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49748. }
  49749. /**
  49750. * Options to create the webXR UI
  49751. */
  49752. export class WebXREnterExitUIOptions {
  49753. /**
  49754. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49755. */
  49756. customButtons?: Array<WebXREnterExitUIButton>;
  49757. /**
  49758. * A reference space type to use when creating the default button.
  49759. * Default is local-floor
  49760. */
  49761. referenceSpaceType?: XRReferenceSpaceType;
  49762. /**
  49763. * Context to enter xr with
  49764. */
  49765. renderTarget?: Nullable<WebXRRenderTarget>;
  49766. /**
  49767. * A session mode to use when creating the default button.
  49768. * Default is immersive-vr
  49769. */
  49770. sessionMode?: XRSessionMode;
  49771. /**
  49772. * A list of optional features to init the session with
  49773. */
  49774. optionalFeatures?: string[];
  49775. }
  49776. /**
  49777. * UI to allow the user to enter/exit XR mode
  49778. */
  49779. export class WebXREnterExitUI implements IDisposable {
  49780. private scene;
  49781. /** version of the options passed to this UI */
  49782. options: WebXREnterExitUIOptions;
  49783. private _activeButton;
  49784. private _buttons;
  49785. private _overlay;
  49786. /**
  49787. * Fired every time the active button is changed.
  49788. *
  49789. * When xr is entered via a button that launches xr that button will be the callback parameter
  49790. *
  49791. * When exiting xr the callback parameter will be null)
  49792. */
  49793. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49794. /**
  49795. *
  49796. * @param scene babylon scene object to use
  49797. * @param options (read-only) version of the options passed to this UI
  49798. */
  49799. private constructor();
  49800. /**
  49801. * Creates UI to allow the user to enter/exit XR mode
  49802. * @param scene the scene to add the ui to
  49803. * @param helper the xr experience helper to enter/exit xr with
  49804. * @param options options to configure the UI
  49805. * @returns the created ui
  49806. */
  49807. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49808. /**
  49809. * Disposes of the XR UI component
  49810. */
  49811. dispose(): void;
  49812. private _updateButtons;
  49813. }
  49814. }
  49815. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49816. import { Vector3 } from "babylonjs/Maths/math.vector";
  49817. import { Color4 } from "babylonjs/Maths/math.color";
  49818. import { Nullable } from "babylonjs/types";
  49819. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49820. import { Scene } from "babylonjs/scene";
  49821. /**
  49822. * Class containing static functions to help procedurally build meshes
  49823. */
  49824. export class LinesBuilder {
  49825. /**
  49826. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49827. * * 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
  49828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49829. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49830. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49831. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49832. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49833. * * 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
  49834. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49837. * @param name defines the name of the new line system
  49838. * @param options defines the options used to create the line system
  49839. * @param scene defines the hosting scene
  49840. * @returns a new line system mesh
  49841. */
  49842. static CreateLineSystem(name: string, options: {
  49843. lines: Vector3[][];
  49844. updatable?: boolean;
  49845. instance?: Nullable<LinesMesh>;
  49846. colors?: Nullable<Color4[][]>;
  49847. useVertexAlpha?: boolean;
  49848. }, scene: Nullable<Scene>): LinesMesh;
  49849. /**
  49850. * Creates a line mesh
  49851. * 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
  49852. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49853. * * The parameter `points` is an array successive Vector3
  49854. * * 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
  49855. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49856. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49857. * * When updating an instance, remember that only point positions can change, not the number of points
  49858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49860. * @param name defines the name of the new line system
  49861. * @param options defines the options used to create the line system
  49862. * @param scene defines the hosting scene
  49863. * @returns a new line mesh
  49864. */
  49865. static CreateLines(name: string, options: {
  49866. points: Vector3[];
  49867. updatable?: boolean;
  49868. instance?: Nullable<LinesMesh>;
  49869. colors?: Color4[];
  49870. useVertexAlpha?: boolean;
  49871. }, scene?: Nullable<Scene>): LinesMesh;
  49872. /**
  49873. * Creates a dashed line mesh
  49874. * * 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
  49875. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49876. * * The parameter `points` is an array successive Vector3
  49877. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49878. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49879. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49880. * * 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
  49881. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49882. * * When updating an instance, remember that only point positions can change, not the number of points
  49883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49884. * @param name defines the name of the mesh
  49885. * @param options defines the options used to create the mesh
  49886. * @param scene defines the hosting scene
  49887. * @returns the dashed line mesh
  49888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49889. */
  49890. static CreateDashedLines(name: string, options: {
  49891. points: Vector3[];
  49892. dashSize?: number;
  49893. gapSize?: number;
  49894. dashNb?: number;
  49895. updatable?: boolean;
  49896. instance?: LinesMesh;
  49897. useVertexAlpha?: boolean;
  49898. }, scene?: Nullable<Scene>): LinesMesh;
  49899. }
  49900. }
  49901. declare module "babylonjs/Misc/timer" {
  49902. import { Observable, Observer } from "babylonjs/Misc/observable";
  49903. import { Nullable } from "babylonjs/types";
  49904. import { IDisposable } from "babylonjs/scene";
  49905. /**
  49906. * Construction options for a timer
  49907. */
  49908. export interface ITimerOptions<T> {
  49909. /**
  49910. * Time-to-end
  49911. */
  49912. timeout: number;
  49913. /**
  49914. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49915. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49916. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49917. */
  49918. contextObservable: Observable<T>;
  49919. /**
  49920. * Optional parameters when adding an observer to the observable
  49921. */
  49922. observableParameters?: {
  49923. mask?: number;
  49924. insertFirst?: boolean;
  49925. scope?: any;
  49926. };
  49927. /**
  49928. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49929. */
  49930. breakCondition?: (data?: ITimerData<T>) => boolean;
  49931. /**
  49932. * Will be triggered when the time condition has met
  49933. */
  49934. onEnded?: (data: ITimerData<any>) => void;
  49935. /**
  49936. * Will be triggered when the break condition has met (prematurely ended)
  49937. */
  49938. onAborted?: (data: ITimerData<any>) => void;
  49939. /**
  49940. * Optional function to execute on each tick (or count)
  49941. */
  49942. onTick?: (data: ITimerData<any>) => void;
  49943. }
  49944. /**
  49945. * An interface defining the data sent by the timer
  49946. */
  49947. export interface ITimerData<T> {
  49948. /**
  49949. * When did it start
  49950. */
  49951. startTime: number;
  49952. /**
  49953. * Time now
  49954. */
  49955. currentTime: number;
  49956. /**
  49957. * Time passed since started
  49958. */
  49959. deltaTime: number;
  49960. /**
  49961. * How much is completed, in [0.0...1.0].
  49962. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49963. */
  49964. completeRate: number;
  49965. /**
  49966. * What the registered observable sent in the last count
  49967. */
  49968. payload: T;
  49969. }
  49970. /**
  49971. * The current state of the timer
  49972. */
  49973. export enum TimerState {
  49974. /**
  49975. * Timer initialized, not yet started
  49976. */
  49977. INIT = 0,
  49978. /**
  49979. * Timer started and counting
  49980. */
  49981. STARTED = 1,
  49982. /**
  49983. * Timer ended (whether aborted or time reached)
  49984. */
  49985. ENDED = 2
  49986. }
  49987. /**
  49988. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49989. *
  49990. * @param options options with which to initialize this timer
  49991. */
  49992. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49993. /**
  49994. * An advanced implementation of a timer class
  49995. */
  49996. export class AdvancedTimer<T = any> implements IDisposable {
  49997. /**
  49998. * Will notify each time the timer calculates the remaining time
  49999. */
  50000. onEachCountObservable: Observable<ITimerData<T>>;
  50001. /**
  50002. * Will trigger when the timer was aborted due to the break condition
  50003. */
  50004. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50005. /**
  50006. * Will trigger when the timer ended successfully
  50007. */
  50008. onTimerEndedObservable: Observable<ITimerData<T>>;
  50009. /**
  50010. * Will trigger when the timer state has changed
  50011. */
  50012. onStateChangedObservable: Observable<TimerState>;
  50013. private _observer;
  50014. private _contextObservable;
  50015. private _observableParameters;
  50016. private _startTime;
  50017. private _timer;
  50018. private _state;
  50019. private _breakCondition;
  50020. private _timeToEnd;
  50021. private _breakOnNextTick;
  50022. /**
  50023. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50024. * @param options construction options for this advanced timer
  50025. */
  50026. constructor(options: ITimerOptions<T>);
  50027. /**
  50028. * set a breaking condition for this timer. Default is to never break during count
  50029. * @param predicate the new break condition. Returns true to break, false otherwise
  50030. */
  50031. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50032. /**
  50033. * Reset ALL associated observables in this advanced timer
  50034. */
  50035. clearObservables(): void;
  50036. /**
  50037. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50038. *
  50039. * @param timeToEnd how much time to measure until timer ended
  50040. */
  50041. start(timeToEnd?: number): void;
  50042. /**
  50043. * Will force a stop on the next tick.
  50044. */
  50045. stop(): void;
  50046. /**
  50047. * Dispose this timer, clearing all resources
  50048. */
  50049. dispose(): void;
  50050. private _setState;
  50051. private _tick;
  50052. private _stop;
  50053. }
  50054. }
  50055. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50056. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50057. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50058. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50060. import { Vector3 } from "babylonjs/Maths/math.vector";
  50061. import { Material } from "babylonjs/Materials/material";
  50062. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50063. import { Scene } from "babylonjs/scene";
  50064. /**
  50065. * The options container for the teleportation module
  50066. */
  50067. export interface IWebXRTeleportationOptions {
  50068. /**
  50069. * if provided, this scene will be used to render meshes.
  50070. */
  50071. customUtilityLayerScene?: Scene;
  50072. /**
  50073. * Values to configure the default target mesh
  50074. */
  50075. defaultTargetMeshOptions?: {
  50076. /**
  50077. * Fill color of the teleportation area
  50078. */
  50079. teleportationFillColor?: string;
  50080. /**
  50081. * Border color for the teleportation area
  50082. */
  50083. teleportationBorderColor?: string;
  50084. /**
  50085. * Disable the mesh's animation sequence
  50086. */
  50087. disableAnimation?: boolean;
  50088. /**
  50089. * Disable lighting on the material or the ring and arrow
  50090. */
  50091. disableLighting?: boolean;
  50092. /**
  50093. * Override the default material of the torus and arrow
  50094. */
  50095. torusArrowMaterial?: Material;
  50096. };
  50097. /**
  50098. * A list of meshes to use as floor meshes.
  50099. * Meshes can be added and removed after initializing the feature using the
  50100. * addFloorMesh and removeFloorMesh functions
  50101. * If empty, rotation will still work
  50102. */
  50103. floorMeshes?: AbstractMesh[];
  50104. /**
  50105. * use this rendering group id for the meshes (optional)
  50106. */
  50107. renderingGroupId?: number;
  50108. /**
  50109. * Should teleportation move only to snap points
  50110. */
  50111. snapPointsOnly?: boolean;
  50112. /**
  50113. * An array of points to which the teleportation will snap to.
  50114. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50115. */
  50116. snapPositions?: Vector3[];
  50117. /**
  50118. * How close should the teleportation ray be in order to snap to position.
  50119. * Default to 0.8 units (meters)
  50120. */
  50121. snapToPositionRadius?: number;
  50122. /**
  50123. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50124. * If you want to support rotation, make sure your mesh has a direction indicator.
  50125. *
  50126. * When left untouched, the default mesh will be initialized.
  50127. */
  50128. teleportationTargetMesh?: AbstractMesh;
  50129. /**
  50130. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50131. */
  50132. timeToTeleport?: number;
  50133. /**
  50134. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50135. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50136. */
  50137. useMainComponentOnly?: boolean;
  50138. /**
  50139. * Should meshes created here be added to a utility layer or the main scene
  50140. */
  50141. useUtilityLayer?: boolean;
  50142. /**
  50143. * Babylon XR Input class for controller
  50144. */
  50145. xrInput: WebXRInput;
  50146. }
  50147. /**
  50148. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50149. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50150. * the input of the attached controllers.
  50151. */
  50152. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50153. private _options;
  50154. private _controllers;
  50155. private _currentTeleportationControllerId;
  50156. private _floorMeshes;
  50157. private _quadraticBezierCurve;
  50158. private _selectionFeature;
  50159. private _snapToPositions;
  50160. private _snappedToPoint;
  50161. private _teleportationRingMaterial?;
  50162. private _tmpRay;
  50163. private _tmpVector;
  50164. /**
  50165. * The module's name
  50166. */
  50167. static readonly Name: string;
  50168. /**
  50169. * The (Babylon) version of this module.
  50170. * This is an integer representing the implementation version.
  50171. * This number does not correspond to the webxr specs version
  50172. */
  50173. static readonly Version: number;
  50174. /**
  50175. * Is movement backwards enabled
  50176. */
  50177. backwardsMovementEnabled: boolean;
  50178. /**
  50179. * Distance to travel when moving backwards
  50180. */
  50181. backwardsTeleportationDistance: number;
  50182. /**
  50183. * The distance from the user to the inspection point in the direction of the controller
  50184. * A higher number will allow the user to move further
  50185. * defaults to 5 (meters, in xr units)
  50186. */
  50187. parabolicCheckRadius: number;
  50188. /**
  50189. * Should the module support parabolic ray on top of direct ray
  50190. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50191. * Very helpful when moving between floors / different heights
  50192. */
  50193. parabolicRayEnabled: boolean;
  50194. /**
  50195. * How much rotation should be applied when rotating right and left
  50196. */
  50197. rotationAngle: number;
  50198. /**
  50199. * Is rotation enabled when moving forward?
  50200. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50201. */
  50202. rotationEnabled: boolean;
  50203. /**
  50204. * constructs a new anchor system
  50205. * @param _xrSessionManager an instance of WebXRSessionManager
  50206. * @param _options configuration object for this feature
  50207. */
  50208. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50209. /**
  50210. * Get the snapPointsOnly flag
  50211. */
  50212. get snapPointsOnly(): boolean;
  50213. /**
  50214. * Sets the snapPointsOnly flag
  50215. * @param snapToPoints should teleportation be exclusively to snap points
  50216. */
  50217. set snapPointsOnly(snapToPoints: boolean);
  50218. /**
  50219. * Add a new mesh to the floor meshes array
  50220. * @param mesh the mesh to use as floor mesh
  50221. */
  50222. addFloorMesh(mesh: AbstractMesh): void;
  50223. /**
  50224. * Add a new snap-to point to fix teleportation to this position
  50225. * @param newSnapPoint The new Snap-To point
  50226. */
  50227. addSnapPoint(newSnapPoint: Vector3): void;
  50228. attach(): boolean;
  50229. detach(): boolean;
  50230. dispose(): void;
  50231. /**
  50232. * Remove a mesh from the floor meshes array
  50233. * @param mesh the mesh to remove
  50234. */
  50235. removeFloorMesh(mesh: AbstractMesh): void;
  50236. /**
  50237. * Remove a mesh from the floor meshes array using its name
  50238. * @param name the mesh name to remove
  50239. */
  50240. removeFloorMeshByName(name: string): void;
  50241. /**
  50242. * 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
  50243. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50244. * @returns was the point found and removed or not
  50245. */
  50246. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50247. /**
  50248. * This function sets a selection feature that will be disabled when
  50249. * the forward ray is shown and will be reattached when hidden.
  50250. * This is used to remove the selection rays when moving.
  50251. * @param selectionFeature the feature to disable when forward movement is enabled
  50252. */
  50253. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50254. protected _onXRFrame(_xrFrame: XRFrame): void;
  50255. private _attachController;
  50256. private _createDefaultTargetMesh;
  50257. private _detachController;
  50258. private _findClosestSnapPointWithRadius;
  50259. private _setTargetMeshPosition;
  50260. private _setTargetMeshVisibility;
  50261. private _showParabolicPath;
  50262. private _teleportForward;
  50263. }
  50264. }
  50265. declare module "babylonjs/XR/webXRDefaultExperience" {
  50266. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50267. import { Scene } from "babylonjs/scene";
  50268. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50269. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50270. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50271. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50273. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50274. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50275. /**
  50276. * Options for the default xr helper
  50277. */
  50278. export class WebXRDefaultExperienceOptions {
  50279. /**
  50280. * Enable or disable default UI to enter XR
  50281. */
  50282. disableDefaultUI?: boolean;
  50283. /**
  50284. * Should teleportation not initialize. defaults to false.
  50285. */
  50286. disableTeleportation?: boolean;
  50287. /**
  50288. * Floor meshes that will be used for teleport
  50289. */
  50290. floorMeshes?: Array<AbstractMesh>;
  50291. /**
  50292. * If set to true, the first frame will not be used to reset position
  50293. * The first frame is mainly used when copying transformation from the old camera
  50294. * Mainly used in AR
  50295. */
  50296. ignoreNativeCameraTransformation?: boolean;
  50297. /**
  50298. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50299. */
  50300. inputOptions?: IWebXRInputOptions;
  50301. /**
  50302. * optional configuration for the output canvas
  50303. */
  50304. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50305. /**
  50306. * optional UI options. This can be used among other to change session mode and reference space type
  50307. */
  50308. uiOptions?: WebXREnterExitUIOptions;
  50309. /**
  50310. * When loading teleportation and pointer select, use stable versions instead of latest.
  50311. */
  50312. useStablePlugins?: boolean;
  50313. /**
  50314. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50315. */
  50316. renderingGroupId?: number;
  50317. /**
  50318. * A list of optional features to init the session with
  50319. * If set to true, all features we support will be added
  50320. */
  50321. optionalFeatures?: boolean | string[];
  50322. }
  50323. /**
  50324. * Default experience which provides a similar setup to the previous webVRExperience
  50325. */
  50326. export class WebXRDefaultExperience {
  50327. /**
  50328. * Base experience
  50329. */
  50330. baseExperience: WebXRExperienceHelper;
  50331. /**
  50332. * Enables ui for entering/exiting xr
  50333. */
  50334. enterExitUI: WebXREnterExitUI;
  50335. /**
  50336. * Input experience extension
  50337. */
  50338. input: WebXRInput;
  50339. /**
  50340. * Enables laser pointer and selection
  50341. */
  50342. pointerSelection: WebXRControllerPointerSelection;
  50343. /**
  50344. * Default target xr should render to
  50345. */
  50346. renderTarget: WebXRRenderTarget;
  50347. /**
  50348. * Enables teleportation
  50349. */
  50350. teleportation: WebXRMotionControllerTeleportation;
  50351. private constructor();
  50352. /**
  50353. * Creates the default xr experience
  50354. * @param scene scene
  50355. * @param options options for basic configuration
  50356. * @returns resulting WebXRDefaultExperience
  50357. */
  50358. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50359. /**
  50360. * DIsposes of the experience helper
  50361. */
  50362. dispose(): void;
  50363. }
  50364. }
  50365. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50366. import { Observable } from "babylonjs/Misc/observable";
  50367. import { Nullable } from "babylonjs/types";
  50368. import { Camera } from "babylonjs/Cameras/camera";
  50369. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50370. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50371. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50372. import { Scene } from "babylonjs/scene";
  50373. import { Vector3 } from "babylonjs/Maths/math.vector";
  50374. import { Color3 } from "babylonjs/Maths/math.color";
  50375. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50377. import { Mesh } from "babylonjs/Meshes/mesh";
  50378. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50379. import { EasingFunction } from "babylonjs/Animations/easing";
  50380. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50381. import "babylonjs/Meshes/Builders/groundBuilder";
  50382. import "babylonjs/Meshes/Builders/torusBuilder";
  50383. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50384. import "babylonjs/Gamepads/gamepadSceneComponent";
  50385. import "babylonjs/Animations/animatable";
  50386. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50387. /**
  50388. * Options to modify the vr teleportation behavior.
  50389. */
  50390. export interface VRTeleportationOptions {
  50391. /**
  50392. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50393. */
  50394. floorMeshName?: string;
  50395. /**
  50396. * A list of meshes to be used as the teleportation floor. (default: empty)
  50397. */
  50398. floorMeshes?: Mesh[];
  50399. /**
  50400. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50401. */
  50402. teleportationMode?: number;
  50403. /**
  50404. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50405. */
  50406. teleportationTime?: number;
  50407. /**
  50408. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50409. */
  50410. teleportationSpeed?: number;
  50411. /**
  50412. * The easing function used in the animation or null for Linear. (default CircleEase)
  50413. */
  50414. easingFunction?: EasingFunction;
  50415. }
  50416. /**
  50417. * Options to modify the vr experience helper's behavior.
  50418. */
  50419. export interface VRExperienceHelperOptions extends WebVROptions {
  50420. /**
  50421. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50422. */
  50423. createDeviceOrientationCamera?: boolean;
  50424. /**
  50425. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50426. */
  50427. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50428. /**
  50429. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50430. */
  50431. laserToggle?: boolean;
  50432. /**
  50433. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50434. */
  50435. floorMeshes?: Mesh[];
  50436. /**
  50437. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50438. */
  50439. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50440. /**
  50441. * Defines if WebXR should be used instead of WebVR (if available)
  50442. */
  50443. useXR?: boolean;
  50444. }
  50445. /**
  50446. * Event containing information after VR has been entered
  50447. */
  50448. export class OnAfterEnteringVRObservableEvent {
  50449. /**
  50450. * If entering vr was successful
  50451. */
  50452. success: boolean;
  50453. }
  50454. /**
  50455. * Helps to quickly add VR support to an existing scene.
  50456. * See http://doc.babylonjs.com/how_to/webvr_helper
  50457. */
  50458. export class VRExperienceHelper {
  50459. /** Options to modify the vr experience helper's behavior. */
  50460. webVROptions: VRExperienceHelperOptions;
  50461. private _scene;
  50462. private _position;
  50463. private _btnVR;
  50464. private _btnVRDisplayed;
  50465. private _webVRsupported;
  50466. private _webVRready;
  50467. private _webVRrequesting;
  50468. private _webVRpresenting;
  50469. private _hasEnteredVR;
  50470. private _fullscreenVRpresenting;
  50471. private _inputElement;
  50472. private _webVRCamera;
  50473. private _vrDeviceOrientationCamera;
  50474. private _deviceOrientationCamera;
  50475. private _existingCamera;
  50476. private _onKeyDown;
  50477. private _onVrDisplayPresentChange;
  50478. private _onVRDisplayChanged;
  50479. private _onVRRequestPresentStart;
  50480. private _onVRRequestPresentComplete;
  50481. /**
  50482. * 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)
  50483. */
  50484. enableGazeEvenWhenNoPointerLock: boolean;
  50485. /**
  50486. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50487. */
  50488. exitVROnDoubleTap: boolean;
  50489. /**
  50490. * Observable raised right before entering VR.
  50491. */
  50492. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50493. /**
  50494. * Observable raised when entering VR has completed.
  50495. */
  50496. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50497. /**
  50498. * Observable raised when exiting VR.
  50499. */
  50500. onExitingVRObservable: Observable<VRExperienceHelper>;
  50501. /**
  50502. * Observable raised when controller mesh is loaded.
  50503. */
  50504. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50505. /** Return this.onEnteringVRObservable
  50506. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50507. */
  50508. get onEnteringVR(): Observable<VRExperienceHelper>;
  50509. /** Return this.onExitingVRObservable
  50510. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50511. */
  50512. get onExitingVR(): Observable<VRExperienceHelper>;
  50513. /** Return this.onControllerMeshLoadedObservable
  50514. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50515. */
  50516. get onControllerMeshLoaded(): Observable<WebVRController>;
  50517. private _rayLength;
  50518. private _useCustomVRButton;
  50519. private _teleportationRequested;
  50520. private _teleportActive;
  50521. private _floorMeshName;
  50522. private _floorMeshesCollection;
  50523. private _teleportationMode;
  50524. private _teleportationTime;
  50525. private _teleportationSpeed;
  50526. private _teleportationEasing;
  50527. private _rotationAllowed;
  50528. private _teleportBackwardsVector;
  50529. private _teleportationTarget;
  50530. private _isDefaultTeleportationTarget;
  50531. private _postProcessMove;
  50532. private _teleportationFillColor;
  50533. private _teleportationBorderColor;
  50534. private _rotationAngle;
  50535. private _haloCenter;
  50536. private _cameraGazer;
  50537. private _padSensibilityUp;
  50538. private _padSensibilityDown;
  50539. private _leftController;
  50540. private _rightController;
  50541. private _gazeColor;
  50542. private _laserColor;
  50543. private _pickedLaserColor;
  50544. private _pickedGazeColor;
  50545. /**
  50546. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50547. */
  50548. onNewMeshSelected: Observable<AbstractMesh>;
  50549. /**
  50550. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50551. * This observable will provide the mesh and the controller used to select the mesh
  50552. */
  50553. onMeshSelectedWithController: Observable<{
  50554. mesh: AbstractMesh;
  50555. controller: WebVRController;
  50556. }>;
  50557. /**
  50558. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50559. */
  50560. onNewMeshPicked: Observable<PickingInfo>;
  50561. private _circleEase;
  50562. /**
  50563. * Observable raised before camera teleportation
  50564. */
  50565. onBeforeCameraTeleport: Observable<Vector3>;
  50566. /**
  50567. * Observable raised after camera teleportation
  50568. */
  50569. onAfterCameraTeleport: Observable<Vector3>;
  50570. /**
  50571. * Observable raised when current selected mesh gets unselected
  50572. */
  50573. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50574. private _raySelectionPredicate;
  50575. /**
  50576. * To be optionaly changed by user to define custom ray selection
  50577. */
  50578. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50579. /**
  50580. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50581. */
  50582. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50583. /**
  50584. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50585. */
  50586. teleportationEnabled: boolean;
  50587. private _defaultHeight;
  50588. private _teleportationInitialized;
  50589. private _interactionsEnabled;
  50590. private _interactionsRequested;
  50591. private _displayGaze;
  50592. private _displayLaserPointer;
  50593. /**
  50594. * The mesh used to display where the user is going to teleport.
  50595. */
  50596. get teleportationTarget(): Mesh;
  50597. /**
  50598. * Sets the mesh to be used to display where the user is going to teleport.
  50599. */
  50600. set teleportationTarget(value: Mesh);
  50601. /**
  50602. * 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
  50603. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50604. * See http://doc.babylonjs.com/resources/baking_transformations
  50605. */
  50606. get gazeTrackerMesh(): Mesh;
  50607. set gazeTrackerMesh(value: Mesh);
  50608. /**
  50609. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50610. */
  50611. updateGazeTrackerScale: boolean;
  50612. /**
  50613. * If the gaze trackers color should be updated when selecting meshes
  50614. */
  50615. updateGazeTrackerColor: boolean;
  50616. /**
  50617. * If the controller laser color should be updated when selecting meshes
  50618. */
  50619. updateControllerLaserColor: boolean;
  50620. /**
  50621. * The gaze tracking mesh corresponding to the left controller
  50622. */
  50623. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50624. /**
  50625. * The gaze tracking mesh corresponding to the right controller
  50626. */
  50627. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50628. /**
  50629. * If the ray of the gaze should be displayed.
  50630. */
  50631. get displayGaze(): boolean;
  50632. /**
  50633. * Sets if the ray of the gaze should be displayed.
  50634. */
  50635. set displayGaze(value: boolean);
  50636. /**
  50637. * If the ray of the LaserPointer should be displayed.
  50638. */
  50639. get displayLaserPointer(): boolean;
  50640. /**
  50641. * Sets if the ray of the LaserPointer should be displayed.
  50642. */
  50643. set displayLaserPointer(value: boolean);
  50644. /**
  50645. * The deviceOrientationCamera used as the camera when not in VR.
  50646. */
  50647. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50648. /**
  50649. * Based on the current WebVR support, returns the current VR camera used.
  50650. */
  50651. get currentVRCamera(): Nullable<Camera>;
  50652. /**
  50653. * The webVRCamera which is used when in VR.
  50654. */
  50655. get webVRCamera(): WebVRFreeCamera;
  50656. /**
  50657. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50658. */
  50659. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50660. /**
  50661. * The html button that is used to trigger entering into VR.
  50662. */
  50663. get vrButton(): Nullable<HTMLButtonElement>;
  50664. private get _teleportationRequestInitiated();
  50665. /**
  50666. * Defines whether or not Pointer lock should be requested when switching to
  50667. * full screen.
  50668. */
  50669. requestPointerLockOnFullScreen: boolean;
  50670. /**
  50671. * If asking to force XR, this will be populated with the default xr experience
  50672. */
  50673. xr: WebXRDefaultExperience;
  50674. /**
  50675. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50676. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50677. */
  50678. xrTestDone: boolean;
  50679. /**
  50680. * Instantiates a VRExperienceHelper.
  50681. * Helps to quickly add VR support to an existing scene.
  50682. * @param scene The scene the VRExperienceHelper belongs to.
  50683. * @param webVROptions Options to modify the vr experience helper's behavior.
  50684. */
  50685. constructor(scene: Scene,
  50686. /** Options to modify the vr experience helper's behavior. */
  50687. webVROptions?: VRExperienceHelperOptions);
  50688. private completeVRInit;
  50689. private _onDefaultMeshLoaded;
  50690. private _onResize;
  50691. private _onFullscreenChange;
  50692. /**
  50693. * Gets a value indicating if we are currently in VR mode.
  50694. */
  50695. get isInVRMode(): boolean;
  50696. private onVrDisplayPresentChange;
  50697. private onVRDisplayChanged;
  50698. private moveButtonToBottomRight;
  50699. private displayVRButton;
  50700. private updateButtonVisibility;
  50701. private _cachedAngularSensibility;
  50702. /**
  50703. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50704. * Otherwise, will use the fullscreen API.
  50705. */
  50706. enterVR(): void;
  50707. /**
  50708. * Attempt to exit VR, or fullscreen.
  50709. */
  50710. exitVR(): void;
  50711. /**
  50712. * The position of the vr experience helper.
  50713. */
  50714. get position(): Vector3;
  50715. /**
  50716. * Sets the position of the vr experience helper.
  50717. */
  50718. set position(value: Vector3);
  50719. /**
  50720. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50721. */
  50722. enableInteractions(): void;
  50723. private get _noControllerIsActive();
  50724. private beforeRender;
  50725. private _isTeleportationFloor;
  50726. /**
  50727. * Adds a floor mesh to be used for teleportation.
  50728. * @param floorMesh the mesh to be used for teleportation.
  50729. */
  50730. addFloorMesh(floorMesh: Mesh): void;
  50731. /**
  50732. * Removes a floor mesh from being used for teleportation.
  50733. * @param floorMesh the mesh to be removed.
  50734. */
  50735. removeFloorMesh(floorMesh: Mesh): void;
  50736. /**
  50737. * Enables interactions and teleportation using the VR controllers and gaze.
  50738. * @param vrTeleportationOptions options to modify teleportation behavior.
  50739. */
  50740. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50741. private _onNewGamepadConnected;
  50742. private _tryEnableInteractionOnController;
  50743. private _onNewGamepadDisconnected;
  50744. private _enableInteractionOnController;
  50745. private _checkTeleportWithRay;
  50746. private _checkRotate;
  50747. private _checkTeleportBackwards;
  50748. private _enableTeleportationOnController;
  50749. private _createTeleportationCircles;
  50750. private _displayTeleportationTarget;
  50751. private _hideTeleportationTarget;
  50752. private _rotateCamera;
  50753. private _moveTeleportationSelectorTo;
  50754. private _workingVector;
  50755. private _workingQuaternion;
  50756. private _workingMatrix;
  50757. /**
  50758. * Time Constant Teleportation Mode
  50759. */
  50760. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50761. /**
  50762. * Speed Constant Teleportation Mode
  50763. */
  50764. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50765. /**
  50766. * Teleports the users feet to the desired location
  50767. * @param location The location where the user's feet should be placed
  50768. */
  50769. teleportCamera(location: Vector3): void;
  50770. private _convertNormalToDirectionOfRay;
  50771. private _castRayAndSelectObject;
  50772. private _notifySelectedMeshUnselected;
  50773. /**
  50774. * Permanently set new colors for the laser pointer
  50775. * @param color the new laser color
  50776. * @param pickedColor the new laser color when picked mesh detected
  50777. */
  50778. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50779. /**
  50780. * Set lighting enabled / disabled on the laser pointer of both controllers
  50781. * @param enabled should the lighting be enabled on the laser pointer
  50782. */
  50783. setLaserLightingState(enabled?: boolean): void;
  50784. /**
  50785. * Permanently set new colors for the gaze pointer
  50786. * @param color the new gaze color
  50787. * @param pickedColor the new gaze color when picked mesh detected
  50788. */
  50789. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50790. /**
  50791. * Sets the color of the laser ray from the vr controllers.
  50792. * @param color new color for the ray.
  50793. */
  50794. changeLaserColor(color: Color3): void;
  50795. /**
  50796. * Sets the color of the ray from the vr headsets gaze.
  50797. * @param color new color for the ray.
  50798. */
  50799. changeGazeColor(color: Color3): void;
  50800. /**
  50801. * Exits VR and disposes of the vr experience helper
  50802. */
  50803. dispose(): void;
  50804. /**
  50805. * Gets the name of the VRExperienceHelper class
  50806. * @returns "VRExperienceHelper"
  50807. */
  50808. getClassName(): string;
  50809. }
  50810. }
  50811. declare module "babylonjs/Cameras/VR/index" {
  50812. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50813. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50814. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50815. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50816. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50817. export * from "babylonjs/Cameras/VR/webVRCamera";
  50818. }
  50819. declare module "babylonjs/Cameras/RigModes/index" {
  50820. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50821. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50822. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50823. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50824. }
  50825. declare module "babylonjs/Cameras/index" {
  50826. export * from "babylonjs/Cameras/Inputs/index";
  50827. export * from "babylonjs/Cameras/cameraInputsManager";
  50828. export * from "babylonjs/Cameras/camera";
  50829. export * from "babylonjs/Cameras/targetCamera";
  50830. export * from "babylonjs/Cameras/freeCamera";
  50831. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50832. export * from "babylonjs/Cameras/touchCamera";
  50833. export * from "babylonjs/Cameras/arcRotateCamera";
  50834. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50835. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50836. export * from "babylonjs/Cameras/flyCamera";
  50837. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50838. export * from "babylonjs/Cameras/followCamera";
  50839. export * from "babylonjs/Cameras/followCameraInputsManager";
  50840. export * from "babylonjs/Cameras/gamepadCamera";
  50841. export * from "babylonjs/Cameras/Stereoscopic/index";
  50842. export * from "babylonjs/Cameras/universalCamera";
  50843. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50844. export * from "babylonjs/Cameras/VR/index";
  50845. export * from "babylonjs/Cameras/RigModes/index";
  50846. }
  50847. declare module "babylonjs/Collisions/index" {
  50848. export * from "babylonjs/Collisions/collider";
  50849. export * from "babylonjs/Collisions/collisionCoordinator";
  50850. export * from "babylonjs/Collisions/pickingInfo";
  50851. export * from "babylonjs/Collisions/intersectionInfo";
  50852. export * from "babylonjs/Collisions/meshCollisionData";
  50853. }
  50854. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50855. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50856. import { Vector3 } from "babylonjs/Maths/math.vector";
  50857. import { Ray } from "babylonjs/Culling/ray";
  50858. import { Plane } from "babylonjs/Maths/math.plane";
  50859. /**
  50860. * Contains an array of blocks representing the octree
  50861. */
  50862. export interface IOctreeContainer<T> {
  50863. /**
  50864. * Blocks within the octree
  50865. */
  50866. blocks: Array<OctreeBlock<T>>;
  50867. }
  50868. /**
  50869. * Class used to store a cell in an octree
  50870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50871. */
  50872. export class OctreeBlock<T> {
  50873. /**
  50874. * Gets the content of the current block
  50875. */
  50876. entries: T[];
  50877. /**
  50878. * Gets the list of block children
  50879. */
  50880. blocks: Array<OctreeBlock<T>>;
  50881. private _depth;
  50882. private _maxDepth;
  50883. private _capacity;
  50884. private _minPoint;
  50885. private _maxPoint;
  50886. private _boundingVectors;
  50887. private _creationFunc;
  50888. /**
  50889. * Creates a new block
  50890. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50891. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50892. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50893. * @param depth defines the current depth of this block in the octree
  50894. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50895. * @param creationFunc defines a callback to call when an element is added to the block
  50896. */
  50897. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50898. /**
  50899. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50900. */
  50901. get capacity(): number;
  50902. /**
  50903. * Gets the minimum vector (in world space) of the block's bounding box
  50904. */
  50905. get minPoint(): Vector3;
  50906. /**
  50907. * Gets the maximum vector (in world space) of the block's bounding box
  50908. */
  50909. get maxPoint(): Vector3;
  50910. /**
  50911. * Add a new element to this block
  50912. * @param entry defines the element to add
  50913. */
  50914. addEntry(entry: T): void;
  50915. /**
  50916. * Remove an element from this block
  50917. * @param entry defines the element to remove
  50918. */
  50919. removeEntry(entry: T): void;
  50920. /**
  50921. * Add an array of elements to this block
  50922. * @param entries defines the array of elements to add
  50923. */
  50924. addEntries(entries: T[]): void;
  50925. /**
  50926. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50927. * @param frustumPlanes defines the frustum planes to test
  50928. * @param selection defines the array to store current content if selection is positive
  50929. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50930. */
  50931. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50932. /**
  50933. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50934. * @param sphereCenter defines the bounding sphere center
  50935. * @param sphereRadius defines the bounding sphere radius
  50936. * @param selection defines the array to store current content if selection is positive
  50937. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50938. */
  50939. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50940. /**
  50941. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50942. * @param ray defines the ray to test with
  50943. * @param selection defines the array to store current content if selection is positive
  50944. */
  50945. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50946. /**
  50947. * Subdivide the content into child blocks (this block will then be empty)
  50948. */
  50949. createInnerBlocks(): void;
  50950. /**
  50951. * @hidden
  50952. */
  50953. 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;
  50954. }
  50955. }
  50956. declare module "babylonjs/Culling/Octrees/octree" {
  50957. import { SmartArray } from "babylonjs/Misc/smartArray";
  50958. import { Vector3 } from "babylonjs/Maths/math.vector";
  50959. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50961. import { Ray } from "babylonjs/Culling/ray";
  50962. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50963. import { Plane } from "babylonjs/Maths/math.plane";
  50964. /**
  50965. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50966. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50967. */
  50968. export class Octree<T> {
  50969. /** 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.) */
  50970. maxDepth: number;
  50971. /**
  50972. * Blocks within the octree containing objects
  50973. */
  50974. blocks: Array<OctreeBlock<T>>;
  50975. /**
  50976. * Content stored in the octree
  50977. */
  50978. dynamicContent: T[];
  50979. private _maxBlockCapacity;
  50980. private _selectionContent;
  50981. private _creationFunc;
  50982. /**
  50983. * Creates a octree
  50984. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50985. * @param creationFunc function to be used to instatiate the octree
  50986. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50987. * @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.)
  50988. */
  50989. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50990. /** 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.) */
  50991. maxDepth?: number);
  50992. /**
  50993. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50994. * @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);
  50995. * @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);
  50996. * @param entries meshes to be added to the octree blocks
  50997. */
  50998. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50999. /**
  51000. * Adds a mesh to the octree
  51001. * @param entry Mesh to add to the octree
  51002. */
  51003. addMesh(entry: T): void;
  51004. /**
  51005. * Remove an element from the octree
  51006. * @param entry defines the element to remove
  51007. */
  51008. removeMesh(entry: T): void;
  51009. /**
  51010. * Selects an array of meshes within the frustum
  51011. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51012. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51013. * @returns array of meshes within the frustum
  51014. */
  51015. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51016. /**
  51017. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51018. * @param sphereCenter defines the bounding sphere center
  51019. * @param sphereRadius defines the bounding sphere radius
  51020. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51021. * @returns an array of objects that intersect the sphere
  51022. */
  51023. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51024. /**
  51025. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51026. * @param ray defines the ray to test with
  51027. * @returns array of intersected objects
  51028. */
  51029. intersectsRay(ray: Ray): SmartArray<T>;
  51030. /**
  51031. * Adds a mesh into the octree block if it intersects the block
  51032. */
  51033. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51034. /**
  51035. * Adds a submesh into the octree block if it intersects the block
  51036. */
  51037. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51038. }
  51039. }
  51040. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51041. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51042. import { Scene } from "babylonjs/scene";
  51043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51045. import { Ray } from "babylonjs/Culling/ray";
  51046. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51047. import { Collider } from "babylonjs/Collisions/collider";
  51048. module "babylonjs/scene" {
  51049. interface Scene {
  51050. /**
  51051. * @hidden
  51052. * Backing Filed
  51053. */
  51054. _selectionOctree: Octree<AbstractMesh>;
  51055. /**
  51056. * Gets the octree used to boost mesh selection (picking)
  51057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51058. */
  51059. selectionOctree: Octree<AbstractMesh>;
  51060. /**
  51061. * Creates or updates the octree used to boost selection (picking)
  51062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51063. * @param maxCapacity defines the maximum capacity per leaf
  51064. * @param maxDepth defines the maximum depth of the octree
  51065. * @returns an octree of AbstractMesh
  51066. */
  51067. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51068. }
  51069. }
  51070. module "babylonjs/Meshes/abstractMesh" {
  51071. interface AbstractMesh {
  51072. /**
  51073. * @hidden
  51074. * Backing Field
  51075. */
  51076. _submeshesOctree: Octree<SubMesh>;
  51077. /**
  51078. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51079. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51080. * @param maxCapacity defines the maximum size of each block (64 by default)
  51081. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51082. * @returns the new octree
  51083. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51085. */
  51086. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51087. }
  51088. }
  51089. /**
  51090. * Defines the octree scene component responsible to manage any octrees
  51091. * in a given scene.
  51092. */
  51093. export class OctreeSceneComponent {
  51094. /**
  51095. * The component name help to identify the component in the list of scene components.
  51096. */
  51097. readonly name: string;
  51098. /**
  51099. * The scene the component belongs to.
  51100. */
  51101. scene: Scene;
  51102. /**
  51103. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51104. */
  51105. readonly checksIsEnabled: boolean;
  51106. /**
  51107. * Creates a new instance of the component for the given scene
  51108. * @param scene Defines the scene to register the component in
  51109. */
  51110. constructor(scene: Scene);
  51111. /**
  51112. * Registers the component in a given scene
  51113. */
  51114. register(): void;
  51115. /**
  51116. * Return the list of active meshes
  51117. * @returns the list of active meshes
  51118. */
  51119. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51120. /**
  51121. * Return the list of active sub meshes
  51122. * @param mesh The mesh to get the candidates sub meshes from
  51123. * @returns the list of active sub meshes
  51124. */
  51125. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51126. private _tempRay;
  51127. /**
  51128. * Return the list of sub meshes intersecting with a given local ray
  51129. * @param mesh defines the mesh to find the submesh for
  51130. * @param localRay defines the ray in local space
  51131. * @returns the list of intersecting sub meshes
  51132. */
  51133. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51134. /**
  51135. * Return the list of sub meshes colliding with a collider
  51136. * @param mesh defines the mesh to find the submesh for
  51137. * @param collider defines the collider to evaluate the collision against
  51138. * @returns the list of colliding sub meshes
  51139. */
  51140. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51141. /**
  51142. * Rebuilds the elements related to this component in case of
  51143. * context lost for instance.
  51144. */
  51145. rebuild(): void;
  51146. /**
  51147. * Disposes the component and the associated ressources.
  51148. */
  51149. dispose(): void;
  51150. }
  51151. }
  51152. declare module "babylonjs/Culling/Octrees/index" {
  51153. export * from "babylonjs/Culling/Octrees/octree";
  51154. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51155. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51156. }
  51157. declare module "babylonjs/Culling/index" {
  51158. export * from "babylonjs/Culling/boundingBox";
  51159. export * from "babylonjs/Culling/boundingInfo";
  51160. export * from "babylonjs/Culling/boundingSphere";
  51161. export * from "babylonjs/Culling/Octrees/index";
  51162. export * from "babylonjs/Culling/ray";
  51163. }
  51164. declare module "babylonjs/Gizmos/gizmo" {
  51165. import { Nullable } from "babylonjs/types";
  51166. import { IDisposable } from "babylonjs/scene";
  51167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51168. import { Mesh } from "babylonjs/Meshes/mesh";
  51169. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51170. /**
  51171. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51172. */
  51173. export class Gizmo implements IDisposable {
  51174. /** The utility layer the gizmo will be added to */
  51175. gizmoLayer: UtilityLayerRenderer;
  51176. /**
  51177. * The root mesh of the gizmo
  51178. */
  51179. _rootMesh: Mesh;
  51180. private _attachedMesh;
  51181. /**
  51182. * Ratio for the scale of the gizmo (Default: 1)
  51183. */
  51184. scaleRatio: number;
  51185. /**
  51186. * If a custom mesh has been set (Default: false)
  51187. */
  51188. protected _customMeshSet: boolean;
  51189. /**
  51190. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51191. * * When set, interactions will be enabled
  51192. */
  51193. get attachedMesh(): Nullable<AbstractMesh>;
  51194. set attachedMesh(value: Nullable<AbstractMesh>);
  51195. /**
  51196. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51197. * @param mesh The mesh to replace the default mesh of the gizmo
  51198. */
  51199. setCustomMesh(mesh: Mesh): void;
  51200. /**
  51201. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51202. */
  51203. updateGizmoRotationToMatchAttachedMesh: boolean;
  51204. /**
  51205. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51206. */
  51207. updateGizmoPositionToMatchAttachedMesh: boolean;
  51208. /**
  51209. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51210. */
  51211. updateScale: boolean;
  51212. protected _interactionsEnabled: boolean;
  51213. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51214. private _beforeRenderObserver;
  51215. private _tempVector;
  51216. /**
  51217. * Creates a gizmo
  51218. * @param gizmoLayer The utility layer the gizmo will be added to
  51219. */
  51220. constructor(
  51221. /** The utility layer the gizmo will be added to */
  51222. gizmoLayer?: UtilityLayerRenderer);
  51223. /**
  51224. * Updates the gizmo to match the attached mesh's position/rotation
  51225. */
  51226. protected _update(): void;
  51227. /**
  51228. * Disposes of the gizmo
  51229. */
  51230. dispose(): void;
  51231. }
  51232. }
  51233. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51234. import { Observable } from "babylonjs/Misc/observable";
  51235. import { Nullable } from "babylonjs/types";
  51236. import { Vector3 } from "babylonjs/Maths/math.vector";
  51237. import { Color3 } from "babylonjs/Maths/math.color";
  51238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51240. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51241. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51242. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51243. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51244. import { Scene } from "babylonjs/scene";
  51245. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51246. /**
  51247. * Single plane drag gizmo
  51248. */
  51249. export class PlaneDragGizmo extends Gizmo {
  51250. /**
  51251. * Drag behavior responsible for the gizmos dragging interactions
  51252. */
  51253. dragBehavior: PointerDragBehavior;
  51254. private _pointerObserver;
  51255. /**
  51256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51257. */
  51258. snapDistance: number;
  51259. /**
  51260. * Event that fires each time the gizmo snaps to a new location.
  51261. * * snapDistance is the the change in distance
  51262. */
  51263. onSnapObservable: Observable<{
  51264. snapDistance: number;
  51265. }>;
  51266. private _plane;
  51267. private _coloredMaterial;
  51268. private _hoverMaterial;
  51269. private _isEnabled;
  51270. private _parent;
  51271. /** @hidden */
  51272. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51273. /** @hidden */
  51274. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51275. /**
  51276. * Creates a PlaneDragGizmo
  51277. * @param gizmoLayer The utility layer the gizmo will be added to
  51278. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51279. * @param color The color of the gizmo
  51280. */
  51281. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51282. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51283. /**
  51284. * If the gizmo is enabled
  51285. */
  51286. set isEnabled(value: boolean);
  51287. get isEnabled(): boolean;
  51288. /**
  51289. * Disposes of the gizmo
  51290. */
  51291. dispose(): void;
  51292. }
  51293. }
  51294. declare module "babylonjs/Gizmos/positionGizmo" {
  51295. import { Observable } from "babylonjs/Misc/observable";
  51296. import { Nullable } from "babylonjs/types";
  51297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51298. import { Mesh } from "babylonjs/Meshes/mesh";
  51299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51300. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51301. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51302. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51303. /**
  51304. * Gizmo that enables dragging a mesh along 3 axis
  51305. */
  51306. export class PositionGizmo extends Gizmo {
  51307. /**
  51308. * Internal gizmo used for interactions on the x axis
  51309. */
  51310. xGizmo: AxisDragGizmo;
  51311. /**
  51312. * Internal gizmo used for interactions on the y axis
  51313. */
  51314. yGizmo: AxisDragGizmo;
  51315. /**
  51316. * Internal gizmo used for interactions on the z axis
  51317. */
  51318. zGizmo: AxisDragGizmo;
  51319. /**
  51320. * Internal gizmo used for interactions on the yz plane
  51321. */
  51322. xPlaneGizmo: PlaneDragGizmo;
  51323. /**
  51324. * Internal gizmo used for interactions on the xz plane
  51325. */
  51326. yPlaneGizmo: PlaneDragGizmo;
  51327. /**
  51328. * Internal gizmo used for interactions on the xy plane
  51329. */
  51330. zPlaneGizmo: PlaneDragGizmo;
  51331. /**
  51332. * private variables
  51333. */
  51334. private _meshAttached;
  51335. private _updateGizmoRotationToMatchAttachedMesh;
  51336. private _snapDistance;
  51337. private _scaleRatio;
  51338. /** Fires an event when any of it's sub gizmos are dragged */
  51339. onDragStartObservable: Observable<unknown>;
  51340. /** Fires an event when any of it's sub gizmos are released from dragging */
  51341. onDragEndObservable: Observable<unknown>;
  51342. /**
  51343. * If set to true, planar drag is enabled
  51344. */
  51345. private _planarGizmoEnabled;
  51346. get attachedMesh(): Nullable<AbstractMesh>;
  51347. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51348. /**
  51349. * Creates a PositionGizmo
  51350. * @param gizmoLayer The utility layer the gizmo will be added to
  51351. */
  51352. constructor(gizmoLayer?: UtilityLayerRenderer);
  51353. /**
  51354. * If the planar drag gizmo is enabled
  51355. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51356. */
  51357. set planarGizmoEnabled(value: boolean);
  51358. get planarGizmoEnabled(): boolean;
  51359. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51360. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51361. /**
  51362. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51363. */
  51364. set snapDistance(value: number);
  51365. get snapDistance(): number;
  51366. /**
  51367. * Ratio for the scale of the gizmo (Default: 1)
  51368. */
  51369. set scaleRatio(value: number);
  51370. get scaleRatio(): number;
  51371. /**
  51372. * Disposes of the gizmo
  51373. */
  51374. dispose(): void;
  51375. /**
  51376. * CustomMeshes are not supported by this gizmo
  51377. * @param mesh The mesh to replace the default mesh of the gizmo
  51378. */
  51379. setCustomMesh(mesh: Mesh): void;
  51380. }
  51381. }
  51382. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51383. import { Observable } from "babylonjs/Misc/observable";
  51384. import { Nullable } from "babylonjs/types";
  51385. import { Vector3 } from "babylonjs/Maths/math.vector";
  51386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51388. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51389. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51390. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51391. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51392. import { Scene } from "babylonjs/scene";
  51393. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51394. import { Color3 } from "babylonjs/Maths/math.color";
  51395. /**
  51396. * Single axis drag gizmo
  51397. */
  51398. export class AxisDragGizmo extends Gizmo {
  51399. /**
  51400. * Drag behavior responsible for the gizmos dragging interactions
  51401. */
  51402. dragBehavior: PointerDragBehavior;
  51403. private _pointerObserver;
  51404. /**
  51405. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51406. */
  51407. snapDistance: number;
  51408. /**
  51409. * Event that fires each time the gizmo snaps to a new location.
  51410. * * snapDistance is the the change in distance
  51411. */
  51412. onSnapObservable: Observable<{
  51413. snapDistance: number;
  51414. }>;
  51415. private _isEnabled;
  51416. private _parent;
  51417. private _arrow;
  51418. private _coloredMaterial;
  51419. private _hoverMaterial;
  51420. /** @hidden */
  51421. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51422. /** @hidden */
  51423. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51424. /**
  51425. * Creates an AxisDragGizmo
  51426. * @param gizmoLayer The utility layer the gizmo will be added to
  51427. * @param dragAxis The axis which the gizmo will be able to drag on
  51428. * @param color The color of the gizmo
  51429. */
  51430. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51431. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51432. /**
  51433. * If the gizmo is enabled
  51434. */
  51435. set isEnabled(value: boolean);
  51436. get isEnabled(): boolean;
  51437. /**
  51438. * Disposes of the gizmo
  51439. */
  51440. dispose(): void;
  51441. }
  51442. }
  51443. declare module "babylonjs/Debug/axesViewer" {
  51444. import { Vector3 } from "babylonjs/Maths/math.vector";
  51445. import { Nullable } from "babylonjs/types";
  51446. import { Scene } from "babylonjs/scene";
  51447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51448. /**
  51449. * The Axes viewer will show 3 axes in a specific point in space
  51450. */
  51451. export class AxesViewer {
  51452. private _xAxis;
  51453. private _yAxis;
  51454. private _zAxis;
  51455. private _scaleLinesFactor;
  51456. private _instanced;
  51457. /**
  51458. * Gets the hosting scene
  51459. */
  51460. scene: Scene;
  51461. /**
  51462. * Gets or sets a number used to scale line length
  51463. */
  51464. scaleLines: number;
  51465. /** Gets the node hierarchy used to render x-axis */
  51466. get xAxis(): TransformNode;
  51467. /** Gets the node hierarchy used to render y-axis */
  51468. get yAxis(): TransformNode;
  51469. /** Gets the node hierarchy used to render z-axis */
  51470. get zAxis(): TransformNode;
  51471. /**
  51472. * Creates a new AxesViewer
  51473. * @param scene defines the hosting scene
  51474. * @param scaleLines defines a number used to scale line length (1 by default)
  51475. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51476. * @param xAxis defines the node hierarchy used to render the x-axis
  51477. * @param yAxis defines the node hierarchy used to render the y-axis
  51478. * @param zAxis defines the node hierarchy used to render the z-axis
  51479. */
  51480. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51481. /**
  51482. * Force the viewer to update
  51483. * @param position defines the position of the viewer
  51484. * @param xaxis defines the x axis of the viewer
  51485. * @param yaxis defines the y axis of the viewer
  51486. * @param zaxis defines the z axis of the viewer
  51487. */
  51488. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51489. /**
  51490. * Creates an instance of this axes viewer.
  51491. * @returns a new axes viewer with instanced meshes
  51492. */
  51493. createInstance(): AxesViewer;
  51494. /** Releases resources */
  51495. dispose(): void;
  51496. private static _SetRenderingGroupId;
  51497. }
  51498. }
  51499. declare module "babylonjs/Debug/boneAxesViewer" {
  51500. import { Nullable } from "babylonjs/types";
  51501. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51502. import { Vector3 } from "babylonjs/Maths/math.vector";
  51503. import { Mesh } from "babylonjs/Meshes/mesh";
  51504. import { Bone } from "babylonjs/Bones/bone";
  51505. import { Scene } from "babylonjs/scene";
  51506. /**
  51507. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51508. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51509. */
  51510. export class BoneAxesViewer extends AxesViewer {
  51511. /**
  51512. * Gets or sets the target mesh where to display the axes viewer
  51513. */
  51514. mesh: Nullable<Mesh>;
  51515. /**
  51516. * Gets or sets the target bone where to display the axes viewer
  51517. */
  51518. bone: Nullable<Bone>;
  51519. /** Gets current position */
  51520. pos: Vector3;
  51521. /** Gets direction of X axis */
  51522. xaxis: Vector3;
  51523. /** Gets direction of Y axis */
  51524. yaxis: Vector3;
  51525. /** Gets direction of Z axis */
  51526. zaxis: Vector3;
  51527. /**
  51528. * Creates a new BoneAxesViewer
  51529. * @param scene defines the hosting scene
  51530. * @param bone defines the target bone
  51531. * @param mesh defines the target mesh
  51532. * @param scaleLines defines a scaling factor for line length (1 by default)
  51533. */
  51534. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51535. /**
  51536. * Force the viewer to update
  51537. */
  51538. update(): void;
  51539. /** Releases resources */
  51540. dispose(): void;
  51541. }
  51542. }
  51543. declare module "babylonjs/Debug/debugLayer" {
  51544. import { Scene } from "babylonjs/scene";
  51545. /**
  51546. * Interface used to define scene explorer extensibility option
  51547. */
  51548. export interface IExplorerExtensibilityOption {
  51549. /**
  51550. * Define the option label
  51551. */
  51552. label: string;
  51553. /**
  51554. * Defines the action to execute on click
  51555. */
  51556. action: (entity: any) => void;
  51557. }
  51558. /**
  51559. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51560. */
  51561. export interface IExplorerExtensibilityGroup {
  51562. /**
  51563. * Defines a predicate to test if a given type mut be extended
  51564. */
  51565. predicate: (entity: any) => boolean;
  51566. /**
  51567. * Gets the list of options added to a type
  51568. */
  51569. entries: IExplorerExtensibilityOption[];
  51570. }
  51571. /**
  51572. * Interface used to define the options to use to create the Inspector
  51573. */
  51574. export interface IInspectorOptions {
  51575. /**
  51576. * Display in overlay mode (default: false)
  51577. */
  51578. overlay?: boolean;
  51579. /**
  51580. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51581. */
  51582. globalRoot?: HTMLElement;
  51583. /**
  51584. * Display the Scene explorer
  51585. */
  51586. showExplorer?: boolean;
  51587. /**
  51588. * Display the property inspector
  51589. */
  51590. showInspector?: boolean;
  51591. /**
  51592. * Display in embed mode (both panes on the right)
  51593. */
  51594. embedMode?: boolean;
  51595. /**
  51596. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51597. */
  51598. handleResize?: boolean;
  51599. /**
  51600. * Allow the panes to popup (default: true)
  51601. */
  51602. enablePopup?: boolean;
  51603. /**
  51604. * Allow the panes to be closed by users (default: true)
  51605. */
  51606. enableClose?: boolean;
  51607. /**
  51608. * Optional list of extensibility entries
  51609. */
  51610. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51611. /**
  51612. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51613. */
  51614. inspectorURL?: string;
  51615. /**
  51616. * Optional initial tab (default to DebugLayerTab.Properties)
  51617. */
  51618. initialTab?: DebugLayerTab;
  51619. }
  51620. module "babylonjs/scene" {
  51621. interface Scene {
  51622. /**
  51623. * @hidden
  51624. * Backing field
  51625. */
  51626. _debugLayer: DebugLayer;
  51627. /**
  51628. * Gets the debug layer (aka Inspector) associated with the scene
  51629. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51630. */
  51631. debugLayer: DebugLayer;
  51632. }
  51633. }
  51634. /**
  51635. * Enum of inspector action tab
  51636. */
  51637. export enum DebugLayerTab {
  51638. /**
  51639. * Properties tag (default)
  51640. */
  51641. Properties = 0,
  51642. /**
  51643. * Debug tab
  51644. */
  51645. Debug = 1,
  51646. /**
  51647. * Statistics tab
  51648. */
  51649. Statistics = 2,
  51650. /**
  51651. * Tools tab
  51652. */
  51653. Tools = 3,
  51654. /**
  51655. * Settings tab
  51656. */
  51657. Settings = 4
  51658. }
  51659. /**
  51660. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51661. * what is happening in your scene
  51662. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51663. */
  51664. export class DebugLayer {
  51665. /**
  51666. * Define the url to get the inspector script from.
  51667. * By default it uses the babylonjs CDN.
  51668. * @ignoreNaming
  51669. */
  51670. static InspectorURL: string;
  51671. private _scene;
  51672. private BJSINSPECTOR;
  51673. private _onPropertyChangedObservable?;
  51674. /**
  51675. * Observable triggered when a property is changed through the inspector.
  51676. */
  51677. get onPropertyChangedObservable(): any;
  51678. /**
  51679. * Instantiates a new debug layer.
  51680. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51681. * what is happening in your scene
  51682. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51683. * @param scene Defines the scene to inspect
  51684. */
  51685. constructor(scene: Scene);
  51686. /** Creates the inspector window. */
  51687. private _createInspector;
  51688. /**
  51689. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51690. * @param entity defines the entity to select
  51691. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51692. */
  51693. select(entity: any, lineContainerTitles?: string | string[]): void;
  51694. /** Get the inspector from bundle or global */
  51695. private _getGlobalInspector;
  51696. /**
  51697. * Get if the inspector is visible or not.
  51698. * @returns true if visible otherwise, false
  51699. */
  51700. isVisible(): boolean;
  51701. /**
  51702. * Hide the inspector and close its window.
  51703. */
  51704. hide(): void;
  51705. /**
  51706. * Update the scene in the inspector
  51707. */
  51708. setAsActiveScene(): void;
  51709. /**
  51710. * Launch the debugLayer.
  51711. * @param config Define the configuration of the inspector
  51712. * @return a promise fulfilled when the debug layer is visible
  51713. */
  51714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51715. }
  51716. }
  51717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51718. import { Nullable } from "babylonjs/types";
  51719. import { Scene } from "babylonjs/scene";
  51720. import { Vector4 } from "babylonjs/Maths/math.vector";
  51721. import { Color4 } from "babylonjs/Maths/math.color";
  51722. import { Mesh } from "babylonjs/Meshes/mesh";
  51723. /**
  51724. * Class containing static functions to help procedurally build meshes
  51725. */
  51726. export class BoxBuilder {
  51727. /**
  51728. * Creates a box mesh
  51729. * * The parameter `size` sets the size (float) of each box side (default 1)
  51730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51731. * * 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)
  51732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51737. * @param name defines the name of the mesh
  51738. * @param options defines the options used to create the mesh
  51739. * @param scene defines the hosting scene
  51740. * @returns the box mesh
  51741. */
  51742. static CreateBox(name: string, options: {
  51743. size?: number;
  51744. width?: number;
  51745. height?: number;
  51746. depth?: number;
  51747. faceUV?: Vector4[];
  51748. faceColors?: Color4[];
  51749. sideOrientation?: number;
  51750. frontUVs?: Vector4;
  51751. backUVs?: Vector4;
  51752. wrap?: boolean;
  51753. topBaseAt?: number;
  51754. bottomBaseAt?: number;
  51755. updatable?: boolean;
  51756. }, scene?: Nullable<Scene>): Mesh;
  51757. }
  51758. }
  51759. declare module "babylonjs/Debug/physicsViewer" {
  51760. import { Nullable } from "babylonjs/types";
  51761. import { Scene } from "babylonjs/scene";
  51762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51763. import { Mesh } from "babylonjs/Meshes/mesh";
  51764. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51765. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51766. /**
  51767. * Used to show the physics impostor around the specific mesh
  51768. */
  51769. export class PhysicsViewer {
  51770. /** @hidden */
  51771. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51772. /** @hidden */
  51773. protected _meshes: Array<Nullable<AbstractMesh>>;
  51774. /** @hidden */
  51775. protected _scene: Nullable<Scene>;
  51776. /** @hidden */
  51777. protected _numMeshes: number;
  51778. /** @hidden */
  51779. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51780. private _renderFunction;
  51781. private _utilityLayer;
  51782. private _debugBoxMesh;
  51783. private _debugSphereMesh;
  51784. private _debugCylinderMesh;
  51785. private _debugMaterial;
  51786. private _debugMeshMeshes;
  51787. /**
  51788. * Creates a new PhysicsViewer
  51789. * @param scene defines the hosting scene
  51790. */
  51791. constructor(scene: Scene);
  51792. /** @hidden */
  51793. protected _updateDebugMeshes(): void;
  51794. /**
  51795. * Renders a specified physic impostor
  51796. * @param impostor defines the impostor to render
  51797. * @param targetMesh defines the mesh represented by the impostor
  51798. * @returns the new debug mesh used to render the impostor
  51799. */
  51800. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51801. /**
  51802. * Hides a specified physic impostor
  51803. * @param impostor defines the impostor to hide
  51804. */
  51805. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51806. private _getDebugMaterial;
  51807. private _getDebugBoxMesh;
  51808. private _getDebugSphereMesh;
  51809. private _getDebugCylinderMesh;
  51810. private _getDebugMeshMesh;
  51811. private _getDebugMesh;
  51812. /** Releases all resources */
  51813. dispose(): void;
  51814. }
  51815. }
  51816. declare module "babylonjs/Debug/rayHelper" {
  51817. import { Nullable } from "babylonjs/types";
  51818. import { Ray } from "babylonjs/Culling/ray";
  51819. import { Vector3 } from "babylonjs/Maths/math.vector";
  51820. import { Color3 } from "babylonjs/Maths/math.color";
  51821. import { Scene } from "babylonjs/scene";
  51822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51823. import "babylonjs/Meshes/Builders/linesBuilder";
  51824. /**
  51825. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51826. * in order to better appreciate the issue one might have.
  51827. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51828. */
  51829. export class RayHelper {
  51830. /**
  51831. * Defines the ray we are currently tryin to visualize.
  51832. */
  51833. ray: Nullable<Ray>;
  51834. private _renderPoints;
  51835. private _renderLine;
  51836. private _renderFunction;
  51837. private _scene;
  51838. private _updateToMeshFunction;
  51839. private _attachedToMesh;
  51840. private _meshSpaceDirection;
  51841. private _meshSpaceOrigin;
  51842. /**
  51843. * Helper function to create a colored helper in a scene in one line.
  51844. * @param ray Defines the ray we are currently tryin to visualize
  51845. * @param scene Defines the scene the ray is used in
  51846. * @param color Defines the color we want to see the ray in
  51847. * @returns The newly created ray helper.
  51848. */
  51849. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51850. /**
  51851. * Instantiate a new ray helper.
  51852. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51853. * in order to better appreciate the issue one might have.
  51854. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51855. * @param ray Defines the ray we are currently tryin to visualize
  51856. */
  51857. constructor(ray: Ray);
  51858. /**
  51859. * Shows the ray we are willing to debug.
  51860. * @param scene Defines the scene the ray needs to be rendered in
  51861. * @param color Defines the color the ray needs to be rendered in
  51862. */
  51863. show(scene: Scene, color?: Color3): void;
  51864. /**
  51865. * Hides the ray we are debugging.
  51866. */
  51867. hide(): void;
  51868. private _render;
  51869. /**
  51870. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51871. * @param mesh Defines the mesh we want the helper attached to
  51872. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51873. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51874. * @param length Defines the length of the ray
  51875. */
  51876. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51877. /**
  51878. * Detach the ray helper from the mesh it has previously been attached to.
  51879. */
  51880. detachFromMesh(): void;
  51881. private _updateToMesh;
  51882. /**
  51883. * Dispose the helper and release its associated resources.
  51884. */
  51885. dispose(): void;
  51886. }
  51887. }
  51888. declare module "babylonjs/Debug/skeletonViewer" {
  51889. import { Color3 } from "babylonjs/Maths/math.color";
  51890. import { Scene } from "babylonjs/scene";
  51891. import { Nullable } from "babylonjs/types";
  51892. import { Skeleton } from "babylonjs/Bones/skeleton";
  51893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51894. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51895. /**
  51896. * Class used to render a debug view of a given skeleton
  51897. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51898. */
  51899. export class SkeletonViewer {
  51900. /** defines the skeleton to render */
  51901. skeleton: Skeleton;
  51902. /** defines the mesh attached to the skeleton */
  51903. mesh: AbstractMesh;
  51904. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51905. autoUpdateBonesMatrices: boolean;
  51906. /** defines the rendering group id to use with the viewer */
  51907. renderingGroupId: number;
  51908. /** Gets or sets the color used to render the skeleton */
  51909. color: Color3;
  51910. private _scene;
  51911. private _debugLines;
  51912. private _debugMesh;
  51913. private _isEnabled;
  51914. private _renderFunction;
  51915. private _utilityLayer;
  51916. /**
  51917. * Returns the mesh used to render the bones
  51918. */
  51919. get debugMesh(): Nullable<LinesMesh>;
  51920. /**
  51921. * Creates a new SkeletonViewer
  51922. * @param skeleton defines the skeleton to render
  51923. * @param mesh defines the mesh attached to the skeleton
  51924. * @param scene defines the hosting scene
  51925. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51926. * @param renderingGroupId defines the rendering group id to use with the viewer
  51927. */
  51928. constructor(
  51929. /** defines the skeleton to render */
  51930. skeleton: Skeleton,
  51931. /** defines the mesh attached to the skeleton */
  51932. mesh: AbstractMesh, scene: Scene,
  51933. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51934. autoUpdateBonesMatrices?: boolean,
  51935. /** defines the rendering group id to use with the viewer */
  51936. renderingGroupId?: number);
  51937. /** Gets or sets a boolean indicating if the viewer is enabled */
  51938. set isEnabled(value: boolean);
  51939. get isEnabled(): boolean;
  51940. private _getBonePosition;
  51941. private _getLinesForBonesWithLength;
  51942. private _getLinesForBonesNoLength;
  51943. /** Update the viewer to sync with current skeleton state */
  51944. update(): void;
  51945. /** Release associated resources */
  51946. dispose(): void;
  51947. }
  51948. }
  51949. declare module "babylonjs/Debug/index" {
  51950. export * from "babylonjs/Debug/axesViewer";
  51951. export * from "babylonjs/Debug/boneAxesViewer";
  51952. export * from "babylonjs/Debug/debugLayer";
  51953. export * from "babylonjs/Debug/physicsViewer";
  51954. export * from "babylonjs/Debug/rayHelper";
  51955. export * from "babylonjs/Debug/skeletonViewer";
  51956. }
  51957. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51958. /**
  51959. * Enum for Device Types
  51960. */
  51961. export enum DeviceType {
  51962. /** Generic */
  51963. Generic = 0,
  51964. /** Keyboard */
  51965. Keyboard = 1,
  51966. /** Mouse */
  51967. Mouse = 2,
  51968. /** Touch Pointers */
  51969. Touch = 3,
  51970. /** PS4 Dual Shock */
  51971. DualShock = 4,
  51972. /** Xbox */
  51973. Xbox = 5,
  51974. /** Switch Controller */
  51975. Switch = 6
  51976. }
  51977. /**
  51978. * Enum for All Pointers (Touch/Mouse)
  51979. */
  51980. export enum PointerInput {
  51981. /** Horizontal Axis */
  51982. Horizontal = 0,
  51983. /** Vertical Axis */
  51984. Vertical = 1,
  51985. /** Left Click or Touch */
  51986. LeftClick = 2,
  51987. /** Middle Click */
  51988. MiddleClick = 3,
  51989. /** Right Click */
  51990. RightClick = 4,
  51991. /** Browser Back */
  51992. BrowserBack = 5,
  51993. /** Browser Forward */
  51994. BrowserForward = 6
  51995. }
  51996. /**
  51997. * Enum for Dual Shock Gamepad
  51998. */
  51999. export enum DualShockInput {
  52000. /** Cross */
  52001. Cross = 0,
  52002. /** Circle */
  52003. Circle = 1,
  52004. /** Square */
  52005. Square = 2,
  52006. /** Triangle */
  52007. Triangle = 3,
  52008. /** L1 */
  52009. L1 = 4,
  52010. /** R1 */
  52011. R1 = 5,
  52012. /** L2 */
  52013. L2 = 6,
  52014. /** R2 */
  52015. R2 = 7,
  52016. /** Share */
  52017. Share = 8,
  52018. /** Options */
  52019. Options = 9,
  52020. /** L3 */
  52021. L3 = 10,
  52022. /** R3 */
  52023. R3 = 11,
  52024. /** DPadUp */
  52025. DPadUp = 12,
  52026. /** DPadDown */
  52027. DPadDown = 13,
  52028. /** DPadLeft */
  52029. DPadLeft = 14,
  52030. /** DRight */
  52031. DPadRight = 15,
  52032. /** Home */
  52033. Home = 16,
  52034. /** TouchPad */
  52035. TouchPad = 17,
  52036. /** LStickXAxis */
  52037. LStickXAxis = 18,
  52038. /** LStickYAxis */
  52039. LStickYAxis = 19,
  52040. /** RStickXAxis */
  52041. RStickXAxis = 20,
  52042. /** RStickYAxis */
  52043. RStickYAxis = 21
  52044. }
  52045. /**
  52046. * Enum for Xbox Gamepad
  52047. */
  52048. export enum XboxInput {
  52049. /** A */
  52050. A = 0,
  52051. /** B */
  52052. B = 1,
  52053. /** X */
  52054. X = 2,
  52055. /** Y */
  52056. Y = 3,
  52057. /** LB */
  52058. LB = 4,
  52059. /** RB */
  52060. RB = 5,
  52061. /** LT */
  52062. LT = 6,
  52063. /** RT */
  52064. RT = 7,
  52065. /** Back */
  52066. Back = 8,
  52067. /** Start */
  52068. Start = 9,
  52069. /** LS */
  52070. LS = 10,
  52071. /** RS */
  52072. RS = 11,
  52073. /** DPadUp */
  52074. DPadUp = 12,
  52075. /** DPadDown */
  52076. DPadDown = 13,
  52077. /** DPadLeft */
  52078. DPadLeft = 14,
  52079. /** DRight */
  52080. DPadRight = 15,
  52081. /** Home */
  52082. Home = 16,
  52083. /** LStickXAxis */
  52084. LStickXAxis = 17,
  52085. /** LStickYAxis */
  52086. LStickYAxis = 18,
  52087. /** RStickXAxis */
  52088. RStickXAxis = 19,
  52089. /** RStickYAxis */
  52090. RStickYAxis = 20
  52091. }
  52092. /**
  52093. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52094. */
  52095. export enum SwitchInput {
  52096. /** B */
  52097. B = 0,
  52098. /** A */
  52099. A = 1,
  52100. /** Y */
  52101. Y = 2,
  52102. /** X */
  52103. X = 3,
  52104. /** L */
  52105. L = 4,
  52106. /** R */
  52107. R = 5,
  52108. /** ZL */
  52109. ZL = 6,
  52110. /** ZR */
  52111. ZR = 7,
  52112. /** Minus */
  52113. Minus = 8,
  52114. /** Plus */
  52115. Plus = 9,
  52116. /** LS */
  52117. LS = 10,
  52118. /** RS */
  52119. RS = 11,
  52120. /** DPadUp */
  52121. DPadUp = 12,
  52122. /** DPadDown */
  52123. DPadDown = 13,
  52124. /** DPadLeft */
  52125. DPadLeft = 14,
  52126. /** DRight */
  52127. DPadRight = 15,
  52128. /** Home */
  52129. Home = 16,
  52130. /** Capture */
  52131. Capture = 17,
  52132. /** LStickXAxis */
  52133. LStickXAxis = 18,
  52134. /** LStickYAxis */
  52135. LStickYAxis = 19,
  52136. /** RStickXAxis */
  52137. RStickXAxis = 20,
  52138. /** RStickYAxis */
  52139. RStickYAxis = 21
  52140. }
  52141. }
  52142. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52143. import { Engine } from "babylonjs/Engines/engine";
  52144. import { IDisposable } from "babylonjs/scene";
  52145. import { Nullable } from "babylonjs/types";
  52146. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52147. /**
  52148. * This class will take all inputs from Keyboard, Pointer, and
  52149. * any Gamepads and provide a polling system that all devices
  52150. * will use. This class assumes that there will only be one
  52151. * pointer device and one keyboard.
  52152. */
  52153. export class DeviceInputSystem implements IDisposable {
  52154. /**
  52155. * Callback to be triggered when a device is connected
  52156. */
  52157. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52158. /**
  52159. * Callback to be triggered when a device is disconnected
  52160. */
  52161. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52162. /**
  52163. * Callback to be triggered when event driven input is updated
  52164. */
  52165. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52166. private _inputs;
  52167. private _gamepads;
  52168. private _keyboardActive;
  52169. private _pointerActive;
  52170. private _elementToAttachTo;
  52171. private _keyboardDownEvent;
  52172. private _keyboardUpEvent;
  52173. private _pointerMoveEvent;
  52174. private _pointerDownEvent;
  52175. private _pointerUpEvent;
  52176. private _gamepadConnectedEvent;
  52177. private _gamepadDisconnectedEvent;
  52178. private static _MAX_KEYCODES;
  52179. private static _MAX_POINTER_INPUTS;
  52180. private constructor();
  52181. /**
  52182. * Creates a new DeviceInputSystem instance
  52183. * @param engine Engine to pull input element from
  52184. * @returns The new instance
  52185. */
  52186. static Create(engine: Engine): DeviceInputSystem;
  52187. /**
  52188. * Checks for current device input value, given an id and input index
  52189. * @param deviceName Id of connected device
  52190. * @param inputIndex Index of device input
  52191. * @returns Current value of input
  52192. */
  52193. /**
  52194. * Checks for current device input value, given an id and input index
  52195. * @param deviceType Enum specifiying device type
  52196. * @param deviceSlot "Slot" or index that device is referenced in
  52197. * @param inputIndex Id of input to be checked
  52198. * @returns Current value of input
  52199. */
  52200. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52201. /**
  52202. * Dispose of all the eventlisteners
  52203. */
  52204. dispose(): void;
  52205. /**
  52206. * Add device and inputs to device array
  52207. * @param deviceType Enum specifiying device type
  52208. * @param deviceSlot "Slot" or index that device is referenced in
  52209. * @param numberOfInputs Number of input entries to create for given device
  52210. */
  52211. private _registerDevice;
  52212. /**
  52213. * Given a specific device name, remove that device from the device map
  52214. * @param deviceType Enum specifiying device type
  52215. * @param deviceSlot "Slot" or index that device is referenced in
  52216. */
  52217. private _unregisterDevice;
  52218. /**
  52219. * Handle all actions that come from keyboard interaction
  52220. */
  52221. private _handleKeyActions;
  52222. /**
  52223. * Handle all actions that come from pointer interaction
  52224. */
  52225. private _handlePointerActions;
  52226. /**
  52227. * Handle all actions that come from gamepad interaction
  52228. */
  52229. private _handleGamepadActions;
  52230. /**
  52231. * Update all non-event based devices with each frame
  52232. * @param deviceType Enum specifiying device type
  52233. * @param deviceSlot "Slot" or index that device is referenced in
  52234. * @param inputIndex Id of input to be checked
  52235. */
  52236. private _updateDevice;
  52237. /**
  52238. * Gets DeviceType from the device name
  52239. * @param deviceName Name of Device from DeviceInputSystem
  52240. * @returns DeviceType enum value
  52241. */
  52242. private _getGamepadDeviceType;
  52243. }
  52244. }
  52245. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52246. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52247. /**
  52248. * Type to handle enforcement of inputs
  52249. */
  52250. 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;
  52251. }
  52252. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52253. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52254. import { Engine } from "babylonjs/Engines/engine";
  52255. import { IDisposable } from "babylonjs/scene";
  52256. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52257. import { Nullable } from "babylonjs/types";
  52258. import { Observable } from "babylonjs/Misc/observable";
  52259. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52260. /**
  52261. * Class that handles all input for a specific device
  52262. */
  52263. export class DeviceSource<T extends DeviceType> {
  52264. /** Type of device */
  52265. readonly deviceType: DeviceType;
  52266. /** "Slot" or index that device is referenced in */
  52267. readonly deviceSlot: number;
  52268. /**
  52269. * Observable to handle device input changes per device
  52270. */
  52271. readonly onInputChangedObservable: Observable<{
  52272. inputIndex: DeviceInput<T>;
  52273. previousState: Nullable<number>;
  52274. currentState: Nullable<number>;
  52275. }>;
  52276. private readonly _deviceInputSystem;
  52277. /**
  52278. * Default Constructor
  52279. * @param deviceInputSystem Reference to DeviceInputSystem
  52280. * @param deviceType Type of device
  52281. * @param deviceSlot "Slot" or index that device is referenced in
  52282. */
  52283. constructor(deviceInputSystem: DeviceInputSystem,
  52284. /** Type of device */
  52285. deviceType: DeviceType,
  52286. /** "Slot" or index that device is referenced in */
  52287. deviceSlot?: number);
  52288. /**
  52289. * Get input for specific input
  52290. * @param inputIndex index of specific input on device
  52291. * @returns Input value from DeviceInputSystem
  52292. */
  52293. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52294. }
  52295. /**
  52296. * Class to keep track of devices
  52297. */
  52298. export class DeviceSourceManager implements IDisposable {
  52299. /**
  52300. * Observable to be triggered when before a device is connected
  52301. */
  52302. readonly onBeforeDeviceConnectedObservable: Observable<{
  52303. deviceType: DeviceType;
  52304. deviceSlot: number;
  52305. }>;
  52306. /**
  52307. * Observable to be triggered when before a device is disconnected
  52308. */
  52309. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52310. deviceType: DeviceType;
  52311. deviceSlot: number;
  52312. }>;
  52313. /**
  52314. * Observable to be triggered when after a device is connected
  52315. */
  52316. readonly onAfterDeviceConnectedObservable: Observable<{
  52317. deviceType: DeviceType;
  52318. deviceSlot: number;
  52319. }>;
  52320. /**
  52321. * Observable to be triggered when after a device is disconnected
  52322. */
  52323. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52324. deviceType: DeviceType;
  52325. deviceSlot: number;
  52326. }>;
  52327. private readonly _devices;
  52328. private readonly _firstDevice;
  52329. private readonly _deviceInputSystem;
  52330. /**
  52331. * Default Constructor
  52332. * @param engine engine to pull input element from
  52333. */
  52334. constructor(engine: Engine);
  52335. /**
  52336. * Gets a DeviceSource, given a type and slot
  52337. * @param deviceType Enum specifying device type
  52338. * @param deviceSlot "Slot" or index that device is referenced in
  52339. * @returns DeviceSource object
  52340. */
  52341. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52342. /**
  52343. * Gets an array of DeviceSource objects for a given device type
  52344. * @param deviceType Enum specifying device type
  52345. * @returns Array of DeviceSource objects
  52346. */
  52347. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52348. /**
  52349. * Dispose of DeviceInputSystem and other parts
  52350. */
  52351. dispose(): void;
  52352. /**
  52353. * Function to add device name to device list
  52354. * @param deviceType Enum specifying device type
  52355. * @param deviceSlot "Slot" or index that device is referenced in
  52356. */
  52357. private _addDevice;
  52358. /**
  52359. * Function to remove device name to device list
  52360. * @param deviceType Enum specifying device type
  52361. * @param deviceSlot "Slot" or index that device is referenced in
  52362. */
  52363. private _removeDevice;
  52364. /**
  52365. * Updates array storing first connected device of each type
  52366. * @param type Type of Device
  52367. */
  52368. private _updateFirstDevices;
  52369. }
  52370. }
  52371. declare module "babylonjs/DeviceInput/index" {
  52372. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52373. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52374. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52375. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52376. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52377. }
  52378. declare module "babylonjs/Engines/nullEngine" {
  52379. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52380. import { Engine } from "babylonjs/Engines/engine";
  52381. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52382. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52384. import { Effect } from "babylonjs/Materials/effect";
  52385. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52386. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52387. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52388. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52389. /**
  52390. * Options to create the null engine
  52391. */
  52392. export class NullEngineOptions {
  52393. /**
  52394. * Render width (Default: 512)
  52395. */
  52396. renderWidth: number;
  52397. /**
  52398. * Render height (Default: 256)
  52399. */
  52400. renderHeight: number;
  52401. /**
  52402. * Texture size (Default: 512)
  52403. */
  52404. textureSize: number;
  52405. /**
  52406. * If delta time between frames should be constant
  52407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52408. */
  52409. deterministicLockstep: boolean;
  52410. /**
  52411. * Maximum about of steps between frames (Default: 4)
  52412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52413. */
  52414. lockstepMaxSteps: number;
  52415. }
  52416. /**
  52417. * The null engine class provides support for headless version of babylon.js.
  52418. * This can be used in server side scenario or for testing purposes
  52419. */
  52420. export class NullEngine extends Engine {
  52421. private _options;
  52422. /**
  52423. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52425. * @returns true if engine is in deterministic lock step mode
  52426. */
  52427. isDeterministicLockStep(): boolean;
  52428. /**
  52429. * Gets the max steps when engine is running in deterministic lock step
  52430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52431. * @returns the max steps
  52432. */
  52433. getLockstepMaxSteps(): number;
  52434. /**
  52435. * Gets the current hardware scaling level.
  52436. * By default the hardware scaling level is computed from the window device ratio.
  52437. * 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.
  52438. * @returns a number indicating the current hardware scaling level
  52439. */
  52440. getHardwareScalingLevel(): number;
  52441. constructor(options?: NullEngineOptions);
  52442. /**
  52443. * Creates a vertex buffer
  52444. * @param vertices the data for the vertex buffer
  52445. * @returns the new WebGL static buffer
  52446. */
  52447. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52448. /**
  52449. * Creates a new index buffer
  52450. * @param indices defines the content of the index buffer
  52451. * @param updatable defines if the index buffer must be updatable
  52452. * @returns a new webGL buffer
  52453. */
  52454. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52455. /**
  52456. * Clear the current render buffer or the current render target (if any is set up)
  52457. * @param color defines the color to use
  52458. * @param backBuffer defines if the back buffer must be cleared
  52459. * @param depth defines if the depth buffer must be cleared
  52460. * @param stencil defines if the stencil buffer must be cleared
  52461. */
  52462. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52463. /**
  52464. * Gets the current render width
  52465. * @param useScreen defines if screen size must be used (or the current render target if any)
  52466. * @returns a number defining the current render width
  52467. */
  52468. getRenderWidth(useScreen?: boolean): number;
  52469. /**
  52470. * Gets the current render height
  52471. * @param useScreen defines if screen size must be used (or the current render target if any)
  52472. * @returns a number defining the current render height
  52473. */
  52474. getRenderHeight(useScreen?: boolean): number;
  52475. /**
  52476. * Set the WebGL's viewport
  52477. * @param viewport defines the viewport element to be used
  52478. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52479. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52480. */
  52481. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52482. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52483. /**
  52484. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52485. * @param pipelineContext defines the pipeline context to use
  52486. * @param uniformsNames defines the list of uniform names
  52487. * @returns an array of webGL uniform locations
  52488. */
  52489. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52490. /**
  52491. * Gets the lsit of active attributes for a given webGL program
  52492. * @param pipelineContext defines the pipeline context to use
  52493. * @param attributesNames defines the list of attribute names to get
  52494. * @returns an array of indices indicating the offset of each attribute
  52495. */
  52496. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52497. /**
  52498. * Binds an effect to the webGL context
  52499. * @param effect defines the effect to bind
  52500. */
  52501. bindSamplers(effect: Effect): void;
  52502. /**
  52503. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52504. * @param effect defines the effect to activate
  52505. */
  52506. enableEffect(effect: Effect): void;
  52507. /**
  52508. * Set various states to the webGL context
  52509. * @param culling defines backface culling state
  52510. * @param zOffset defines the value to apply to zOffset (0 by default)
  52511. * @param force defines if states must be applied even if cache is up to date
  52512. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52513. */
  52514. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52515. /**
  52516. * Set the value of an uniform to an array of int32
  52517. * @param uniform defines the webGL uniform location where to store the value
  52518. * @param array defines the array of int32 to store
  52519. */
  52520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52521. /**
  52522. * Set the value of an uniform to an array of int32 (stored as vec2)
  52523. * @param uniform defines the webGL uniform location where to store the value
  52524. * @param array defines the array of int32 to store
  52525. */
  52526. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52527. /**
  52528. * Set the value of an uniform to an array of int32 (stored as vec3)
  52529. * @param uniform defines the webGL uniform location where to store the value
  52530. * @param array defines the array of int32 to store
  52531. */
  52532. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52533. /**
  52534. * Set the value of an uniform to an array of int32 (stored as vec4)
  52535. * @param uniform defines the webGL uniform location where to store the value
  52536. * @param array defines the array of int32 to store
  52537. */
  52538. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52539. /**
  52540. * Set the value of an uniform to an array of float32
  52541. * @param uniform defines the webGL uniform location where to store the value
  52542. * @param array defines the array of float32 to store
  52543. */
  52544. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52545. /**
  52546. * Set the value of an uniform to an array of float32 (stored as vec2)
  52547. * @param uniform defines the webGL uniform location where to store the value
  52548. * @param array defines the array of float32 to store
  52549. */
  52550. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52551. /**
  52552. * Set the value of an uniform to an array of float32 (stored as vec3)
  52553. * @param uniform defines the webGL uniform location where to store the value
  52554. * @param array defines the array of float32 to store
  52555. */
  52556. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52557. /**
  52558. * Set the value of an uniform to an array of float32 (stored as vec4)
  52559. * @param uniform defines the webGL uniform location where to store the value
  52560. * @param array defines the array of float32 to store
  52561. */
  52562. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52563. /**
  52564. * Set the value of an uniform to an array of number
  52565. * @param uniform defines the webGL uniform location where to store the value
  52566. * @param array defines the array of number to store
  52567. */
  52568. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52569. /**
  52570. * Set the value of an uniform to an array of number (stored as vec2)
  52571. * @param uniform defines the webGL uniform location where to store the value
  52572. * @param array defines the array of number to store
  52573. */
  52574. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52575. /**
  52576. * Set the value of an uniform to an array of number (stored as vec3)
  52577. * @param uniform defines the webGL uniform location where to store the value
  52578. * @param array defines the array of number to store
  52579. */
  52580. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52581. /**
  52582. * Set the value of an uniform to an array of number (stored as vec4)
  52583. * @param uniform defines the webGL uniform location where to store the value
  52584. * @param array defines the array of number to store
  52585. */
  52586. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52587. /**
  52588. * Set the value of an uniform to an array of float32 (stored as matrices)
  52589. * @param uniform defines the webGL uniform location where to store the value
  52590. * @param matrices defines the array of float32 to store
  52591. */
  52592. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52593. /**
  52594. * Set the value of an uniform to a matrix (3x3)
  52595. * @param uniform defines the webGL uniform location where to store the value
  52596. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52597. */
  52598. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52599. /**
  52600. * Set the value of an uniform to a matrix (2x2)
  52601. * @param uniform defines the webGL uniform location where to store the value
  52602. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52603. */
  52604. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52605. /**
  52606. * Set the value of an uniform to a number (float)
  52607. * @param uniform defines the webGL uniform location where to store the value
  52608. * @param value defines the float number to store
  52609. */
  52610. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52611. /**
  52612. * Set the value of an uniform to a vec2
  52613. * @param uniform defines the webGL uniform location where to store the value
  52614. * @param x defines the 1st component of the value
  52615. * @param y defines the 2nd component of the value
  52616. */
  52617. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52618. /**
  52619. * Set the value of an uniform to a vec3
  52620. * @param uniform defines the webGL uniform location where to store the value
  52621. * @param x defines the 1st component of the value
  52622. * @param y defines the 2nd component of the value
  52623. * @param z defines the 3rd component of the value
  52624. */
  52625. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52626. /**
  52627. * Set the value of an uniform to a boolean
  52628. * @param uniform defines the webGL uniform location where to store the value
  52629. * @param bool defines the boolean to store
  52630. */
  52631. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52632. /**
  52633. * Set the value of an uniform to a vec4
  52634. * @param uniform defines the webGL uniform location where to store the value
  52635. * @param x defines the 1st component of the value
  52636. * @param y defines the 2nd component of the value
  52637. * @param z defines the 3rd component of the value
  52638. * @param w defines the 4th component of the value
  52639. */
  52640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52641. /**
  52642. * Sets the current alpha mode
  52643. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52644. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52646. */
  52647. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52648. /**
  52649. * Bind webGl buffers directly to the webGL context
  52650. * @param vertexBuffers defines the vertex buffer to bind
  52651. * @param indexBuffer defines the index buffer to bind
  52652. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52653. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52654. * @param effect defines the effect associated with the vertex buffer
  52655. */
  52656. bindBuffers(vertexBuffers: {
  52657. [key: string]: VertexBuffer;
  52658. }, indexBuffer: DataBuffer, effect: Effect): void;
  52659. /**
  52660. * Force the entire cache to be cleared
  52661. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52662. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52663. */
  52664. wipeCaches(bruteForce?: boolean): void;
  52665. /**
  52666. * Send a draw order
  52667. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52668. * @param indexStart defines the starting index
  52669. * @param indexCount defines the number of index to draw
  52670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52671. */
  52672. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52673. /**
  52674. * Draw a list of indexed primitives
  52675. * @param fillMode defines the primitive to use
  52676. * @param indexStart defines the starting index
  52677. * @param indexCount defines the number of index to draw
  52678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52679. */
  52680. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52681. /**
  52682. * Draw a list of unindexed primitives
  52683. * @param fillMode defines the primitive to use
  52684. * @param verticesStart defines the index of first vertex to draw
  52685. * @param verticesCount defines the count of vertices to draw
  52686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52687. */
  52688. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52689. /** @hidden */
  52690. _createTexture(): WebGLTexture;
  52691. /** @hidden */
  52692. _releaseTexture(texture: InternalTexture): void;
  52693. /**
  52694. * Usually called from Texture.ts.
  52695. * Passed information to create a WebGLTexture
  52696. * @param urlArg defines a value which contains one of the following:
  52697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52701. * @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)
  52702. * @param scene needed for loading to the correct scene
  52703. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52704. * @param onLoad optional callback to be called upon successful completion
  52705. * @param onError optional callback to be called upon failure
  52706. * @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
  52707. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52709. * @param forcedExtension defines the extension to use to pick the right loader
  52710. * @param mimeType defines an optional mime type
  52711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52712. */
  52713. 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;
  52714. /**
  52715. * Creates a new render target texture
  52716. * @param size defines the size of the texture
  52717. * @param options defines the options used to create the texture
  52718. * @returns a new render target texture stored in an InternalTexture
  52719. */
  52720. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52721. /**
  52722. * Update the sampling mode of a given texture
  52723. * @param samplingMode defines the required sampling mode
  52724. * @param texture defines the texture to update
  52725. */
  52726. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52727. /**
  52728. * Binds the frame buffer to the specified texture.
  52729. * @param texture The texture to render to or null for the default canvas
  52730. * @param faceIndex The face of the texture to render to in case of cube texture
  52731. * @param requiredWidth The width of the target to render to
  52732. * @param requiredHeight The height of the target to render to
  52733. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52734. * @param lodLevel defines le lod level to bind to the frame buffer
  52735. */
  52736. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52737. /**
  52738. * Unbind the current render target texture from the webGL context
  52739. * @param texture defines the render target texture to unbind
  52740. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52741. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52742. */
  52743. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52744. /**
  52745. * Creates a dynamic vertex buffer
  52746. * @param vertices the data for the dynamic vertex buffer
  52747. * @returns the new WebGL dynamic buffer
  52748. */
  52749. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52750. /**
  52751. * Update the content of a dynamic texture
  52752. * @param texture defines the texture to update
  52753. * @param canvas defines the canvas containing the source
  52754. * @param invertY defines if data must be stored with Y axis inverted
  52755. * @param premulAlpha defines if alpha is stored as premultiplied
  52756. * @param format defines the format of the data
  52757. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52758. */
  52759. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52760. /**
  52761. * Gets a boolean indicating if all created effects are ready
  52762. * @returns true if all effects are ready
  52763. */
  52764. areAllEffectsReady(): boolean;
  52765. /**
  52766. * @hidden
  52767. * Get the current error code of the webGL context
  52768. * @returns the error code
  52769. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52770. */
  52771. getError(): number;
  52772. /** @hidden */
  52773. _getUnpackAlignement(): number;
  52774. /** @hidden */
  52775. _unpackFlipY(value: boolean): void;
  52776. /**
  52777. * Update a dynamic index buffer
  52778. * @param indexBuffer defines the target index buffer
  52779. * @param indices defines the data to update
  52780. * @param offset defines the offset in the target index buffer where update should start
  52781. */
  52782. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52783. /**
  52784. * Updates a dynamic vertex buffer.
  52785. * @param vertexBuffer the vertex buffer to update
  52786. * @param vertices the data used to update the vertex buffer
  52787. * @param byteOffset the byte offset of the data (optional)
  52788. * @param byteLength the byte length of the data (optional)
  52789. */
  52790. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52791. /** @hidden */
  52792. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52793. /** @hidden */
  52794. _bindTexture(channel: number, texture: InternalTexture): void;
  52795. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52796. /**
  52797. * 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
  52798. */
  52799. releaseEffects(): void;
  52800. displayLoadingUI(): void;
  52801. hideLoadingUI(): void;
  52802. /** @hidden */
  52803. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52804. /** @hidden */
  52805. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52806. /** @hidden */
  52807. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52808. /** @hidden */
  52809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52810. }
  52811. }
  52812. declare module "babylonjs/Instrumentation/timeToken" {
  52813. import { Nullable } from "babylonjs/types";
  52814. /**
  52815. * @hidden
  52816. **/
  52817. export class _TimeToken {
  52818. _startTimeQuery: Nullable<WebGLQuery>;
  52819. _endTimeQuery: Nullable<WebGLQuery>;
  52820. _timeElapsedQuery: Nullable<WebGLQuery>;
  52821. _timeElapsedQueryEnded: boolean;
  52822. }
  52823. }
  52824. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52825. import { Nullable, int } from "babylonjs/types";
  52826. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52827. /** @hidden */
  52828. export class _OcclusionDataStorage {
  52829. /** @hidden */
  52830. occlusionInternalRetryCounter: number;
  52831. /** @hidden */
  52832. isOcclusionQueryInProgress: boolean;
  52833. /** @hidden */
  52834. isOccluded: boolean;
  52835. /** @hidden */
  52836. occlusionRetryCount: number;
  52837. /** @hidden */
  52838. occlusionType: number;
  52839. /** @hidden */
  52840. occlusionQueryAlgorithmType: number;
  52841. }
  52842. module "babylonjs/Engines/engine" {
  52843. interface Engine {
  52844. /**
  52845. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52846. * @return the new query
  52847. */
  52848. createQuery(): WebGLQuery;
  52849. /**
  52850. * Delete and release a webGL query
  52851. * @param query defines the query to delete
  52852. * @return the current engine
  52853. */
  52854. deleteQuery(query: WebGLQuery): Engine;
  52855. /**
  52856. * Check if a given query has resolved and got its value
  52857. * @param query defines the query to check
  52858. * @returns true if the query got its value
  52859. */
  52860. isQueryResultAvailable(query: WebGLQuery): boolean;
  52861. /**
  52862. * Gets the value of a given query
  52863. * @param query defines the query to check
  52864. * @returns the value of the query
  52865. */
  52866. getQueryResult(query: WebGLQuery): number;
  52867. /**
  52868. * Initiates an occlusion query
  52869. * @param algorithmType defines the algorithm to use
  52870. * @param query defines the query to use
  52871. * @returns the current engine
  52872. * @see http://doc.babylonjs.com/features/occlusionquery
  52873. */
  52874. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52875. /**
  52876. * Ends an occlusion query
  52877. * @see http://doc.babylonjs.com/features/occlusionquery
  52878. * @param algorithmType defines the algorithm to use
  52879. * @returns the current engine
  52880. */
  52881. endOcclusionQuery(algorithmType: number): Engine;
  52882. /**
  52883. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52884. * Please note that only one query can be issued at a time
  52885. * @returns a time token used to track the time span
  52886. */
  52887. startTimeQuery(): Nullable<_TimeToken>;
  52888. /**
  52889. * Ends a time query
  52890. * @param token defines the token used to measure the time span
  52891. * @returns the time spent (in ns)
  52892. */
  52893. endTimeQuery(token: _TimeToken): int;
  52894. /** @hidden */
  52895. _currentNonTimestampToken: Nullable<_TimeToken>;
  52896. /** @hidden */
  52897. _createTimeQuery(): WebGLQuery;
  52898. /** @hidden */
  52899. _deleteTimeQuery(query: WebGLQuery): void;
  52900. /** @hidden */
  52901. _getGlAlgorithmType(algorithmType: number): number;
  52902. /** @hidden */
  52903. _getTimeQueryResult(query: WebGLQuery): any;
  52904. /** @hidden */
  52905. _getTimeQueryAvailability(query: WebGLQuery): any;
  52906. }
  52907. }
  52908. module "babylonjs/Meshes/abstractMesh" {
  52909. interface AbstractMesh {
  52910. /**
  52911. * Backing filed
  52912. * @hidden
  52913. */
  52914. __occlusionDataStorage: _OcclusionDataStorage;
  52915. /**
  52916. * Access property
  52917. * @hidden
  52918. */
  52919. _occlusionDataStorage: _OcclusionDataStorage;
  52920. /**
  52921. * 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.
  52922. * The default value is -1 which means don't break the query and wait till the result
  52923. * @see http://doc.babylonjs.com/features/occlusionquery
  52924. */
  52925. occlusionRetryCount: number;
  52926. /**
  52927. * 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:
  52928. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52929. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52930. * * 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.
  52931. * @see http://doc.babylonjs.com/features/occlusionquery
  52932. */
  52933. occlusionType: number;
  52934. /**
  52935. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52936. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52937. * * 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.
  52938. * @see http://doc.babylonjs.com/features/occlusionquery
  52939. */
  52940. occlusionQueryAlgorithmType: number;
  52941. /**
  52942. * 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
  52943. * @see http://doc.babylonjs.com/features/occlusionquery
  52944. */
  52945. isOccluded: boolean;
  52946. /**
  52947. * Flag to check the progress status of the query
  52948. * @see http://doc.babylonjs.com/features/occlusionquery
  52949. */
  52950. isOcclusionQueryInProgress: boolean;
  52951. }
  52952. }
  52953. }
  52954. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52955. import { Nullable } from "babylonjs/types";
  52956. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52957. /** @hidden */
  52958. export var _forceTransformFeedbackToBundle: boolean;
  52959. module "babylonjs/Engines/engine" {
  52960. interface Engine {
  52961. /**
  52962. * Creates a webGL transform feedback object
  52963. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52964. * @returns the webGL transform feedback object
  52965. */
  52966. createTransformFeedback(): WebGLTransformFeedback;
  52967. /**
  52968. * Delete a webGL transform feedback object
  52969. * @param value defines the webGL transform feedback object to delete
  52970. */
  52971. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52972. /**
  52973. * Bind a webGL transform feedback object to the webgl context
  52974. * @param value defines the webGL transform feedback object to bind
  52975. */
  52976. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52977. /**
  52978. * Begins a transform feedback operation
  52979. * @param usePoints defines if points or triangles must be used
  52980. */
  52981. beginTransformFeedback(usePoints: boolean): void;
  52982. /**
  52983. * Ends a transform feedback operation
  52984. */
  52985. endTransformFeedback(): void;
  52986. /**
  52987. * Specify the varyings to use with transform feedback
  52988. * @param program defines the associated webGL program
  52989. * @param value defines the list of strings representing the varying names
  52990. */
  52991. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52992. /**
  52993. * Bind a webGL buffer for a transform feedback operation
  52994. * @param value defines the webGL buffer to bind
  52995. */
  52996. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52997. }
  52998. }
  52999. }
  53000. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53001. import { Scene } from "babylonjs/scene";
  53002. import { Engine } from "babylonjs/Engines/engine";
  53003. import { Texture } from "babylonjs/Materials/Textures/texture";
  53004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53005. import "babylonjs/Engines/Extensions/engine.multiRender";
  53006. /**
  53007. * Creation options of the multi render target texture.
  53008. */
  53009. export interface IMultiRenderTargetOptions {
  53010. /**
  53011. * Define if the texture needs to create mip maps after render.
  53012. */
  53013. generateMipMaps?: boolean;
  53014. /**
  53015. * Define the types of all the draw buffers we want to create
  53016. */
  53017. types?: number[];
  53018. /**
  53019. * Define the sampling modes of all the draw buffers we want to create
  53020. */
  53021. samplingModes?: number[];
  53022. /**
  53023. * Define if a depth buffer is required
  53024. */
  53025. generateDepthBuffer?: boolean;
  53026. /**
  53027. * Define if a stencil buffer is required
  53028. */
  53029. generateStencilBuffer?: boolean;
  53030. /**
  53031. * Define if a depth texture is required instead of a depth buffer
  53032. */
  53033. generateDepthTexture?: boolean;
  53034. /**
  53035. * Define the number of desired draw buffers
  53036. */
  53037. textureCount?: number;
  53038. /**
  53039. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53040. */
  53041. doNotChangeAspectRatio?: boolean;
  53042. /**
  53043. * Define the default type of the buffers we are creating
  53044. */
  53045. defaultType?: number;
  53046. }
  53047. /**
  53048. * A multi render target, like a render target provides the ability to render to a texture.
  53049. * Unlike the render target, it can render to several draw buffers in one draw.
  53050. * This is specially interesting in deferred rendering or for any effects requiring more than
  53051. * just one color from a single pass.
  53052. */
  53053. export class MultiRenderTarget extends RenderTargetTexture {
  53054. private _internalTextures;
  53055. private _textures;
  53056. private _multiRenderTargetOptions;
  53057. /**
  53058. * Get if draw buffers are currently supported by the used hardware and browser.
  53059. */
  53060. get isSupported(): boolean;
  53061. /**
  53062. * Get the list of textures generated by the multi render target.
  53063. */
  53064. get textures(): Texture[];
  53065. /**
  53066. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53067. */
  53068. get depthTexture(): Texture;
  53069. /**
  53070. * Set the wrapping mode on U of all the textures we are rendering to.
  53071. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53072. */
  53073. set wrapU(wrap: number);
  53074. /**
  53075. * Set the wrapping mode on V of all the textures we are rendering to.
  53076. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53077. */
  53078. set wrapV(wrap: number);
  53079. /**
  53080. * Instantiate a new multi render target texture.
  53081. * A multi render target, like a render target provides the ability to render to a texture.
  53082. * Unlike the render target, it can render to several draw buffers in one draw.
  53083. * This is specially interesting in deferred rendering or for any effects requiring more than
  53084. * just one color from a single pass.
  53085. * @param name Define the name of the texture
  53086. * @param size Define the size of the buffers to render to
  53087. * @param count Define the number of target we are rendering into
  53088. * @param scene Define the scene the texture belongs to
  53089. * @param options Define the options used to create the multi render target
  53090. */
  53091. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53092. /** @hidden */
  53093. _rebuild(): void;
  53094. private _createInternalTextures;
  53095. private _createTextures;
  53096. /**
  53097. * Define the number of samples used if MSAA is enabled.
  53098. */
  53099. get samples(): number;
  53100. set samples(value: number);
  53101. /**
  53102. * Resize all the textures in the multi render target.
  53103. * Be carrefull as it will recreate all the data in the new texture.
  53104. * @param size Define the new size
  53105. */
  53106. resize(size: any): void;
  53107. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53108. /**
  53109. * Dispose the render targets and their associated resources
  53110. */
  53111. dispose(): void;
  53112. /**
  53113. * Release all the underlying texture used as draw buffers.
  53114. */
  53115. releaseInternalTextures(): void;
  53116. }
  53117. }
  53118. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53120. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53121. import { Nullable } from "babylonjs/types";
  53122. module "babylonjs/Engines/thinEngine" {
  53123. interface ThinEngine {
  53124. /**
  53125. * Unbind a list of render target textures from the webGL context
  53126. * This is used only when drawBuffer extension or webGL2 are active
  53127. * @param textures defines the render target textures to unbind
  53128. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53129. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53130. */
  53131. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53132. /**
  53133. * Create a multi render target texture
  53134. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  53135. * @param size defines the size of the texture
  53136. * @param options defines the creation options
  53137. * @returns the cube texture as an InternalTexture
  53138. */
  53139. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53140. /**
  53141. * Update the sample count for a given multiple render target texture
  53142. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53143. * @param textures defines the textures to update
  53144. * @param samples defines the sample count to set
  53145. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53146. */
  53147. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53148. }
  53149. }
  53150. }
  53151. declare module "babylonjs/Engines/Extensions/engine.views" {
  53152. import { Camera } from "babylonjs/Cameras/camera";
  53153. import { Nullable } from "babylonjs/types";
  53154. /**
  53155. * Class used to define an additional view for the engine
  53156. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53157. */
  53158. export class EngineView {
  53159. /** Defines the canvas where to render the view */
  53160. target: HTMLCanvasElement;
  53161. /** Defines an optional camera used to render the view (will use active camera else) */
  53162. camera?: Camera;
  53163. }
  53164. module "babylonjs/Engines/engine" {
  53165. interface Engine {
  53166. /**
  53167. * Gets or sets the HTML element to use for attaching events
  53168. */
  53169. inputElement: Nullable<HTMLElement>;
  53170. /**
  53171. * Gets the current engine view
  53172. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53173. */
  53174. activeView: Nullable<EngineView>;
  53175. /** Gets or sets the list of views */
  53176. views: EngineView[];
  53177. /**
  53178. * Register a new child canvas
  53179. * @param canvas defines the canvas to register
  53180. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53181. * @returns the associated view
  53182. */
  53183. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53184. /**
  53185. * Remove a registered child canvas
  53186. * @param canvas defines the canvas to remove
  53187. * @returns the current engine
  53188. */
  53189. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53190. }
  53191. }
  53192. }
  53193. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53194. import { Nullable } from "babylonjs/types";
  53195. module "babylonjs/Engines/engine" {
  53196. interface Engine {
  53197. /** @hidden */
  53198. _excludedCompressedTextures: string[];
  53199. /** @hidden */
  53200. _textureFormatInUse: string;
  53201. /**
  53202. * Gets the list of texture formats supported
  53203. */
  53204. readonly texturesSupported: Array<string>;
  53205. /**
  53206. * Gets the texture format in use
  53207. */
  53208. readonly textureFormatInUse: Nullable<string>;
  53209. /**
  53210. * Set the compressed texture extensions or file names to skip.
  53211. *
  53212. * @param skippedFiles defines the list of those texture files you want to skip
  53213. * Example: [".dds", ".env", "myfile.png"]
  53214. */
  53215. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53216. /**
  53217. * Set the compressed texture format to use, based on the formats you have, and the formats
  53218. * supported by the hardware / browser.
  53219. *
  53220. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53221. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53222. * to API arguments needed to compressed textures. This puts the burden on the container
  53223. * generator to house the arcane code for determining these for current & future formats.
  53224. *
  53225. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53226. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53227. *
  53228. * Note: The result of this call is not taken into account when a texture is base64.
  53229. *
  53230. * @param formatsAvailable defines the list of those format families you have created
  53231. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53232. *
  53233. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53234. * @returns The extension selected.
  53235. */
  53236. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53237. }
  53238. }
  53239. }
  53240. declare module "babylonjs/Engines/Extensions/index" {
  53241. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53242. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53243. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53244. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53245. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53246. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53247. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53248. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53249. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53250. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53251. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53252. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53253. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53254. export * from "babylonjs/Engines/Extensions/engine.views";
  53255. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53256. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53257. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53258. }
  53259. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53260. import { Nullable } from "babylonjs/types";
  53261. /**
  53262. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53263. */
  53264. export interface CubeMapInfo {
  53265. /**
  53266. * The pixel array for the front face.
  53267. * This is stored in format, left to right, up to down format.
  53268. */
  53269. front: Nullable<ArrayBufferView>;
  53270. /**
  53271. * The pixel array for the back face.
  53272. * This is stored in format, left to right, up to down format.
  53273. */
  53274. back: Nullable<ArrayBufferView>;
  53275. /**
  53276. * The pixel array for the left face.
  53277. * This is stored in format, left to right, up to down format.
  53278. */
  53279. left: Nullable<ArrayBufferView>;
  53280. /**
  53281. * The pixel array for the right face.
  53282. * This is stored in format, left to right, up to down format.
  53283. */
  53284. right: Nullable<ArrayBufferView>;
  53285. /**
  53286. * The pixel array for the up face.
  53287. * This is stored in format, left to right, up to down format.
  53288. */
  53289. up: Nullable<ArrayBufferView>;
  53290. /**
  53291. * The pixel array for the down face.
  53292. * This is stored in format, left to right, up to down format.
  53293. */
  53294. down: Nullable<ArrayBufferView>;
  53295. /**
  53296. * The size of the cubemap stored.
  53297. *
  53298. * Each faces will be size * size pixels.
  53299. */
  53300. size: number;
  53301. /**
  53302. * The format of the texture.
  53303. *
  53304. * RGBA, RGB.
  53305. */
  53306. format: number;
  53307. /**
  53308. * The type of the texture data.
  53309. *
  53310. * UNSIGNED_INT, FLOAT.
  53311. */
  53312. type: number;
  53313. /**
  53314. * Specifies whether the texture is in gamma space.
  53315. */
  53316. gammaSpace: boolean;
  53317. }
  53318. /**
  53319. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53320. */
  53321. export class PanoramaToCubeMapTools {
  53322. private static FACE_LEFT;
  53323. private static FACE_RIGHT;
  53324. private static FACE_FRONT;
  53325. private static FACE_BACK;
  53326. private static FACE_DOWN;
  53327. private static FACE_UP;
  53328. /**
  53329. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53330. *
  53331. * @param float32Array The source data.
  53332. * @param inputWidth The width of the input panorama.
  53333. * @param inputHeight The height of the input panorama.
  53334. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53335. * @return The cubemap data
  53336. */
  53337. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53338. private static CreateCubemapTexture;
  53339. private static CalcProjectionSpherical;
  53340. }
  53341. }
  53342. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53343. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53345. import { Nullable } from "babylonjs/types";
  53346. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53347. /**
  53348. * Helper class dealing with the extraction of spherical polynomial dataArray
  53349. * from a cube map.
  53350. */
  53351. export class CubeMapToSphericalPolynomialTools {
  53352. private static FileFaces;
  53353. /**
  53354. * Converts a texture to the according Spherical Polynomial data.
  53355. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53356. *
  53357. * @param texture The texture to extract the information from.
  53358. * @return The Spherical Polynomial data.
  53359. */
  53360. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53361. /**
  53362. * Converts a cubemap to the according Spherical Polynomial data.
  53363. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53364. *
  53365. * @param cubeInfo The Cube map to extract the information from.
  53366. * @return The Spherical Polynomial data.
  53367. */
  53368. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53369. }
  53370. }
  53371. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53372. import { Nullable } from "babylonjs/types";
  53373. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53374. module "babylonjs/Materials/Textures/baseTexture" {
  53375. interface BaseTexture {
  53376. /**
  53377. * Get the polynomial representation of the texture data.
  53378. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53379. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53380. */
  53381. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53382. }
  53383. }
  53384. }
  53385. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53387. /** @hidden */
  53388. export var rgbdEncodePixelShader: {
  53389. name: string;
  53390. shader: string;
  53391. };
  53392. }
  53393. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53395. /** @hidden */
  53396. export var rgbdDecodePixelShader: {
  53397. name: string;
  53398. shader: string;
  53399. };
  53400. }
  53401. declare module "babylonjs/Misc/environmentTextureTools" {
  53402. import { Nullable } from "babylonjs/types";
  53403. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53406. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53407. import "babylonjs/Engines/Extensions/engine.readTexture";
  53408. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53409. import "babylonjs/Shaders/rgbdEncode.fragment";
  53410. import "babylonjs/Shaders/rgbdDecode.fragment";
  53411. /**
  53412. * Raw texture data and descriptor sufficient for WebGL texture upload
  53413. */
  53414. export interface EnvironmentTextureInfo {
  53415. /**
  53416. * Version of the environment map
  53417. */
  53418. version: number;
  53419. /**
  53420. * Width of image
  53421. */
  53422. width: number;
  53423. /**
  53424. * Irradiance information stored in the file.
  53425. */
  53426. irradiance: any;
  53427. /**
  53428. * Specular information stored in the file.
  53429. */
  53430. specular: any;
  53431. }
  53432. /**
  53433. * Defines One Image in the file. It requires only the position in the file
  53434. * as well as the length.
  53435. */
  53436. interface BufferImageData {
  53437. /**
  53438. * Length of the image data.
  53439. */
  53440. length: number;
  53441. /**
  53442. * Position of the data from the null terminator delimiting the end of the JSON.
  53443. */
  53444. position: number;
  53445. }
  53446. /**
  53447. * Defines the specular data enclosed in the file.
  53448. * This corresponds to the version 1 of the data.
  53449. */
  53450. export interface EnvironmentTextureSpecularInfoV1 {
  53451. /**
  53452. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53453. */
  53454. specularDataPosition?: number;
  53455. /**
  53456. * This contains all the images data needed to reconstruct the cubemap.
  53457. */
  53458. mipmaps: Array<BufferImageData>;
  53459. /**
  53460. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53461. */
  53462. lodGenerationScale: number;
  53463. }
  53464. /**
  53465. * Sets of helpers addressing the serialization and deserialization of environment texture
  53466. * stored in a BabylonJS env file.
  53467. * Those files are usually stored as .env files.
  53468. */
  53469. export class EnvironmentTextureTools {
  53470. /**
  53471. * Magic number identifying the env file.
  53472. */
  53473. private static _MagicBytes;
  53474. /**
  53475. * Gets the environment info from an env file.
  53476. * @param data The array buffer containing the .env bytes.
  53477. * @returns the environment file info (the json header) if successfully parsed.
  53478. */
  53479. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53480. /**
  53481. * Creates an environment texture from a loaded cube texture.
  53482. * @param texture defines the cube texture to convert in env file
  53483. * @return a promise containing the environment data if succesfull.
  53484. */
  53485. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53486. /**
  53487. * Creates a JSON representation of the spherical data.
  53488. * @param texture defines the texture containing the polynomials
  53489. * @return the JSON representation of the spherical info
  53490. */
  53491. private static _CreateEnvTextureIrradiance;
  53492. /**
  53493. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53494. * @param data the image data
  53495. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53496. * @return the views described by info providing access to the underlying buffer
  53497. */
  53498. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53499. /**
  53500. * Uploads the texture info contained in the env file to the GPU.
  53501. * @param texture defines the internal texture to upload to
  53502. * @param data defines the data to load
  53503. * @param info defines the texture info retrieved through the GetEnvInfo method
  53504. * @returns a promise
  53505. */
  53506. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53507. private static _OnImageReadyAsync;
  53508. /**
  53509. * Uploads the levels of image data to the GPU.
  53510. * @param texture defines the internal texture to upload to
  53511. * @param imageData defines the array buffer views of image data [mipmap][face]
  53512. * @returns a promise
  53513. */
  53514. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53515. /**
  53516. * Uploads spherical polynomials information to the texture.
  53517. * @param texture defines the texture we are trying to upload the information to
  53518. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53519. */
  53520. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53521. /** @hidden */
  53522. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53523. }
  53524. }
  53525. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53526. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53527. /** @hidden */
  53528. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53529. private _genericAttributeLocation;
  53530. private _varyingLocationCount;
  53531. private _varyingLocationMap;
  53532. private _replacements;
  53533. private _textureCount;
  53534. private _uniforms;
  53535. lineProcessor(line: string): string;
  53536. attributeProcessor(attribute: string): string;
  53537. varyingProcessor(varying: string, isFragment: boolean): string;
  53538. uniformProcessor(uniform: string): string;
  53539. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53540. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53541. }
  53542. }
  53543. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53544. /**
  53545. * Class used to inline functions in shader code
  53546. */
  53547. export class ShaderCodeInliner {
  53548. private static readonly _RegexpFindFunctionNameAndType;
  53549. private _sourceCode;
  53550. private _functionDescr;
  53551. private _numMaxIterations;
  53552. /** Gets or sets the token used to mark the functions to inline */
  53553. inlineToken: string;
  53554. /** Gets or sets the debug mode */
  53555. debug: boolean;
  53556. /** Gets the code after the inlining process */
  53557. get code(): string;
  53558. /**
  53559. * Initializes the inliner
  53560. * @param sourceCode shader code source to inline
  53561. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53562. */
  53563. constructor(sourceCode: string, numMaxIterations?: number);
  53564. /**
  53565. * Start the processing of the shader code
  53566. */
  53567. processCode(): void;
  53568. private _collectFunctions;
  53569. private _processInlining;
  53570. private _extractBetweenMarkers;
  53571. private _skipWhitespaces;
  53572. private _removeComments;
  53573. private _replaceFunctionCallsByCode;
  53574. private _findBackward;
  53575. private _escapeRegExp;
  53576. private _replaceNames;
  53577. }
  53578. }
  53579. declare module "babylonjs/Engines/nativeEngine" {
  53580. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53581. import { Engine } from "babylonjs/Engines/engine";
  53582. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53583. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53585. import { Effect } from "babylonjs/Materials/effect";
  53586. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53587. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53588. import { IColor4Like } from "babylonjs/Maths/math.like";
  53589. import { Scene } from "babylonjs/scene";
  53590. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53591. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53592. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53593. /**
  53594. * Container for accessors for natively-stored mesh data buffers.
  53595. */
  53596. class NativeDataBuffer extends DataBuffer {
  53597. /**
  53598. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53599. */
  53600. nativeIndexBuffer?: any;
  53601. /**
  53602. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53603. */
  53604. nativeVertexBuffer?: any;
  53605. }
  53606. /** @hidden */
  53607. class NativeTexture extends InternalTexture {
  53608. getInternalTexture(): InternalTexture;
  53609. getViewCount(): number;
  53610. }
  53611. /** @hidden */
  53612. export class NativeEngine extends Engine {
  53613. private readonly _native;
  53614. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53615. private readonly INVALID_HANDLE;
  53616. getHardwareScalingLevel(): number;
  53617. constructor();
  53618. dispose(): void;
  53619. /**
  53620. * Can be used to override the current requestAnimationFrame requester.
  53621. * @hidden
  53622. */
  53623. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53624. /**
  53625. * Override default engine behavior.
  53626. * @param color
  53627. * @param backBuffer
  53628. * @param depth
  53629. * @param stencil
  53630. */
  53631. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53632. /**
  53633. * Gets host document
  53634. * @returns the host document object
  53635. */
  53636. getHostDocument(): Nullable<Document>;
  53637. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53638. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53639. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53640. recordVertexArrayObject(vertexBuffers: {
  53641. [key: string]: VertexBuffer;
  53642. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53643. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53644. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53645. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53646. /**
  53647. * Draw a list of indexed primitives
  53648. * @param fillMode defines the primitive to use
  53649. * @param indexStart defines the starting index
  53650. * @param indexCount defines the number of index to draw
  53651. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53652. */
  53653. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53654. /**
  53655. * Draw a list of unindexed primitives
  53656. * @param fillMode defines the primitive to use
  53657. * @param verticesStart defines the index of first vertex to draw
  53658. * @param verticesCount defines the count of vertices to draw
  53659. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53660. */
  53661. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53662. createPipelineContext(): IPipelineContext;
  53663. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53664. /** @hidden */
  53665. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53666. /** @hidden */
  53667. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53668. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53669. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53670. protected _setProgram(program: WebGLProgram): void;
  53671. _releaseEffect(effect: Effect): void;
  53672. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53673. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53674. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53675. bindSamplers(effect: Effect): void;
  53676. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53677. getRenderWidth(useScreen?: boolean): number;
  53678. getRenderHeight(useScreen?: boolean): number;
  53679. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53680. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53681. /**
  53682. * Set the z offset to apply to current rendering
  53683. * @param value defines the offset to apply
  53684. */
  53685. setZOffset(value: number): void;
  53686. /**
  53687. * Gets the current value of the zOffset
  53688. * @returns the current zOffset state
  53689. */
  53690. getZOffset(): number;
  53691. /**
  53692. * Enable or disable depth buffering
  53693. * @param enable defines the state to set
  53694. */
  53695. setDepthBuffer(enable: boolean): void;
  53696. /**
  53697. * Gets a boolean indicating if depth writing is enabled
  53698. * @returns the current depth writing state
  53699. */
  53700. getDepthWrite(): boolean;
  53701. /**
  53702. * Enable or disable depth writing
  53703. * @param enable defines the state to set
  53704. */
  53705. setDepthWrite(enable: boolean): void;
  53706. /**
  53707. * Enable or disable color writing
  53708. * @param enable defines the state to set
  53709. */
  53710. setColorWrite(enable: boolean): void;
  53711. /**
  53712. * Gets a boolean indicating if color writing is enabled
  53713. * @returns the current color writing state
  53714. */
  53715. getColorWrite(): boolean;
  53716. /**
  53717. * Sets alpha constants used by some alpha blending modes
  53718. * @param r defines the red component
  53719. * @param g defines the green component
  53720. * @param b defines the blue component
  53721. * @param a defines the alpha component
  53722. */
  53723. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53724. /**
  53725. * Sets the current alpha mode
  53726. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53727. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53728. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53729. */
  53730. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53731. /**
  53732. * Gets the current alpha mode
  53733. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53734. * @returns the current alpha mode
  53735. */
  53736. getAlphaMode(): number;
  53737. setInt(uniform: WebGLUniformLocation, int: number): void;
  53738. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53739. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53740. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53741. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53742. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53743. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53744. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53745. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53746. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53747. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53748. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53749. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53750. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53751. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53752. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53753. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53754. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53755. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53756. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53757. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53758. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53759. wipeCaches(bruteForce?: boolean): void;
  53760. _createTexture(): WebGLTexture;
  53761. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53762. /**
  53763. * Usually called from Texture.ts.
  53764. * Passed information to create a WebGLTexture
  53765. * @param url defines a value which contains one of the following:
  53766. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53767. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53768. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53769. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53770. * @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)
  53771. * @param scene needed for loading to the correct scene
  53772. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53773. * @param onLoad optional callback to be called upon successful completion
  53774. * @param onError optional callback to be called upon failure
  53775. * @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
  53776. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53777. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53778. * @param forcedExtension defines the extension to use to pick the right loader
  53779. * @param mimeType defines an optional mime type
  53780. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53781. */
  53782. 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;
  53783. /**
  53784. * Creates a cube texture
  53785. * @param rootUrl defines the url where the files to load is located
  53786. * @param scene defines the current scene
  53787. * @param files defines the list of files to load (1 per face)
  53788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53789. * @param onLoad defines an optional callback raised when the texture is loaded
  53790. * @param onError defines an optional callback raised if there is an issue to load the texture
  53791. * @param format defines the format of the data
  53792. * @param forcedExtension defines the extension to use to pick the right loader
  53793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53796. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53797. * @returns the cube texture as an InternalTexture
  53798. */
  53799. 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;
  53800. private _getSamplingFilter;
  53801. private static _GetNativeTextureFormat;
  53802. createRenderTargetTexture(size: number | {
  53803. width: number;
  53804. height: number;
  53805. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53806. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53807. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53808. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53809. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53810. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53811. /**
  53812. * Updates a dynamic vertex buffer.
  53813. * @param vertexBuffer the vertex buffer to update
  53814. * @param data the data used to update the vertex buffer
  53815. * @param byteOffset the byte offset of the data (optional)
  53816. * @param byteLength the byte length of the data (optional)
  53817. */
  53818. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53819. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53820. private _updateAnisotropicLevel;
  53821. private _getAddressMode;
  53822. /** @hidden */
  53823. _bindTexture(channel: number, texture: InternalTexture): void;
  53824. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53825. releaseEffects(): void;
  53826. /** @hidden */
  53827. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53828. /** @hidden */
  53829. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53830. /** @hidden */
  53831. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53832. /** @hidden */
  53833. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53834. }
  53835. }
  53836. declare module "babylonjs/Engines/index" {
  53837. export * from "babylonjs/Engines/constants";
  53838. export * from "babylonjs/Engines/engineCapabilities";
  53839. export * from "babylonjs/Engines/instancingAttributeInfo";
  53840. export * from "babylonjs/Engines/thinEngine";
  53841. export * from "babylonjs/Engines/engine";
  53842. export * from "babylonjs/Engines/engineStore";
  53843. export * from "babylonjs/Engines/nullEngine";
  53844. export * from "babylonjs/Engines/Extensions/index";
  53845. export * from "babylonjs/Engines/IPipelineContext";
  53846. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53847. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53848. export * from "babylonjs/Engines/nativeEngine";
  53849. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53850. }
  53851. declare module "babylonjs/Events/clipboardEvents" {
  53852. /**
  53853. * Gather the list of clipboard event types as constants.
  53854. */
  53855. export class ClipboardEventTypes {
  53856. /**
  53857. * The clipboard event is fired when a copy command is active (pressed).
  53858. */
  53859. static readonly COPY: number;
  53860. /**
  53861. * The clipboard event is fired when a cut command is active (pressed).
  53862. */
  53863. static readonly CUT: number;
  53864. /**
  53865. * The clipboard event is fired when a paste command is active (pressed).
  53866. */
  53867. static readonly PASTE: number;
  53868. }
  53869. /**
  53870. * This class is used to store clipboard related info for the onClipboardObservable event.
  53871. */
  53872. export class ClipboardInfo {
  53873. /**
  53874. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53875. */
  53876. type: number;
  53877. /**
  53878. * Defines the related dom event
  53879. */
  53880. event: ClipboardEvent;
  53881. /**
  53882. *Creates an instance of ClipboardInfo.
  53883. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53884. * @param event Defines the related dom event
  53885. */
  53886. constructor(
  53887. /**
  53888. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53889. */
  53890. type: number,
  53891. /**
  53892. * Defines the related dom event
  53893. */
  53894. event: ClipboardEvent);
  53895. /**
  53896. * Get the clipboard event's type from the keycode.
  53897. * @param keyCode Defines the keyCode for the current keyboard event.
  53898. * @return {number}
  53899. */
  53900. static GetTypeFromCharacter(keyCode: number): number;
  53901. }
  53902. }
  53903. declare module "babylonjs/Events/index" {
  53904. export * from "babylonjs/Events/keyboardEvents";
  53905. export * from "babylonjs/Events/pointerEvents";
  53906. export * from "babylonjs/Events/clipboardEvents";
  53907. }
  53908. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53909. import { Scene } from "babylonjs/scene";
  53910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53911. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53912. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53913. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53914. /**
  53915. * Google Daydream controller
  53916. */
  53917. export class DaydreamController extends WebVRController {
  53918. /**
  53919. * Base Url for the controller model.
  53920. */
  53921. static MODEL_BASE_URL: string;
  53922. /**
  53923. * File name for the controller model.
  53924. */
  53925. static MODEL_FILENAME: string;
  53926. /**
  53927. * Gamepad Id prefix used to identify Daydream Controller.
  53928. */
  53929. static readonly GAMEPAD_ID_PREFIX: string;
  53930. /**
  53931. * Creates a new DaydreamController from a gamepad
  53932. * @param vrGamepad the gamepad that the controller should be created from
  53933. */
  53934. constructor(vrGamepad: any);
  53935. /**
  53936. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53937. * @param scene scene in which to add meshes
  53938. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53939. */
  53940. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53941. /**
  53942. * Called once for each button that changed state since the last frame
  53943. * @param buttonIdx Which button index changed
  53944. * @param state New state of the button
  53945. * @param changes Which properties on the state changed since last frame
  53946. */
  53947. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53948. }
  53949. }
  53950. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53951. import { Scene } from "babylonjs/scene";
  53952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53953. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53954. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53955. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53956. /**
  53957. * Gear VR Controller
  53958. */
  53959. export class GearVRController extends WebVRController {
  53960. /**
  53961. * Base Url for the controller model.
  53962. */
  53963. static MODEL_BASE_URL: string;
  53964. /**
  53965. * File name for the controller model.
  53966. */
  53967. static MODEL_FILENAME: string;
  53968. /**
  53969. * Gamepad Id prefix used to identify this controller.
  53970. */
  53971. static readonly GAMEPAD_ID_PREFIX: string;
  53972. private readonly _buttonIndexToObservableNameMap;
  53973. /**
  53974. * Creates a new GearVRController from a gamepad
  53975. * @param vrGamepad the gamepad that the controller should be created from
  53976. */
  53977. constructor(vrGamepad: any);
  53978. /**
  53979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53980. * @param scene scene in which to add meshes
  53981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53982. */
  53983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53984. /**
  53985. * Called once for each button that changed state since the last frame
  53986. * @param buttonIdx Which button index changed
  53987. * @param state New state of the button
  53988. * @param changes Which properties on the state changed since last frame
  53989. */
  53990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53991. }
  53992. }
  53993. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53994. import { Scene } from "babylonjs/scene";
  53995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53996. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53997. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53998. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53999. /**
  54000. * Generic Controller
  54001. */
  54002. export class GenericController extends WebVRController {
  54003. /**
  54004. * Base Url for the controller model.
  54005. */
  54006. static readonly MODEL_BASE_URL: string;
  54007. /**
  54008. * File name for the controller model.
  54009. */
  54010. static readonly MODEL_FILENAME: string;
  54011. /**
  54012. * Creates a new GenericController from a gamepad
  54013. * @param vrGamepad the gamepad that the controller should be created from
  54014. */
  54015. constructor(vrGamepad: any);
  54016. /**
  54017. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54018. * @param scene scene in which to add meshes
  54019. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54020. */
  54021. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54022. /**
  54023. * Called once for each button that changed state since the last frame
  54024. * @param buttonIdx Which button index changed
  54025. * @param state New state of the button
  54026. * @param changes Which properties on the state changed since last frame
  54027. */
  54028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54029. }
  54030. }
  54031. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54032. import { Observable } from "babylonjs/Misc/observable";
  54033. import { Scene } from "babylonjs/scene";
  54034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54035. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54036. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54037. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54038. /**
  54039. * Oculus Touch Controller
  54040. */
  54041. export class OculusTouchController extends WebVRController {
  54042. /**
  54043. * Base Url for the controller model.
  54044. */
  54045. static MODEL_BASE_URL: string;
  54046. /**
  54047. * File name for the left controller model.
  54048. */
  54049. static MODEL_LEFT_FILENAME: string;
  54050. /**
  54051. * File name for the right controller model.
  54052. */
  54053. static MODEL_RIGHT_FILENAME: string;
  54054. /**
  54055. * Base Url for the Quest controller model.
  54056. */
  54057. static QUEST_MODEL_BASE_URL: string;
  54058. /**
  54059. * @hidden
  54060. * If the controllers are running on a device that needs the updated Quest controller models
  54061. */
  54062. static _IsQuest: boolean;
  54063. /**
  54064. * Fired when the secondary trigger on this controller is modified
  54065. */
  54066. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54067. /**
  54068. * Fired when the thumb rest on this controller is modified
  54069. */
  54070. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54071. /**
  54072. * Creates a new OculusTouchController from a gamepad
  54073. * @param vrGamepad the gamepad that the controller should be created from
  54074. */
  54075. constructor(vrGamepad: any);
  54076. /**
  54077. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54078. * @param scene scene in which to add meshes
  54079. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54080. */
  54081. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54082. /**
  54083. * Fired when the A button on this controller is modified
  54084. */
  54085. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54086. /**
  54087. * Fired when the B button on this controller is modified
  54088. */
  54089. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54090. /**
  54091. * Fired when the X button on this controller is modified
  54092. */
  54093. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54094. /**
  54095. * Fired when the Y button on this controller is modified
  54096. */
  54097. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54098. /**
  54099. * Called once for each button that changed state since the last frame
  54100. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54101. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54102. * 2) secondary trigger (same)
  54103. * 3) A (right) X (left), touch, pressed = value
  54104. * 4) B / Y
  54105. * 5) thumb rest
  54106. * @param buttonIdx Which button index changed
  54107. * @param state New state of the button
  54108. * @param changes Which properties on the state changed since last frame
  54109. */
  54110. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54111. }
  54112. }
  54113. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54114. import { Scene } from "babylonjs/scene";
  54115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54116. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54117. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54118. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54119. import { Observable } from "babylonjs/Misc/observable";
  54120. /**
  54121. * Vive Controller
  54122. */
  54123. export class ViveController extends WebVRController {
  54124. /**
  54125. * Base Url for the controller model.
  54126. */
  54127. static MODEL_BASE_URL: string;
  54128. /**
  54129. * File name for the controller model.
  54130. */
  54131. static MODEL_FILENAME: string;
  54132. /**
  54133. * Creates a new ViveController from a gamepad
  54134. * @param vrGamepad the gamepad that the controller should be created from
  54135. */
  54136. constructor(vrGamepad: any);
  54137. /**
  54138. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54139. * @param scene scene in which to add meshes
  54140. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54141. */
  54142. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54143. /**
  54144. * Fired when the left button on this controller is modified
  54145. */
  54146. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54147. /**
  54148. * Fired when the right button on this controller is modified
  54149. */
  54150. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54151. /**
  54152. * Fired when the menu button on this controller is modified
  54153. */
  54154. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54155. /**
  54156. * Called once for each button that changed state since the last frame
  54157. * Vive mapping:
  54158. * 0: touchpad
  54159. * 1: trigger
  54160. * 2: left AND right buttons
  54161. * 3: menu button
  54162. * @param buttonIdx Which button index changed
  54163. * @param state New state of the button
  54164. * @param changes Which properties on the state changed since last frame
  54165. */
  54166. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54167. }
  54168. }
  54169. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54170. import { Observable } from "babylonjs/Misc/observable";
  54171. import { Scene } from "babylonjs/scene";
  54172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54173. import { Ray } from "babylonjs/Culling/ray";
  54174. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54175. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54177. /**
  54178. * Defines the WindowsMotionController object that the state of the windows motion controller
  54179. */
  54180. export class WindowsMotionController extends WebVRController {
  54181. /**
  54182. * The base url used to load the left and right controller models
  54183. */
  54184. static MODEL_BASE_URL: string;
  54185. /**
  54186. * The name of the left controller model file
  54187. */
  54188. static MODEL_LEFT_FILENAME: string;
  54189. /**
  54190. * The name of the right controller model file
  54191. */
  54192. static MODEL_RIGHT_FILENAME: string;
  54193. /**
  54194. * The controller name prefix for this controller type
  54195. */
  54196. static readonly GAMEPAD_ID_PREFIX: string;
  54197. /**
  54198. * The controller id pattern for this controller type
  54199. */
  54200. private static readonly GAMEPAD_ID_PATTERN;
  54201. private _loadedMeshInfo;
  54202. protected readonly _mapping: {
  54203. buttons: string[];
  54204. buttonMeshNames: {
  54205. trigger: string;
  54206. menu: string;
  54207. grip: string;
  54208. thumbstick: string;
  54209. trackpad: string;
  54210. };
  54211. buttonObservableNames: {
  54212. trigger: string;
  54213. menu: string;
  54214. grip: string;
  54215. thumbstick: string;
  54216. trackpad: string;
  54217. };
  54218. axisMeshNames: string[];
  54219. pointingPoseMeshName: string;
  54220. };
  54221. /**
  54222. * Fired when the trackpad on this controller is clicked
  54223. */
  54224. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54225. /**
  54226. * Fired when the trackpad on this controller is modified
  54227. */
  54228. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54229. /**
  54230. * The current x and y values of this controller's trackpad
  54231. */
  54232. trackpad: StickValues;
  54233. /**
  54234. * Creates a new WindowsMotionController from a gamepad
  54235. * @param vrGamepad the gamepad that the controller should be created from
  54236. */
  54237. constructor(vrGamepad: any);
  54238. /**
  54239. * Fired when the trigger on this controller is modified
  54240. */
  54241. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54242. /**
  54243. * Fired when the menu button on this controller is modified
  54244. */
  54245. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54246. /**
  54247. * Fired when the grip button on this controller is modified
  54248. */
  54249. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54250. /**
  54251. * Fired when the thumbstick button on this controller is modified
  54252. */
  54253. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54254. /**
  54255. * Fired when the touchpad button on this controller is modified
  54256. */
  54257. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54258. /**
  54259. * Fired when the touchpad values on this controller are modified
  54260. */
  54261. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54262. protected _updateTrackpad(): void;
  54263. /**
  54264. * Called once per frame by the engine.
  54265. */
  54266. update(): void;
  54267. /**
  54268. * Called once for each button that changed state since the last frame
  54269. * @param buttonIdx Which button index changed
  54270. * @param state New state of the button
  54271. * @param changes Which properties on the state changed since last frame
  54272. */
  54273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54274. /**
  54275. * Moves the buttons on the controller mesh based on their current state
  54276. * @param buttonName the name of the button to move
  54277. * @param buttonValue the value of the button which determines the buttons new position
  54278. */
  54279. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54280. /**
  54281. * Moves the axis on the controller mesh based on its current state
  54282. * @param axis the index of the axis
  54283. * @param axisValue the value of the axis which determines the meshes new position
  54284. * @hidden
  54285. */
  54286. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54287. /**
  54288. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54289. * @param scene scene in which to add meshes
  54290. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54291. */
  54292. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54293. /**
  54294. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54295. * can be transformed by button presses and axes values, based on this._mapping.
  54296. *
  54297. * @param scene scene in which the meshes exist
  54298. * @param meshes list of meshes that make up the controller model to process
  54299. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54300. */
  54301. private processModel;
  54302. private createMeshInfo;
  54303. /**
  54304. * Gets the ray of the controller in the direction the controller is pointing
  54305. * @param length the length the resulting ray should be
  54306. * @returns a ray in the direction the controller is pointing
  54307. */
  54308. getForwardRay(length?: number): Ray;
  54309. /**
  54310. * Disposes of the controller
  54311. */
  54312. dispose(): void;
  54313. }
  54314. /**
  54315. * This class represents a new windows motion controller in XR.
  54316. */
  54317. export class XRWindowsMotionController extends WindowsMotionController {
  54318. /**
  54319. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54320. */
  54321. protected readonly _mapping: {
  54322. buttons: string[];
  54323. buttonMeshNames: {
  54324. trigger: string;
  54325. menu: string;
  54326. grip: string;
  54327. thumbstick: string;
  54328. trackpad: string;
  54329. };
  54330. buttonObservableNames: {
  54331. trigger: string;
  54332. menu: string;
  54333. grip: string;
  54334. thumbstick: string;
  54335. trackpad: string;
  54336. };
  54337. axisMeshNames: string[];
  54338. pointingPoseMeshName: string;
  54339. };
  54340. /**
  54341. * Construct a new XR-Based windows motion controller
  54342. *
  54343. * @param gamepadInfo the gamepad object from the browser
  54344. */
  54345. constructor(gamepadInfo: any);
  54346. /**
  54347. * holds the thumbstick values (X,Y)
  54348. */
  54349. thumbstickValues: StickValues;
  54350. /**
  54351. * Fired when the thumbstick on this controller is clicked
  54352. */
  54353. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54354. /**
  54355. * Fired when the thumbstick on this controller is modified
  54356. */
  54357. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54358. /**
  54359. * Fired when the touchpad button on this controller is modified
  54360. */
  54361. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54362. /**
  54363. * Fired when the touchpad values on this controller are modified
  54364. */
  54365. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54366. /**
  54367. * Fired when the thumbstick button on this controller is modified
  54368. * here to prevent breaking changes
  54369. */
  54370. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54371. /**
  54372. * updating the thumbstick(!) and not the trackpad.
  54373. * This is named this way due to the difference between WebVR and XR and to avoid
  54374. * changing the parent class.
  54375. */
  54376. protected _updateTrackpad(): void;
  54377. /**
  54378. * Disposes the class with joy
  54379. */
  54380. dispose(): void;
  54381. }
  54382. }
  54383. declare module "babylonjs/Gamepads/Controllers/index" {
  54384. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54385. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54386. export * from "babylonjs/Gamepads/Controllers/genericController";
  54387. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54388. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54389. export * from "babylonjs/Gamepads/Controllers/viveController";
  54390. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54391. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54392. }
  54393. declare module "babylonjs/Gamepads/index" {
  54394. export * from "babylonjs/Gamepads/Controllers/index";
  54395. export * from "babylonjs/Gamepads/gamepad";
  54396. export * from "babylonjs/Gamepads/gamepadManager";
  54397. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54398. export * from "babylonjs/Gamepads/xboxGamepad";
  54399. export * from "babylonjs/Gamepads/dualShockGamepad";
  54400. }
  54401. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54402. import { Scene } from "babylonjs/scene";
  54403. import { Vector4 } from "babylonjs/Maths/math.vector";
  54404. import { Color4 } from "babylonjs/Maths/math.color";
  54405. import { Mesh } from "babylonjs/Meshes/mesh";
  54406. import { Nullable } from "babylonjs/types";
  54407. /**
  54408. * Class containing static functions to help procedurally build meshes
  54409. */
  54410. export class PolyhedronBuilder {
  54411. /**
  54412. * Creates a polyhedron mesh
  54413. * * 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
  54414. * * The parameter `size` (positive float, default 1) sets the polygon size
  54415. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54416. * * 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`
  54417. * * 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
  54418. * * 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)`)
  54419. * * 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
  54420. * * 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
  54421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54424. * @param name defines the name of the mesh
  54425. * @param options defines the options used to create the mesh
  54426. * @param scene defines the hosting scene
  54427. * @returns the polyhedron mesh
  54428. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54429. */
  54430. static CreatePolyhedron(name: string, options: {
  54431. type?: number;
  54432. size?: number;
  54433. sizeX?: number;
  54434. sizeY?: number;
  54435. sizeZ?: number;
  54436. custom?: any;
  54437. faceUV?: Vector4[];
  54438. faceColors?: Color4[];
  54439. flat?: boolean;
  54440. updatable?: boolean;
  54441. sideOrientation?: number;
  54442. frontUVs?: Vector4;
  54443. backUVs?: Vector4;
  54444. }, scene?: Nullable<Scene>): Mesh;
  54445. }
  54446. }
  54447. declare module "babylonjs/Gizmos/scaleGizmo" {
  54448. import { Observable } from "babylonjs/Misc/observable";
  54449. import { Nullable } from "babylonjs/types";
  54450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54451. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54452. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54453. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54454. /**
  54455. * Gizmo that enables scaling a mesh along 3 axis
  54456. */
  54457. export class ScaleGizmo extends Gizmo {
  54458. /**
  54459. * Internal gizmo used for interactions on the x axis
  54460. */
  54461. xGizmo: AxisScaleGizmo;
  54462. /**
  54463. * Internal gizmo used for interactions on the y axis
  54464. */
  54465. yGizmo: AxisScaleGizmo;
  54466. /**
  54467. * Internal gizmo used for interactions on the z axis
  54468. */
  54469. zGizmo: AxisScaleGizmo;
  54470. /**
  54471. * Internal gizmo used to scale all axis equally
  54472. */
  54473. uniformScaleGizmo: AxisScaleGizmo;
  54474. private _meshAttached;
  54475. private _updateGizmoRotationToMatchAttachedMesh;
  54476. private _snapDistance;
  54477. private _scaleRatio;
  54478. private _uniformScalingMesh;
  54479. private _octahedron;
  54480. private _sensitivity;
  54481. /** Fires an event when any of it's sub gizmos are dragged */
  54482. onDragStartObservable: Observable<unknown>;
  54483. /** Fires an event when any of it's sub gizmos are released from dragging */
  54484. onDragEndObservable: Observable<unknown>;
  54485. get attachedMesh(): Nullable<AbstractMesh>;
  54486. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54487. /**
  54488. * Creates a ScaleGizmo
  54489. * @param gizmoLayer The utility layer the gizmo will be added to
  54490. */
  54491. constructor(gizmoLayer?: UtilityLayerRenderer);
  54492. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54493. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54494. /**
  54495. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54496. */
  54497. set snapDistance(value: number);
  54498. get snapDistance(): number;
  54499. /**
  54500. * Ratio for the scale of the gizmo (Default: 1)
  54501. */
  54502. set scaleRatio(value: number);
  54503. get scaleRatio(): number;
  54504. /**
  54505. * Sensitivity factor for dragging (Default: 1)
  54506. */
  54507. set sensitivity(value: number);
  54508. get sensitivity(): number;
  54509. /**
  54510. * Disposes of the gizmo
  54511. */
  54512. dispose(): void;
  54513. }
  54514. }
  54515. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54516. import { Observable } from "babylonjs/Misc/observable";
  54517. import { Nullable } from "babylonjs/types";
  54518. import { Vector3 } from "babylonjs/Maths/math.vector";
  54519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54520. import { Mesh } from "babylonjs/Meshes/mesh";
  54521. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54522. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54523. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54524. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54525. import { Color3 } from "babylonjs/Maths/math.color";
  54526. /**
  54527. * Single axis scale gizmo
  54528. */
  54529. export class AxisScaleGizmo extends Gizmo {
  54530. /**
  54531. * Drag behavior responsible for the gizmos dragging interactions
  54532. */
  54533. dragBehavior: PointerDragBehavior;
  54534. private _pointerObserver;
  54535. /**
  54536. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54537. */
  54538. snapDistance: number;
  54539. /**
  54540. * Event that fires each time the gizmo snaps to a new location.
  54541. * * snapDistance is the the change in distance
  54542. */
  54543. onSnapObservable: Observable<{
  54544. snapDistance: number;
  54545. }>;
  54546. /**
  54547. * If the scaling operation should be done on all axis (default: false)
  54548. */
  54549. uniformScaling: boolean;
  54550. /**
  54551. * Custom sensitivity value for the drag strength
  54552. */
  54553. sensitivity: number;
  54554. private _isEnabled;
  54555. private _parent;
  54556. private _arrow;
  54557. private _coloredMaterial;
  54558. private _hoverMaterial;
  54559. /**
  54560. * Creates an AxisScaleGizmo
  54561. * @param gizmoLayer The utility layer the gizmo will be added to
  54562. * @param dragAxis The axis which the gizmo will be able to scale on
  54563. * @param color The color of the gizmo
  54564. */
  54565. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54567. /**
  54568. * If the gizmo is enabled
  54569. */
  54570. set isEnabled(value: boolean);
  54571. get isEnabled(): boolean;
  54572. /**
  54573. * Disposes of the gizmo
  54574. */
  54575. dispose(): void;
  54576. /**
  54577. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54578. * @param mesh The mesh to replace the default mesh of the gizmo
  54579. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54580. */
  54581. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54582. }
  54583. }
  54584. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54585. import { Observable } from "babylonjs/Misc/observable";
  54586. import { Nullable } from "babylonjs/types";
  54587. import { Vector3 } from "babylonjs/Maths/math.vector";
  54588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54589. import { Mesh } from "babylonjs/Meshes/mesh";
  54590. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54592. import { Color3 } from "babylonjs/Maths/math.color";
  54593. import "babylonjs/Meshes/Builders/boxBuilder";
  54594. /**
  54595. * Bounding box gizmo
  54596. */
  54597. export class BoundingBoxGizmo extends Gizmo {
  54598. private _lineBoundingBox;
  54599. private _rotateSpheresParent;
  54600. private _scaleBoxesParent;
  54601. private _boundingDimensions;
  54602. private _renderObserver;
  54603. private _pointerObserver;
  54604. private _scaleDragSpeed;
  54605. private _tmpQuaternion;
  54606. private _tmpVector;
  54607. private _tmpRotationMatrix;
  54608. /**
  54609. * 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)
  54610. */
  54611. ignoreChildren: boolean;
  54612. /**
  54613. * 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)
  54614. */
  54615. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54616. /**
  54617. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54618. */
  54619. rotationSphereSize: number;
  54620. /**
  54621. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54622. */
  54623. scaleBoxSize: number;
  54624. /**
  54625. * 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)
  54626. */
  54627. fixedDragMeshScreenSize: boolean;
  54628. /**
  54629. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54630. */
  54631. fixedDragMeshScreenSizeDistanceFactor: number;
  54632. /**
  54633. * Fired when a rotation sphere or scale box is dragged
  54634. */
  54635. onDragStartObservable: Observable<{}>;
  54636. /**
  54637. * Fired when a scale box is dragged
  54638. */
  54639. onScaleBoxDragObservable: Observable<{}>;
  54640. /**
  54641. * Fired when a scale box drag is ended
  54642. */
  54643. onScaleBoxDragEndObservable: Observable<{}>;
  54644. /**
  54645. * Fired when a rotation sphere is dragged
  54646. */
  54647. onRotationSphereDragObservable: Observable<{}>;
  54648. /**
  54649. * Fired when a rotation sphere drag is ended
  54650. */
  54651. onRotationSphereDragEndObservable: Observable<{}>;
  54652. /**
  54653. * Relative bounding box pivot used when scaling the attached mesh. 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)
  54654. */
  54655. scalePivot: Nullable<Vector3>;
  54656. /**
  54657. * Mesh used as a pivot to rotate the attached mesh
  54658. */
  54659. private _anchorMesh;
  54660. private _existingMeshScale;
  54661. private _dragMesh;
  54662. private pointerDragBehavior;
  54663. private coloredMaterial;
  54664. private hoverColoredMaterial;
  54665. /**
  54666. * Sets the color of the bounding box gizmo
  54667. * @param color the color to set
  54668. */
  54669. setColor(color: Color3): void;
  54670. /**
  54671. * Creates an BoundingBoxGizmo
  54672. * @param gizmoLayer The utility layer the gizmo will be added to
  54673. * @param color The color of the gizmo
  54674. */
  54675. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54676. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54677. private _selectNode;
  54678. /**
  54679. * Updates the bounding box information for the Gizmo
  54680. */
  54681. updateBoundingBox(): void;
  54682. private _updateRotationSpheres;
  54683. private _updateScaleBoxes;
  54684. /**
  54685. * Enables rotation on the specified axis and disables rotation on the others
  54686. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54687. */
  54688. setEnabledRotationAxis(axis: string): void;
  54689. /**
  54690. * Enables/disables scaling
  54691. * @param enable if scaling should be enabled
  54692. * @param homogeneousScaling defines if scaling should only be homogeneous
  54693. */
  54694. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54695. private _updateDummy;
  54696. /**
  54697. * Enables a pointer drag behavior on the bounding box of the gizmo
  54698. */
  54699. enableDragBehavior(): void;
  54700. /**
  54701. * Disposes of the gizmo
  54702. */
  54703. dispose(): void;
  54704. /**
  54705. * 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)
  54706. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54707. * @returns the bounding box mesh with the passed in mesh as a child
  54708. */
  54709. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54710. /**
  54711. * CustomMeshes are not supported by this gizmo
  54712. * @param mesh The mesh to replace the default mesh of the gizmo
  54713. */
  54714. setCustomMesh(mesh: Mesh): void;
  54715. }
  54716. }
  54717. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54718. import { Observable } from "babylonjs/Misc/observable";
  54719. import { Nullable } from "babylonjs/types";
  54720. import { Vector3 } from "babylonjs/Maths/math.vector";
  54721. import { Color3 } from "babylonjs/Maths/math.color";
  54722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54723. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54724. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54726. import "babylonjs/Meshes/Builders/linesBuilder";
  54727. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54728. /**
  54729. * Single plane rotation gizmo
  54730. */
  54731. export class PlaneRotationGizmo extends Gizmo {
  54732. /**
  54733. * Drag behavior responsible for the gizmos dragging interactions
  54734. */
  54735. dragBehavior: PointerDragBehavior;
  54736. private _pointerObserver;
  54737. /**
  54738. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54739. */
  54740. snapDistance: number;
  54741. /**
  54742. * Event that fires each time the gizmo snaps to a new location.
  54743. * * snapDistance is the the change in distance
  54744. */
  54745. onSnapObservable: Observable<{
  54746. snapDistance: number;
  54747. }>;
  54748. private _isEnabled;
  54749. private _parent;
  54750. /**
  54751. * Creates a PlaneRotationGizmo
  54752. * @param gizmoLayer The utility layer the gizmo will be added to
  54753. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54754. * @param color The color of the gizmo
  54755. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54756. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54757. */
  54758. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54759. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54760. /**
  54761. * If the gizmo is enabled
  54762. */
  54763. set isEnabled(value: boolean);
  54764. get isEnabled(): boolean;
  54765. /**
  54766. * Disposes of the gizmo
  54767. */
  54768. dispose(): void;
  54769. }
  54770. }
  54771. declare module "babylonjs/Gizmos/rotationGizmo" {
  54772. import { Observable } from "babylonjs/Misc/observable";
  54773. import { Nullable } from "babylonjs/types";
  54774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54775. import { Mesh } from "babylonjs/Meshes/mesh";
  54776. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54777. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54778. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54779. /**
  54780. * Gizmo that enables rotating a mesh along 3 axis
  54781. */
  54782. export class RotationGizmo extends Gizmo {
  54783. /**
  54784. * Internal gizmo used for interactions on the x axis
  54785. */
  54786. xGizmo: PlaneRotationGizmo;
  54787. /**
  54788. * Internal gizmo used for interactions on the y axis
  54789. */
  54790. yGizmo: PlaneRotationGizmo;
  54791. /**
  54792. * Internal gizmo used for interactions on the z axis
  54793. */
  54794. zGizmo: PlaneRotationGizmo;
  54795. /** Fires an event when any of it's sub gizmos are dragged */
  54796. onDragStartObservable: Observable<unknown>;
  54797. /** Fires an event when any of it's sub gizmos are released from dragging */
  54798. onDragEndObservable: Observable<unknown>;
  54799. private _meshAttached;
  54800. get attachedMesh(): Nullable<AbstractMesh>;
  54801. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54802. /**
  54803. * Creates a RotationGizmo
  54804. * @param gizmoLayer The utility layer the gizmo will be added to
  54805. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54806. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54807. */
  54808. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54809. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54810. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54811. /**
  54812. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54813. */
  54814. set snapDistance(value: number);
  54815. get snapDistance(): number;
  54816. /**
  54817. * Ratio for the scale of the gizmo (Default: 1)
  54818. */
  54819. set scaleRatio(value: number);
  54820. get scaleRatio(): number;
  54821. /**
  54822. * Disposes of the gizmo
  54823. */
  54824. dispose(): void;
  54825. /**
  54826. * CustomMeshes are not supported by this gizmo
  54827. * @param mesh The mesh to replace the default mesh of the gizmo
  54828. */
  54829. setCustomMesh(mesh: Mesh): void;
  54830. }
  54831. }
  54832. declare module "babylonjs/Gizmos/gizmoManager" {
  54833. import { Observable } from "babylonjs/Misc/observable";
  54834. import { Nullable } from "babylonjs/types";
  54835. import { Scene, IDisposable } from "babylonjs/scene";
  54836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54837. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54838. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54839. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54840. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54841. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54842. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54843. /**
  54844. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54845. */
  54846. export class GizmoManager implements IDisposable {
  54847. private scene;
  54848. /**
  54849. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54850. */
  54851. gizmos: {
  54852. positionGizmo: Nullable<PositionGizmo>;
  54853. rotationGizmo: Nullable<RotationGizmo>;
  54854. scaleGizmo: Nullable<ScaleGizmo>;
  54855. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54856. };
  54857. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54858. clearGizmoOnEmptyPointerEvent: boolean;
  54859. /** Fires an event when the manager is attached to a mesh */
  54860. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54861. private _gizmosEnabled;
  54862. private _pointerObserver;
  54863. private _attachedMesh;
  54864. private _boundingBoxColor;
  54865. private _defaultUtilityLayer;
  54866. private _defaultKeepDepthUtilityLayer;
  54867. /**
  54868. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54869. */
  54870. boundingBoxDragBehavior: SixDofDragBehavior;
  54871. /**
  54872. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54873. */
  54874. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54875. /**
  54876. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54877. */
  54878. usePointerToAttachGizmos: boolean;
  54879. /**
  54880. * Utility layer that the bounding box gizmo belongs to
  54881. */
  54882. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54883. /**
  54884. * Utility layer that all gizmos besides bounding box belong to
  54885. */
  54886. get utilityLayer(): UtilityLayerRenderer;
  54887. /**
  54888. * Instatiates a gizmo manager
  54889. * @param scene the scene to overlay the gizmos on top of
  54890. */
  54891. constructor(scene: Scene);
  54892. /**
  54893. * Attaches a set of gizmos to the specified mesh
  54894. * @param mesh The mesh the gizmo's should be attached to
  54895. */
  54896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54897. /**
  54898. * If the position gizmo is enabled
  54899. */
  54900. set positionGizmoEnabled(value: boolean);
  54901. get positionGizmoEnabled(): boolean;
  54902. /**
  54903. * If the rotation gizmo is enabled
  54904. */
  54905. set rotationGizmoEnabled(value: boolean);
  54906. get rotationGizmoEnabled(): boolean;
  54907. /**
  54908. * If the scale gizmo is enabled
  54909. */
  54910. set scaleGizmoEnabled(value: boolean);
  54911. get scaleGizmoEnabled(): boolean;
  54912. /**
  54913. * If the boundingBox gizmo is enabled
  54914. */
  54915. set boundingBoxGizmoEnabled(value: boolean);
  54916. get boundingBoxGizmoEnabled(): boolean;
  54917. /**
  54918. * Disposes of the gizmo manager
  54919. */
  54920. dispose(): void;
  54921. }
  54922. }
  54923. declare module "babylonjs/Lights/directionalLight" {
  54924. import { Camera } from "babylonjs/Cameras/camera";
  54925. import { Scene } from "babylonjs/scene";
  54926. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54928. import { Light } from "babylonjs/Lights/light";
  54929. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54930. import { Effect } from "babylonjs/Materials/effect";
  54931. /**
  54932. * A directional light is defined by a direction (what a surprise!).
  54933. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54934. * 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.
  54935. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54936. */
  54937. export class DirectionalLight extends ShadowLight {
  54938. private _shadowFrustumSize;
  54939. /**
  54940. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54941. */
  54942. get shadowFrustumSize(): number;
  54943. /**
  54944. * Specifies a fix frustum size for the shadow generation.
  54945. */
  54946. set shadowFrustumSize(value: number);
  54947. private _shadowOrthoScale;
  54948. /**
  54949. * Gets the shadow projection scale against the optimal computed one.
  54950. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54951. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54952. */
  54953. get shadowOrthoScale(): number;
  54954. /**
  54955. * Sets the shadow projection scale against the optimal computed one.
  54956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54958. */
  54959. set shadowOrthoScale(value: number);
  54960. /**
  54961. * Automatically compute the projection matrix to best fit (including all the casters)
  54962. * on each frame.
  54963. */
  54964. autoUpdateExtends: boolean;
  54965. /**
  54966. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54967. * on each frame. autoUpdateExtends must be set to true for this to work
  54968. */
  54969. autoCalcShadowZBounds: boolean;
  54970. private _orthoLeft;
  54971. private _orthoRight;
  54972. private _orthoTop;
  54973. private _orthoBottom;
  54974. /**
  54975. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54976. * The directional light is emitted from everywhere in the given direction.
  54977. * It can cast shadows.
  54978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54979. * @param name The friendly name of the light
  54980. * @param direction The direction of the light
  54981. * @param scene The scene the light belongs to
  54982. */
  54983. constructor(name: string, direction: Vector3, scene: Scene);
  54984. /**
  54985. * Returns the string "DirectionalLight".
  54986. * @return The class name
  54987. */
  54988. getClassName(): string;
  54989. /**
  54990. * Returns the integer 1.
  54991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54992. */
  54993. getTypeID(): number;
  54994. /**
  54995. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54996. * Returns the DirectionalLight Shadow projection matrix.
  54997. */
  54998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54999. /**
  55000. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55001. * Returns the DirectionalLight Shadow projection matrix.
  55002. */
  55003. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55004. /**
  55005. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55006. * Returns the DirectionalLight Shadow projection matrix.
  55007. */
  55008. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55009. protected _buildUniformLayout(): void;
  55010. /**
  55011. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55012. * @param effect The effect to update
  55013. * @param lightIndex The index of the light in the effect to update
  55014. * @returns The directional light
  55015. */
  55016. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55017. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55018. /**
  55019. * Gets the minZ used for shadow according to both the scene and the light.
  55020. *
  55021. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55022. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55023. * @param activeCamera The camera we are returning the min for
  55024. * @returns the depth min z
  55025. */
  55026. getDepthMinZ(activeCamera: Camera): number;
  55027. /**
  55028. * Gets the maxZ used for shadow according to both the scene and the light.
  55029. *
  55030. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55031. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55032. * @param activeCamera The camera we are returning the max for
  55033. * @returns the depth max z
  55034. */
  55035. getDepthMaxZ(activeCamera: Camera): number;
  55036. /**
  55037. * Prepares the list of defines specific to the light type.
  55038. * @param defines the list of defines
  55039. * @param lightIndex defines the index of the light for the effect
  55040. */
  55041. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55042. }
  55043. }
  55044. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55045. import { Mesh } from "babylonjs/Meshes/mesh";
  55046. /**
  55047. * Class containing static functions to help procedurally build meshes
  55048. */
  55049. export class HemisphereBuilder {
  55050. /**
  55051. * Creates a hemisphere mesh
  55052. * @param name defines the name of the mesh
  55053. * @param options defines the options used to create the mesh
  55054. * @param scene defines the hosting scene
  55055. * @returns the hemisphere mesh
  55056. */
  55057. static CreateHemisphere(name: string, options: {
  55058. segments?: number;
  55059. diameter?: number;
  55060. sideOrientation?: number;
  55061. }, scene: any): Mesh;
  55062. }
  55063. }
  55064. declare module "babylonjs/Lights/spotLight" {
  55065. import { Nullable } from "babylonjs/types";
  55066. import { Scene } from "babylonjs/scene";
  55067. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55069. import { Effect } from "babylonjs/Materials/effect";
  55070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55071. import { Light } from "babylonjs/Lights/light";
  55072. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55073. /**
  55074. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55075. * These values define a cone of light starting from the position, emitting toward the direction.
  55076. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55077. * and the exponent defines the speed of the decay of the light with distance (reach).
  55078. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55079. */
  55080. export class SpotLight extends ShadowLight {
  55081. private _angle;
  55082. private _innerAngle;
  55083. private _cosHalfAngle;
  55084. private _lightAngleScale;
  55085. private _lightAngleOffset;
  55086. /**
  55087. * Gets the cone angle of the spot light in Radians.
  55088. */
  55089. get angle(): number;
  55090. /**
  55091. * Sets the cone angle of the spot light in Radians.
  55092. */
  55093. set angle(value: number);
  55094. /**
  55095. * Only used in gltf falloff mode, this defines the angle where
  55096. * the directional falloff will start before cutting at angle which could be seen
  55097. * as outer angle.
  55098. */
  55099. get innerAngle(): number;
  55100. /**
  55101. * Only used in gltf falloff mode, this defines the angle where
  55102. * the directional falloff will start before cutting at angle which could be seen
  55103. * as outer angle.
  55104. */
  55105. set innerAngle(value: number);
  55106. private _shadowAngleScale;
  55107. /**
  55108. * Allows scaling the angle of the light for shadow generation only.
  55109. */
  55110. get shadowAngleScale(): number;
  55111. /**
  55112. * Allows scaling the angle of the light for shadow generation only.
  55113. */
  55114. set shadowAngleScale(value: number);
  55115. /**
  55116. * The light decay speed with the distance from the emission spot.
  55117. */
  55118. exponent: number;
  55119. private _projectionTextureMatrix;
  55120. /**
  55121. * Allows reading the projecton texture
  55122. */
  55123. get projectionTextureMatrix(): Matrix;
  55124. protected _projectionTextureLightNear: number;
  55125. /**
  55126. * Gets the near clip of the Spotlight for texture projection.
  55127. */
  55128. get projectionTextureLightNear(): number;
  55129. /**
  55130. * Sets the near clip of the Spotlight for texture projection.
  55131. */
  55132. set projectionTextureLightNear(value: number);
  55133. protected _projectionTextureLightFar: number;
  55134. /**
  55135. * Gets the far clip of the Spotlight for texture projection.
  55136. */
  55137. get projectionTextureLightFar(): number;
  55138. /**
  55139. * Sets the far clip of the Spotlight for texture projection.
  55140. */
  55141. set projectionTextureLightFar(value: number);
  55142. protected _projectionTextureUpDirection: Vector3;
  55143. /**
  55144. * Gets the Up vector of the Spotlight for texture projection.
  55145. */
  55146. get projectionTextureUpDirection(): Vector3;
  55147. /**
  55148. * Sets the Up vector of the Spotlight for texture projection.
  55149. */
  55150. set projectionTextureUpDirection(value: Vector3);
  55151. private _projectionTexture;
  55152. /**
  55153. * Gets the projection texture of the light.
  55154. */
  55155. get projectionTexture(): Nullable<BaseTexture>;
  55156. /**
  55157. * Sets the projection texture of the light.
  55158. */
  55159. set projectionTexture(value: Nullable<BaseTexture>);
  55160. private _projectionTextureViewLightDirty;
  55161. private _projectionTextureProjectionLightDirty;
  55162. private _projectionTextureDirty;
  55163. private _projectionTextureViewTargetVector;
  55164. private _projectionTextureViewLightMatrix;
  55165. private _projectionTextureProjectionLightMatrix;
  55166. private _projectionTextureScalingMatrix;
  55167. /**
  55168. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55169. * It can cast shadows.
  55170. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55171. * @param name The light friendly name
  55172. * @param position The position of the spot light in the scene
  55173. * @param direction The direction of the light in the scene
  55174. * @param angle The cone angle of the light in Radians
  55175. * @param exponent The light decay speed with the distance from the emission spot
  55176. * @param scene The scene the lights belongs to
  55177. */
  55178. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55179. /**
  55180. * Returns the string "SpotLight".
  55181. * @returns the class name
  55182. */
  55183. getClassName(): string;
  55184. /**
  55185. * Returns the integer 2.
  55186. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55187. */
  55188. getTypeID(): number;
  55189. /**
  55190. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55191. */
  55192. protected _setDirection(value: Vector3): void;
  55193. /**
  55194. * Overrides the position setter to recompute the projection texture view light Matrix.
  55195. */
  55196. protected _setPosition(value: Vector3): void;
  55197. /**
  55198. * 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.
  55199. * Returns the SpotLight.
  55200. */
  55201. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55202. protected _computeProjectionTextureViewLightMatrix(): void;
  55203. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55204. /**
  55205. * Main function for light texture projection matrix computing.
  55206. */
  55207. protected _computeProjectionTextureMatrix(): void;
  55208. protected _buildUniformLayout(): void;
  55209. private _computeAngleValues;
  55210. /**
  55211. * Sets the passed Effect "effect" with the Light textures.
  55212. * @param effect The effect to update
  55213. * @param lightIndex The index of the light in the effect to update
  55214. * @returns The light
  55215. */
  55216. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55217. /**
  55218. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55219. * @param effect The effect to update
  55220. * @param lightIndex The index of the light in the effect to update
  55221. * @returns The spot light
  55222. */
  55223. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55224. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55225. /**
  55226. * Disposes the light and the associated resources.
  55227. */
  55228. dispose(): void;
  55229. /**
  55230. * Prepares the list of defines specific to the light type.
  55231. * @param defines the list of defines
  55232. * @param lightIndex defines the index of the light for the effect
  55233. */
  55234. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55235. }
  55236. }
  55237. declare module "babylonjs/Gizmos/lightGizmo" {
  55238. import { Nullable } from "babylonjs/types";
  55239. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55241. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55242. import { Light } from "babylonjs/Lights/light";
  55243. /**
  55244. * Gizmo that enables viewing a light
  55245. */
  55246. export class LightGizmo extends Gizmo {
  55247. private _lightMesh;
  55248. private _material;
  55249. private _cachedPosition;
  55250. private _cachedForward;
  55251. private _attachedMeshParent;
  55252. /**
  55253. * Creates a LightGizmo
  55254. * @param gizmoLayer The utility layer the gizmo will be added to
  55255. */
  55256. constructor(gizmoLayer?: UtilityLayerRenderer);
  55257. private _light;
  55258. /**
  55259. * The light that the gizmo is attached to
  55260. */
  55261. set light(light: Nullable<Light>);
  55262. get light(): Nullable<Light>;
  55263. /**
  55264. * Gets the material used to render the light gizmo
  55265. */
  55266. get material(): StandardMaterial;
  55267. /**
  55268. * @hidden
  55269. * Updates the gizmo to match the attached mesh's position/rotation
  55270. */
  55271. protected _update(): void;
  55272. private static _Scale;
  55273. /**
  55274. * Creates the lines for a light mesh
  55275. */
  55276. private static _CreateLightLines;
  55277. /**
  55278. * Disposes of the light gizmo
  55279. */
  55280. dispose(): void;
  55281. private static _CreateHemisphericLightMesh;
  55282. private static _CreatePointLightMesh;
  55283. private static _CreateSpotLightMesh;
  55284. private static _CreateDirectionalLightMesh;
  55285. }
  55286. }
  55287. declare module "babylonjs/Gizmos/index" {
  55288. export * from "babylonjs/Gizmos/axisDragGizmo";
  55289. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55290. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55291. export * from "babylonjs/Gizmos/gizmo";
  55292. export * from "babylonjs/Gizmos/gizmoManager";
  55293. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55294. export * from "babylonjs/Gizmos/positionGizmo";
  55295. export * from "babylonjs/Gizmos/rotationGizmo";
  55296. export * from "babylonjs/Gizmos/scaleGizmo";
  55297. export * from "babylonjs/Gizmos/lightGizmo";
  55298. export * from "babylonjs/Gizmos/planeDragGizmo";
  55299. }
  55300. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55301. /** @hidden */
  55302. export var backgroundFragmentDeclaration: {
  55303. name: string;
  55304. shader: string;
  55305. };
  55306. }
  55307. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55308. /** @hidden */
  55309. export var backgroundUboDeclaration: {
  55310. name: string;
  55311. shader: string;
  55312. };
  55313. }
  55314. declare module "babylonjs/Shaders/background.fragment" {
  55315. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55316. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55317. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55318. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55319. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55320. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55321. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55322. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55323. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55326. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55328. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55329. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55330. /** @hidden */
  55331. export var backgroundPixelShader: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55337. /** @hidden */
  55338. export var backgroundVertexDeclaration: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module "babylonjs/Shaders/background.vertex" {
  55344. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55345. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55347. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55348. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55350. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55351. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55352. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55353. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55354. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55355. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55356. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55357. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55358. /** @hidden */
  55359. export var backgroundVertexShader: {
  55360. name: string;
  55361. shader: string;
  55362. };
  55363. }
  55364. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55365. import { Nullable, int, float } from "babylonjs/types";
  55366. import { Scene } from "babylonjs/scene";
  55367. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55370. import { Mesh } from "babylonjs/Meshes/mesh";
  55371. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55372. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55373. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55375. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55376. import { Color3 } from "babylonjs/Maths/math.color";
  55377. import "babylonjs/Shaders/background.fragment";
  55378. import "babylonjs/Shaders/background.vertex";
  55379. /**
  55380. * Background material used to create an efficient environement around your scene.
  55381. */
  55382. export class BackgroundMaterial extends PushMaterial {
  55383. /**
  55384. * Standard reflectance value at parallel view angle.
  55385. */
  55386. static StandardReflectance0: number;
  55387. /**
  55388. * Standard reflectance value at grazing angle.
  55389. */
  55390. static StandardReflectance90: number;
  55391. protected _primaryColor: Color3;
  55392. /**
  55393. * Key light Color (multiply against the environement texture)
  55394. */
  55395. primaryColor: Color3;
  55396. protected __perceptualColor: Nullable<Color3>;
  55397. /**
  55398. * Experimental Internal Use Only.
  55399. *
  55400. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55401. * This acts as a helper to set the primary color to a more "human friendly" value.
  55402. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55403. * output color as close as possible from the chosen value.
  55404. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55405. * part of lighting setup.)
  55406. */
  55407. get _perceptualColor(): Nullable<Color3>;
  55408. set _perceptualColor(value: Nullable<Color3>);
  55409. protected _primaryColorShadowLevel: float;
  55410. /**
  55411. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55412. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55413. */
  55414. get primaryColorShadowLevel(): float;
  55415. set primaryColorShadowLevel(value: float);
  55416. protected _primaryColorHighlightLevel: float;
  55417. /**
  55418. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55419. * The primary color is used at the level chosen to define what the white area would look.
  55420. */
  55421. get primaryColorHighlightLevel(): float;
  55422. set primaryColorHighlightLevel(value: float);
  55423. protected _reflectionTexture: Nullable<BaseTexture>;
  55424. /**
  55425. * Reflection Texture used in the material.
  55426. * Should be author in a specific way for the best result (refer to the documentation).
  55427. */
  55428. reflectionTexture: Nullable<BaseTexture>;
  55429. protected _reflectionBlur: float;
  55430. /**
  55431. * Reflection Texture level of blur.
  55432. *
  55433. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55434. * texture twice.
  55435. */
  55436. reflectionBlur: float;
  55437. protected _diffuseTexture: Nullable<BaseTexture>;
  55438. /**
  55439. * Diffuse Texture used in the material.
  55440. * Should be author in a specific way for the best result (refer to the documentation).
  55441. */
  55442. diffuseTexture: Nullable<BaseTexture>;
  55443. protected _shadowLights: Nullable<IShadowLight[]>;
  55444. /**
  55445. * Specify the list of lights casting shadow on the material.
  55446. * All scene shadow lights will be included if null.
  55447. */
  55448. shadowLights: Nullable<IShadowLight[]>;
  55449. protected _shadowLevel: float;
  55450. /**
  55451. * Helps adjusting the shadow to a softer level if required.
  55452. * 0 means black shadows and 1 means no shadows.
  55453. */
  55454. shadowLevel: float;
  55455. protected _sceneCenter: Vector3;
  55456. /**
  55457. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55458. * It is usually zero but might be interesting to modify according to your setup.
  55459. */
  55460. sceneCenter: Vector3;
  55461. protected _opacityFresnel: boolean;
  55462. /**
  55463. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55464. * This helps ensuring a nice transition when the camera goes under the ground.
  55465. */
  55466. opacityFresnel: boolean;
  55467. protected _reflectionFresnel: boolean;
  55468. /**
  55469. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55470. * This helps adding a mirror texture on the ground.
  55471. */
  55472. reflectionFresnel: boolean;
  55473. protected _reflectionFalloffDistance: number;
  55474. /**
  55475. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55476. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55477. */
  55478. reflectionFalloffDistance: number;
  55479. protected _reflectionAmount: number;
  55480. /**
  55481. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55482. */
  55483. reflectionAmount: number;
  55484. protected _reflectionReflectance0: number;
  55485. /**
  55486. * This specifies the weight of the reflection at grazing angle.
  55487. */
  55488. reflectionReflectance0: number;
  55489. protected _reflectionReflectance90: number;
  55490. /**
  55491. * This specifies the weight of the reflection at a perpendicular point of view.
  55492. */
  55493. reflectionReflectance90: number;
  55494. /**
  55495. * Sets the reflection reflectance fresnel values according to the default standard
  55496. * empirically know to work well :-)
  55497. */
  55498. set reflectionStandardFresnelWeight(value: number);
  55499. protected _useRGBColor: boolean;
  55500. /**
  55501. * Helps to directly use the maps channels instead of their level.
  55502. */
  55503. useRGBColor: boolean;
  55504. protected _enableNoise: boolean;
  55505. /**
  55506. * This helps reducing the banding effect that could occur on the background.
  55507. */
  55508. enableNoise: boolean;
  55509. /**
  55510. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55511. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55512. * Recommended to be keep at 1.0 except for special cases.
  55513. */
  55514. get fovMultiplier(): number;
  55515. set fovMultiplier(value: number);
  55516. private _fovMultiplier;
  55517. /**
  55518. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55519. */
  55520. useEquirectangularFOV: boolean;
  55521. private _maxSimultaneousLights;
  55522. /**
  55523. * Number of Simultaneous lights allowed on the material.
  55524. */
  55525. maxSimultaneousLights: int;
  55526. /**
  55527. * Default configuration related to image processing available in the Background Material.
  55528. */
  55529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55530. /**
  55531. * Keep track of the image processing observer to allow dispose and replace.
  55532. */
  55533. private _imageProcessingObserver;
  55534. /**
  55535. * Attaches a new image processing configuration to the PBR Material.
  55536. * @param configuration (if null the scene configuration will be use)
  55537. */
  55538. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55539. /**
  55540. * Gets the image processing configuration used either in this material.
  55541. */
  55542. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55543. /**
  55544. * Sets the Default image processing configuration used either in the this material.
  55545. *
  55546. * If sets to null, the scene one is in use.
  55547. */
  55548. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55549. /**
  55550. * Gets wether the color curves effect is enabled.
  55551. */
  55552. get cameraColorCurvesEnabled(): boolean;
  55553. /**
  55554. * Sets wether the color curves effect is enabled.
  55555. */
  55556. set cameraColorCurvesEnabled(value: boolean);
  55557. /**
  55558. * Gets wether the color grading effect is enabled.
  55559. */
  55560. get cameraColorGradingEnabled(): boolean;
  55561. /**
  55562. * Gets wether the color grading effect is enabled.
  55563. */
  55564. set cameraColorGradingEnabled(value: boolean);
  55565. /**
  55566. * Gets wether tonemapping is enabled or not.
  55567. */
  55568. get cameraToneMappingEnabled(): boolean;
  55569. /**
  55570. * Sets wether tonemapping is enabled or not
  55571. */
  55572. set cameraToneMappingEnabled(value: boolean);
  55573. /**
  55574. * The camera exposure used on this material.
  55575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55576. * This corresponds to a photographic exposure.
  55577. */
  55578. get cameraExposure(): float;
  55579. /**
  55580. * The camera exposure used on this material.
  55581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55582. * This corresponds to a photographic exposure.
  55583. */
  55584. set cameraExposure(value: float);
  55585. /**
  55586. * Gets The camera contrast used on this material.
  55587. */
  55588. get cameraContrast(): float;
  55589. /**
  55590. * Sets The camera contrast used on this material.
  55591. */
  55592. set cameraContrast(value: float);
  55593. /**
  55594. * Gets the Color Grading 2D Lookup Texture.
  55595. */
  55596. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55597. /**
  55598. * Sets the Color Grading 2D Lookup Texture.
  55599. */
  55600. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55601. /**
  55602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55604. * 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;
  55605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55606. */
  55607. get cameraColorCurves(): Nullable<ColorCurves>;
  55608. /**
  55609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55611. * 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;
  55612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55613. */
  55614. set cameraColorCurves(value: Nullable<ColorCurves>);
  55615. /**
  55616. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55617. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55618. */
  55619. switchToBGR: boolean;
  55620. private _renderTargets;
  55621. private _reflectionControls;
  55622. private _white;
  55623. private _primaryShadowColor;
  55624. private _primaryHighlightColor;
  55625. /**
  55626. * Instantiates a Background Material in the given scene
  55627. * @param name The friendly name of the material
  55628. * @param scene The scene to add the material to
  55629. */
  55630. constructor(name: string, scene: Scene);
  55631. /**
  55632. * Gets a boolean indicating that current material needs to register RTT
  55633. */
  55634. get hasRenderTargetTextures(): boolean;
  55635. /**
  55636. * The entire material has been created in order to prevent overdraw.
  55637. * @returns false
  55638. */
  55639. needAlphaTesting(): boolean;
  55640. /**
  55641. * The entire material has been created in order to prevent overdraw.
  55642. * @returns true if blending is enable
  55643. */
  55644. needAlphaBlending(): boolean;
  55645. /**
  55646. * Checks wether the material is ready to be rendered for a given mesh.
  55647. * @param mesh The mesh to render
  55648. * @param subMesh The submesh to check against
  55649. * @param useInstances Specify wether or not the material is used with instances
  55650. * @returns true if all the dependencies are ready (Textures, Effects...)
  55651. */
  55652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55653. /**
  55654. * Compute the primary color according to the chosen perceptual color.
  55655. */
  55656. private _computePrimaryColorFromPerceptualColor;
  55657. /**
  55658. * Compute the highlights and shadow colors according to their chosen levels.
  55659. */
  55660. private _computePrimaryColors;
  55661. /**
  55662. * Build the uniform buffer used in the material.
  55663. */
  55664. buildUniformLayout(): void;
  55665. /**
  55666. * Unbind the material.
  55667. */
  55668. unbind(): void;
  55669. /**
  55670. * Bind only the world matrix to the material.
  55671. * @param world The world matrix to bind.
  55672. */
  55673. bindOnlyWorldMatrix(world: Matrix): void;
  55674. /**
  55675. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55676. * @param world The world matrix to bind.
  55677. * @param subMesh The submesh to bind for.
  55678. */
  55679. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55680. /**
  55681. * Checks to see if a texture is used in the material.
  55682. * @param texture - Base texture to use.
  55683. * @returns - Boolean specifying if a texture is used in the material.
  55684. */
  55685. hasTexture(texture: BaseTexture): boolean;
  55686. /**
  55687. * Dispose the material.
  55688. * @param forceDisposeEffect Force disposal of the associated effect.
  55689. * @param forceDisposeTextures Force disposal of the associated textures.
  55690. */
  55691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55692. /**
  55693. * Clones the material.
  55694. * @param name The cloned name.
  55695. * @returns The cloned material.
  55696. */
  55697. clone(name: string): BackgroundMaterial;
  55698. /**
  55699. * Serializes the current material to its JSON representation.
  55700. * @returns The JSON representation.
  55701. */
  55702. serialize(): any;
  55703. /**
  55704. * Gets the class name of the material
  55705. * @returns "BackgroundMaterial"
  55706. */
  55707. getClassName(): string;
  55708. /**
  55709. * Parse a JSON input to create back a background material.
  55710. * @param source The JSON data to parse
  55711. * @param scene The scene to create the parsed material in
  55712. * @param rootUrl The root url of the assets the material depends upon
  55713. * @returns the instantiated BackgroundMaterial.
  55714. */
  55715. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55716. }
  55717. }
  55718. declare module "babylonjs/Helpers/environmentHelper" {
  55719. import { Observable } from "babylonjs/Misc/observable";
  55720. import { Nullable } from "babylonjs/types";
  55721. import { Scene } from "babylonjs/scene";
  55722. import { Vector3 } from "babylonjs/Maths/math.vector";
  55723. import { Color3 } from "babylonjs/Maths/math.color";
  55724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55725. import { Mesh } from "babylonjs/Meshes/mesh";
  55726. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55727. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55728. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55729. import "babylonjs/Meshes/Builders/planeBuilder";
  55730. import "babylonjs/Meshes/Builders/boxBuilder";
  55731. /**
  55732. * Represents the different options available during the creation of
  55733. * a Environment helper.
  55734. *
  55735. * This can control the default ground, skybox and image processing setup of your scene.
  55736. */
  55737. export interface IEnvironmentHelperOptions {
  55738. /**
  55739. * Specifies whether or not to create a ground.
  55740. * True by default.
  55741. */
  55742. createGround: boolean;
  55743. /**
  55744. * Specifies the ground size.
  55745. * 15 by default.
  55746. */
  55747. groundSize: number;
  55748. /**
  55749. * The texture used on the ground for the main color.
  55750. * Comes from the BabylonJS CDN by default.
  55751. *
  55752. * Remarks: Can be either a texture or a url.
  55753. */
  55754. groundTexture: string | BaseTexture;
  55755. /**
  55756. * The color mixed in the ground texture by default.
  55757. * BabylonJS clearColor by default.
  55758. */
  55759. groundColor: Color3;
  55760. /**
  55761. * Specifies the ground opacity.
  55762. * 1 by default.
  55763. */
  55764. groundOpacity: number;
  55765. /**
  55766. * Enables the ground to receive shadows.
  55767. * True by default.
  55768. */
  55769. enableGroundShadow: boolean;
  55770. /**
  55771. * Helps preventing the shadow to be fully black on the ground.
  55772. * 0.5 by default.
  55773. */
  55774. groundShadowLevel: number;
  55775. /**
  55776. * Creates a mirror texture attach to the ground.
  55777. * false by default.
  55778. */
  55779. enableGroundMirror: boolean;
  55780. /**
  55781. * Specifies the ground mirror size ratio.
  55782. * 0.3 by default as the default kernel is 64.
  55783. */
  55784. groundMirrorSizeRatio: number;
  55785. /**
  55786. * Specifies the ground mirror blur kernel size.
  55787. * 64 by default.
  55788. */
  55789. groundMirrorBlurKernel: number;
  55790. /**
  55791. * Specifies the ground mirror visibility amount.
  55792. * 1 by default
  55793. */
  55794. groundMirrorAmount: number;
  55795. /**
  55796. * Specifies the ground mirror reflectance weight.
  55797. * This uses the standard weight of the background material to setup the fresnel effect
  55798. * of the mirror.
  55799. * 1 by default.
  55800. */
  55801. groundMirrorFresnelWeight: number;
  55802. /**
  55803. * Specifies the ground mirror Falloff distance.
  55804. * This can helps reducing the size of the reflection.
  55805. * 0 by Default.
  55806. */
  55807. groundMirrorFallOffDistance: number;
  55808. /**
  55809. * Specifies the ground mirror texture type.
  55810. * Unsigned Int by Default.
  55811. */
  55812. groundMirrorTextureType: number;
  55813. /**
  55814. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55815. * the shown objects.
  55816. */
  55817. groundYBias: number;
  55818. /**
  55819. * Specifies whether or not to create a skybox.
  55820. * True by default.
  55821. */
  55822. createSkybox: boolean;
  55823. /**
  55824. * Specifies the skybox size.
  55825. * 20 by default.
  55826. */
  55827. skyboxSize: number;
  55828. /**
  55829. * The texture used on the skybox for the main color.
  55830. * Comes from the BabylonJS CDN by default.
  55831. *
  55832. * Remarks: Can be either a texture or a url.
  55833. */
  55834. skyboxTexture: string | BaseTexture;
  55835. /**
  55836. * The color mixed in the skybox texture by default.
  55837. * BabylonJS clearColor by default.
  55838. */
  55839. skyboxColor: Color3;
  55840. /**
  55841. * The background rotation around the Y axis of the scene.
  55842. * This helps aligning the key lights of your scene with the background.
  55843. * 0 by default.
  55844. */
  55845. backgroundYRotation: number;
  55846. /**
  55847. * Compute automatically the size of the elements to best fit with the scene.
  55848. */
  55849. sizeAuto: boolean;
  55850. /**
  55851. * Default position of the rootMesh if autoSize is not true.
  55852. */
  55853. rootPosition: Vector3;
  55854. /**
  55855. * Sets up the image processing in the scene.
  55856. * true by default.
  55857. */
  55858. setupImageProcessing: boolean;
  55859. /**
  55860. * The texture used as your environment texture in the scene.
  55861. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55862. *
  55863. * Remarks: Can be either a texture or a url.
  55864. */
  55865. environmentTexture: string | BaseTexture;
  55866. /**
  55867. * The value of the exposure to apply to the scene.
  55868. * 0.6 by default if setupImageProcessing is true.
  55869. */
  55870. cameraExposure: number;
  55871. /**
  55872. * The value of the contrast to apply to the scene.
  55873. * 1.6 by default if setupImageProcessing is true.
  55874. */
  55875. cameraContrast: number;
  55876. /**
  55877. * Specifies whether or not tonemapping should be enabled in the scene.
  55878. * true by default if setupImageProcessing is true.
  55879. */
  55880. toneMappingEnabled: boolean;
  55881. }
  55882. /**
  55883. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55884. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55885. * It also helps with the default setup of your imageProcessing configuration.
  55886. */
  55887. export class EnvironmentHelper {
  55888. /**
  55889. * Default ground texture URL.
  55890. */
  55891. private static _groundTextureCDNUrl;
  55892. /**
  55893. * Default skybox texture URL.
  55894. */
  55895. private static _skyboxTextureCDNUrl;
  55896. /**
  55897. * Default environment texture URL.
  55898. */
  55899. private static _environmentTextureCDNUrl;
  55900. /**
  55901. * Creates the default options for the helper.
  55902. */
  55903. private static _getDefaultOptions;
  55904. private _rootMesh;
  55905. /**
  55906. * Gets the root mesh created by the helper.
  55907. */
  55908. get rootMesh(): Mesh;
  55909. private _skybox;
  55910. /**
  55911. * Gets the skybox created by the helper.
  55912. */
  55913. get skybox(): Nullable<Mesh>;
  55914. private _skyboxTexture;
  55915. /**
  55916. * Gets the skybox texture created by the helper.
  55917. */
  55918. get skyboxTexture(): Nullable<BaseTexture>;
  55919. private _skyboxMaterial;
  55920. /**
  55921. * Gets the skybox material created by the helper.
  55922. */
  55923. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55924. private _ground;
  55925. /**
  55926. * Gets the ground mesh created by the helper.
  55927. */
  55928. get ground(): Nullable<Mesh>;
  55929. private _groundTexture;
  55930. /**
  55931. * Gets the ground texture created by the helper.
  55932. */
  55933. get groundTexture(): Nullable<BaseTexture>;
  55934. private _groundMirror;
  55935. /**
  55936. * Gets the ground mirror created by the helper.
  55937. */
  55938. get groundMirror(): Nullable<MirrorTexture>;
  55939. /**
  55940. * Gets the ground mirror render list to helps pushing the meshes
  55941. * you wish in the ground reflection.
  55942. */
  55943. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55944. private _groundMaterial;
  55945. /**
  55946. * Gets the ground material created by the helper.
  55947. */
  55948. get groundMaterial(): Nullable<BackgroundMaterial>;
  55949. /**
  55950. * Stores the creation options.
  55951. */
  55952. private readonly _scene;
  55953. private _options;
  55954. /**
  55955. * This observable will be notified with any error during the creation of the environment,
  55956. * mainly texture creation errors.
  55957. */
  55958. onErrorObservable: Observable<{
  55959. message?: string;
  55960. exception?: any;
  55961. }>;
  55962. /**
  55963. * constructor
  55964. * @param options Defines the options we want to customize the helper
  55965. * @param scene The scene to add the material to
  55966. */
  55967. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55968. /**
  55969. * Updates the background according to the new options
  55970. * @param options
  55971. */
  55972. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55973. /**
  55974. * Sets the primary color of all the available elements.
  55975. * @param color the main color to affect to the ground and the background
  55976. */
  55977. setMainColor(color: Color3): void;
  55978. /**
  55979. * Setup the image processing according to the specified options.
  55980. */
  55981. private _setupImageProcessing;
  55982. /**
  55983. * Setup the environment texture according to the specified options.
  55984. */
  55985. private _setupEnvironmentTexture;
  55986. /**
  55987. * Setup the background according to the specified options.
  55988. */
  55989. private _setupBackground;
  55990. /**
  55991. * Get the scene sizes according to the setup.
  55992. */
  55993. private _getSceneSize;
  55994. /**
  55995. * Setup the ground according to the specified options.
  55996. */
  55997. private _setupGround;
  55998. /**
  55999. * Setup the ground material according to the specified options.
  56000. */
  56001. private _setupGroundMaterial;
  56002. /**
  56003. * Setup the ground diffuse texture according to the specified options.
  56004. */
  56005. private _setupGroundDiffuseTexture;
  56006. /**
  56007. * Setup the ground mirror texture according to the specified options.
  56008. */
  56009. private _setupGroundMirrorTexture;
  56010. /**
  56011. * Setup the ground to receive the mirror texture.
  56012. */
  56013. private _setupMirrorInGroundMaterial;
  56014. /**
  56015. * Setup the skybox according to the specified options.
  56016. */
  56017. private _setupSkybox;
  56018. /**
  56019. * Setup the skybox material according to the specified options.
  56020. */
  56021. private _setupSkyboxMaterial;
  56022. /**
  56023. * Setup the skybox reflection texture according to the specified options.
  56024. */
  56025. private _setupSkyboxReflectionTexture;
  56026. private _errorHandler;
  56027. /**
  56028. * Dispose all the elements created by the Helper.
  56029. */
  56030. dispose(): void;
  56031. }
  56032. }
  56033. declare module "babylonjs/Helpers/photoDome" {
  56034. import { Observable } from "babylonjs/Misc/observable";
  56035. import { Nullable } from "babylonjs/types";
  56036. import { Scene } from "babylonjs/scene";
  56037. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56038. import { Mesh } from "babylonjs/Meshes/mesh";
  56039. import { Texture } from "babylonjs/Materials/Textures/texture";
  56040. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56041. import "babylonjs/Meshes/Builders/sphereBuilder";
  56042. /**
  56043. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56044. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56045. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56046. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56047. */
  56048. export class PhotoDome extends TransformNode {
  56049. /**
  56050. * Define the image as a Monoscopic panoramic 360 image.
  56051. */
  56052. static readonly MODE_MONOSCOPIC: number;
  56053. /**
  56054. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56055. */
  56056. static readonly MODE_TOPBOTTOM: number;
  56057. /**
  56058. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56059. */
  56060. static readonly MODE_SIDEBYSIDE: number;
  56061. private _useDirectMapping;
  56062. /**
  56063. * The texture being displayed on the sphere
  56064. */
  56065. protected _photoTexture: Texture;
  56066. /**
  56067. * Gets or sets the texture being displayed on the sphere
  56068. */
  56069. get photoTexture(): Texture;
  56070. set photoTexture(value: Texture);
  56071. /**
  56072. * Observable raised when an error occured while loading the 360 image
  56073. */
  56074. onLoadErrorObservable: Observable<string>;
  56075. /**
  56076. * The skybox material
  56077. */
  56078. protected _material: BackgroundMaterial;
  56079. /**
  56080. * The surface used for the skybox
  56081. */
  56082. protected _mesh: Mesh;
  56083. /**
  56084. * Gets the mesh used for the skybox.
  56085. */
  56086. get mesh(): Mesh;
  56087. /**
  56088. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56089. * Also see the options.resolution property.
  56090. */
  56091. get fovMultiplier(): number;
  56092. set fovMultiplier(value: number);
  56093. private _imageMode;
  56094. /**
  56095. * Gets or set the current video mode for the video. It can be:
  56096. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56097. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56098. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56099. */
  56100. get imageMode(): number;
  56101. set imageMode(value: number);
  56102. /**
  56103. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56104. * @param name Element's name, child elements will append suffixes for their own names.
  56105. * @param urlsOfPhoto defines the url of the photo to display
  56106. * @param options defines an object containing optional or exposed sub element properties
  56107. * @param onError defines a callback called when an error occured while loading the texture
  56108. */
  56109. constructor(name: string, urlOfPhoto: string, options: {
  56110. resolution?: number;
  56111. size?: number;
  56112. useDirectMapping?: boolean;
  56113. faceForward?: boolean;
  56114. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56115. private _onBeforeCameraRenderObserver;
  56116. private _changeImageMode;
  56117. /**
  56118. * Releases resources associated with this node.
  56119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56121. */
  56122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56123. }
  56124. }
  56125. declare module "babylonjs/Misc/rgbdTextureTools" {
  56126. import "babylonjs/Shaders/rgbdDecode.fragment";
  56127. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56128. import { Texture } from "babylonjs/Materials/Textures/texture";
  56129. /**
  56130. * Class used to host RGBD texture specific utilities
  56131. */
  56132. export class RGBDTextureTools {
  56133. /**
  56134. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56135. * @param texture the texture to expand.
  56136. */
  56137. static ExpandRGBDTexture(texture: Texture): void;
  56138. }
  56139. }
  56140. declare module "babylonjs/Misc/brdfTextureTools" {
  56141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56142. import { Scene } from "babylonjs/scene";
  56143. /**
  56144. * Class used to host texture specific utilities
  56145. */
  56146. export class BRDFTextureTools {
  56147. /**
  56148. * Prevents texture cache collision
  56149. */
  56150. private static _instanceNumber;
  56151. /**
  56152. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56153. * @param scene defines the hosting scene
  56154. * @returns the environment BRDF texture
  56155. */
  56156. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56157. private static _environmentBRDFBase64Texture;
  56158. }
  56159. }
  56160. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56161. import { Nullable } from "babylonjs/types";
  56162. import { Color3 } from "babylonjs/Maths/math.color";
  56163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56164. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56165. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56166. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56167. import { Engine } from "babylonjs/Engines/engine";
  56168. import { Scene } from "babylonjs/scene";
  56169. /**
  56170. * @hidden
  56171. */
  56172. export interface IMaterialClearCoatDefines {
  56173. CLEARCOAT: boolean;
  56174. CLEARCOAT_DEFAULTIOR: boolean;
  56175. CLEARCOAT_TEXTURE: boolean;
  56176. CLEARCOAT_TEXTUREDIRECTUV: number;
  56177. CLEARCOAT_BUMP: boolean;
  56178. CLEARCOAT_BUMPDIRECTUV: number;
  56179. CLEARCOAT_TINT: boolean;
  56180. CLEARCOAT_TINT_TEXTURE: boolean;
  56181. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56182. /** @hidden */
  56183. _areTexturesDirty: boolean;
  56184. }
  56185. /**
  56186. * Define the code related to the clear coat parameters of the pbr material.
  56187. */
  56188. export class PBRClearCoatConfiguration {
  56189. /**
  56190. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56191. * The default fits with a polyurethane material.
  56192. */
  56193. private static readonly _DefaultIndexOfRefraction;
  56194. private _isEnabled;
  56195. /**
  56196. * Defines if the clear coat is enabled in the material.
  56197. */
  56198. isEnabled: boolean;
  56199. /**
  56200. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56201. */
  56202. intensity: number;
  56203. /**
  56204. * Defines the clear coat layer roughness.
  56205. */
  56206. roughness: number;
  56207. private _indexOfRefraction;
  56208. /**
  56209. * Defines the index of refraction of the clear coat.
  56210. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56211. * The default fits with a polyurethane material.
  56212. * Changing the default value is more performance intensive.
  56213. */
  56214. indexOfRefraction: number;
  56215. private _texture;
  56216. /**
  56217. * Stores the clear coat values in a texture.
  56218. */
  56219. texture: Nullable<BaseTexture>;
  56220. private _bumpTexture;
  56221. /**
  56222. * Define the clear coat specific bump texture.
  56223. */
  56224. bumpTexture: Nullable<BaseTexture>;
  56225. private _isTintEnabled;
  56226. /**
  56227. * Defines if the clear coat tint is enabled in the material.
  56228. */
  56229. isTintEnabled: boolean;
  56230. /**
  56231. * Defines the clear coat tint of the material.
  56232. * This is only use if tint is enabled
  56233. */
  56234. tintColor: Color3;
  56235. /**
  56236. * Defines the distance at which the tint color should be found in the
  56237. * clear coat media.
  56238. * This is only use if tint is enabled
  56239. */
  56240. tintColorAtDistance: number;
  56241. /**
  56242. * Defines the clear coat layer thickness.
  56243. * This is only use if tint is enabled
  56244. */
  56245. tintThickness: number;
  56246. private _tintTexture;
  56247. /**
  56248. * Stores the clear tint values in a texture.
  56249. * rgb is tint
  56250. * a is a thickness factor
  56251. */
  56252. tintTexture: Nullable<BaseTexture>;
  56253. /** @hidden */
  56254. private _internalMarkAllSubMeshesAsTexturesDirty;
  56255. /** @hidden */
  56256. _markAllSubMeshesAsTexturesDirty(): void;
  56257. /**
  56258. * Instantiate a new istance of clear coat configuration.
  56259. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56260. */
  56261. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56262. /**
  56263. * Gets wehter the submesh is ready to be used or not.
  56264. * @param defines the list of "defines" to update.
  56265. * @param scene defines the scene the material belongs to.
  56266. * @param engine defines the engine the material belongs to.
  56267. * @param disableBumpMap defines wether the material disables bump or not.
  56268. * @returns - boolean indicating that the submesh is ready or not.
  56269. */
  56270. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56271. /**
  56272. * Checks to see if a texture is used in the material.
  56273. * @param defines the list of "defines" to update.
  56274. * @param scene defines the scene to the material belongs to.
  56275. */
  56276. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56277. /**
  56278. * Binds the material data.
  56279. * @param uniformBuffer defines the Uniform buffer to fill in.
  56280. * @param scene defines the scene the material belongs to.
  56281. * @param engine defines the engine the material belongs to.
  56282. * @param disableBumpMap defines wether the material disables bump or not.
  56283. * @param isFrozen defines wether the material is frozen or not.
  56284. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56285. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56286. */
  56287. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56288. /**
  56289. * Checks to see if a texture is used in the material.
  56290. * @param texture - Base texture to use.
  56291. * @returns - Boolean specifying if a texture is used in the material.
  56292. */
  56293. hasTexture(texture: BaseTexture): boolean;
  56294. /**
  56295. * Returns an array of the actively used textures.
  56296. * @param activeTextures Array of BaseTextures
  56297. */
  56298. getActiveTextures(activeTextures: BaseTexture[]): void;
  56299. /**
  56300. * Returns the animatable textures.
  56301. * @param animatables Array of animatable textures.
  56302. */
  56303. getAnimatables(animatables: IAnimatable[]): void;
  56304. /**
  56305. * Disposes the resources of the material.
  56306. * @param forceDisposeTextures - Forces the disposal of all textures.
  56307. */
  56308. dispose(forceDisposeTextures?: boolean): void;
  56309. /**
  56310. * Get the current class name of the texture useful for serialization or dynamic coding.
  56311. * @returns "PBRClearCoatConfiguration"
  56312. */
  56313. getClassName(): string;
  56314. /**
  56315. * Add fallbacks to the effect fallbacks list.
  56316. * @param defines defines the Base texture to use.
  56317. * @param fallbacks defines the current fallback list.
  56318. * @param currentRank defines the current fallback rank.
  56319. * @returns the new fallback rank.
  56320. */
  56321. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56322. /**
  56323. * Add the required uniforms to the current list.
  56324. * @param uniforms defines the current uniform list.
  56325. */
  56326. static AddUniforms(uniforms: string[]): void;
  56327. /**
  56328. * Add the required samplers to the current list.
  56329. * @param samplers defines the current sampler list.
  56330. */
  56331. static AddSamplers(samplers: string[]): void;
  56332. /**
  56333. * Add the required uniforms to the current buffer.
  56334. * @param uniformBuffer defines the current uniform buffer.
  56335. */
  56336. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56337. /**
  56338. * Makes a duplicate of the current configuration into another one.
  56339. * @param clearCoatConfiguration define the config where to copy the info
  56340. */
  56341. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56342. /**
  56343. * Serializes this clear coat configuration.
  56344. * @returns - An object with the serialized config.
  56345. */
  56346. serialize(): any;
  56347. /**
  56348. * Parses a anisotropy Configuration from a serialized object.
  56349. * @param source - Serialized object.
  56350. * @param scene Defines the scene we are parsing for
  56351. * @param rootUrl Defines the rootUrl to load from
  56352. */
  56353. parse(source: any, scene: Scene, rootUrl: string): void;
  56354. }
  56355. }
  56356. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56357. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56359. import { Vector2 } from "babylonjs/Maths/math.vector";
  56360. import { Scene } from "babylonjs/scene";
  56361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56362. import { Nullable } from "babylonjs/types";
  56363. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56364. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56365. /**
  56366. * @hidden
  56367. */
  56368. export interface IMaterialAnisotropicDefines {
  56369. ANISOTROPIC: boolean;
  56370. ANISOTROPIC_TEXTURE: boolean;
  56371. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56372. MAINUV1: boolean;
  56373. _areTexturesDirty: boolean;
  56374. _needUVs: boolean;
  56375. }
  56376. /**
  56377. * Define the code related to the anisotropic parameters of the pbr material.
  56378. */
  56379. export class PBRAnisotropicConfiguration {
  56380. private _isEnabled;
  56381. /**
  56382. * Defines if the anisotropy is enabled in the material.
  56383. */
  56384. isEnabled: boolean;
  56385. /**
  56386. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56387. */
  56388. intensity: number;
  56389. /**
  56390. * Defines if the effect is along the tangents, bitangents or in between.
  56391. * By default, the effect is "strectching" the highlights along the tangents.
  56392. */
  56393. direction: Vector2;
  56394. private _texture;
  56395. /**
  56396. * Stores the anisotropy values in a texture.
  56397. * rg is direction (like normal from -1 to 1)
  56398. * b is a intensity
  56399. */
  56400. texture: Nullable<BaseTexture>;
  56401. /** @hidden */
  56402. private _internalMarkAllSubMeshesAsTexturesDirty;
  56403. /** @hidden */
  56404. _markAllSubMeshesAsTexturesDirty(): void;
  56405. /**
  56406. * Instantiate a new istance of anisotropy configuration.
  56407. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56408. */
  56409. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56410. /**
  56411. * Specifies that the submesh is ready to be used.
  56412. * @param defines the list of "defines" to update.
  56413. * @param scene defines the scene the material belongs to.
  56414. * @returns - boolean indicating that the submesh is ready or not.
  56415. */
  56416. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56417. /**
  56418. * Checks to see if a texture is used in the material.
  56419. * @param defines the list of "defines" to update.
  56420. * @param mesh the mesh we are preparing the defines for.
  56421. * @param scene defines the scene the material belongs to.
  56422. */
  56423. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56424. /**
  56425. * Binds the material data.
  56426. * @param uniformBuffer defines the Uniform buffer to fill in.
  56427. * @param scene defines the scene the material belongs to.
  56428. * @param isFrozen defines wether the material is frozen or not.
  56429. */
  56430. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56431. /**
  56432. * Checks to see if a texture is used in the material.
  56433. * @param texture - Base texture to use.
  56434. * @returns - Boolean specifying if a texture is used in the material.
  56435. */
  56436. hasTexture(texture: BaseTexture): boolean;
  56437. /**
  56438. * Returns an array of the actively used textures.
  56439. * @param activeTextures Array of BaseTextures
  56440. */
  56441. getActiveTextures(activeTextures: BaseTexture[]): void;
  56442. /**
  56443. * Returns the animatable textures.
  56444. * @param animatables Array of animatable textures.
  56445. */
  56446. getAnimatables(animatables: IAnimatable[]): void;
  56447. /**
  56448. * Disposes the resources of the material.
  56449. * @param forceDisposeTextures - Forces the disposal of all textures.
  56450. */
  56451. dispose(forceDisposeTextures?: boolean): void;
  56452. /**
  56453. * Get the current class name of the texture useful for serialization or dynamic coding.
  56454. * @returns "PBRAnisotropicConfiguration"
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Add fallbacks to the effect fallbacks list.
  56459. * @param defines defines the Base texture to use.
  56460. * @param fallbacks defines the current fallback list.
  56461. * @param currentRank defines the current fallback rank.
  56462. * @returns the new fallback rank.
  56463. */
  56464. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56465. /**
  56466. * Add the required uniforms to the current list.
  56467. * @param uniforms defines the current uniform list.
  56468. */
  56469. static AddUniforms(uniforms: string[]): void;
  56470. /**
  56471. * Add the required uniforms to the current buffer.
  56472. * @param uniformBuffer defines the current uniform buffer.
  56473. */
  56474. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56475. /**
  56476. * Add the required samplers to the current list.
  56477. * @param samplers defines the current sampler list.
  56478. */
  56479. static AddSamplers(samplers: string[]): void;
  56480. /**
  56481. * Makes a duplicate of the current configuration into another one.
  56482. * @param anisotropicConfiguration define the config where to copy the info
  56483. */
  56484. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56485. /**
  56486. * Serializes this anisotropy configuration.
  56487. * @returns - An object with the serialized config.
  56488. */
  56489. serialize(): any;
  56490. /**
  56491. * Parses a anisotropy Configuration from a serialized object.
  56492. * @param source - Serialized object.
  56493. * @param scene Defines the scene we are parsing for
  56494. * @param rootUrl Defines the rootUrl to load from
  56495. */
  56496. parse(source: any, scene: Scene, rootUrl: string): void;
  56497. }
  56498. }
  56499. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56500. import { Scene } from "babylonjs/scene";
  56501. /**
  56502. * @hidden
  56503. */
  56504. export interface IMaterialBRDFDefines {
  56505. BRDF_V_HEIGHT_CORRELATED: boolean;
  56506. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56507. SPHERICAL_HARMONICS: boolean;
  56508. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56509. /** @hidden */
  56510. _areMiscDirty: boolean;
  56511. }
  56512. /**
  56513. * Define the code related to the BRDF parameters of the pbr material.
  56514. */
  56515. export class PBRBRDFConfiguration {
  56516. /**
  56517. * Default value used for the energy conservation.
  56518. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56519. */
  56520. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56521. /**
  56522. * Default value used for the Smith Visibility Height Correlated mode.
  56523. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56524. */
  56525. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56526. /**
  56527. * Default value used for the IBL diffuse part.
  56528. * This can help switching back to the polynomials mode globally which is a tiny bit
  56529. * less GPU intensive at the drawback of a lower quality.
  56530. */
  56531. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56532. /**
  56533. * Default value used for activating energy conservation for the specular workflow.
  56534. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56535. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56536. */
  56537. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56538. private _useEnergyConservation;
  56539. /**
  56540. * Defines if the material uses energy conservation.
  56541. */
  56542. useEnergyConservation: boolean;
  56543. private _useSmithVisibilityHeightCorrelated;
  56544. /**
  56545. * LEGACY Mode set to false
  56546. * Defines if the material uses height smith correlated visibility term.
  56547. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56548. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56549. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56550. * Not relying on height correlated will also disable energy conservation.
  56551. */
  56552. useSmithVisibilityHeightCorrelated: boolean;
  56553. private _useSphericalHarmonics;
  56554. /**
  56555. * LEGACY Mode set to false
  56556. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56557. * diffuse part of the IBL.
  56558. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56559. * to the ground truth.
  56560. */
  56561. useSphericalHarmonics: boolean;
  56562. private _useSpecularGlossinessInputEnergyConservation;
  56563. /**
  56564. * Defines if the material uses energy conservation, when the specular workflow is active.
  56565. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56566. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56567. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56568. */
  56569. useSpecularGlossinessInputEnergyConservation: boolean;
  56570. /** @hidden */
  56571. private _internalMarkAllSubMeshesAsMiscDirty;
  56572. /** @hidden */
  56573. _markAllSubMeshesAsMiscDirty(): void;
  56574. /**
  56575. * Instantiate a new istance of clear coat configuration.
  56576. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56577. */
  56578. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56579. /**
  56580. * Checks to see if a texture is used in the material.
  56581. * @param defines the list of "defines" to update.
  56582. */
  56583. prepareDefines(defines: IMaterialBRDFDefines): void;
  56584. /**
  56585. * Get the current class name of the texture useful for serialization or dynamic coding.
  56586. * @returns "PBRClearCoatConfiguration"
  56587. */
  56588. getClassName(): string;
  56589. /**
  56590. * Makes a duplicate of the current configuration into another one.
  56591. * @param brdfConfiguration define the config where to copy the info
  56592. */
  56593. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56594. /**
  56595. * Serializes this BRDF configuration.
  56596. * @returns - An object with the serialized config.
  56597. */
  56598. serialize(): any;
  56599. /**
  56600. * Parses a anisotropy Configuration from a serialized object.
  56601. * @param source - Serialized object.
  56602. * @param scene Defines the scene we are parsing for
  56603. * @param rootUrl Defines the rootUrl to load from
  56604. */
  56605. parse(source: any, scene: Scene, rootUrl: string): void;
  56606. }
  56607. }
  56608. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56610. import { Color3 } from "babylonjs/Maths/math.color";
  56611. import { Scene } from "babylonjs/scene";
  56612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56613. import { Nullable } from "babylonjs/types";
  56614. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56615. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56616. /**
  56617. * @hidden
  56618. */
  56619. export interface IMaterialSheenDefines {
  56620. SHEEN: boolean;
  56621. SHEEN_TEXTURE: boolean;
  56622. SHEEN_TEXTUREDIRECTUV: number;
  56623. SHEEN_LINKWITHALBEDO: boolean;
  56624. SHEEN_ROUGHNESS: boolean;
  56625. SHEEN_ALBEDOSCALING: boolean;
  56626. /** @hidden */
  56627. _areTexturesDirty: boolean;
  56628. }
  56629. /**
  56630. * Define the code related to the Sheen parameters of the pbr material.
  56631. */
  56632. export class PBRSheenConfiguration {
  56633. private _isEnabled;
  56634. /**
  56635. * Defines if the material uses sheen.
  56636. */
  56637. isEnabled: boolean;
  56638. private _linkSheenWithAlbedo;
  56639. /**
  56640. * Defines if the sheen is linked to the sheen color.
  56641. */
  56642. linkSheenWithAlbedo: boolean;
  56643. /**
  56644. * Defines the sheen intensity.
  56645. */
  56646. intensity: number;
  56647. /**
  56648. * Defines the sheen color.
  56649. */
  56650. color: Color3;
  56651. private _texture;
  56652. /**
  56653. * Stores the sheen tint values in a texture.
  56654. * rgb is tint
  56655. * a is a intensity
  56656. */
  56657. texture: Nullable<BaseTexture>;
  56658. private _roughness;
  56659. /**
  56660. * Defines the sheen roughness.
  56661. * It is not taken into account if linkSheenWithAlbedo is true.
  56662. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56663. */
  56664. roughness: Nullable<number>;
  56665. private _albedoScaling;
  56666. /**
  56667. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56668. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56669. * making it easier to setup and tweak the effect
  56670. */
  56671. albedoScaling: boolean;
  56672. /** @hidden */
  56673. private _internalMarkAllSubMeshesAsTexturesDirty;
  56674. /** @hidden */
  56675. _markAllSubMeshesAsTexturesDirty(): void;
  56676. /**
  56677. * Instantiate a new istance of clear coat configuration.
  56678. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56679. */
  56680. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56681. /**
  56682. * Specifies that the submesh is ready to be used.
  56683. * @param defines the list of "defines" to update.
  56684. * @param scene defines the scene the material belongs to.
  56685. * @returns - boolean indicating that the submesh is ready or not.
  56686. */
  56687. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56688. /**
  56689. * Checks to see if a texture is used in the material.
  56690. * @param defines the list of "defines" to update.
  56691. * @param scene defines the scene the material belongs to.
  56692. */
  56693. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56694. /**
  56695. * Binds the material data.
  56696. * @param uniformBuffer defines the Uniform buffer to fill in.
  56697. * @param scene defines the scene the material belongs to.
  56698. * @param isFrozen defines wether the material is frozen or not.
  56699. */
  56700. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56701. /**
  56702. * Checks to see if a texture is used in the material.
  56703. * @param texture - Base texture to use.
  56704. * @returns - Boolean specifying if a texture is used in the material.
  56705. */
  56706. hasTexture(texture: BaseTexture): boolean;
  56707. /**
  56708. * Returns an array of the actively used textures.
  56709. * @param activeTextures Array of BaseTextures
  56710. */
  56711. getActiveTextures(activeTextures: BaseTexture[]): void;
  56712. /**
  56713. * Returns the animatable textures.
  56714. * @param animatables Array of animatable textures.
  56715. */
  56716. getAnimatables(animatables: IAnimatable[]): void;
  56717. /**
  56718. * Disposes the resources of the material.
  56719. * @param forceDisposeTextures - Forces the disposal of all textures.
  56720. */
  56721. dispose(forceDisposeTextures?: boolean): void;
  56722. /**
  56723. * Get the current class name of the texture useful for serialization or dynamic coding.
  56724. * @returns "PBRSheenConfiguration"
  56725. */
  56726. getClassName(): string;
  56727. /**
  56728. * Add fallbacks to the effect fallbacks list.
  56729. * @param defines defines the Base texture to use.
  56730. * @param fallbacks defines the current fallback list.
  56731. * @param currentRank defines the current fallback rank.
  56732. * @returns the new fallback rank.
  56733. */
  56734. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56735. /**
  56736. * Add the required uniforms to the current list.
  56737. * @param uniforms defines the current uniform list.
  56738. */
  56739. static AddUniforms(uniforms: string[]): void;
  56740. /**
  56741. * Add the required uniforms to the current buffer.
  56742. * @param uniformBuffer defines the current uniform buffer.
  56743. */
  56744. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56745. /**
  56746. * Add the required samplers to the current list.
  56747. * @param samplers defines the current sampler list.
  56748. */
  56749. static AddSamplers(samplers: string[]): void;
  56750. /**
  56751. * Makes a duplicate of the current configuration into another one.
  56752. * @param sheenConfiguration define the config where to copy the info
  56753. */
  56754. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56755. /**
  56756. * Serializes this BRDF configuration.
  56757. * @returns - An object with the serialized config.
  56758. */
  56759. serialize(): any;
  56760. /**
  56761. * Parses a anisotropy Configuration from a serialized object.
  56762. * @param source - Serialized object.
  56763. * @param scene Defines the scene we are parsing for
  56764. * @param rootUrl Defines the rootUrl to load from
  56765. */
  56766. parse(source: any, scene: Scene, rootUrl: string): void;
  56767. }
  56768. }
  56769. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56770. import { Nullable } from "babylonjs/types";
  56771. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56772. import { Color3 } from "babylonjs/Maths/math.color";
  56773. import { SmartArray } from "babylonjs/Misc/smartArray";
  56774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56776. import { Effect } from "babylonjs/Materials/effect";
  56777. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56778. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56779. import { Engine } from "babylonjs/Engines/engine";
  56780. import { Scene } from "babylonjs/scene";
  56781. /**
  56782. * @hidden
  56783. */
  56784. export interface IMaterialSubSurfaceDefines {
  56785. SUBSURFACE: boolean;
  56786. SS_REFRACTION: boolean;
  56787. SS_TRANSLUCENCY: boolean;
  56788. SS_SCATTERING: boolean;
  56789. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56790. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56791. SS_REFRACTIONMAP_3D: boolean;
  56792. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56793. SS_LODINREFRACTIONALPHA: boolean;
  56794. SS_GAMMAREFRACTION: boolean;
  56795. SS_RGBDREFRACTION: boolean;
  56796. SS_LINEARSPECULARREFRACTION: boolean;
  56797. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56798. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56799. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56800. /** @hidden */
  56801. _areTexturesDirty: boolean;
  56802. }
  56803. /**
  56804. * Define the code related to the sub surface parameters of the pbr material.
  56805. */
  56806. export class PBRSubSurfaceConfiguration {
  56807. private _isRefractionEnabled;
  56808. /**
  56809. * Defines if the refraction is enabled in the material.
  56810. */
  56811. isRefractionEnabled: boolean;
  56812. private _isTranslucencyEnabled;
  56813. /**
  56814. * Defines if the translucency is enabled in the material.
  56815. */
  56816. isTranslucencyEnabled: boolean;
  56817. private _isScatteringEnabled;
  56818. /**
  56819. * Defines the refraction intensity of the material.
  56820. * The refraction when enabled replaces the Diffuse part of the material.
  56821. * The intensity helps transitionning between diffuse and refraction.
  56822. */
  56823. refractionIntensity: number;
  56824. /**
  56825. * Defines the translucency intensity of the material.
  56826. * When translucency has been enabled, this defines how much of the "translucency"
  56827. * is addded to the diffuse part of the material.
  56828. */
  56829. translucencyIntensity: number;
  56830. /**
  56831. * Defines the scattering intensity of the material.
  56832. * When scattering has been enabled, this defines how much of the "scattered light"
  56833. * is addded to the diffuse part of the material.
  56834. */
  56835. scatteringIntensity: number;
  56836. /**
  56837. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56838. */
  56839. useAlbedoToTintRefraction: boolean;
  56840. private _thicknessTexture;
  56841. /**
  56842. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56843. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56844. * 0 would mean minimumThickness
  56845. * 1 would mean maximumThickness
  56846. * The other channels might be use as a mask to vary the different effects intensity.
  56847. */
  56848. thicknessTexture: Nullable<BaseTexture>;
  56849. private _refractionTexture;
  56850. /**
  56851. * Defines the texture to use for refraction.
  56852. */
  56853. refractionTexture: Nullable<BaseTexture>;
  56854. private _indexOfRefraction;
  56855. /**
  56856. * Index of refraction of the material base layer.
  56857. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56858. *
  56859. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56860. *
  56861. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56862. */
  56863. indexOfRefraction: number;
  56864. private _volumeIndexOfRefraction;
  56865. /**
  56866. * Index of refraction of the material's volume.
  56867. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56868. *
  56869. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56870. * the volume will use the same IOR as the surface.
  56871. */
  56872. get volumeIndexOfRefraction(): number;
  56873. set volumeIndexOfRefraction(value: number);
  56874. private _invertRefractionY;
  56875. /**
  56876. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56877. */
  56878. invertRefractionY: boolean;
  56879. private _linkRefractionWithTransparency;
  56880. /**
  56881. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56882. * Materials half opaque for instance using refraction could benefit from this control.
  56883. */
  56884. linkRefractionWithTransparency: boolean;
  56885. /**
  56886. * Defines the minimum thickness stored in the thickness map.
  56887. * If no thickness map is defined, this value will be used to simulate thickness.
  56888. */
  56889. minimumThickness: number;
  56890. /**
  56891. * Defines the maximum thickness stored in the thickness map.
  56892. */
  56893. maximumThickness: number;
  56894. /**
  56895. * Defines the volume tint of the material.
  56896. * This is used for both translucency and scattering.
  56897. */
  56898. tintColor: Color3;
  56899. /**
  56900. * Defines the distance at which the tint color should be found in the media.
  56901. * This is used for refraction only.
  56902. */
  56903. tintColorAtDistance: number;
  56904. /**
  56905. * Defines how far each channel transmit through the media.
  56906. * It is defined as a color to simplify it selection.
  56907. */
  56908. diffusionDistance: Color3;
  56909. private _useMaskFromThicknessTexture;
  56910. /**
  56911. * Stores the intensity of the different subsurface effects in the thickness texture.
  56912. * * the green channel is the translucency intensity.
  56913. * * the blue channel is the scattering intensity.
  56914. * * the alpha channel is the refraction intensity.
  56915. */
  56916. useMaskFromThicknessTexture: boolean;
  56917. /** @hidden */
  56918. private _internalMarkAllSubMeshesAsTexturesDirty;
  56919. /** @hidden */
  56920. _markAllSubMeshesAsTexturesDirty(): void;
  56921. /**
  56922. * Instantiate a new istance of sub surface configuration.
  56923. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56924. */
  56925. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56926. /**
  56927. * Gets wehter the submesh is ready to be used or not.
  56928. * @param defines the list of "defines" to update.
  56929. * @param scene defines the scene the material belongs to.
  56930. * @returns - boolean indicating that the submesh is ready or not.
  56931. */
  56932. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56933. /**
  56934. * Checks to see if a texture is used in the material.
  56935. * @param defines the list of "defines" to update.
  56936. * @param scene defines the scene to the material belongs to.
  56937. */
  56938. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56939. /**
  56940. * Binds the material data.
  56941. * @param uniformBuffer defines the Uniform buffer to fill in.
  56942. * @param scene defines the scene the material belongs to.
  56943. * @param engine defines the engine the material belongs to.
  56944. * @param isFrozen defines whether the material is frozen or not.
  56945. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56946. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56947. */
  56948. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56949. /**
  56950. * Unbinds the material from the mesh.
  56951. * @param activeEffect defines the effect that should be unbound from.
  56952. * @returns true if unbound, otherwise false
  56953. */
  56954. unbind(activeEffect: Effect): boolean;
  56955. /**
  56956. * Returns the texture used for refraction or null if none is used.
  56957. * @param scene defines the scene the material belongs to.
  56958. * @returns - Refraction texture if present. If no refraction texture and refraction
  56959. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56960. */
  56961. private _getRefractionTexture;
  56962. /**
  56963. * Returns true if alpha blending should be disabled.
  56964. */
  56965. get disableAlphaBlending(): boolean;
  56966. /**
  56967. * Fills the list of render target textures.
  56968. * @param renderTargets the list of render targets to update
  56969. */
  56970. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56971. /**
  56972. * Checks to see if a texture is used in the material.
  56973. * @param texture - Base texture to use.
  56974. * @returns - Boolean specifying if a texture is used in the material.
  56975. */
  56976. hasTexture(texture: BaseTexture): boolean;
  56977. /**
  56978. * Gets a boolean indicating that current material needs to register RTT
  56979. * @returns true if this uses a render target otherwise false.
  56980. */
  56981. hasRenderTargetTextures(): boolean;
  56982. /**
  56983. * Returns an array of the actively used textures.
  56984. * @param activeTextures Array of BaseTextures
  56985. */
  56986. getActiveTextures(activeTextures: BaseTexture[]): void;
  56987. /**
  56988. * Returns the animatable textures.
  56989. * @param animatables Array of animatable textures.
  56990. */
  56991. getAnimatables(animatables: IAnimatable[]): void;
  56992. /**
  56993. * Disposes the resources of the material.
  56994. * @param forceDisposeTextures - Forces the disposal of all textures.
  56995. */
  56996. dispose(forceDisposeTextures?: boolean): void;
  56997. /**
  56998. * Get the current class name of the texture useful for serialization or dynamic coding.
  56999. * @returns "PBRSubSurfaceConfiguration"
  57000. */
  57001. getClassName(): string;
  57002. /**
  57003. * Add fallbacks to the effect fallbacks list.
  57004. * @param defines defines the Base texture to use.
  57005. * @param fallbacks defines the current fallback list.
  57006. * @param currentRank defines the current fallback rank.
  57007. * @returns the new fallback rank.
  57008. */
  57009. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57010. /**
  57011. * Add the required uniforms to the current list.
  57012. * @param uniforms defines the current uniform list.
  57013. */
  57014. static AddUniforms(uniforms: string[]): void;
  57015. /**
  57016. * Add the required samplers to the current list.
  57017. * @param samplers defines the current sampler list.
  57018. */
  57019. static AddSamplers(samplers: string[]): void;
  57020. /**
  57021. * Add the required uniforms to the current buffer.
  57022. * @param uniformBuffer defines the current uniform buffer.
  57023. */
  57024. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57025. /**
  57026. * Makes a duplicate of the current configuration into another one.
  57027. * @param configuration define the config where to copy the info
  57028. */
  57029. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57030. /**
  57031. * Serializes this Sub Surface configuration.
  57032. * @returns - An object with the serialized config.
  57033. */
  57034. serialize(): any;
  57035. /**
  57036. * Parses a anisotropy Configuration from a serialized object.
  57037. * @param source - Serialized object.
  57038. * @param scene Defines the scene we are parsing for
  57039. * @param rootUrl Defines the rootUrl to load from
  57040. */
  57041. parse(source: any, scene: Scene, rootUrl: string): void;
  57042. }
  57043. }
  57044. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57045. /** @hidden */
  57046. export var pbrFragmentDeclaration: {
  57047. name: string;
  57048. shader: string;
  57049. };
  57050. }
  57051. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57052. /** @hidden */
  57053. export var pbrUboDeclaration: {
  57054. name: string;
  57055. shader: string;
  57056. };
  57057. }
  57058. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57059. /** @hidden */
  57060. export var pbrFragmentExtraDeclaration: {
  57061. name: string;
  57062. shader: string;
  57063. };
  57064. }
  57065. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57066. /** @hidden */
  57067. export var pbrFragmentSamplersDeclaration: {
  57068. name: string;
  57069. shader: string;
  57070. };
  57071. }
  57072. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57073. /** @hidden */
  57074. export var importanceSampling: {
  57075. name: string;
  57076. shader: string;
  57077. };
  57078. }
  57079. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57080. /** @hidden */
  57081. export var pbrHelperFunctions: {
  57082. name: string;
  57083. shader: string;
  57084. };
  57085. }
  57086. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57087. /** @hidden */
  57088. export var harmonicsFunctions: {
  57089. name: string;
  57090. shader: string;
  57091. };
  57092. }
  57093. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57094. /** @hidden */
  57095. export var pbrDirectLightingSetupFunctions: {
  57096. name: string;
  57097. shader: string;
  57098. };
  57099. }
  57100. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57101. /** @hidden */
  57102. export var pbrDirectLightingFalloffFunctions: {
  57103. name: string;
  57104. shader: string;
  57105. };
  57106. }
  57107. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57108. /** @hidden */
  57109. export var pbrBRDFFunctions: {
  57110. name: string;
  57111. shader: string;
  57112. };
  57113. }
  57114. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57115. /** @hidden */
  57116. export var hdrFilteringFunctions: {
  57117. name: string;
  57118. shader: string;
  57119. };
  57120. }
  57121. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57122. /** @hidden */
  57123. export var pbrDirectLightingFunctions: {
  57124. name: string;
  57125. shader: string;
  57126. };
  57127. }
  57128. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57129. /** @hidden */
  57130. export var pbrIBLFunctions: {
  57131. name: string;
  57132. shader: string;
  57133. };
  57134. }
  57135. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57136. /** @hidden */
  57137. export var pbrBlockAlbedoOpacity: {
  57138. name: string;
  57139. shader: string;
  57140. };
  57141. }
  57142. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57143. /** @hidden */
  57144. export var pbrBlockReflectivity: {
  57145. name: string;
  57146. shader: string;
  57147. };
  57148. }
  57149. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57150. /** @hidden */
  57151. export var pbrBlockAmbientOcclusion: {
  57152. name: string;
  57153. shader: string;
  57154. };
  57155. }
  57156. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57157. /** @hidden */
  57158. export var pbrBlockAlphaFresnel: {
  57159. name: string;
  57160. shader: string;
  57161. };
  57162. }
  57163. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57164. /** @hidden */
  57165. export var pbrBlockAnisotropic: {
  57166. name: string;
  57167. shader: string;
  57168. };
  57169. }
  57170. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57171. /** @hidden */
  57172. export var pbrBlockReflection: {
  57173. name: string;
  57174. shader: string;
  57175. };
  57176. }
  57177. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57178. /** @hidden */
  57179. export var pbrBlockSheen: {
  57180. name: string;
  57181. shader: string;
  57182. };
  57183. }
  57184. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57185. /** @hidden */
  57186. export var pbrBlockClearcoat: {
  57187. name: string;
  57188. shader: string;
  57189. };
  57190. }
  57191. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57192. /** @hidden */
  57193. export var pbrBlockSubSurface: {
  57194. name: string;
  57195. shader: string;
  57196. };
  57197. }
  57198. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57199. /** @hidden */
  57200. export var pbrBlockNormalGeometric: {
  57201. name: string;
  57202. shader: string;
  57203. };
  57204. }
  57205. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57206. /** @hidden */
  57207. export var pbrBlockNormalFinal: {
  57208. name: string;
  57209. shader: string;
  57210. };
  57211. }
  57212. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57213. /** @hidden */
  57214. export var pbrBlockGeometryInfo: {
  57215. name: string;
  57216. shader: string;
  57217. };
  57218. }
  57219. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57220. /** @hidden */
  57221. export var pbrBlockReflectance0: {
  57222. name: string;
  57223. shader: string;
  57224. };
  57225. }
  57226. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57227. /** @hidden */
  57228. export var pbrBlockReflectance: {
  57229. name: string;
  57230. shader: string;
  57231. };
  57232. }
  57233. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57234. /** @hidden */
  57235. export var pbrBlockDirectLighting: {
  57236. name: string;
  57237. shader: string;
  57238. };
  57239. }
  57240. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57241. /** @hidden */
  57242. export var pbrBlockFinalLitComponents: {
  57243. name: string;
  57244. shader: string;
  57245. };
  57246. }
  57247. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57248. /** @hidden */
  57249. export var pbrBlockFinalUnlitComponents: {
  57250. name: string;
  57251. shader: string;
  57252. };
  57253. }
  57254. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57255. /** @hidden */
  57256. export var pbrBlockFinalColorComposition: {
  57257. name: string;
  57258. shader: string;
  57259. };
  57260. }
  57261. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57262. /** @hidden */
  57263. export var pbrBlockImageProcessing: {
  57264. name: string;
  57265. shader: string;
  57266. };
  57267. }
  57268. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57269. /** @hidden */
  57270. export var pbrDebug: {
  57271. name: string;
  57272. shader: string;
  57273. };
  57274. }
  57275. declare module "babylonjs/Shaders/pbr.fragment" {
  57276. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57277. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57278. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57279. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57280. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57281. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57282. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57283. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57284. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57285. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57286. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57287. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57288. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57289. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57290. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57291. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57292. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57293. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57294. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57295. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57296. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57297. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57298. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57299. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57300. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57301. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57302. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57303. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57304. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57305. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57306. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57307. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57308. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57309. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57310. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57311. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57312. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57313. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57314. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57315. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57316. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57317. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57318. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57319. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57320. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57321. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57322. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57323. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57324. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57325. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57326. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57327. /** @hidden */
  57328. export var pbrPixelShader: {
  57329. name: string;
  57330. shader: string;
  57331. };
  57332. }
  57333. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57334. /** @hidden */
  57335. export var pbrVertexDeclaration: {
  57336. name: string;
  57337. shader: string;
  57338. };
  57339. }
  57340. declare module "babylonjs/Shaders/pbr.vertex" {
  57341. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57342. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57344. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57345. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57346. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57347. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57349. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57350. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57351. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57352. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57354. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57355. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57356. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57357. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57358. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57360. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57361. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57362. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57363. /** @hidden */
  57364. export var pbrVertexShader: {
  57365. name: string;
  57366. shader: string;
  57367. };
  57368. }
  57369. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57370. import { Nullable } from "babylonjs/types";
  57371. import { Scene } from "babylonjs/scene";
  57372. import { Matrix } from "babylonjs/Maths/math.vector";
  57373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57375. import { Mesh } from "babylonjs/Meshes/mesh";
  57376. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57377. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57378. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57379. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57380. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57381. import { Color3 } from "babylonjs/Maths/math.color";
  57382. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57383. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57384. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57385. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57388. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57389. import "babylonjs/Shaders/pbr.fragment";
  57390. import "babylonjs/Shaders/pbr.vertex";
  57391. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57392. /**
  57393. * Manages the defines for the PBR Material.
  57394. * @hidden
  57395. */
  57396. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57397. PBR: boolean;
  57398. NUM_SAMPLES: string;
  57399. REALTIME_FILTERING: boolean;
  57400. MAINUV1: boolean;
  57401. MAINUV2: boolean;
  57402. UV1: boolean;
  57403. UV2: boolean;
  57404. ALBEDO: boolean;
  57405. GAMMAALBEDO: boolean;
  57406. ALBEDODIRECTUV: number;
  57407. VERTEXCOLOR: boolean;
  57408. DETAIL: boolean;
  57409. DETAILDIRECTUV: number;
  57410. DETAIL_NORMALBLENDMETHOD: number;
  57411. AMBIENT: boolean;
  57412. AMBIENTDIRECTUV: number;
  57413. AMBIENTINGRAYSCALE: boolean;
  57414. OPACITY: boolean;
  57415. VERTEXALPHA: boolean;
  57416. OPACITYDIRECTUV: number;
  57417. OPACITYRGB: boolean;
  57418. ALPHATEST: boolean;
  57419. DEPTHPREPASS: boolean;
  57420. ALPHABLEND: boolean;
  57421. ALPHAFROMALBEDO: boolean;
  57422. ALPHATESTVALUE: string;
  57423. SPECULAROVERALPHA: boolean;
  57424. RADIANCEOVERALPHA: boolean;
  57425. ALPHAFRESNEL: boolean;
  57426. LINEARALPHAFRESNEL: boolean;
  57427. PREMULTIPLYALPHA: boolean;
  57428. EMISSIVE: boolean;
  57429. EMISSIVEDIRECTUV: number;
  57430. REFLECTIVITY: boolean;
  57431. REFLECTIVITYDIRECTUV: number;
  57432. SPECULARTERM: boolean;
  57433. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57434. MICROSURFACEAUTOMATIC: boolean;
  57435. LODBASEDMICROSFURACE: boolean;
  57436. MICROSURFACEMAP: boolean;
  57437. MICROSURFACEMAPDIRECTUV: number;
  57438. METALLICWORKFLOW: boolean;
  57439. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57440. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57441. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57442. AOSTOREINMETALMAPRED: boolean;
  57443. METALLIC_REFLECTANCE: boolean;
  57444. METALLIC_REFLECTANCEDIRECTUV: number;
  57445. ENVIRONMENTBRDF: boolean;
  57446. ENVIRONMENTBRDF_RGBD: boolean;
  57447. NORMAL: boolean;
  57448. TANGENT: boolean;
  57449. BUMP: boolean;
  57450. BUMPDIRECTUV: number;
  57451. OBJECTSPACE_NORMALMAP: boolean;
  57452. PARALLAX: boolean;
  57453. PARALLAXOCCLUSION: boolean;
  57454. NORMALXYSCALE: boolean;
  57455. LIGHTMAP: boolean;
  57456. LIGHTMAPDIRECTUV: number;
  57457. USELIGHTMAPASSHADOWMAP: boolean;
  57458. GAMMALIGHTMAP: boolean;
  57459. RGBDLIGHTMAP: boolean;
  57460. REFLECTION: boolean;
  57461. REFLECTIONMAP_3D: boolean;
  57462. REFLECTIONMAP_SPHERICAL: boolean;
  57463. REFLECTIONMAP_PLANAR: boolean;
  57464. REFLECTIONMAP_CUBIC: boolean;
  57465. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57466. REFLECTIONMAP_PROJECTION: boolean;
  57467. REFLECTIONMAP_SKYBOX: boolean;
  57468. REFLECTIONMAP_EXPLICIT: boolean;
  57469. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57470. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57471. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57472. INVERTCUBICMAP: boolean;
  57473. USESPHERICALFROMREFLECTIONMAP: boolean;
  57474. USEIRRADIANCEMAP: boolean;
  57475. SPHERICAL_HARMONICS: boolean;
  57476. USESPHERICALINVERTEX: boolean;
  57477. REFLECTIONMAP_OPPOSITEZ: boolean;
  57478. LODINREFLECTIONALPHA: boolean;
  57479. GAMMAREFLECTION: boolean;
  57480. RGBDREFLECTION: boolean;
  57481. LINEARSPECULARREFLECTION: boolean;
  57482. RADIANCEOCCLUSION: boolean;
  57483. HORIZONOCCLUSION: boolean;
  57484. INSTANCES: boolean;
  57485. THIN_INSTANCES: boolean;
  57486. NUM_BONE_INFLUENCERS: number;
  57487. BonesPerMesh: number;
  57488. BONETEXTURE: boolean;
  57489. NONUNIFORMSCALING: boolean;
  57490. MORPHTARGETS: boolean;
  57491. MORPHTARGETS_NORMAL: boolean;
  57492. MORPHTARGETS_TANGENT: boolean;
  57493. MORPHTARGETS_UV: boolean;
  57494. NUM_MORPH_INFLUENCERS: number;
  57495. IMAGEPROCESSING: boolean;
  57496. VIGNETTE: boolean;
  57497. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57498. VIGNETTEBLENDMODEOPAQUE: boolean;
  57499. TONEMAPPING: boolean;
  57500. TONEMAPPING_ACES: boolean;
  57501. CONTRAST: boolean;
  57502. COLORCURVES: boolean;
  57503. COLORGRADING: boolean;
  57504. COLORGRADING3D: boolean;
  57505. SAMPLER3DGREENDEPTH: boolean;
  57506. SAMPLER3DBGRMAP: boolean;
  57507. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57508. EXPOSURE: boolean;
  57509. MULTIVIEW: boolean;
  57510. USEPHYSICALLIGHTFALLOFF: boolean;
  57511. USEGLTFLIGHTFALLOFF: boolean;
  57512. TWOSIDEDLIGHTING: boolean;
  57513. SHADOWFLOAT: boolean;
  57514. CLIPPLANE: boolean;
  57515. CLIPPLANE2: boolean;
  57516. CLIPPLANE3: boolean;
  57517. CLIPPLANE4: boolean;
  57518. CLIPPLANE5: boolean;
  57519. CLIPPLANE6: boolean;
  57520. POINTSIZE: boolean;
  57521. FOG: boolean;
  57522. LOGARITHMICDEPTH: boolean;
  57523. FORCENORMALFORWARD: boolean;
  57524. SPECULARAA: boolean;
  57525. CLEARCOAT: boolean;
  57526. CLEARCOAT_DEFAULTIOR: boolean;
  57527. CLEARCOAT_TEXTURE: boolean;
  57528. CLEARCOAT_TEXTUREDIRECTUV: number;
  57529. CLEARCOAT_BUMP: boolean;
  57530. CLEARCOAT_BUMPDIRECTUV: number;
  57531. CLEARCOAT_TINT: boolean;
  57532. CLEARCOAT_TINT_TEXTURE: boolean;
  57533. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57534. ANISOTROPIC: boolean;
  57535. ANISOTROPIC_TEXTURE: boolean;
  57536. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57537. BRDF_V_HEIGHT_CORRELATED: boolean;
  57538. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57539. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57540. SHEEN: boolean;
  57541. SHEEN_TEXTURE: boolean;
  57542. SHEEN_TEXTUREDIRECTUV: number;
  57543. SHEEN_LINKWITHALBEDO: boolean;
  57544. SHEEN_ROUGHNESS: boolean;
  57545. SHEEN_ALBEDOSCALING: boolean;
  57546. SUBSURFACE: boolean;
  57547. SS_REFRACTION: boolean;
  57548. SS_TRANSLUCENCY: boolean;
  57549. SS_SCATTERING: boolean;
  57550. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57551. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57552. SS_REFRACTIONMAP_3D: boolean;
  57553. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57554. SS_LODINREFRACTIONALPHA: boolean;
  57555. SS_GAMMAREFRACTION: boolean;
  57556. SS_RGBDREFRACTION: boolean;
  57557. SS_LINEARSPECULARREFRACTION: boolean;
  57558. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57559. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57560. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57561. UNLIT: boolean;
  57562. DEBUGMODE: number;
  57563. /**
  57564. * Initializes the PBR Material defines.
  57565. */
  57566. constructor();
  57567. /**
  57568. * Resets the PBR Material defines.
  57569. */
  57570. reset(): void;
  57571. }
  57572. /**
  57573. * The Physically based material base class of BJS.
  57574. *
  57575. * This offers the main features of a standard PBR material.
  57576. * For more information, please refer to the documentation :
  57577. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57578. */
  57579. export abstract class PBRBaseMaterial extends PushMaterial {
  57580. /**
  57581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57582. */
  57583. static readonly PBRMATERIAL_OPAQUE: number;
  57584. /**
  57585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57586. */
  57587. static readonly PBRMATERIAL_ALPHATEST: number;
  57588. /**
  57589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57590. */
  57591. static readonly PBRMATERIAL_ALPHABLEND: number;
  57592. /**
  57593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57594. * They are also discarded below the alpha cutoff threshold to improve performances.
  57595. */
  57596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57597. /**
  57598. * Defines the default value of how much AO map is occluding the analytical lights
  57599. * (point spot...).
  57600. */
  57601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57602. /**
  57603. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57604. */
  57605. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57606. /**
  57607. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57608. * to enhance interoperability with other engines.
  57609. */
  57610. static readonly LIGHTFALLOFF_GLTF: number;
  57611. /**
  57612. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57613. * to enhance interoperability with other materials.
  57614. */
  57615. static readonly LIGHTFALLOFF_STANDARD: number;
  57616. /**
  57617. * Intensity of the direct lights e.g. the four lights available in your scene.
  57618. * This impacts both the direct diffuse and specular highlights.
  57619. */
  57620. protected _directIntensity: number;
  57621. /**
  57622. * Intensity of the emissive part of the material.
  57623. * This helps controlling the emissive effect without modifying the emissive color.
  57624. */
  57625. protected _emissiveIntensity: number;
  57626. /**
  57627. * Intensity of the environment e.g. how much the environment will light the object
  57628. * either through harmonics for rough material or through the refelction for shiny ones.
  57629. */
  57630. protected _environmentIntensity: number;
  57631. /**
  57632. * This is a special control allowing the reduction of the specular highlights coming from the
  57633. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57634. */
  57635. protected _specularIntensity: number;
  57636. /**
  57637. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57638. */
  57639. private _lightingInfos;
  57640. /**
  57641. * Debug Control allowing disabling the bump map on this material.
  57642. */
  57643. protected _disableBumpMap: boolean;
  57644. /**
  57645. * AKA Diffuse Texture in standard nomenclature.
  57646. */
  57647. protected _albedoTexture: Nullable<BaseTexture>;
  57648. /**
  57649. * AKA Occlusion Texture in other nomenclature.
  57650. */
  57651. protected _ambientTexture: Nullable<BaseTexture>;
  57652. /**
  57653. * AKA Occlusion Texture Intensity in other nomenclature.
  57654. */
  57655. protected _ambientTextureStrength: number;
  57656. /**
  57657. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57658. * 1 means it completely occludes it
  57659. * 0 mean it has no impact
  57660. */
  57661. protected _ambientTextureImpactOnAnalyticalLights: number;
  57662. /**
  57663. * Stores the alpha values in a texture.
  57664. */
  57665. protected _opacityTexture: Nullable<BaseTexture>;
  57666. /**
  57667. * Stores the reflection values in a texture.
  57668. */
  57669. protected _reflectionTexture: Nullable<BaseTexture>;
  57670. /**
  57671. * Stores the emissive values in a texture.
  57672. */
  57673. protected _emissiveTexture: Nullable<BaseTexture>;
  57674. /**
  57675. * AKA Specular texture in other nomenclature.
  57676. */
  57677. protected _reflectivityTexture: Nullable<BaseTexture>;
  57678. /**
  57679. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57680. */
  57681. protected _metallicTexture: Nullable<BaseTexture>;
  57682. /**
  57683. * Specifies the metallic scalar of the metallic/roughness workflow.
  57684. * Can also be used to scale the metalness values of the metallic texture.
  57685. */
  57686. protected _metallic: Nullable<number>;
  57687. /**
  57688. * Specifies the roughness scalar of the metallic/roughness workflow.
  57689. * Can also be used to scale the roughness values of the metallic texture.
  57690. */
  57691. protected _roughness: Nullable<number>;
  57692. /**
  57693. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57694. * By default the indexOfrefraction is used to compute F0;
  57695. *
  57696. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57697. *
  57698. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57699. * F90 = metallicReflectanceColor;
  57700. */
  57701. protected _metallicF0Factor: number;
  57702. /**
  57703. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57704. * By default the F90 is always 1;
  57705. *
  57706. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57707. *
  57708. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57709. * F90 = metallicReflectanceColor;
  57710. */
  57711. protected _metallicReflectanceColor: Color3;
  57712. /**
  57713. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57714. * This is multiply against the scalar values defined in the material.
  57715. */
  57716. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57717. /**
  57718. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57719. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57720. */
  57721. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57722. /**
  57723. * Stores surface normal data used to displace a mesh in a texture.
  57724. */
  57725. protected _bumpTexture: Nullable<BaseTexture>;
  57726. /**
  57727. * Stores the pre-calculated light information of a mesh in a texture.
  57728. */
  57729. protected _lightmapTexture: Nullable<BaseTexture>;
  57730. /**
  57731. * The color of a material in ambient lighting.
  57732. */
  57733. protected _ambientColor: Color3;
  57734. /**
  57735. * AKA Diffuse Color in other nomenclature.
  57736. */
  57737. protected _albedoColor: Color3;
  57738. /**
  57739. * AKA Specular Color in other nomenclature.
  57740. */
  57741. protected _reflectivityColor: Color3;
  57742. /**
  57743. * The color applied when light is reflected from a material.
  57744. */
  57745. protected _reflectionColor: Color3;
  57746. /**
  57747. * The color applied when light is emitted from a material.
  57748. */
  57749. protected _emissiveColor: Color3;
  57750. /**
  57751. * AKA Glossiness in other nomenclature.
  57752. */
  57753. protected _microSurface: number;
  57754. /**
  57755. * Specifies that the material will use the light map as a show map.
  57756. */
  57757. protected _useLightmapAsShadowmap: boolean;
  57758. /**
  57759. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57760. * makes the reflect vector face the model (under horizon).
  57761. */
  57762. protected _useHorizonOcclusion: boolean;
  57763. /**
  57764. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57765. * too much the area relying on ambient texture to define their ambient occlusion.
  57766. */
  57767. protected _useRadianceOcclusion: boolean;
  57768. /**
  57769. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57770. */
  57771. protected _useAlphaFromAlbedoTexture: boolean;
  57772. /**
  57773. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57774. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57775. */
  57776. protected _useSpecularOverAlpha: boolean;
  57777. /**
  57778. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57779. */
  57780. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57781. /**
  57782. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57783. */
  57784. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57785. /**
  57786. * Specifies if the metallic texture contains the roughness information in its green channel.
  57787. */
  57788. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57789. /**
  57790. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57791. */
  57792. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57793. /**
  57794. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57795. */
  57796. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57797. /**
  57798. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57799. */
  57800. protected _useAmbientInGrayScale: boolean;
  57801. /**
  57802. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57803. * The material will try to infer what glossiness each pixel should be.
  57804. */
  57805. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57806. /**
  57807. * Defines the falloff type used in this material.
  57808. * It by default is Physical.
  57809. */
  57810. protected _lightFalloff: number;
  57811. /**
  57812. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57813. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57814. */
  57815. protected _useRadianceOverAlpha: boolean;
  57816. /**
  57817. * Allows using an object space normal map (instead of tangent space).
  57818. */
  57819. protected _useObjectSpaceNormalMap: boolean;
  57820. /**
  57821. * Allows using the bump map in parallax mode.
  57822. */
  57823. protected _useParallax: boolean;
  57824. /**
  57825. * Allows using the bump map in parallax occlusion mode.
  57826. */
  57827. protected _useParallaxOcclusion: boolean;
  57828. /**
  57829. * Controls the scale bias of the parallax mode.
  57830. */
  57831. protected _parallaxScaleBias: number;
  57832. /**
  57833. * If sets to true, disables all the lights affecting the material.
  57834. */
  57835. protected _disableLighting: boolean;
  57836. /**
  57837. * Number of Simultaneous lights allowed on the material.
  57838. */
  57839. protected _maxSimultaneousLights: number;
  57840. /**
  57841. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57842. */
  57843. protected _invertNormalMapX: boolean;
  57844. /**
  57845. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57846. */
  57847. protected _invertNormalMapY: boolean;
  57848. /**
  57849. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57850. */
  57851. protected _twoSidedLighting: boolean;
  57852. /**
  57853. * Defines the alpha limits in alpha test mode.
  57854. */
  57855. protected _alphaCutOff: number;
  57856. /**
  57857. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57858. */
  57859. protected _forceAlphaTest: boolean;
  57860. /**
  57861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57862. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57863. */
  57864. protected _useAlphaFresnel: boolean;
  57865. /**
  57866. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57867. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57868. */
  57869. protected _useLinearAlphaFresnel: boolean;
  57870. /**
  57871. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57872. * from cos thetav and roughness:
  57873. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57874. */
  57875. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57876. /**
  57877. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57878. */
  57879. protected _forceIrradianceInFragment: boolean;
  57880. private _realTimeFiltering;
  57881. /**
  57882. * Enables realtime filtering on the texture.
  57883. */
  57884. get realTimeFiltering(): boolean;
  57885. set realTimeFiltering(b: boolean);
  57886. private _realTimeFilteringQuality;
  57887. /**
  57888. * Quality switch for realtime filtering
  57889. */
  57890. get realTimeFilteringQuality(): number;
  57891. set realTimeFilteringQuality(n: number);
  57892. /**
  57893. * Force normal to face away from face.
  57894. */
  57895. protected _forceNormalForward: boolean;
  57896. /**
  57897. * Enables specular anti aliasing in the PBR shader.
  57898. * It will both interacts on the Geometry for analytical and IBL lighting.
  57899. * It also prefilter the roughness map based on the bump values.
  57900. */
  57901. protected _enableSpecularAntiAliasing: boolean;
  57902. /**
  57903. * Default configuration related to image processing available in the PBR Material.
  57904. */
  57905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57906. /**
  57907. * Keep track of the image processing observer to allow dispose and replace.
  57908. */
  57909. private _imageProcessingObserver;
  57910. /**
  57911. * Attaches a new image processing configuration to the PBR Material.
  57912. * @param configuration
  57913. */
  57914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57915. /**
  57916. * Stores the available render targets.
  57917. */
  57918. private _renderTargets;
  57919. /**
  57920. * Sets the global ambient color for the material used in lighting calculations.
  57921. */
  57922. private _globalAmbientColor;
  57923. /**
  57924. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57925. */
  57926. private _useLogarithmicDepth;
  57927. /**
  57928. * If set to true, no lighting calculations will be applied.
  57929. */
  57930. private _unlit;
  57931. private _debugMode;
  57932. /**
  57933. * @hidden
  57934. * This is reserved for the inspector.
  57935. * Defines the material debug mode.
  57936. * It helps seeing only some components of the material while troubleshooting.
  57937. */
  57938. debugMode: number;
  57939. /**
  57940. * @hidden
  57941. * This is reserved for the inspector.
  57942. * Specify from where on screen the debug mode should start.
  57943. * The value goes from -1 (full screen) to 1 (not visible)
  57944. * It helps with side by side comparison against the final render
  57945. * This defaults to -1
  57946. */
  57947. private debugLimit;
  57948. /**
  57949. * @hidden
  57950. * This is reserved for the inspector.
  57951. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57952. * You can use the factor to better multiply the final value.
  57953. */
  57954. private debugFactor;
  57955. /**
  57956. * Defines the clear coat layer parameters for the material.
  57957. */
  57958. readonly clearCoat: PBRClearCoatConfiguration;
  57959. /**
  57960. * Defines the anisotropic parameters for the material.
  57961. */
  57962. readonly anisotropy: PBRAnisotropicConfiguration;
  57963. /**
  57964. * Defines the BRDF parameters for the material.
  57965. */
  57966. readonly brdf: PBRBRDFConfiguration;
  57967. /**
  57968. * Defines the Sheen parameters for the material.
  57969. */
  57970. readonly sheen: PBRSheenConfiguration;
  57971. /**
  57972. * Defines the SubSurface parameters for the material.
  57973. */
  57974. readonly subSurface: PBRSubSurfaceConfiguration;
  57975. /**
  57976. * Defines the detail map parameters for the material.
  57977. */
  57978. readonly detailMap: DetailMapConfiguration;
  57979. protected _rebuildInParallel: boolean;
  57980. /**
  57981. * Instantiates a new PBRMaterial instance.
  57982. *
  57983. * @param name The material name
  57984. * @param scene The scene the material will be use in.
  57985. */
  57986. constructor(name: string, scene: Scene);
  57987. /**
  57988. * Gets a boolean indicating that current material needs to register RTT
  57989. */
  57990. get hasRenderTargetTextures(): boolean;
  57991. /**
  57992. * Gets the name of the material class.
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57997. */
  57998. get useLogarithmicDepth(): boolean;
  57999. /**
  58000. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58001. */
  58002. set useLogarithmicDepth(value: boolean);
  58003. /**
  58004. * Returns true if alpha blending should be disabled.
  58005. */
  58006. protected get _disableAlphaBlending(): boolean;
  58007. /**
  58008. * Specifies whether or not this material should be rendered in alpha blend mode.
  58009. */
  58010. needAlphaBlending(): boolean;
  58011. /**
  58012. * Specifies whether or not this material should be rendered in alpha test mode.
  58013. */
  58014. needAlphaTesting(): boolean;
  58015. /**
  58016. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58017. */
  58018. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58019. /**
  58020. * Gets the texture used for the alpha test.
  58021. */
  58022. getAlphaTestTexture(): Nullable<BaseTexture>;
  58023. /**
  58024. * Specifies that the submesh is ready to be used.
  58025. * @param mesh - BJS mesh.
  58026. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58027. * @param useInstances - Specifies that instances should be used.
  58028. * @returns - boolean indicating that the submesh is ready or not.
  58029. */
  58030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58031. /**
  58032. * Specifies if the material uses metallic roughness workflow.
  58033. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58034. */
  58035. isMetallicWorkflow(): boolean;
  58036. private _prepareEffect;
  58037. private _prepareDefines;
  58038. /**
  58039. * Force shader compilation
  58040. */
  58041. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58042. /**
  58043. * Initializes the uniform buffer layout for the shader.
  58044. */
  58045. buildUniformLayout(): void;
  58046. /**
  58047. * Unbinds the material from the mesh
  58048. */
  58049. unbind(): void;
  58050. /**
  58051. * Binds the submesh data.
  58052. * @param world - The world matrix.
  58053. * @param mesh - The BJS mesh.
  58054. * @param subMesh - A submesh of the BJS mesh.
  58055. */
  58056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58057. /**
  58058. * Returns the animatable textures.
  58059. * @returns - Array of animatable textures.
  58060. */
  58061. getAnimatables(): IAnimatable[];
  58062. /**
  58063. * Returns the texture used for reflections.
  58064. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58065. */
  58066. private _getReflectionTexture;
  58067. /**
  58068. * Returns an array of the actively used textures.
  58069. * @returns - Array of BaseTextures
  58070. */
  58071. getActiveTextures(): BaseTexture[];
  58072. /**
  58073. * Checks to see if a texture is used in the material.
  58074. * @param texture - Base texture to use.
  58075. * @returns - Boolean specifying if a texture is used in the material.
  58076. */
  58077. hasTexture(texture: BaseTexture): boolean;
  58078. /**
  58079. * Disposes the resources of the material.
  58080. * @param forceDisposeEffect - Forces the disposal of effects.
  58081. * @param forceDisposeTextures - Forces the disposal of all textures.
  58082. */
  58083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58084. }
  58085. }
  58086. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58087. import { Nullable } from "babylonjs/types";
  58088. import { Scene } from "babylonjs/scene";
  58089. import { Color3 } from "babylonjs/Maths/math.color";
  58090. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58091. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58093. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58094. /**
  58095. * The Physically based material of BJS.
  58096. *
  58097. * This offers the main features of a standard PBR material.
  58098. * For more information, please refer to the documentation :
  58099. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58100. */
  58101. export class PBRMaterial extends PBRBaseMaterial {
  58102. /**
  58103. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58104. */
  58105. static readonly PBRMATERIAL_OPAQUE: number;
  58106. /**
  58107. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58108. */
  58109. static readonly PBRMATERIAL_ALPHATEST: number;
  58110. /**
  58111. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58112. */
  58113. static readonly PBRMATERIAL_ALPHABLEND: number;
  58114. /**
  58115. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58116. * They are also discarded below the alpha cutoff threshold to improve performances.
  58117. */
  58118. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58119. /**
  58120. * Defines the default value of how much AO map is occluding the analytical lights
  58121. * (point spot...).
  58122. */
  58123. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58124. /**
  58125. * Intensity of the direct lights e.g. the four lights available in your scene.
  58126. * This impacts both the direct diffuse and specular highlights.
  58127. */
  58128. directIntensity: number;
  58129. /**
  58130. * Intensity of the emissive part of the material.
  58131. * This helps controlling the emissive effect without modifying the emissive color.
  58132. */
  58133. emissiveIntensity: number;
  58134. /**
  58135. * Intensity of the environment e.g. how much the environment will light the object
  58136. * either through harmonics for rough material or through the refelction for shiny ones.
  58137. */
  58138. environmentIntensity: number;
  58139. /**
  58140. * This is a special control allowing the reduction of the specular highlights coming from the
  58141. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58142. */
  58143. specularIntensity: number;
  58144. /**
  58145. * Debug Control allowing disabling the bump map on this material.
  58146. */
  58147. disableBumpMap: boolean;
  58148. /**
  58149. * AKA Diffuse Texture in standard nomenclature.
  58150. */
  58151. albedoTexture: BaseTexture;
  58152. /**
  58153. * AKA Occlusion Texture in other nomenclature.
  58154. */
  58155. ambientTexture: BaseTexture;
  58156. /**
  58157. * AKA Occlusion Texture Intensity in other nomenclature.
  58158. */
  58159. ambientTextureStrength: number;
  58160. /**
  58161. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58162. * 1 means it completely occludes it
  58163. * 0 mean it has no impact
  58164. */
  58165. ambientTextureImpactOnAnalyticalLights: number;
  58166. /**
  58167. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58168. */
  58169. opacityTexture: BaseTexture;
  58170. /**
  58171. * Stores the reflection values in a texture.
  58172. */
  58173. reflectionTexture: Nullable<BaseTexture>;
  58174. /**
  58175. * Stores the emissive values in a texture.
  58176. */
  58177. emissiveTexture: BaseTexture;
  58178. /**
  58179. * AKA Specular texture in other nomenclature.
  58180. */
  58181. reflectivityTexture: BaseTexture;
  58182. /**
  58183. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58184. */
  58185. metallicTexture: BaseTexture;
  58186. /**
  58187. * Specifies the metallic scalar of the metallic/roughness workflow.
  58188. * Can also be used to scale the metalness values of the metallic texture.
  58189. */
  58190. metallic: Nullable<number>;
  58191. /**
  58192. * Specifies the roughness scalar of the metallic/roughness workflow.
  58193. * Can also be used to scale the roughness values of the metallic texture.
  58194. */
  58195. roughness: Nullable<number>;
  58196. /**
  58197. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58198. * By default the indexOfrefraction is used to compute F0;
  58199. *
  58200. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58201. *
  58202. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58203. * F90 = metallicReflectanceColor;
  58204. */
  58205. metallicF0Factor: number;
  58206. /**
  58207. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58208. * By default the F90 is always 1;
  58209. *
  58210. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58211. *
  58212. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58213. * F90 = metallicReflectanceColor;
  58214. */
  58215. metallicReflectanceColor: Color3;
  58216. /**
  58217. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58218. * This is multiply against the scalar values defined in the material.
  58219. */
  58220. metallicReflectanceTexture: Nullable<BaseTexture>;
  58221. /**
  58222. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58223. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58224. */
  58225. microSurfaceTexture: BaseTexture;
  58226. /**
  58227. * Stores surface normal data used to displace a mesh in a texture.
  58228. */
  58229. bumpTexture: BaseTexture;
  58230. /**
  58231. * Stores the pre-calculated light information of a mesh in a texture.
  58232. */
  58233. lightmapTexture: BaseTexture;
  58234. /**
  58235. * Stores the refracted light information in a texture.
  58236. */
  58237. get refractionTexture(): Nullable<BaseTexture>;
  58238. set refractionTexture(value: Nullable<BaseTexture>);
  58239. /**
  58240. * The color of a material in ambient lighting.
  58241. */
  58242. ambientColor: Color3;
  58243. /**
  58244. * AKA Diffuse Color in other nomenclature.
  58245. */
  58246. albedoColor: Color3;
  58247. /**
  58248. * AKA Specular Color in other nomenclature.
  58249. */
  58250. reflectivityColor: Color3;
  58251. /**
  58252. * The color reflected from the material.
  58253. */
  58254. reflectionColor: Color3;
  58255. /**
  58256. * The color emitted from the material.
  58257. */
  58258. emissiveColor: Color3;
  58259. /**
  58260. * AKA Glossiness in other nomenclature.
  58261. */
  58262. microSurface: number;
  58263. /**
  58264. * Index of refraction of the material base layer.
  58265. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58266. *
  58267. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58268. *
  58269. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58270. */
  58271. get indexOfRefraction(): number;
  58272. set indexOfRefraction(value: number);
  58273. /**
  58274. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58275. */
  58276. get invertRefractionY(): boolean;
  58277. set invertRefractionY(value: boolean);
  58278. /**
  58279. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58280. * Materials half opaque for instance using refraction could benefit from this control.
  58281. */
  58282. get linkRefractionWithTransparency(): boolean;
  58283. set linkRefractionWithTransparency(value: boolean);
  58284. /**
  58285. * If true, the light map contains occlusion information instead of lighting info.
  58286. */
  58287. useLightmapAsShadowmap: boolean;
  58288. /**
  58289. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58290. */
  58291. useAlphaFromAlbedoTexture: boolean;
  58292. /**
  58293. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58294. */
  58295. forceAlphaTest: boolean;
  58296. /**
  58297. * Defines the alpha limits in alpha test mode.
  58298. */
  58299. alphaCutOff: number;
  58300. /**
  58301. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58302. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58303. */
  58304. useSpecularOverAlpha: boolean;
  58305. /**
  58306. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58307. */
  58308. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58309. /**
  58310. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58311. */
  58312. useRoughnessFromMetallicTextureAlpha: boolean;
  58313. /**
  58314. * Specifies if the metallic texture contains the roughness information in its green channel.
  58315. */
  58316. useRoughnessFromMetallicTextureGreen: boolean;
  58317. /**
  58318. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58319. */
  58320. useMetallnessFromMetallicTextureBlue: boolean;
  58321. /**
  58322. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58323. */
  58324. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58325. /**
  58326. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58327. */
  58328. useAmbientInGrayScale: boolean;
  58329. /**
  58330. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58331. * The material will try to infer what glossiness each pixel should be.
  58332. */
  58333. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58334. /**
  58335. * BJS is using an harcoded light falloff based on a manually sets up range.
  58336. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58337. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58338. */
  58339. get usePhysicalLightFalloff(): boolean;
  58340. /**
  58341. * BJS is using an harcoded light falloff based on a manually sets up range.
  58342. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58343. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58344. */
  58345. set usePhysicalLightFalloff(value: boolean);
  58346. /**
  58347. * In order to support the falloff compatibility with gltf, a special mode has been added
  58348. * to reproduce the gltf light falloff.
  58349. */
  58350. get useGLTFLightFalloff(): boolean;
  58351. /**
  58352. * In order to support the falloff compatibility with gltf, a special mode has been added
  58353. * to reproduce the gltf light falloff.
  58354. */
  58355. set useGLTFLightFalloff(value: boolean);
  58356. /**
  58357. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58358. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58359. */
  58360. useRadianceOverAlpha: boolean;
  58361. /**
  58362. * Allows using an object space normal map (instead of tangent space).
  58363. */
  58364. useObjectSpaceNormalMap: boolean;
  58365. /**
  58366. * Allows using the bump map in parallax mode.
  58367. */
  58368. useParallax: boolean;
  58369. /**
  58370. * Allows using the bump map in parallax occlusion mode.
  58371. */
  58372. useParallaxOcclusion: boolean;
  58373. /**
  58374. * Controls the scale bias of the parallax mode.
  58375. */
  58376. parallaxScaleBias: number;
  58377. /**
  58378. * If sets to true, disables all the lights affecting the material.
  58379. */
  58380. disableLighting: boolean;
  58381. /**
  58382. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58383. */
  58384. forceIrradianceInFragment: boolean;
  58385. /**
  58386. * Number of Simultaneous lights allowed on the material.
  58387. */
  58388. maxSimultaneousLights: number;
  58389. /**
  58390. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58391. */
  58392. invertNormalMapX: boolean;
  58393. /**
  58394. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58395. */
  58396. invertNormalMapY: boolean;
  58397. /**
  58398. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58399. */
  58400. twoSidedLighting: boolean;
  58401. /**
  58402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58403. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58404. */
  58405. useAlphaFresnel: boolean;
  58406. /**
  58407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58408. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58409. */
  58410. useLinearAlphaFresnel: boolean;
  58411. /**
  58412. * Let user defines the brdf lookup texture used for IBL.
  58413. * A default 8bit version is embedded but you could point at :
  58414. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58415. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58416. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58417. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58418. */
  58419. environmentBRDFTexture: Nullable<BaseTexture>;
  58420. /**
  58421. * Force normal to face away from face.
  58422. */
  58423. forceNormalForward: boolean;
  58424. /**
  58425. * Enables specular anti aliasing in the PBR shader.
  58426. * It will both interacts on the Geometry for analytical and IBL lighting.
  58427. * It also prefilter the roughness map based on the bump values.
  58428. */
  58429. enableSpecularAntiAliasing: boolean;
  58430. /**
  58431. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58432. * makes the reflect vector face the model (under horizon).
  58433. */
  58434. useHorizonOcclusion: boolean;
  58435. /**
  58436. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58437. * too much the area relying on ambient texture to define their ambient occlusion.
  58438. */
  58439. useRadianceOcclusion: boolean;
  58440. /**
  58441. * If set to true, no lighting calculations will be applied.
  58442. */
  58443. unlit: boolean;
  58444. /**
  58445. * Gets the image processing configuration used either in this material.
  58446. */
  58447. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58448. /**
  58449. * Sets the Default image processing configuration used either in the this material.
  58450. *
  58451. * If sets to null, the scene one is in use.
  58452. */
  58453. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58454. /**
  58455. * Gets wether the color curves effect is enabled.
  58456. */
  58457. get cameraColorCurvesEnabled(): boolean;
  58458. /**
  58459. * Sets wether the color curves effect is enabled.
  58460. */
  58461. set cameraColorCurvesEnabled(value: boolean);
  58462. /**
  58463. * Gets wether the color grading effect is enabled.
  58464. */
  58465. get cameraColorGradingEnabled(): boolean;
  58466. /**
  58467. * Gets wether the color grading effect is enabled.
  58468. */
  58469. set cameraColorGradingEnabled(value: boolean);
  58470. /**
  58471. * Gets wether tonemapping is enabled or not.
  58472. */
  58473. get cameraToneMappingEnabled(): boolean;
  58474. /**
  58475. * Sets wether tonemapping is enabled or not
  58476. */
  58477. set cameraToneMappingEnabled(value: boolean);
  58478. /**
  58479. * The camera exposure used on this material.
  58480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58481. * This corresponds to a photographic exposure.
  58482. */
  58483. get cameraExposure(): number;
  58484. /**
  58485. * The camera exposure used on this material.
  58486. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58487. * This corresponds to a photographic exposure.
  58488. */
  58489. set cameraExposure(value: number);
  58490. /**
  58491. * Gets The camera contrast used on this material.
  58492. */
  58493. get cameraContrast(): number;
  58494. /**
  58495. * Sets The camera contrast used on this material.
  58496. */
  58497. set cameraContrast(value: number);
  58498. /**
  58499. * Gets the Color Grading 2D Lookup Texture.
  58500. */
  58501. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58502. /**
  58503. * Sets the Color Grading 2D Lookup Texture.
  58504. */
  58505. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58506. /**
  58507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58509. * 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;
  58510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58511. */
  58512. get cameraColorCurves(): Nullable<ColorCurves>;
  58513. /**
  58514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58516. * 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;
  58517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58518. */
  58519. set cameraColorCurves(value: Nullable<ColorCurves>);
  58520. /**
  58521. * Instantiates a new PBRMaterial instance.
  58522. *
  58523. * @param name The material name
  58524. * @param scene The scene the material will be use in.
  58525. */
  58526. constructor(name: string, scene: Scene);
  58527. /**
  58528. * Returns the name of this material class.
  58529. */
  58530. getClassName(): string;
  58531. /**
  58532. * Makes a duplicate of the current material.
  58533. * @param name - name to use for the new material.
  58534. */
  58535. clone(name: string): PBRMaterial;
  58536. /**
  58537. * Serializes this PBR Material.
  58538. * @returns - An object with the serialized material.
  58539. */
  58540. serialize(): any;
  58541. /**
  58542. * Parses a PBR Material from a serialized object.
  58543. * @param source - Serialized object.
  58544. * @param scene - BJS scene instance.
  58545. * @param rootUrl - url for the scene object
  58546. * @returns - PBRMaterial
  58547. */
  58548. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58549. }
  58550. }
  58551. declare module "babylonjs/Misc/dds" {
  58552. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58554. import { Nullable } from "babylonjs/types";
  58555. import { Scene } from "babylonjs/scene";
  58556. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58557. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58558. /**
  58559. * Direct draw surface info
  58560. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58561. */
  58562. export interface DDSInfo {
  58563. /**
  58564. * Width of the texture
  58565. */
  58566. width: number;
  58567. /**
  58568. * Width of the texture
  58569. */
  58570. height: number;
  58571. /**
  58572. * Number of Mipmaps for the texture
  58573. * @see https://en.wikipedia.org/wiki/Mipmap
  58574. */
  58575. mipmapCount: number;
  58576. /**
  58577. * If the textures format is a known fourCC format
  58578. * @see https://www.fourcc.org/
  58579. */
  58580. isFourCC: boolean;
  58581. /**
  58582. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58583. */
  58584. isRGB: boolean;
  58585. /**
  58586. * If the texture is a lumincance format
  58587. */
  58588. isLuminance: boolean;
  58589. /**
  58590. * If this is a cube texture
  58591. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58592. */
  58593. isCube: boolean;
  58594. /**
  58595. * If the texture is a compressed format eg. FOURCC_DXT1
  58596. */
  58597. isCompressed: boolean;
  58598. /**
  58599. * The dxgiFormat of the texture
  58600. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58601. */
  58602. dxgiFormat: number;
  58603. /**
  58604. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58605. */
  58606. textureType: number;
  58607. /**
  58608. * Sphericle polynomial created for the dds texture
  58609. */
  58610. sphericalPolynomial?: SphericalPolynomial;
  58611. }
  58612. /**
  58613. * Class used to provide DDS decompression tools
  58614. */
  58615. export class DDSTools {
  58616. /**
  58617. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58618. */
  58619. static StoreLODInAlphaChannel: boolean;
  58620. /**
  58621. * Gets DDS information from an array buffer
  58622. * @param data defines the array buffer view to read data from
  58623. * @returns the DDS information
  58624. */
  58625. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58626. private static _FloatView;
  58627. private static _Int32View;
  58628. private static _ToHalfFloat;
  58629. private static _FromHalfFloat;
  58630. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58631. private static _GetHalfFloatRGBAArrayBuffer;
  58632. private static _GetFloatRGBAArrayBuffer;
  58633. private static _GetFloatAsUIntRGBAArrayBuffer;
  58634. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58635. private static _GetRGBAArrayBuffer;
  58636. private static _ExtractLongWordOrder;
  58637. private static _GetRGBArrayBuffer;
  58638. private static _GetLuminanceArrayBuffer;
  58639. /**
  58640. * Uploads DDS Levels to a Babylon Texture
  58641. * @hidden
  58642. */
  58643. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58644. }
  58645. module "babylonjs/Engines/thinEngine" {
  58646. interface ThinEngine {
  58647. /**
  58648. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58649. * @param rootUrl defines the url where the file to load is located
  58650. * @param scene defines the current scene
  58651. * @param lodScale defines scale to apply to the mip map selection
  58652. * @param lodOffset defines offset to apply to the mip map selection
  58653. * @param onLoad defines an optional callback raised when the texture is loaded
  58654. * @param onError defines an optional callback raised if there is an issue to load the texture
  58655. * @param format defines the format of the data
  58656. * @param forcedExtension defines the extension to use to pick the right loader
  58657. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58658. * @returns the cube texture as an InternalTexture
  58659. */
  58660. 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;
  58661. }
  58662. }
  58663. }
  58664. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58665. import { Nullable } from "babylonjs/types";
  58666. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58667. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58668. /**
  58669. * Implementation of the DDS Texture Loader.
  58670. * @hidden
  58671. */
  58672. export class _DDSTextureLoader implements IInternalTextureLoader {
  58673. /**
  58674. * Defines wether the loader supports cascade loading the different faces.
  58675. */
  58676. readonly supportCascades: boolean;
  58677. /**
  58678. * This returns if the loader support the current file information.
  58679. * @param extension defines the file extension of the file being loaded
  58680. * @returns true if the loader can load the specified file
  58681. */
  58682. canLoad(extension: string): boolean;
  58683. /**
  58684. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58685. * @param data contains the texture data
  58686. * @param texture defines the BabylonJS internal texture
  58687. * @param createPolynomials will be true if polynomials have been requested
  58688. * @param onLoad defines the callback to trigger once the texture is ready
  58689. * @param onError defines the callback to trigger in case of error
  58690. */
  58691. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58692. /**
  58693. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58694. * @param data contains the texture data
  58695. * @param texture defines the BabylonJS internal texture
  58696. * @param callback defines the method to call once ready to upload
  58697. */
  58698. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58699. }
  58700. }
  58701. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58702. import { Nullable } from "babylonjs/types";
  58703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58704. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58705. /**
  58706. * Implementation of the ENV Texture Loader.
  58707. * @hidden
  58708. */
  58709. export class _ENVTextureLoader implements IInternalTextureLoader {
  58710. /**
  58711. * Defines wether the loader supports cascade loading the different faces.
  58712. */
  58713. readonly supportCascades: boolean;
  58714. /**
  58715. * This returns if the loader support the current file information.
  58716. * @param extension defines the file extension of the file being loaded
  58717. * @returns true if the loader can load the specified file
  58718. */
  58719. canLoad(extension: string): boolean;
  58720. /**
  58721. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58722. * @param data contains the texture data
  58723. * @param texture defines the BabylonJS internal texture
  58724. * @param createPolynomials will be true if polynomials have been requested
  58725. * @param onLoad defines the callback to trigger once the texture is ready
  58726. * @param onError defines the callback to trigger in case of error
  58727. */
  58728. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58729. /**
  58730. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58731. * @param data contains the texture data
  58732. * @param texture defines the BabylonJS internal texture
  58733. * @param callback defines the method to call once ready to upload
  58734. */
  58735. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58736. }
  58737. }
  58738. declare module "babylonjs/Misc/khronosTextureContainer" {
  58739. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58740. /**
  58741. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58742. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58743. */
  58744. export class KhronosTextureContainer {
  58745. /** contents of the KTX container file */
  58746. data: ArrayBufferView;
  58747. private static HEADER_LEN;
  58748. private static COMPRESSED_2D;
  58749. private static COMPRESSED_3D;
  58750. private static TEX_2D;
  58751. private static TEX_3D;
  58752. /**
  58753. * Gets the openGL type
  58754. */
  58755. glType: number;
  58756. /**
  58757. * Gets the openGL type size
  58758. */
  58759. glTypeSize: number;
  58760. /**
  58761. * Gets the openGL format
  58762. */
  58763. glFormat: number;
  58764. /**
  58765. * Gets the openGL internal format
  58766. */
  58767. glInternalFormat: number;
  58768. /**
  58769. * Gets the base internal format
  58770. */
  58771. glBaseInternalFormat: number;
  58772. /**
  58773. * Gets image width in pixel
  58774. */
  58775. pixelWidth: number;
  58776. /**
  58777. * Gets image height in pixel
  58778. */
  58779. pixelHeight: number;
  58780. /**
  58781. * Gets image depth in pixels
  58782. */
  58783. pixelDepth: number;
  58784. /**
  58785. * Gets the number of array elements
  58786. */
  58787. numberOfArrayElements: number;
  58788. /**
  58789. * Gets the number of faces
  58790. */
  58791. numberOfFaces: number;
  58792. /**
  58793. * Gets the number of mipmap levels
  58794. */
  58795. numberOfMipmapLevels: number;
  58796. /**
  58797. * Gets the bytes of key value data
  58798. */
  58799. bytesOfKeyValueData: number;
  58800. /**
  58801. * Gets the load type
  58802. */
  58803. loadType: number;
  58804. /**
  58805. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58806. */
  58807. isInvalid: boolean;
  58808. /**
  58809. * Creates a new KhronosTextureContainer
  58810. * @param data contents of the KTX container file
  58811. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58812. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58813. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58814. */
  58815. constructor(
  58816. /** contents of the KTX container file */
  58817. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58818. /**
  58819. * Uploads KTX content to a Babylon Texture.
  58820. * It is assumed that the texture has already been created & is currently bound
  58821. * @hidden
  58822. */
  58823. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58824. private _upload2DCompressedLevels;
  58825. /**
  58826. * Checks if the given data starts with a KTX file identifier.
  58827. * @param data the data to check
  58828. * @returns true if the data is a KTX file or false otherwise
  58829. */
  58830. static IsValid(data: ArrayBufferView): boolean;
  58831. }
  58832. }
  58833. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58835. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58836. /**
  58837. * Class for loading KTX2 files
  58838. * !!! Experimental Extension Subject to Changes !!!
  58839. * @hidden
  58840. */
  58841. export class KhronosTextureContainer2 {
  58842. private static _ModulePromise;
  58843. private static _TranscodeFormat;
  58844. constructor(engine: ThinEngine);
  58845. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58846. private _determineTranscodeFormat;
  58847. /**
  58848. * Checks if the given data starts with a KTX2 file identifier.
  58849. * @param data the data to check
  58850. * @returns true if the data is a KTX2 file or false otherwise
  58851. */
  58852. static IsValid(data: ArrayBufferView): boolean;
  58853. }
  58854. }
  58855. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58856. import { Nullable } from "babylonjs/types";
  58857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58858. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58859. /**
  58860. * Implementation of the KTX Texture Loader.
  58861. * @hidden
  58862. */
  58863. export class _KTXTextureLoader implements IInternalTextureLoader {
  58864. /**
  58865. * Defines wether the loader supports cascade loading the different faces.
  58866. */
  58867. readonly supportCascades: boolean;
  58868. /**
  58869. * This returns if the loader support the current file information.
  58870. * @param extension defines the file extension of the file being loaded
  58871. * @returns true if the loader can load the specified file
  58872. */
  58873. canLoad(extension: string): boolean;
  58874. /**
  58875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58876. * @param data contains the texture data
  58877. * @param texture defines the BabylonJS internal texture
  58878. * @param createPolynomials will be true if polynomials have been requested
  58879. * @param onLoad defines the callback to trigger once the texture is ready
  58880. * @param onError defines the callback to trigger in case of error
  58881. */
  58882. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58883. /**
  58884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58885. * @param data contains the texture data
  58886. * @param texture defines the BabylonJS internal texture
  58887. * @param callback defines the method to call once ready to upload
  58888. */
  58889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58890. }
  58891. }
  58892. declare module "babylonjs/Helpers/sceneHelpers" {
  58893. import { Nullable } from "babylonjs/types";
  58894. import { Mesh } from "babylonjs/Meshes/mesh";
  58895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58896. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58897. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58898. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58899. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58900. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58901. import "babylonjs/Meshes/Builders/boxBuilder";
  58902. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58903. /** @hidden */
  58904. export var _forceSceneHelpersToBundle: boolean;
  58905. module "babylonjs/scene" {
  58906. interface Scene {
  58907. /**
  58908. * Creates a default light for the scene.
  58909. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58910. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58911. */
  58912. createDefaultLight(replace?: boolean): void;
  58913. /**
  58914. * Creates a default camera for the scene.
  58915. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58916. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58917. * @param replace has default false, when true replaces the active camera in the scene
  58918. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58919. */
  58920. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58921. /**
  58922. * Creates a default camera and a default light.
  58923. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58924. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58925. * @param replace has the default false, when true replaces the active camera/light in the scene
  58926. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58927. */
  58928. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58929. /**
  58930. * Creates a new sky box
  58931. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58932. * @param environmentTexture defines the texture to use as environment texture
  58933. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58934. * @param scale defines the overall scale of the skybox
  58935. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58936. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58937. * @returns a new mesh holding the sky box
  58938. */
  58939. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58940. /**
  58941. * Creates a new environment
  58942. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58943. * @param options defines the options you can use to configure the environment
  58944. * @returns the new EnvironmentHelper
  58945. */
  58946. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58947. /**
  58948. * Creates a new VREXperienceHelper
  58949. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58950. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58951. * @returns a new VREXperienceHelper
  58952. */
  58953. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58954. /**
  58955. * Creates a new WebXRDefaultExperience
  58956. * @see http://doc.babylonjs.com/how_to/webxr
  58957. * @param options experience options
  58958. * @returns a promise for a new WebXRDefaultExperience
  58959. */
  58960. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58961. }
  58962. }
  58963. }
  58964. declare module "babylonjs/Helpers/videoDome" {
  58965. import { Scene } from "babylonjs/scene";
  58966. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58967. import { Mesh } from "babylonjs/Meshes/mesh";
  58968. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58969. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58970. import "babylonjs/Meshes/Builders/sphereBuilder";
  58971. /**
  58972. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58973. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58974. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58975. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58976. */
  58977. export class VideoDome extends TransformNode {
  58978. /**
  58979. * Define the video source as a Monoscopic panoramic 360 video.
  58980. */
  58981. static readonly MODE_MONOSCOPIC: number;
  58982. /**
  58983. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58984. */
  58985. static readonly MODE_TOPBOTTOM: number;
  58986. /**
  58987. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58988. */
  58989. static readonly MODE_SIDEBYSIDE: number;
  58990. private _halfDome;
  58991. private _useDirectMapping;
  58992. /**
  58993. * The video texture being displayed on the sphere
  58994. */
  58995. protected _videoTexture: VideoTexture;
  58996. /**
  58997. * Gets the video texture being displayed on the sphere
  58998. */
  58999. get videoTexture(): VideoTexture;
  59000. /**
  59001. * The skybox material
  59002. */
  59003. protected _material: BackgroundMaterial;
  59004. /**
  59005. * The surface used for the skybox
  59006. */
  59007. protected _mesh: Mesh;
  59008. /**
  59009. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59010. */
  59011. private _halfDomeMask;
  59012. /**
  59013. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59014. * Also see the options.resolution property.
  59015. */
  59016. get fovMultiplier(): number;
  59017. set fovMultiplier(value: number);
  59018. private _videoMode;
  59019. /**
  59020. * Gets or set the current video mode for the video. It can be:
  59021. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59022. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59023. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59024. */
  59025. get videoMode(): number;
  59026. set videoMode(value: number);
  59027. /**
  59028. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59029. *
  59030. */
  59031. get halfDome(): boolean;
  59032. /**
  59033. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59034. */
  59035. set halfDome(enabled: boolean);
  59036. /**
  59037. * Oberserver used in Stereoscopic VR Mode.
  59038. */
  59039. private _onBeforeCameraRenderObserver;
  59040. /**
  59041. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59042. * @param name Element's name, child elements will append suffixes for their own names.
  59043. * @param urlsOrVideo defines the url(s) or the video element to use
  59044. * @param options An object containing optional or exposed sub element properties
  59045. */
  59046. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59047. resolution?: number;
  59048. clickToPlay?: boolean;
  59049. autoPlay?: boolean;
  59050. loop?: boolean;
  59051. size?: number;
  59052. poster?: string;
  59053. faceForward?: boolean;
  59054. useDirectMapping?: boolean;
  59055. halfDomeMode?: boolean;
  59056. }, scene: Scene);
  59057. private _changeVideoMode;
  59058. /**
  59059. * Releases resources associated with this node.
  59060. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59061. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59062. */
  59063. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59064. }
  59065. }
  59066. declare module "babylonjs/Helpers/index" {
  59067. export * from "babylonjs/Helpers/environmentHelper";
  59068. export * from "babylonjs/Helpers/photoDome";
  59069. export * from "babylonjs/Helpers/sceneHelpers";
  59070. export * from "babylonjs/Helpers/videoDome";
  59071. }
  59072. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59073. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59074. import { IDisposable } from "babylonjs/scene";
  59075. import { Engine } from "babylonjs/Engines/engine";
  59076. /**
  59077. * This class can be used to get instrumentation data from a Babylon engine
  59078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59079. */
  59080. export class EngineInstrumentation implements IDisposable {
  59081. /**
  59082. * Define the instrumented engine.
  59083. */
  59084. engine: Engine;
  59085. private _captureGPUFrameTime;
  59086. private _gpuFrameTimeToken;
  59087. private _gpuFrameTime;
  59088. private _captureShaderCompilationTime;
  59089. private _shaderCompilationTime;
  59090. private _onBeginFrameObserver;
  59091. private _onEndFrameObserver;
  59092. private _onBeforeShaderCompilationObserver;
  59093. private _onAfterShaderCompilationObserver;
  59094. /**
  59095. * Gets the perf counter used for GPU frame time
  59096. */
  59097. get gpuFrameTimeCounter(): PerfCounter;
  59098. /**
  59099. * Gets the GPU frame time capture status
  59100. */
  59101. get captureGPUFrameTime(): boolean;
  59102. /**
  59103. * Enable or disable the GPU frame time capture
  59104. */
  59105. set captureGPUFrameTime(value: boolean);
  59106. /**
  59107. * Gets the perf counter used for shader compilation time
  59108. */
  59109. get shaderCompilationTimeCounter(): PerfCounter;
  59110. /**
  59111. * Gets the shader compilation time capture status
  59112. */
  59113. get captureShaderCompilationTime(): boolean;
  59114. /**
  59115. * Enable or disable the shader compilation time capture
  59116. */
  59117. set captureShaderCompilationTime(value: boolean);
  59118. /**
  59119. * Instantiates a new engine instrumentation.
  59120. * This class can be used to get instrumentation data from a Babylon engine
  59121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59122. * @param engine Defines the engine to instrument
  59123. */
  59124. constructor(
  59125. /**
  59126. * Define the instrumented engine.
  59127. */
  59128. engine: Engine);
  59129. /**
  59130. * Dispose and release associated resources.
  59131. */
  59132. dispose(): void;
  59133. }
  59134. }
  59135. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59136. import { Scene, IDisposable } from "babylonjs/scene";
  59137. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59138. /**
  59139. * This class can be used to get instrumentation data from a Babylon engine
  59140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59141. */
  59142. export class SceneInstrumentation implements IDisposable {
  59143. /**
  59144. * Defines the scene to instrument
  59145. */
  59146. scene: Scene;
  59147. private _captureActiveMeshesEvaluationTime;
  59148. private _activeMeshesEvaluationTime;
  59149. private _captureRenderTargetsRenderTime;
  59150. private _renderTargetsRenderTime;
  59151. private _captureFrameTime;
  59152. private _frameTime;
  59153. private _captureRenderTime;
  59154. private _renderTime;
  59155. private _captureInterFrameTime;
  59156. private _interFrameTime;
  59157. private _captureParticlesRenderTime;
  59158. private _particlesRenderTime;
  59159. private _captureSpritesRenderTime;
  59160. private _spritesRenderTime;
  59161. private _capturePhysicsTime;
  59162. private _physicsTime;
  59163. private _captureAnimationsTime;
  59164. private _animationsTime;
  59165. private _captureCameraRenderTime;
  59166. private _cameraRenderTime;
  59167. private _onBeforeActiveMeshesEvaluationObserver;
  59168. private _onAfterActiveMeshesEvaluationObserver;
  59169. private _onBeforeRenderTargetsRenderObserver;
  59170. private _onAfterRenderTargetsRenderObserver;
  59171. private _onAfterRenderObserver;
  59172. private _onBeforeDrawPhaseObserver;
  59173. private _onAfterDrawPhaseObserver;
  59174. private _onBeforeAnimationsObserver;
  59175. private _onBeforeParticlesRenderingObserver;
  59176. private _onAfterParticlesRenderingObserver;
  59177. private _onBeforeSpritesRenderingObserver;
  59178. private _onAfterSpritesRenderingObserver;
  59179. private _onBeforePhysicsObserver;
  59180. private _onAfterPhysicsObserver;
  59181. private _onAfterAnimationsObserver;
  59182. private _onBeforeCameraRenderObserver;
  59183. private _onAfterCameraRenderObserver;
  59184. /**
  59185. * Gets the perf counter used for active meshes evaluation time
  59186. */
  59187. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59188. /**
  59189. * Gets the active meshes evaluation time capture status
  59190. */
  59191. get captureActiveMeshesEvaluationTime(): boolean;
  59192. /**
  59193. * Enable or disable the active meshes evaluation time capture
  59194. */
  59195. set captureActiveMeshesEvaluationTime(value: boolean);
  59196. /**
  59197. * Gets the perf counter used for render targets render time
  59198. */
  59199. get renderTargetsRenderTimeCounter(): PerfCounter;
  59200. /**
  59201. * Gets the render targets render time capture status
  59202. */
  59203. get captureRenderTargetsRenderTime(): boolean;
  59204. /**
  59205. * Enable or disable the render targets render time capture
  59206. */
  59207. set captureRenderTargetsRenderTime(value: boolean);
  59208. /**
  59209. * Gets the perf counter used for particles render time
  59210. */
  59211. get particlesRenderTimeCounter(): PerfCounter;
  59212. /**
  59213. * Gets the particles render time capture status
  59214. */
  59215. get captureParticlesRenderTime(): boolean;
  59216. /**
  59217. * Enable or disable the particles render time capture
  59218. */
  59219. set captureParticlesRenderTime(value: boolean);
  59220. /**
  59221. * Gets the perf counter used for sprites render time
  59222. */
  59223. get spritesRenderTimeCounter(): PerfCounter;
  59224. /**
  59225. * Gets the sprites render time capture status
  59226. */
  59227. get captureSpritesRenderTime(): boolean;
  59228. /**
  59229. * Enable or disable the sprites render time capture
  59230. */
  59231. set captureSpritesRenderTime(value: boolean);
  59232. /**
  59233. * Gets the perf counter used for physics time
  59234. */
  59235. get physicsTimeCounter(): PerfCounter;
  59236. /**
  59237. * Gets the physics time capture status
  59238. */
  59239. get capturePhysicsTime(): boolean;
  59240. /**
  59241. * Enable or disable the physics time capture
  59242. */
  59243. set capturePhysicsTime(value: boolean);
  59244. /**
  59245. * Gets the perf counter used for animations time
  59246. */
  59247. get animationsTimeCounter(): PerfCounter;
  59248. /**
  59249. * Gets the animations time capture status
  59250. */
  59251. get captureAnimationsTime(): boolean;
  59252. /**
  59253. * Enable or disable the animations time capture
  59254. */
  59255. set captureAnimationsTime(value: boolean);
  59256. /**
  59257. * Gets the perf counter used for frame time capture
  59258. */
  59259. get frameTimeCounter(): PerfCounter;
  59260. /**
  59261. * Gets the frame time capture status
  59262. */
  59263. get captureFrameTime(): boolean;
  59264. /**
  59265. * Enable or disable the frame time capture
  59266. */
  59267. set captureFrameTime(value: boolean);
  59268. /**
  59269. * Gets the perf counter used for inter-frames time capture
  59270. */
  59271. get interFrameTimeCounter(): PerfCounter;
  59272. /**
  59273. * Gets the inter-frames time capture status
  59274. */
  59275. get captureInterFrameTime(): boolean;
  59276. /**
  59277. * Enable or disable the inter-frames time capture
  59278. */
  59279. set captureInterFrameTime(value: boolean);
  59280. /**
  59281. * Gets the perf counter used for render time capture
  59282. */
  59283. get renderTimeCounter(): PerfCounter;
  59284. /**
  59285. * Gets the render time capture status
  59286. */
  59287. get captureRenderTime(): boolean;
  59288. /**
  59289. * Enable or disable the render time capture
  59290. */
  59291. set captureRenderTime(value: boolean);
  59292. /**
  59293. * Gets the perf counter used for camera render time capture
  59294. */
  59295. get cameraRenderTimeCounter(): PerfCounter;
  59296. /**
  59297. * Gets the camera render time capture status
  59298. */
  59299. get captureCameraRenderTime(): boolean;
  59300. /**
  59301. * Enable or disable the camera render time capture
  59302. */
  59303. set captureCameraRenderTime(value: boolean);
  59304. /**
  59305. * Gets the perf counter used for draw calls
  59306. */
  59307. get drawCallsCounter(): PerfCounter;
  59308. /**
  59309. * Instantiates a new scene instrumentation.
  59310. * This class can be used to get instrumentation data from a Babylon engine
  59311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59312. * @param scene Defines the scene to instrument
  59313. */
  59314. constructor(
  59315. /**
  59316. * Defines the scene to instrument
  59317. */
  59318. scene: Scene);
  59319. /**
  59320. * Dispose and release associated resources.
  59321. */
  59322. dispose(): void;
  59323. }
  59324. }
  59325. declare module "babylonjs/Instrumentation/index" {
  59326. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59327. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59328. export * from "babylonjs/Instrumentation/timeToken";
  59329. }
  59330. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59331. /** @hidden */
  59332. export var glowMapGenerationPixelShader: {
  59333. name: string;
  59334. shader: string;
  59335. };
  59336. }
  59337. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59338. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59339. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59340. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59341. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59343. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59344. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59345. /** @hidden */
  59346. export var glowMapGenerationVertexShader: {
  59347. name: string;
  59348. shader: string;
  59349. };
  59350. }
  59351. declare module "babylonjs/Layers/effectLayer" {
  59352. import { Observable } from "babylonjs/Misc/observable";
  59353. import { Nullable } from "babylonjs/types";
  59354. import { Camera } from "babylonjs/Cameras/camera";
  59355. import { Scene } from "babylonjs/scene";
  59356. import { ISize } from "babylonjs/Maths/math.size";
  59357. import { Color4 } from "babylonjs/Maths/math.color";
  59358. import { Engine } from "babylonjs/Engines/engine";
  59359. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59361. import { Mesh } from "babylonjs/Meshes/mesh";
  59362. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59363. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59364. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59365. import { Effect } from "babylonjs/Materials/effect";
  59366. import { Material } from "babylonjs/Materials/material";
  59367. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59368. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59369. /**
  59370. * Effect layer options. This helps customizing the behaviour
  59371. * of the effect layer.
  59372. */
  59373. export interface IEffectLayerOptions {
  59374. /**
  59375. * Multiplication factor apply to the canvas size to compute the render target size
  59376. * used to generated the objects (the smaller the faster).
  59377. */
  59378. mainTextureRatio: number;
  59379. /**
  59380. * Enforces a fixed size texture to ensure effect stability across devices.
  59381. */
  59382. mainTextureFixedSize?: number;
  59383. /**
  59384. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59385. */
  59386. alphaBlendingMode: number;
  59387. /**
  59388. * The camera attached to the layer.
  59389. */
  59390. camera: Nullable<Camera>;
  59391. /**
  59392. * The rendering group to draw the layer in.
  59393. */
  59394. renderingGroupId: number;
  59395. }
  59396. /**
  59397. * The effect layer Helps adding post process effect blended with the main pass.
  59398. *
  59399. * This can be for instance use to generate glow or higlight effects on the scene.
  59400. *
  59401. * The effect layer class can not be used directly and is intented to inherited from to be
  59402. * customized per effects.
  59403. */
  59404. export abstract class EffectLayer {
  59405. private _vertexBuffers;
  59406. private _indexBuffer;
  59407. private _cachedDefines;
  59408. private _effectLayerMapGenerationEffect;
  59409. private _effectLayerOptions;
  59410. private _mergeEffect;
  59411. protected _scene: Scene;
  59412. protected _engine: Engine;
  59413. protected _maxSize: number;
  59414. protected _mainTextureDesiredSize: ISize;
  59415. protected _mainTexture: RenderTargetTexture;
  59416. protected _shouldRender: boolean;
  59417. protected _postProcesses: PostProcess[];
  59418. protected _textures: BaseTexture[];
  59419. protected _emissiveTextureAndColor: {
  59420. texture: Nullable<BaseTexture>;
  59421. color: Color4;
  59422. };
  59423. /**
  59424. * The name of the layer
  59425. */
  59426. name: string;
  59427. /**
  59428. * The clear color of the texture used to generate the glow map.
  59429. */
  59430. neutralColor: Color4;
  59431. /**
  59432. * Specifies whether the highlight layer is enabled or not.
  59433. */
  59434. isEnabled: boolean;
  59435. /**
  59436. * Gets the camera attached to the layer.
  59437. */
  59438. get camera(): Nullable<Camera>;
  59439. /**
  59440. * Gets the rendering group id the layer should render in.
  59441. */
  59442. get renderingGroupId(): number;
  59443. set renderingGroupId(renderingGroupId: number);
  59444. /**
  59445. * An event triggered when the effect layer has been disposed.
  59446. */
  59447. onDisposeObservable: Observable<EffectLayer>;
  59448. /**
  59449. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59450. */
  59451. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59452. /**
  59453. * An event triggered when the generated texture is being merged in the scene.
  59454. */
  59455. onBeforeComposeObservable: Observable<EffectLayer>;
  59456. /**
  59457. * An event triggered when the mesh is rendered into the effect render target.
  59458. */
  59459. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59460. /**
  59461. * An event triggered after the mesh has been rendered into the effect render target.
  59462. */
  59463. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59464. /**
  59465. * An event triggered when the generated texture has been merged in the scene.
  59466. */
  59467. onAfterComposeObservable: Observable<EffectLayer>;
  59468. /**
  59469. * An event triggered when the efffect layer changes its size.
  59470. */
  59471. onSizeChangedObservable: Observable<EffectLayer>;
  59472. /** @hidden */
  59473. static _SceneComponentInitialization: (scene: Scene) => void;
  59474. /**
  59475. * Instantiates a new effect Layer and references it in the scene.
  59476. * @param name The name of the layer
  59477. * @param scene The scene to use the layer in
  59478. */
  59479. constructor(
  59480. /** The Friendly of the effect in the scene */
  59481. name: string, scene: Scene);
  59482. /**
  59483. * Get the effect name of the layer.
  59484. * @return The effect name
  59485. */
  59486. abstract getEffectName(): string;
  59487. /**
  59488. * Checks for the readiness of the element composing the layer.
  59489. * @param subMesh the mesh to check for
  59490. * @param useInstances specify whether or not to use instances to render the mesh
  59491. * @return true if ready otherwise, false
  59492. */
  59493. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59494. /**
  59495. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59496. * @returns true if the effect requires stencil during the main canvas render pass.
  59497. */
  59498. abstract needStencil(): boolean;
  59499. /**
  59500. * Create the merge effect. This is the shader use to blit the information back
  59501. * to the main canvas at the end of the scene rendering.
  59502. * @returns The effect containing the shader used to merge the effect on the main canvas
  59503. */
  59504. protected abstract _createMergeEffect(): Effect;
  59505. /**
  59506. * Creates the render target textures and post processes used in the effect layer.
  59507. */
  59508. protected abstract _createTextureAndPostProcesses(): void;
  59509. /**
  59510. * Implementation specific of rendering the generating effect on the main canvas.
  59511. * @param effect The effect used to render through
  59512. */
  59513. protected abstract _internalRender(effect: Effect): void;
  59514. /**
  59515. * Sets the required values for both the emissive texture and and the main color.
  59516. */
  59517. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59518. /**
  59519. * Free any resources and references associated to a mesh.
  59520. * Internal use
  59521. * @param mesh The mesh to free.
  59522. */
  59523. abstract _disposeMesh(mesh: Mesh): void;
  59524. /**
  59525. * Serializes this layer (Glow or Highlight for example)
  59526. * @returns a serialized layer object
  59527. */
  59528. abstract serialize?(): any;
  59529. /**
  59530. * Initializes the effect layer with the required options.
  59531. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59532. */
  59533. protected _init(options: Partial<IEffectLayerOptions>): void;
  59534. /**
  59535. * Generates the index buffer of the full screen quad blending to the main canvas.
  59536. */
  59537. private _generateIndexBuffer;
  59538. /**
  59539. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59540. */
  59541. private _generateVertexBuffer;
  59542. /**
  59543. * Sets the main texture desired size which is the closest power of two
  59544. * of the engine canvas size.
  59545. */
  59546. private _setMainTextureSize;
  59547. /**
  59548. * Creates the main texture for the effect layer.
  59549. */
  59550. protected _createMainTexture(): void;
  59551. /**
  59552. * Adds specific effects defines.
  59553. * @param defines The defines to add specifics to.
  59554. */
  59555. protected _addCustomEffectDefines(defines: string[]): void;
  59556. /**
  59557. * Checks for the readiness of the element composing the layer.
  59558. * @param subMesh the mesh to check for
  59559. * @param useInstances specify whether or not to use instances to render the mesh
  59560. * @param emissiveTexture the associated emissive texture used to generate the glow
  59561. * @return true if ready otherwise, false
  59562. */
  59563. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59564. /**
  59565. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59566. */
  59567. render(): void;
  59568. /**
  59569. * Determine if a given mesh will be used in the current effect.
  59570. * @param mesh mesh to test
  59571. * @returns true if the mesh will be used
  59572. */
  59573. hasMesh(mesh: AbstractMesh): boolean;
  59574. /**
  59575. * Returns true if the layer contains information to display, otherwise false.
  59576. * @returns true if the glow layer should be rendered
  59577. */
  59578. shouldRender(): boolean;
  59579. /**
  59580. * Returns true if the mesh should render, otherwise false.
  59581. * @param mesh The mesh to render
  59582. * @returns true if it should render otherwise false
  59583. */
  59584. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59585. /**
  59586. * Returns true if the mesh can be rendered, otherwise false.
  59587. * @param mesh The mesh to render
  59588. * @param material The material used on the mesh
  59589. * @returns true if it can be rendered otherwise false
  59590. */
  59591. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59592. /**
  59593. * Returns true if the mesh should render, otherwise false.
  59594. * @param mesh The mesh to render
  59595. * @returns true if it should render otherwise false
  59596. */
  59597. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59598. /**
  59599. * Renders the submesh passed in parameter to the generation map.
  59600. */
  59601. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59602. /**
  59603. * Defines whether the current material of the mesh should be use to render the effect.
  59604. * @param mesh defines the current mesh to render
  59605. */
  59606. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59607. /**
  59608. * Rebuild the required buffers.
  59609. * @hidden Internal use only.
  59610. */
  59611. _rebuild(): void;
  59612. /**
  59613. * Dispose only the render target textures and post process.
  59614. */
  59615. private _disposeTextureAndPostProcesses;
  59616. /**
  59617. * Dispose the highlight layer and free resources.
  59618. */
  59619. dispose(): void;
  59620. /**
  59621. * Gets the class name of the effect layer
  59622. * @returns the string with the class name of the effect layer
  59623. */
  59624. getClassName(): string;
  59625. /**
  59626. * Creates an effect layer from parsed effect layer data
  59627. * @param parsedEffectLayer defines effect layer data
  59628. * @param scene defines the current scene
  59629. * @param rootUrl defines the root URL containing the effect layer information
  59630. * @returns a parsed effect Layer
  59631. */
  59632. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59633. }
  59634. }
  59635. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59636. import { Scene } from "babylonjs/scene";
  59637. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59638. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59639. import { AbstractScene } from "babylonjs/abstractScene";
  59640. module "babylonjs/abstractScene" {
  59641. interface AbstractScene {
  59642. /**
  59643. * The list of effect layers (highlights/glow) added to the scene
  59644. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59645. * @see http://doc.babylonjs.com/how_to/glow_layer
  59646. */
  59647. effectLayers: Array<EffectLayer>;
  59648. /**
  59649. * Removes the given effect layer from this scene.
  59650. * @param toRemove defines the effect layer to remove
  59651. * @returns the index of the removed effect layer
  59652. */
  59653. removeEffectLayer(toRemove: EffectLayer): number;
  59654. /**
  59655. * Adds the given effect layer to this scene
  59656. * @param newEffectLayer defines the effect layer to add
  59657. */
  59658. addEffectLayer(newEffectLayer: EffectLayer): void;
  59659. }
  59660. }
  59661. /**
  59662. * Defines the layer scene component responsible to manage any effect layers
  59663. * in a given scene.
  59664. */
  59665. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59666. /**
  59667. * The component name helpfull to identify the component in the list of scene components.
  59668. */
  59669. readonly name: string;
  59670. /**
  59671. * The scene the component belongs to.
  59672. */
  59673. scene: Scene;
  59674. private _engine;
  59675. private _renderEffects;
  59676. private _needStencil;
  59677. private _previousStencilState;
  59678. /**
  59679. * Creates a new instance of the component for the given scene
  59680. * @param scene Defines the scene to register the component in
  59681. */
  59682. constructor(scene: Scene);
  59683. /**
  59684. * Registers the component in a given scene
  59685. */
  59686. register(): void;
  59687. /**
  59688. * Rebuilds the elements related to this component in case of
  59689. * context lost for instance.
  59690. */
  59691. rebuild(): void;
  59692. /**
  59693. * Serializes the component data to the specified json object
  59694. * @param serializationObject The object to serialize to
  59695. */
  59696. serialize(serializationObject: any): void;
  59697. /**
  59698. * Adds all the elements from the container to the scene
  59699. * @param container the container holding the elements
  59700. */
  59701. addFromContainer(container: AbstractScene): void;
  59702. /**
  59703. * Removes all the elements in the container from the scene
  59704. * @param container contains the elements to remove
  59705. * @param dispose if the removed element should be disposed (default: false)
  59706. */
  59707. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59708. /**
  59709. * Disposes the component and the associated ressources.
  59710. */
  59711. dispose(): void;
  59712. private _isReadyForMesh;
  59713. private _renderMainTexture;
  59714. private _setStencil;
  59715. private _setStencilBack;
  59716. private _draw;
  59717. private _drawCamera;
  59718. private _drawRenderingGroup;
  59719. }
  59720. }
  59721. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59722. /** @hidden */
  59723. export var glowMapMergePixelShader: {
  59724. name: string;
  59725. shader: string;
  59726. };
  59727. }
  59728. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59729. /** @hidden */
  59730. export var glowMapMergeVertexShader: {
  59731. name: string;
  59732. shader: string;
  59733. };
  59734. }
  59735. declare module "babylonjs/Layers/glowLayer" {
  59736. import { Nullable } from "babylonjs/types";
  59737. import { Camera } from "babylonjs/Cameras/camera";
  59738. import { Scene } from "babylonjs/scene";
  59739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59741. import { Mesh } from "babylonjs/Meshes/mesh";
  59742. import { Texture } from "babylonjs/Materials/Textures/texture";
  59743. import { Effect } from "babylonjs/Materials/effect";
  59744. import { Material } from "babylonjs/Materials/material";
  59745. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59746. import { Color4 } from "babylonjs/Maths/math.color";
  59747. import "babylonjs/Shaders/glowMapMerge.fragment";
  59748. import "babylonjs/Shaders/glowMapMerge.vertex";
  59749. import "babylonjs/Layers/effectLayerSceneComponent";
  59750. module "babylonjs/abstractScene" {
  59751. interface AbstractScene {
  59752. /**
  59753. * Return a the first highlight layer of the scene with a given name.
  59754. * @param name The name of the highlight layer to look for.
  59755. * @return The highlight layer if found otherwise null.
  59756. */
  59757. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59758. }
  59759. }
  59760. /**
  59761. * Glow layer options. This helps customizing the behaviour
  59762. * of the glow layer.
  59763. */
  59764. export interface IGlowLayerOptions {
  59765. /**
  59766. * Multiplication factor apply to the canvas size to compute the render target size
  59767. * used to generated the glowing objects (the smaller the faster).
  59768. */
  59769. mainTextureRatio: number;
  59770. /**
  59771. * Enforces a fixed size texture to ensure resize independant blur.
  59772. */
  59773. mainTextureFixedSize?: number;
  59774. /**
  59775. * How big is the kernel of the blur texture.
  59776. */
  59777. blurKernelSize: number;
  59778. /**
  59779. * The camera attached to the layer.
  59780. */
  59781. camera: Nullable<Camera>;
  59782. /**
  59783. * Enable MSAA by chosing the number of samples.
  59784. */
  59785. mainTextureSamples?: number;
  59786. /**
  59787. * The rendering group to draw the layer in.
  59788. */
  59789. renderingGroupId: number;
  59790. }
  59791. /**
  59792. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59793. *
  59794. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59795. *
  59796. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59797. */
  59798. export class GlowLayer extends EffectLayer {
  59799. /**
  59800. * Effect Name of the layer.
  59801. */
  59802. static readonly EffectName: string;
  59803. /**
  59804. * The default blur kernel size used for the glow.
  59805. */
  59806. static DefaultBlurKernelSize: number;
  59807. /**
  59808. * The default texture size ratio used for the glow.
  59809. */
  59810. static DefaultTextureRatio: number;
  59811. /**
  59812. * Sets the kernel size of the blur.
  59813. */
  59814. set blurKernelSize(value: number);
  59815. /**
  59816. * Gets the kernel size of the blur.
  59817. */
  59818. get blurKernelSize(): number;
  59819. /**
  59820. * Sets the glow intensity.
  59821. */
  59822. set intensity(value: number);
  59823. /**
  59824. * Gets the glow intensity.
  59825. */
  59826. get intensity(): number;
  59827. private _options;
  59828. private _intensity;
  59829. private _horizontalBlurPostprocess1;
  59830. private _verticalBlurPostprocess1;
  59831. private _horizontalBlurPostprocess2;
  59832. private _verticalBlurPostprocess2;
  59833. private _blurTexture1;
  59834. private _blurTexture2;
  59835. private _postProcesses1;
  59836. private _postProcesses2;
  59837. private _includedOnlyMeshes;
  59838. private _excludedMeshes;
  59839. private _meshesUsingTheirOwnMaterials;
  59840. /**
  59841. * Callback used to let the user override the color selection on a per mesh basis
  59842. */
  59843. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59844. /**
  59845. * Callback used to let the user override the texture selection on a per mesh basis
  59846. */
  59847. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59848. /**
  59849. * Instantiates a new glow Layer and references it to the scene.
  59850. * @param name The name of the layer
  59851. * @param scene The scene to use the layer in
  59852. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59853. */
  59854. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59855. /**
  59856. * Get the effect name of the layer.
  59857. * @return The effect name
  59858. */
  59859. getEffectName(): string;
  59860. /**
  59861. * Create the merge effect. This is the shader use to blit the information back
  59862. * to the main canvas at the end of the scene rendering.
  59863. */
  59864. protected _createMergeEffect(): Effect;
  59865. /**
  59866. * Creates the render target textures and post processes used in the glow layer.
  59867. */
  59868. protected _createTextureAndPostProcesses(): void;
  59869. /**
  59870. * Checks for the readiness of the element composing the layer.
  59871. * @param subMesh the mesh to check for
  59872. * @param useInstances specify wether or not to use instances to render the mesh
  59873. * @param emissiveTexture the associated emissive texture used to generate the glow
  59874. * @return true if ready otherwise, false
  59875. */
  59876. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59877. /**
  59878. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59879. */
  59880. needStencil(): boolean;
  59881. /**
  59882. * Returns true if the mesh can be rendered, otherwise false.
  59883. * @param mesh The mesh to render
  59884. * @param material The material used on the mesh
  59885. * @returns true if it can be rendered otherwise false
  59886. */
  59887. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59888. /**
  59889. * Implementation specific of rendering the generating effect on the main canvas.
  59890. * @param effect The effect used to render through
  59891. */
  59892. protected _internalRender(effect: Effect): void;
  59893. /**
  59894. * Sets the required values for both the emissive texture and and the main color.
  59895. */
  59896. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59897. /**
  59898. * Returns true if the mesh should render, otherwise false.
  59899. * @param mesh The mesh to render
  59900. * @returns true if it should render otherwise false
  59901. */
  59902. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59903. /**
  59904. * Adds specific effects defines.
  59905. * @param defines The defines to add specifics to.
  59906. */
  59907. protected _addCustomEffectDefines(defines: string[]): void;
  59908. /**
  59909. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59910. * @param mesh The mesh to exclude from the glow layer
  59911. */
  59912. addExcludedMesh(mesh: Mesh): void;
  59913. /**
  59914. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59915. * @param mesh The mesh to remove
  59916. */
  59917. removeExcludedMesh(mesh: Mesh): void;
  59918. /**
  59919. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59920. * @param mesh The mesh to include in the glow layer
  59921. */
  59922. addIncludedOnlyMesh(mesh: Mesh): void;
  59923. /**
  59924. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59925. * @param mesh The mesh to remove
  59926. */
  59927. removeIncludedOnlyMesh(mesh: Mesh): void;
  59928. /**
  59929. * Determine if a given mesh will be used in the glow layer
  59930. * @param mesh The mesh to test
  59931. * @returns true if the mesh will be highlighted by the current glow layer
  59932. */
  59933. hasMesh(mesh: AbstractMesh): boolean;
  59934. /**
  59935. * Defines whether the current material of the mesh should be use to render the effect.
  59936. * @param mesh defines the current mesh to render
  59937. */
  59938. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59939. /**
  59940. * Add a mesh to be rendered through its own material and not with emissive only.
  59941. * @param mesh The mesh for which we need to use its material
  59942. */
  59943. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59944. /**
  59945. * Remove a mesh from being rendered through its own material and not with emissive only.
  59946. * @param mesh The mesh for which we need to not use its material
  59947. */
  59948. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59949. /**
  59950. * Free any resources and references associated to a mesh.
  59951. * Internal use
  59952. * @param mesh The mesh to free.
  59953. * @hidden
  59954. */
  59955. _disposeMesh(mesh: Mesh): void;
  59956. /**
  59957. * Gets the class name of the effect layer
  59958. * @returns the string with the class name of the effect layer
  59959. */
  59960. getClassName(): string;
  59961. /**
  59962. * Serializes this glow layer
  59963. * @returns a serialized glow layer object
  59964. */
  59965. serialize(): any;
  59966. /**
  59967. * Creates a Glow Layer from parsed glow layer data
  59968. * @param parsedGlowLayer defines glow layer data
  59969. * @param scene defines the current scene
  59970. * @param rootUrl defines the root URL containing the glow layer information
  59971. * @returns a parsed Glow Layer
  59972. */
  59973. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59974. }
  59975. }
  59976. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59977. /** @hidden */
  59978. export var glowBlurPostProcessPixelShader: {
  59979. name: string;
  59980. shader: string;
  59981. };
  59982. }
  59983. declare module "babylonjs/Layers/highlightLayer" {
  59984. import { Observable } from "babylonjs/Misc/observable";
  59985. import { Nullable } from "babylonjs/types";
  59986. import { Camera } from "babylonjs/Cameras/camera";
  59987. import { Scene } from "babylonjs/scene";
  59988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59990. import { Mesh } from "babylonjs/Meshes/mesh";
  59991. import { Effect } from "babylonjs/Materials/effect";
  59992. import { Material } from "babylonjs/Materials/material";
  59993. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59994. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59995. import "babylonjs/Shaders/glowMapMerge.fragment";
  59996. import "babylonjs/Shaders/glowMapMerge.vertex";
  59997. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59998. module "babylonjs/abstractScene" {
  59999. interface AbstractScene {
  60000. /**
  60001. * Return a the first highlight layer of the scene with a given name.
  60002. * @param name The name of the highlight layer to look for.
  60003. * @return The highlight layer if found otherwise null.
  60004. */
  60005. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60006. }
  60007. }
  60008. /**
  60009. * Highlight layer options. This helps customizing the behaviour
  60010. * of the highlight layer.
  60011. */
  60012. export interface IHighlightLayerOptions {
  60013. /**
  60014. * Multiplication factor apply to the canvas size to compute the render target size
  60015. * used to generated the glowing objects (the smaller the faster).
  60016. */
  60017. mainTextureRatio: number;
  60018. /**
  60019. * Enforces a fixed size texture to ensure resize independant blur.
  60020. */
  60021. mainTextureFixedSize?: number;
  60022. /**
  60023. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60024. * of the picture to blur (the smaller the faster).
  60025. */
  60026. blurTextureSizeRatio: number;
  60027. /**
  60028. * How big in texel of the blur texture is the vertical blur.
  60029. */
  60030. blurVerticalSize: number;
  60031. /**
  60032. * How big in texel of the blur texture is the horizontal blur.
  60033. */
  60034. blurHorizontalSize: number;
  60035. /**
  60036. * Alpha blending mode used to apply the blur. Default is combine.
  60037. */
  60038. alphaBlendingMode: number;
  60039. /**
  60040. * The camera attached to the layer.
  60041. */
  60042. camera: Nullable<Camera>;
  60043. /**
  60044. * Should we display highlight as a solid stroke?
  60045. */
  60046. isStroke?: boolean;
  60047. /**
  60048. * The rendering group to draw the layer in.
  60049. */
  60050. renderingGroupId: number;
  60051. }
  60052. /**
  60053. * The highlight layer Helps adding a glow effect around a mesh.
  60054. *
  60055. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60056. * glowy meshes to your scene.
  60057. *
  60058. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60059. */
  60060. export class HighlightLayer extends EffectLayer {
  60061. name: string;
  60062. /**
  60063. * Effect Name of the highlight layer.
  60064. */
  60065. static readonly EffectName: string;
  60066. /**
  60067. * The neutral color used during the preparation of the glow effect.
  60068. * This is black by default as the blend operation is a blend operation.
  60069. */
  60070. static NeutralColor: Color4;
  60071. /**
  60072. * Stencil value used for glowing meshes.
  60073. */
  60074. static GlowingMeshStencilReference: number;
  60075. /**
  60076. * Stencil value used for the other meshes in the scene.
  60077. */
  60078. static NormalMeshStencilReference: number;
  60079. /**
  60080. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60081. */
  60082. innerGlow: boolean;
  60083. /**
  60084. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60085. */
  60086. outerGlow: boolean;
  60087. /**
  60088. * Specifies the horizontal size of the blur.
  60089. */
  60090. set blurHorizontalSize(value: number);
  60091. /**
  60092. * Specifies the vertical size of the blur.
  60093. */
  60094. set blurVerticalSize(value: number);
  60095. /**
  60096. * Gets the horizontal size of the blur.
  60097. */
  60098. get blurHorizontalSize(): number;
  60099. /**
  60100. * Gets the vertical size of the blur.
  60101. */
  60102. get blurVerticalSize(): number;
  60103. /**
  60104. * An event triggered when the highlight layer is being blurred.
  60105. */
  60106. onBeforeBlurObservable: Observable<HighlightLayer>;
  60107. /**
  60108. * An event triggered when the highlight layer has been blurred.
  60109. */
  60110. onAfterBlurObservable: Observable<HighlightLayer>;
  60111. private _instanceGlowingMeshStencilReference;
  60112. private _options;
  60113. private _downSamplePostprocess;
  60114. private _horizontalBlurPostprocess;
  60115. private _verticalBlurPostprocess;
  60116. private _blurTexture;
  60117. private _meshes;
  60118. private _excludedMeshes;
  60119. /**
  60120. * Instantiates a new highlight Layer and references it to the scene..
  60121. * @param name The name of the layer
  60122. * @param scene The scene to use the layer in
  60123. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60124. */
  60125. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60126. /**
  60127. * Get the effect name of the layer.
  60128. * @return The effect name
  60129. */
  60130. getEffectName(): string;
  60131. /**
  60132. * Create the merge effect. This is the shader use to blit the information back
  60133. * to the main canvas at the end of the scene rendering.
  60134. */
  60135. protected _createMergeEffect(): Effect;
  60136. /**
  60137. * Creates the render target textures and post processes used in the highlight layer.
  60138. */
  60139. protected _createTextureAndPostProcesses(): void;
  60140. /**
  60141. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60142. */
  60143. needStencil(): boolean;
  60144. /**
  60145. * Checks for the readiness of the element composing the layer.
  60146. * @param subMesh the mesh to check for
  60147. * @param useInstances specify wether or not to use instances to render the mesh
  60148. * @param emissiveTexture the associated emissive texture used to generate the glow
  60149. * @return true if ready otherwise, false
  60150. */
  60151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60152. /**
  60153. * Implementation specific of rendering the generating effect on the main canvas.
  60154. * @param effect The effect used to render through
  60155. */
  60156. protected _internalRender(effect: Effect): void;
  60157. /**
  60158. * Returns true if the layer contains information to display, otherwise false.
  60159. */
  60160. shouldRender(): boolean;
  60161. /**
  60162. * Returns true if the mesh should render, otherwise false.
  60163. * @param mesh The mesh to render
  60164. * @returns true if it should render otherwise false
  60165. */
  60166. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60167. /**
  60168. * Adds specific effects defines.
  60169. * @param defines The defines to add specifics to.
  60170. */
  60171. protected _addCustomEffectDefines(defines: string[]): void;
  60172. /**
  60173. * Sets the required values for both the emissive texture and and the main color.
  60174. */
  60175. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60176. /**
  60177. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60178. * @param mesh The mesh to exclude from the highlight layer
  60179. */
  60180. addExcludedMesh(mesh: Mesh): void;
  60181. /**
  60182. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60183. * @param mesh The mesh to highlight
  60184. */
  60185. removeExcludedMesh(mesh: Mesh): void;
  60186. /**
  60187. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60188. * @param mesh mesh to test
  60189. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60190. */
  60191. hasMesh(mesh: AbstractMesh): boolean;
  60192. /**
  60193. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60194. * @param mesh The mesh to highlight
  60195. * @param color The color of the highlight
  60196. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60197. */
  60198. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60199. /**
  60200. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60201. * @param mesh The mesh to highlight
  60202. */
  60203. removeMesh(mesh: Mesh): void;
  60204. /**
  60205. * Remove all the meshes currently referenced in the highlight layer
  60206. */
  60207. removeAllMeshes(): void;
  60208. /**
  60209. * Force the stencil to the normal expected value for none glowing parts
  60210. */
  60211. private _defaultStencilReference;
  60212. /**
  60213. * Free any resources and references associated to a mesh.
  60214. * Internal use
  60215. * @param mesh The mesh to free.
  60216. * @hidden
  60217. */
  60218. _disposeMesh(mesh: Mesh): void;
  60219. /**
  60220. * Dispose the highlight layer and free resources.
  60221. */
  60222. dispose(): void;
  60223. /**
  60224. * Gets the class name of the effect layer
  60225. * @returns the string with the class name of the effect layer
  60226. */
  60227. getClassName(): string;
  60228. /**
  60229. * Serializes this Highlight layer
  60230. * @returns a serialized Highlight layer object
  60231. */
  60232. serialize(): any;
  60233. /**
  60234. * Creates a Highlight layer from parsed Highlight layer data
  60235. * @param parsedHightlightLayer defines the Highlight layer data
  60236. * @param scene defines the current scene
  60237. * @param rootUrl defines the root URL containing the Highlight layer information
  60238. * @returns a parsed Highlight layer
  60239. */
  60240. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60241. }
  60242. }
  60243. declare module "babylonjs/Layers/layerSceneComponent" {
  60244. import { Scene } from "babylonjs/scene";
  60245. import { ISceneComponent } from "babylonjs/sceneComponent";
  60246. import { Layer } from "babylonjs/Layers/layer";
  60247. import { AbstractScene } from "babylonjs/abstractScene";
  60248. module "babylonjs/abstractScene" {
  60249. interface AbstractScene {
  60250. /**
  60251. * The list of layers (background and foreground) of the scene
  60252. */
  60253. layers: Array<Layer>;
  60254. }
  60255. }
  60256. /**
  60257. * Defines the layer scene component responsible to manage any layers
  60258. * in a given scene.
  60259. */
  60260. export class LayerSceneComponent implements ISceneComponent {
  60261. /**
  60262. * The component name helpfull to identify the component in the list of scene components.
  60263. */
  60264. readonly name: string;
  60265. /**
  60266. * The scene the component belongs to.
  60267. */
  60268. scene: Scene;
  60269. private _engine;
  60270. /**
  60271. * Creates a new instance of the component for the given scene
  60272. * @param scene Defines the scene to register the component in
  60273. */
  60274. constructor(scene: Scene);
  60275. /**
  60276. * Registers the component in a given scene
  60277. */
  60278. register(): void;
  60279. /**
  60280. * Rebuilds the elements related to this component in case of
  60281. * context lost for instance.
  60282. */
  60283. rebuild(): void;
  60284. /**
  60285. * Disposes the component and the associated ressources.
  60286. */
  60287. dispose(): void;
  60288. private _draw;
  60289. private _drawCameraPredicate;
  60290. private _drawCameraBackground;
  60291. private _drawCameraForeground;
  60292. private _drawRenderTargetPredicate;
  60293. private _drawRenderTargetBackground;
  60294. private _drawRenderTargetForeground;
  60295. /**
  60296. * Adds all the elements from the container to the scene
  60297. * @param container the container holding the elements
  60298. */
  60299. addFromContainer(container: AbstractScene): void;
  60300. /**
  60301. * Removes all the elements in the container from the scene
  60302. * @param container contains the elements to remove
  60303. * @param dispose if the removed element should be disposed (default: false)
  60304. */
  60305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60306. }
  60307. }
  60308. declare module "babylonjs/Shaders/layer.fragment" {
  60309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60310. /** @hidden */
  60311. export var layerPixelShader: {
  60312. name: string;
  60313. shader: string;
  60314. };
  60315. }
  60316. declare module "babylonjs/Shaders/layer.vertex" {
  60317. /** @hidden */
  60318. export var layerVertexShader: {
  60319. name: string;
  60320. shader: string;
  60321. };
  60322. }
  60323. declare module "babylonjs/Layers/layer" {
  60324. import { Observable } from "babylonjs/Misc/observable";
  60325. import { Nullable } from "babylonjs/types";
  60326. import { Scene } from "babylonjs/scene";
  60327. import { Vector2 } from "babylonjs/Maths/math.vector";
  60328. import { Color4 } from "babylonjs/Maths/math.color";
  60329. import { Texture } from "babylonjs/Materials/Textures/texture";
  60330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60331. import "babylonjs/Shaders/layer.fragment";
  60332. import "babylonjs/Shaders/layer.vertex";
  60333. /**
  60334. * This represents a full screen 2d layer.
  60335. * This can be useful to display a picture in the background of your scene for instance.
  60336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60337. */
  60338. export class Layer {
  60339. /**
  60340. * Define the name of the layer.
  60341. */
  60342. name: string;
  60343. /**
  60344. * Define the texture the layer should display.
  60345. */
  60346. texture: Nullable<Texture>;
  60347. /**
  60348. * Is the layer in background or foreground.
  60349. */
  60350. isBackground: boolean;
  60351. /**
  60352. * Define the color of the layer (instead of texture).
  60353. */
  60354. color: Color4;
  60355. /**
  60356. * Define the scale of the layer in order to zoom in out of the texture.
  60357. */
  60358. scale: Vector2;
  60359. /**
  60360. * Define an offset for the layer in order to shift the texture.
  60361. */
  60362. offset: Vector2;
  60363. /**
  60364. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60365. */
  60366. alphaBlendingMode: number;
  60367. /**
  60368. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60369. * Alpha test will not mix with the background color in case of transparency.
  60370. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60371. */
  60372. alphaTest: boolean;
  60373. /**
  60374. * Define a mask to restrict the layer to only some of the scene cameras.
  60375. */
  60376. layerMask: number;
  60377. /**
  60378. * Define the list of render target the layer is visible into.
  60379. */
  60380. renderTargetTextures: RenderTargetTexture[];
  60381. /**
  60382. * Define if the layer is only used in renderTarget or if it also
  60383. * renders in the main frame buffer of the canvas.
  60384. */
  60385. renderOnlyInRenderTargetTextures: boolean;
  60386. private _scene;
  60387. private _vertexBuffers;
  60388. private _indexBuffer;
  60389. private _effect;
  60390. private _previousDefines;
  60391. /**
  60392. * An event triggered when the layer is disposed.
  60393. */
  60394. onDisposeObservable: Observable<Layer>;
  60395. private _onDisposeObserver;
  60396. /**
  60397. * Back compatibility with callback before the onDisposeObservable existed.
  60398. * The set callback will be triggered when the layer has been disposed.
  60399. */
  60400. set onDispose(callback: () => void);
  60401. /**
  60402. * An event triggered before rendering the scene
  60403. */
  60404. onBeforeRenderObservable: Observable<Layer>;
  60405. private _onBeforeRenderObserver;
  60406. /**
  60407. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60408. * The set callback will be triggered just before rendering the layer.
  60409. */
  60410. set onBeforeRender(callback: () => void);
  60411. /**
  60412. * An event triggered after rendering the scene
  60413. */
  60414. onAfterRenderObservable: Observable<Layer>;
  60415. private _onAfterRenderObserver;
  60416. /**
  60417. * Back compatibility with callback before the onAfterRenderObservable existed.
  60418. * The set callback will be triggered just after rendering the layer.
  60419. */
  60420. set onAfterRender(callback: () => void);
  60421. /**
  60422. * Instantiates a new layer.
  60423. * This represents a full screen 2d layer.
  60424. * This can be useful to display a picture in the background of your scene for instance.
  60425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60426. * @param name Define the name of the layer in the scene
  60427. * @param imgUrl Define the url of the texture to display in the layer
  60428. * @param scene Define the scene the layer belongs to
  60429. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60430. * @param color Defines a color for the layer
  60431. */
  60432. constructor(
  60433. /**
  60434. * Define the name of the layer.
  60435. */
  60436. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60437. private _createIndexBuffer;
  60438. /** @hidden */
  60439. _rebuild(): void;
  60440. /**
  60441. * Renders the layer in the scene.
  60442. */
  60443. render(): void;
  60444. /**
  60445. * Disposes and releases the associated ressources.
  60446. */
  60447. dispose(): void;
  60448. }
  60449. }
  60450. declare module "babylonjs/Layers/index" {
  60451. export * from "babylonjs/Layers/effectLayer";
  60452. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60453. export * from "babylonjs/Layers/glowLayer";
  60454. export * from "babylonjs/Layers/highlightLayer";
  60455. export * from "babylonjs/Layers/layer";
  60456. export * from "babylonjs/Layers/layerSceneComponent";
  60457. }
  60458. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60459. /** @hidden */
  60460. export var lensFlarePixelShader: {
  60461. name: string;
  60462. shader: string;
  60463. };
  60464. }
  60465. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60466. /** @hidden */
  60467. export var lensFlareVertexShader: {
  60468. name: string;
  60469. shader: string;
  60470. };
  60471. }
  60472. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60473. import { Scene } from "babylonjs/scene";
  60474. import { Vector3 } from "babylonjs/Maths/math.vector";
  60475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60476. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60477. import "babylonjs/Shaders/lensFlare.fragment";
  60478. import "babylonjs/Shaders/lensFlare.vertex";
  60479. import { Viewport } from "babylonjs/Maths/math.viewport";
  60480. /**
  60481. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60482. * It is usually composed of several `lensFlare`.
  60483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60484. */
  60485. export class LensFlareSystem {
  60486. /**
  60487. * Define the name of the lens flare system
  60488. */
  60489. name: string;
  60490. /**
  60491. * List of lens flares used in this system.
  60492. */
  60493. lensFlares: LensFlare[];
  60494. /**
  60495. * Define a limit from the border the lens flare can be visible.
  60496. */
  60497. borderLimit: number;
  60498. /**
  60499. * Define a viewport border we do not want to see the lens flare in.
  60500. */
  60501. viewportBorder: number;
  60502. /**
  60503. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60504. */
  60505. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60506. /**
  60507. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60508. */
  60509. layerMask: number;
  60510. /**
  60511. * Define the id of the lens flare system in the scene.
  60512. * (equal to name by default)
  60513. */
  60514. id: string;
  60515. private _scene;
  60516. private _emitter;
  60517. private _vertexBuffers;
  60518. private _indexBuffer;
  60519. private _effect;
  60520. private _positionX;
  60521. private _positionY;
  60522. private _isEnabled;
  60523. /** @hidden */
  60524. static _SceneComponentInitialization: (scene: Scene) => void;
  60525. /**
  60526. * Instantiates a lens flare system.
  60527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60528. * It is usually composed of several `lensFlare`.
  60529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60530. * @param name Define the name of the lens flare system in the scene
  60531. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60532. * @param scene Define the scene the lens flare system belongs to
  60533. */
  60534. constructor(
  60535. /**
  60536. * Define the name of the lens flare system
  60537. */
  60538. name: string, emitter: any, scene: Scene);
  60539. /**
  60540. * Define if the lens flare system is enabled.
  60541. */
  60542. get isEnabled(): boolean;
  60543. set isEnabled(value: boolean);
  60544. /**
  60545. * Get the scene the effects belongs to.
  60546. * @returns the scene holding the lens flare system
  60547. */
  60548. getScene(): Scene;
  60549. /**
  60550. * Get the emitter of the lens flare system.
  60551. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60552. * @returns the emitter of the lens flare system
  60553. */
  60554. getEmitter(): any;
  60555. /**
  60556. * Set the emitter of the lens flare system.
  60557. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60558. * @param newEmitter Define the new emitter of the system
  60559. */
  60560. setEmitter(newEmitter: any): void;
  60561. /**
  60562. * Get the lens flare system emitter position.
  60563. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60564. * @returns the position
  60565. */
  60566. getEmitterPosition(): Vector3;
  60567. /**
  60568. * @hidden
  60569. */
  60570. computeEffectivePosition(globalViewport: Viewport): boolean;
  60571. /** @hidden */
  60572. _isVisible(): boolean;
  60573. /**
  60574. * @hidden
  60575. */
  60576. render(): boolean;
  60577. /**
  60578. * Dispose and release the lens flare with its associated resources.
  60579. */
  60580. dispose(): void;
  60581. /**
  60582. * Parse a lens flare system from a JSON repressentation
  60583. * @param parsedLensFlareSystem Define the JSON to parse
  60584. * @param scene Define the scene the parsed system should be instantiated in
  60585. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60586. * @returns the parsed system
  60587. */
  60588. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60589. /**
  60590. * Serialize the current Lens Flare System into a JSON representation.
  60591. * @returns the serialized JSON
  60592. */
  60593. serialize(): any;
  60594. }
  60595. }
  60596. declare module "babylonjs/LensFlares/lensFlare" {
  60597. import { Nullable } from "babylonjs/types";
  60598. import { Color3 } from "babylonjs/Maths/math.color";
  60599. import { Texture } from "babylonjs/Materials/Textures/texture";
  60600. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60601. /**
  60602. * This represents one of the lens effect in a `lensFlareSystem`.
  60603. * It controls one of the indiviual texture used in the effect.
  60604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60605. */
  60606. export class LensFlare {
  60607. /**
  60608. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60609. */
  60610. size: number;
  60611. /**
  60612. * 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.
  60613. */
  60614. position: number;
  60615. /**
  60616. * Define the lens color.
  60617. */
  60618. color: Color3;
  60619. /**
  60620. * Define the lens texture.
  60621. */
  60622. texture: Nullable<Texture>;
  60623. /**
  60624. * Define the alpha mode to render this particular lens.
  60625. */
  60626. alphaMode: number;
  60627. private _system;
  60628. /**
  60629. * Creates a new Lens Flare.
  60630. * This represents one of the lens effect in a `lensFlareSystem`.
  60631. * It controls one of the indiviual texture used in the effect.
  60632. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60633. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60634. * @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.
  60635. * @param color Define the lens color
  60636. * @param imgUrl Define the lens texture url
  60637. * @param system Define the `lensFlareSystem` this flare is part of
  60638. * @returns The newly created Lens Flare
  60639. */
  60640. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60641. /**
  60642. * Instantiates a new Lens Flare.
  60643. * This represents one of the lens effect in a `lensFlareSystem`.
  60644. * It controls one of the indiviual texture used in the effect.
  60645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60646. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60647. * @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.
  60648. * @param color Define the lens color
  60649. * @param imgUrl Define the lens texture url
  60650. * @param system Define the `lensFlareSystem` this flare is part of
  60651. */
  60652. constructor(
  60653. /**
  60654. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60655. */
  60656. size: number,
  60657. /**
  60658. * 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.
  60659. */
  60660. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60661. /**
  60662. * Dispose and release the lens flare with its associated resources.
  60663. */
  60664. dispose(): void;
  60665. }
  60666. }
  60667. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60668. import { Nullable } from "babylonjs/types";
  60669. import { Scene } from "babylonjs/scene";
  60670. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60671. import { AbstractScene } from "babylonjs/abstractScene";
  60672. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60673. module "babylonjs/abstractScene" {
  60674. interface AbstractScene {
  60675. /**
  60676. * The list of lens flare system added to the scene
  60677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60678. */
  60679. lensFlareSystems: Array<LensFlareSystem>;
  60680. /**
  60681. * Removes the given lens flare system from this scene.
  60682. * @param toRemove The lens flare system to remove
  60683. * @returns The index of the removed lens flare system
  60684. */
  60685. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60686. /**
  60687. * Adds the given lens flare system to this scene
  60688. * @param newLensFlareSystem The lens flare system to add
  60689. */
  60690. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60691. /**
  60692. * Gets a lens flare system using its name
  60693. * @param name defines the name to look for
  60694. * @returns the lens flare system or null if not found
  60695. */
  60696. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60697. /**
  60698. * Gets a lens flare system using its id
  60699. * @param id defines the id to look for
  60700. * @returns the lens flare system or null if not found
  60701. */
  60702. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60703. }
  60704. }
  60705. /**
  60706. * Defines the lens flare scene component responsible to manage any lens flares
  60707. * in a given scene.
  60708. */
  60709. export class LensFlareSystemSceneComponent 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. /**
  60719. * Creates a new instance of the component for the given scene
  60720. * @param scene Defines the scene to register the component in
  60721. */
  60722. constructor(scene: Scene);
  60723. /**
  60724. * Registers the component in a given scene
  60725. */
  60726. register(): void;
  60727. /**
  60728. * Rebuilds the elements related to this component in case of
  60729. * context lost for instance.
  60730. */
  60731. rebuild(): void;
  60732. /**
  60733. * Adds all the elements from the container to the scene
  60734. * @param container the container holding the elements
  60735. */
  60736. addFromContainer(container: AbstractScene): void;
  60737. /**
  60738. * Removes all the elements in the container from the scene
  60739. * @param container contains the elements to remove
  60740. * @param dispose if the removed element should be disposed (default: false)
  60741. */
  60742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60743. /**
  60744. * Serializes the component data to the specified json object
  60745. * @param serializationObject The object to serialize to
  60746. */
  60747. serialize(serializationObject: any): void;
  60748. /**
  60749. * Disposes the component and the associated ressources.
  60750. */
  60751. dispose(): void;
  60752. private _draw;
  60753. }
  60754. }
  60755. declare module "babylonjs/LensFlares/index" {
  60756. export * from "babylonjs/LensFlares/lensFlare";
  60757. export * from "babylonjs/LensFlares/lensFlareSystem";
  60758. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60759. }
  60760. declare module "babylonjs/Shaders/depth.fragment" {
  60761. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60762. /** @hidden */
  60763. export var depthPixelShader: {
  60764. name: string;
  60765. shader: string;
  60766. };
  60767. }
  60768. declare module "babylonjs/Shaders/depth.vertex" {
  60769. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60771. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60772. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60773. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60774. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60775. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60776. /** @hidden */
  60777. export var depthVertexShader: {
  60778. name: string;
  60779. shader: string;
  60780. };
  60781. }
  60782. declare module "babylonjs/Rendering/depthRenderer" {
  60783. import { Nullable } from "babylonjs/types";
  60784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60785. import { Scene } from "babylonjs/scene";
  60786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60787. import { Camera } from "babylonjs/Cameras/camera";
  60788. import "babylonjs/Shaders/depth.fragment";
  60789. import "babylonjs/Shaders/depth.vertex";
  60790. /**
  60791. * This represents a depth renderer in Babylon.
  60792. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60793. */
  60794. export class DepthRenderer {
  60795. private _scene;
  60796. private _depthMap;
  60797. private _effect;
  60798. private readonly _storeNonLinearDepth;
  60799. private readonly _clearColor;
  60800. /** Get if the depth renderer is using packed depth or not */
  60801. readonly isPacked: boolean;
  60802. private _cachedDefines;
  60803. private _camera;
  60804. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60805. enabled: boolean;
  60806. /**
  60807. * Specifiess that the depth renderer will only be used within
  60808. * the camera it is created for.
  60809. * This can help forcing its rendering during the camera processing.
  60810. */
  60811. useOnlyInActiveCamera: boolean;
  60812. /** @hidden */
  60813. static _SceneComponentInitialization: (scene: Scene) => void;
  60814. /**
  60815. * Instantiates a depth renderer
  60816. * @param scene The scene the renderer belongs to
  60817. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60818. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60819. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60820. */
  60821. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60822. /**
  60823. * Creates the depth rendering effect and checks if the effect is ready.
  60824. * @param subMesh The submesh to be used to render the depth map of
  60825. * @param useInstances If multiple world instances should be used
  60826. * @returns if the depth renderer is ready to render the depth map
  60827. */
  60828. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60829. /**
  60830. * Gets the texture which the depth map will be written to.
  60831. * @returns The depth map texture
  60832. */
  60833. getDepthMap(): RenderTargetTexture;
  60834. /**
  60835. * Disposes of the depth renderer.
  60836. */
  60837. dispose(): void;
  60838. }
  60839. }
  60840. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60841. /** @hidden */
  60842. export var minmaxReduxPixelShader: {
  60843. name: string;
  60844. shader: string;
  60845. };
  60846. }
  60847. declare module "babylonjs/Misc/minMaxReducer" {
  60848. import { Nullable } from "babylonjs/types";
  60849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60850. import { Camera } from "babylonjs/Cameras/camera";
  60851. import { Observer } from "babylonjs/Misc/observable";
  60852. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60853. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60854. import { Observable } from "babylonjs/Misc/observable";
  60855. import "babylonjs/Shaders/minmaxRedux.fragment";
  60856. /**
  60857. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60858. * and maximum values from all values of the texture.
  60859. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60860. * The source values are read from the red channel of the texture.
  60861. */
  60862. export class MinMaxReducer {
  60863. /**
  60864. * Observable triggered when the computation has been performed
  60865. */
  60866. onAfterReductionPerformed: Observable<{
  60867. min: number;
  60868. max: number;
  60869. }>;
  60870. protected _camera: Camera;
  60871. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60872. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60873. protected _postProcessManager: PostProcessManager;
  60874. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60875. protected _forceFullscreenViewport: boolean;
  60876. /**
  60877. * Creates a min/max reducer
  60878. * @param camera The camera to use for the post processes
  60879. */
  60880. constructor(camera: Camera);
  60881. /**
  60882. * Gets the texture used to read the values from.
  60883. */
  60884. get sourceTexture(): Nullable<RenderTargetTexture>;
  60885. /**
  60886. * Sets the source texture to read the values from.
  60887. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60888. * because in such textures '1' value must not be taken into account to compute the maximum
  60889. * as this value is used to clear the texture.
  60890. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60891. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60892. * @param depthRedux Indicates if the texture is a depth texture or not
  60893. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60894. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60895. */
  60896. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60897. /**
  60898. * Defines the refresh rate of the computation.
  60899. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60900. */
  60901. get refreshRate(): number;
  60902. set refreshRate(value: number);
  60903. protected _activated: boolean;
  60904. /**
  60905. * Gets the activation status of the reducer
  60906. */
  60907. get activated(): boolean;
  60908. /**
  60909. * Activates the reduction computation.
  60910. * When activated, the observers registered in onAfterReductionPerformed are
  60911. * called after the compuation is performed
  60912. */
  60913. activate(): void;
  60914. /**
  60915. * Deactivates the reduction computation.
  60916. */
  60917. deactivate(): void;
  60918. /**
  60919. * Disposes the min/max reducer
  60920. * @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.
  60921. */
  60922. dispose(disposeAll?: boolean): void;
  60923. }
  60924. }
  60925. declare module "babylonjs/Misc/depthReducer" {
  60926. import { Nullable } from "babylonjs/types";
  60927. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60928. import { Camera } from "babylonjs/Cameras/camera";
  60929. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60930. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60931. /**
  60932. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60933. */
  60934. export class DepthReducer extends MinMaxReducer {
  60935. private _depthRenderer;
  60936. private _depthRendererId;
  60937. /**
  60938. * Gets the depth renderer used for the computation.
  60939. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60940. */
  60941. get depthRenderer(): Nullable<DepthRenderer>;
  60942. /**
  60943. * Creates a depth reducer
  60944. * @param camera The camera used to render the depth texture
  60945. */
  60946. constructor(camera: Camera);
  60947. /**
  60948. * Sets the depth renderer to use to generate the depth map
  60949. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60950. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60951. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60952. */
  60953. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60954. /** @hidden */
  60955. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60956. /**
  60957. * Activates the reduction computation.
  60958. * When activated, the observers registered in onAfterReductionPerformed are
  60959. * called after the compuation is performed
  60960. */
  60961. activate(): void;
  60962. /**
  60963. * Deactivates the reduction computation.
  60964. */
  60965. deactivate(): void;
  60966. /**
  60967. * Disposes the depth reducer
  60968. * @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.
  60969. */
  60970. dispose(disposeAll?: boolean): void;
  60971. }
  60972. }
  60973. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60974. import { Nullable } from "babylonjs/types";
  60975. import { Scene } from "babylonjs/scene";
  60976. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60979. import { Effect } from "babylonjs/Materials/effect";
  60980. import "babylonjs/Shaders/shadowMap.fragment";
  60981. import "babylonjs/Shaders/shadowMap.vertex";
  60982. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60983. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60984. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60985. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60986. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60987. /**
  60988. * A CSM implementation allowing casting shadows on large scenes.
  60989. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60990. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60991. */
  60992. export class CascadedShadowGenerator extends ShadowGenerator {
  60993. private static readonly frustumCornersNDCSpace;
  60994. /**
  60995. * Name of the CSM class
  60996. */
  60997. static CLASSNAME: string;
  60998. /**
  60999. * Defines the default number of cascades used by the CSM.
  61000. */
  61001. static readonly DEFAULT_CASCADES_COUNT: number;
  61002. /**
  61003. * Defines the minimum number of cascades used by the CSM.
  61004. */
  61005. static readonly MIN_CASCADES_COUNT: number;
  61006. /**
  61007. * Defines the maximum number of cascades used by the CSM.
  61008. */
  61009. static readonly MAX_CASCADES_COUNT: number;
  61010. protected _validateFilter(filter: number): number;
  61011. /**
  61012. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61013. */
  61014. penumbraDarkness: number;
  61015. private _numCascades;
  61016. /**
  61017. * Gets or set the number of cascades used by the CSM.
  61018. */
  61019. get numCascades(): number;
  61020. set numCascades(value: number);
  61021. /**
  61022. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61023. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61024. */
  61025. stabilizeCascades: boolean;
  61026. private _freezeShadowCastersBoundingInfo;
  61027. private _freezeShadowCastersBoundingInfoObservable;
  61028. /**
  61029. * Enables or disables the shadow casters bounding info computation.
  61030. * If your shadow casters don't move, you can disable this feature.
  61031. * If it is enabled, the bounding box computation is done every frame.
  61032. */
  61033. get freezeShadowCastersBoundingInfo(): boolean;
  61034. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61035. private _scbiMin;
  61036. private _scbiMax;
  61037. protected _computeShadowCastersBoundingInfo(): void;
  61038. protected _shadowCastersBoundingInfo: BoundingInfo;
  61039. /**
  61040. * Gets or sets the shadow casters bounding info.
  61041. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61042. * so that the system won't overwrite the bounds you provide
  61043. */
  61044. get shadowCastersBoundingInfo(): BoundingInfo;
  61045. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61046. protected _breaksAreDirty: boolean;
  61047. protected _minDistance: number;
  61048. protected _maxDistance: number;
  61049. /**
  61050. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61051. *
  61052. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61053. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61054. * @param min minimal distance for the breaks (default to 0.)
  61055. * @param max maximal distance for the breaks (default to 1.)
  61056. */
  61057. setMinMaxDistance(min: number, max: number): void;
  61058. /** Gets the minimal distance used in the cascade break computation */
  61059. get minDistance(): number;
  61060. /** Gets the maximal distance used in the cascade break computation */
  61061. get maxDistance(): number;
  61062. /**
  61063. * Gets the class name of that object
  61064. * @returns "CascadedShadowGenerator"
  61065. */
  61066. getClassName(): string;
  61067. private _cascadeMinExtents;
  61068. private _cascadeMaxExtents;
  61069. /**
  61070. * Gets a cascade minimum extents
  61071. * @param cascadeIndex index of the cascade
  61072. * @returns the minimum cascade extents
  61073. */
  61074. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61075. /**
  61076. * Gets a cascade maximum extents
  61077. * @param cascadeIndex index of the cascade
  61078. * @returns the maximum cascade extents
  61079. */
  61080. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61081. private _cascades;
  61082. private _currentLayer;
  61083. private _viewSpaceFrustumsZ;
  61084. private _viewMatrices;
  61085. private _projectionMatrices;
  61086. private _transformMatrices;
  61087. private _transformMatricesAsArray;
  61088. private _frustumLengths;
  61089. private _lightSizeUVCorrection;
  61090. private _depthCorrection;
  61091. private _frustumCornersWorldSpace;
  61092. private _frustumCenter;
  61093. private _shadowCameraPos;
  61094. private _shadowMaxZ;
  61095. /**
  61096. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61097. * It defaults to camera.maxZ
  61098. */
  61099. get shadowMaxZ(): number;
  61100. /**
  61101. * Sets the shadow max z distance.
  61102. */
  61103. set shadowMaxZ(value: number);
  61104. protected _debug: boolean;
  61105. /**
  61106. * Gets or sets the debug flag.
  61107. * When enabled, the cascades are materialized by different colors on the screen.
  61108. */
  61109. get debug(): boolean;
  61110. set debug(dbg: boolean);
  61111. private _depthClamp;
  61112. /**
  61113. * Gets or sets the depth clamping value.
  61114. *
  61115. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61116. * to account for the shadow casters far away.
  61117. *
  61118. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61119. */
  61120. get depthClamp(): boolean;
  61121. set depthClamp(value: boolean);
  61122. private _cascadeBlendPercentage;
  61123. /**
  61124. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61125. * It defaults to 0.1 (10% blending).
  61126. */
  61127. get cascadeBlendPercentage(): number;
  61128. set cascadeBlendPercentage(value: number);
  61129. private _lambda;
  61130. /**
  61131. * Gets or set the lambda parameter.
  61132. * This parameter is used to split the camera frustum and create the cascades.
  61133. * 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.
  61134. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61135. */
  61136. get lambda(): number;
  61137. set lambda(value: number);
  61138. /**
  61139. * Gets the view matrix corresponding to a given cascade
  61140. * @param cascadeNum cascade to retrieve the view matrix from
  61141. * @returns the cascade view matrix
  61142. */
  61143. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61144. /**
  61145. * Gets the projection matrix corresponding to a given cascade
  61146. * @param cascadeNum cascade to retrieve the projection matrix from
  61147. * @returns the cascade projection matrix
  61148. */
  61149. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61150. /**
  61151. * Gets the transformation matrix corresponding to a given cascade
  61152. * @param cascadeNum cascade to retrieve the transformation matrix from
  61153. * @returns the cascade transformation matrix
  61154. */
  61155. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61156. private _depthRenderer;
  61157. /**
  61158. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61159. *
  61160. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61161. *
  61162. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61163. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61164. * @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
  61165. */
  61166. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61167. private _depthReducer;
  61168. private _autoCalcDepthBounds;
  61169. /**
  61170. * Gets or sets the autoCalcDepthBounds property.
  61171. *
  61172. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61173. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61174. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61175. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61176. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61177. */
  61178. get autoCalcDepthBounds(): boolean;
  61179. set autoCalcDepthBounds(value: boolean);
  61180. /**
  61181. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61182. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61183. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61184. * for setting the refresh rate on the renderer yourself!
  61185. */
  61186. get autoCalcDepthBoundsRefreshRate(): number;
  61187. set autoCalcDepthBoundsRefreshRate(value: number);
  61188. /**
  61189. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61190. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61191. * you change the camera near/far planes!
  61192. */
  61193. splitFrustum(): void;
  61194. private _splitFrustum;
  61195. private _computeMatrices;
  61196. private _computeFrustumInWorldSpace;
  61197. private _computeCascadeFrustum;
  61198. /**
  61199. * Support test.
  61200. */
  61201. static get IsSupported(): boolean;
  61202. /** @hidden */
  61203. static _SceneComponentInitialization: (scene: Scene) => void;
  61204. /**
  61205. * Creates a Cascaded Shadow Generator object.
  61206. * A ShadowGenerator is the required tool to use the shadows.
  61207. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61208. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61209. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61210. * @param light The directional light object generating the shadows.
  61211. * @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.
  61212. */
  61213. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61214. protected _initializeGenerator(): void;
  61215. protected _createTargetRenderTexture(): void;
  61216. protected _initializeShadowMap(): void;
  61217. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61218. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61219. /**
  61220. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61221. * @param defines Defines of the material we want to update
  61222. * @param lightIndex Index of the light in the enabled light list of the material
  61223. */
  61224. prepareDefines(defines: any, lightIndex: number): void;
  61225. /**
  61226. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61227. * defined in the generator but impacting the effect).
  61228. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61229. * @param effect The effect we are binfing the information for
  61230. */
  61231. bindShadowLight(lightIndex: string, effect: Effect): void;
  61232. /**
  61233. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61234. * (eq to view projection * shadow projection matrices)
  61235. * @returns The transform matrix used to create the shadow map
  61236. */
  61237. getTransformMatrix(): Matrix;
  61238. /**
  61239. * Disposes the ShadowGenerator.
  61240. * Returns nothing.
  61241. */
  61242. dispose(): void;
  61243. /**
  61244. * Serializes the shadow generator setup to a json object.
  61245. * @returns The serialized JSON object
  61246. */
  61247. serialize(): any;
  61248. /**
  61249. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61250. * @param parsedShadowGenerator The JSON object to parse
  61251. * @param scene The scene to create the shadow map for
  61252. * @returns The parsed shadow generator
  61253. */
  61254. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61255. }
  61256. }
  61257. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61258. import { Scene } from "babylonjs/scene";
  61259. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61260. import { AbstractScene } from "babylonjs/abstractScene";
  61261. /**
  61262. * Defines the shadow generator component responsible to manage any shadow generators
  61263. * in a given scene.
  61264. */
  61265. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61266. /**
  61267. * The component name helpfull to identify the component in the list of scene components.
  61268. */
  61269. readonly name: string;
  61270. /**
  61271. * The scene the component belongs to.
  61272. */
  61273. scene: Scene;
  61274. /**
  61275. * Creates a new instance of the component for the given scene
  61276. * @param scene Defines the scene to register the component in
  61277. */
  61278. constructor(scene: Scene);
  61279. /**
  61280. * Registers the component in a given scene
  61281. */
  61282. register(): void;
  61283. /**
  61284. * Rebuilds the elements related to this component in case of
  61285. * context lost for instance.
  61286. */
  61287. rebuild(): void;
  61288. /**
  61289. * Serializes the component data to the specified json object
  61290. * @param serializationObject The object to serialize to
  61291. */
  61292. serialize(serializationObject: any): void;
  61293. /**
  61294. * Adds all the elements from the container to the scene
  61295. * @param container the container holding the elements
  61296. */
  61297. addFromContainer(container: AbstractScene): void;
  61298. /**
  61299. * Removes all the elements in the container from the scene
  61300. * @param container contains the elements to remove
  61301. * @param dispose if the removed element should be disposed (default: false)
  61302. */
  61303. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61304. /**
  61305. * Rebuilds the elements related to this component in case of
  61306. * context lost for instance.
  61307. */
  61308. dispose(): void;
  61309. private _gatherRenderTargets;
  61310. }
  61311. }
  61312. declare module "babylonjs/Lights/Shadows/index" {
  61313. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61314. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61315. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61316. }
  61317. declare module "babylonjs/Lights/pointLight" {
  61318. import { Scene } from "babylonjs/scene";
  61319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61321. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61322. import { Effect } from "babylonjs/Materials/effect";
  61323. /**
  61324. * A point light is a light defined by an unique point in world space.
  61325. * The light is emitted in every direction from this point.
  61326. * A good example of a point light is a standard light bulb.
  61327. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61328. */
  61329. export class PointLight extends ShadowLight {
  61330. private _shadowAngle;
  61331. /**
  61332. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61333. * This specifies what angle the shadow will use to be created.
  61334. *
  61335. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61336. */
  61337. get shadowAngle(): number;
  61338. /**
  61339. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61340. * This specifies what angle the shadow will use to be created.
  61341. *
  61342. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61343. */
  61344. set shadowAngle(value: number);
  61345. /**
  61346. * Gets the direction if it has been set.
  61347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61348. */
  61349. get direction(): Vector3;
  61350. /**
  61351. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61352. */
  61353. set direction(value: Vector3);
  61354. /**
  61355. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61356. * A PointLight emits the light in every direction.
  61357. * It can cast shadows.
  61358. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61359. * ```javascript
  61360. * var pointLight = new PointLight("pl", camera.position, scene);
  61361. * ```
  61362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61363. * @param name The light friendly name
  61364. * @param position The position of the point light in the scene
  61365. * @param scene The scene the lights belongs to
  61366. */
  61367. constructor(name: string, position: Vector3, scene: Scene);
  61368. /**
  61369. * Returns the string "PointLight"
  61370. * @returns the class name
  61371. */
  61372. getClassName(): string;
  61373. /**
  61374. * Returns the integer 0.
  61375. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61376. */
  61377. getTypeID(): number;
  61378. /**
  61379. * Specifies wether or not the shadowmap should be a cube texture.
  61380. * @returns true if the shadowmap needs to be a cube texture.
  61381. */
  61382. needCube(): boolean;
  61383. /**
  61384. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61385. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61386. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61387. */
  61388. getShadowDirection(faceIndex?: number): Vector3;
  61389. /**
  61390. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61391. * - fov = PI / 2
  61392. * - aspect ratio : 1.0
  61393. * - z-near and far equal to the active camera minZ and maxZ.
  61394. * Returns the PointLight.
  61395. */
  61396. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61397. protected _buildUniformLayout(): void;
  61398. /**
  61399. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61400. * @param effect The effect to update
  61401. * @param lightIndex The index of the light in the effect to update
  61402. * @returns The point light
  61403. */
  61404. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61405. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61406. /**
  61407. * Prepares the list of defines specific to the light type.
  61408. * @param defines the list of defines
  61409. * @param lightIndex defines the index of the light for the effect
  61410. */
  61411. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61412. }
  61413. }
  61414. declare module "babylonjs/Lights/index" {
  61415. export * from "babylonjs/Lights/light";
  61416. export * from "babylonjs/Lights/shadowLight";
  61417. export * from "babylonjs/Lights/Shadows/index";
  61418. export * from "babylonjs/Lights/directionalLight";
  61419. export * from "babylonjs/Lights/hemisphericLight";
  61420. export * from "babylonjs/Lights/pointLight";
  61421. export * from "babylonjs/Lights/spotLight";
  61422. }
  61423. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61424. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61425. /**
  61426. * Header information of HDR texture files.
  61427. */
  61428. export interface HDRInfo {
  61429. /**
  61430. * The height of the texture in pixels.
  61431. */
  61432. height: number;
  61433. /**
  61434. * The width of the texture in pixels.
  61435. */
  61436. width: number;
  61437. /**
  61438. * The index of the beginning of the data in the binary file.
  61439. */
  61440. dataPosition: number;
  61441. }
  61442. /**
  61443. * This groups tools to convert HDR texture to native colors array.
  61444. */
  61445. export class HDRTools {
  61446. private static Ldexp;
  61447. private static Rgbe2float;
  61448. private static readStringLine;
  61449. /**
  61450. * Reads header information from an RGBE texture stored in a native array.
  61451. * More information on this format are available here:
  61452. * https://en.wikipedia.org/wiki/RGBE_image_format
  61453. *
  61454. * @param uint8array The binary file stored in native array.
  61455. * @return The header information.
  61456. */
  61457. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61458. /**
  61459. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61460. * This RGBE texture needs to store the information as a panorama.
  61461. *
  61462. * More information on this format are available here:
  61463. * https://en.wikipedia.org/wiki/RGBE_image_format
  61464. *
  61465. * @param buffer The binary file stored in an array buffer.
  61466. * @param size The expected size of the extracted cubemap.
  61467. * @return The Cube Map information.
  61468. */
  61469. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61470. /**
  61471. * Returns the pixels data extracted from an RGBE texture.
  61472. * This pixels will be stored left to right up to down in the R G B order in one array.
  61473. *
  61474. * More information on this format are available here:
  61475. * https://en.wikipedia.org/wiki/RGBE_image_format
  61476. *
  61477. * @param uint8array The binary file stored in an array buffer.
  61478. * @param hdrInfo The header information of the file.
  61479. * @return The pixels data in RGB right to left up to down order.
  61480. */
  61481. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61482. private static RGBE_ReadPixels_RLE;
  61483. }
  61484. }
  61485. declare module "babylonjs/Materials/effectRenderer" {
  61486. import { Nullable } from "babylonjs/types";
  61487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61488. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61489. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61490. import { Viewport } from "babylonjs/Maths/math.viewport";
  61491. import { Observable } from "babylonjs/Misc/observable";
  61492. import { Effect } from "babylonjs/Materials/effect";
  61493. import "babylonjs/Shaders/postprocess.vertex";
  61494. /**
  61495. * Effect Render Options
  61496. */
  61497. export interface IEffectRendererOptions {
  61498. /**
  61499. * Defines the vertices positions.
  61500. */
  61501. positions?: number[];
  61502. /**
  61503. * Defines the indices.
  61504. */
  61505. indices?: number[];
  61506. }
  61507. /**
  61508. * Helper class to render one or more effects.
  61509. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61510. */
  61511. export class EffectRenderer {
  61512. private engine;
  61513. private static _DefaultOptions;
  61514. private _vertexBuffers;
  61515. private _indexBuffer;
  61516. private _fullscreenViewport;
  61517. /**
  61518. * Creates an effect renderer
  61519. * @param engine the engine to use for rendering
  61520. * @param options defines the options of the effect renderer
  61521. */
  61522. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61523. /**
  61524. * Sets the current viewport in normalized coordinates 0-1
  61525. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61526. */
  61527. setViewport(viewport?: Viewport): void;
  61528. /**
  61529. * Binds the embedded attributes buffer to the effect.
  61530. * @param effect Defines the effect to bind the attributes for
  61531. */
  61532. bindBuffers(effect: Effect): void;
  61533. /**
  61534. * Sets the current effect wrapper to use during draw.
  61535. * The effect needs to be ready before calling this api.
  61536. * This also sets the default full screen position attribute.
  61537. * @param effectWrapper Defines the effect to draw with
  61538. */
  61539. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61540. /**
  61541. * Restores engine states
  61542. */
  61543. restoreStates(): void;
  61544. /**
  61545. * Draws a full screen quad.
  61546. */
  61547. draw(): void;
  61548. private isRenderTargetTexture;
  61549. /**
  61550. * renders one or more effects to a specified texture
  61551. * @param effectWrapper the effect to renderer
  61552. * @param outputTexture texture to draw to, if null it will render to the screen.
  61553. */
  61554. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61555. /**
  61556. * Disposes of the effect renderer
  61557. */
  61558. dispose(): void;
  61559. }
  61560. /**
  61561. * Options to create an EffectWrapper
  61562. */
  61563. interface EffectWrapperCreationOptions {
  61564. /**
  61565. * Engine to use to create the effect
  61566. */
  61567. engine: ThinEngine;
  61568. /**
  61569. * Fragment shader for the effect
  61570. */
  61571. fragmentShader: string;
  61572. /**
  61573. * Use the shader store instead of direct source code
  61574. */
  61575. useShaderStore?: boolean;
  61576. /**
  61577. * Vertex shader for the effect
  61578. */
  61579. vertexShader?: string;
  61580. /**
  61581. * Attributes to use in the shader
  61582. */
  61583. attributeNames?: Array<string>;
  61584. /**
  61585. * Uniforms to use in the shader
  61586. */
  61587. uniformNames?: Array<string>;
  61588. /**
  61589. * Texture sampler names to use in the shader
  61590. */
  61591. samplerNames?: Array<string>;
  61592. /**
  61593. * Defines to use in the shader
  61594. */
  61595. defines?: Array<string>;
  61596. /**
  61597. * Callback when effect is compiled
  61598. */
  61599. onCompiled?: Nullable<(effect: Effect) => void>;
  61600. /**
  61601. * The friendly name of the effect displayed in Spector.
  61602. */
  61603. name?: string;
  61604. }
  61605. /**
  61606. * Wraps an effect to be used for rendering
  61607. */
  61608. export class EffectWrapper {
  61609. /**
  61610. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61611. */
  61612. onApplyObservable: Observable<{}>;
  61613. /**
  61614. * The underlying effect
  61615. */
  61616. effect: Effect;
  61617. /**
  61618. * Creates an effect to be renderer
  61619. * @param creationOptions options to create the effect
  61620. */
  61621. constructor(creationOptions: EffectWrapperCreationOptions);
  61622. /**
  61623. * Disposes of the effect wrapper
  61624. */
  61625. dispose(): void;
  61626. }
  61627. }
  61628. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61629. /** @hidden */
  61630. export var hdrFilteringVertexShader: {
  61631. name: string;
  61632. shader: string;
  61633. };
  61634. }
  61635. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61637. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61638. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61639. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61640. /** @hidden */
  61641. export var hdrFilteringPixelShader: {
  61642. name: string;
  61643. shader: string;
  61644. };
  61645. }
  61646. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61648. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61649. import { Nullable } from "babylonjs/types";
  61650. import "babylonjs/Shaders/hdrFiltering.vertex";
  61651. import "babylonjs/Shaders/hdrFiltering.fragment";
  61652. /**
  61653. * Options for texture filtering
  61654. */
  61655. interface IHDRFilteringOptions {
  61656. /**
  61657. * Scales pixel intensity for the input HDR map.
  61658. */
  61659. hdrScale?: number;
  61660. /**
  61661. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61662. */
  61663. quality?: number;
  61664. }
  61665. /**
  61666. * Filters HDR maps to get correct renderings of PBR reflections
  61667. */
  61668. export class HDRFiltering {
  61669. private _engine;
  61670. private _effectRenderer;
  61671. private _effectWrapper;
  61672. private _lodGenerationOffset;
  61673. private _lodGenerationScale;
  61674. /**
  61675. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61676. * you care about baking speed.
  61677. */
  61678. quality: number;
  61679. /**
  61680. * Scales pixel intensity for the input HDR map.
  61681. */
  61682. hdrScale: number;
  61683. /**
  61684. * Instantiates HDR filter for reflection maps
  61685. *
  61686. * @param engine Thin engine
  61687. * @param options Options
  61688. */
  61689. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61690. private _createRenderTarget;
  61691. private _prefilterInternal;
  61692. private _createEffect;
  61693. /**
  61694. * Get a value indicating if the filter is ready to be used
  61695. * @param texture Texture to filter
  61696. * @returns true if the filter is ready
  61697. */
  61698. isReady(texture: BaseTexture): boolean;
  61699. /**
  61700. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61701. * Prefiltering will be invoked at the end of next rendering pass.
  61702. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61703. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61704. * @param texture Texture to filter
  61705. * @param onFinished Callback when filtering is done
  61706. * @return Promise called when prefiltering is done
  61707. */
  61708. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61709. }
  61710. }
  61711. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61712. import { Nullable } from "babylonjs/types";
  61713. import { Scene } from "babylonjs/scene";
  61714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61716. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61717. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61718. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61719. /**
  61720. * This represents a texture coming from an HDR input.
  61721. *
  61722. * The only supported format is currently panorama picture stored in RGBE format.
  61723. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61724. */
  61725. export class HDRCubeTexture extends BaseTexture {
  61726. private static _facesMapping;
  61727. private _generateHarmonics;
  61728. private _noMipmap;
  61729. private _prefilterOnLoad;
  61730. private _textureMatrix;
  61731. private _size;
  61732. private _onLoad;
  61733. private _onError;
  61734. /**
  61735. * The texture URL.
  61736. */
  61737. url: string;
  61738. /**
  61739. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61740. */
  61741. coordinatesMode: number;
  61742. protected _isBlocking: boolean;
  61743. /**
  61744. * Sets wether or not the texture is blocking during loading.
  61745. */
  61746. set isBlocking(value: boolean);
  61747. /**
  61748. * Gets wether or not the texture is blocking during loading.
  61749. */
  61750. get isBlocking(): boolean;
  61751. protected _rotationY: number;
  61752. /**
  61753. * Sets texture matrix rotation angle around Y axis in radians.
  61754. */
  61755. set rotationY(value: number);
  61756. /**
  61757. * Gets texture matrix rotation angle around Y axis radians.
  61758. */
  61759. get rotationY(): number;
  61760. /**
  61761. * Gets or sets the center of the bounding box associated with the cube texture
  61762. * It must define where the camera used to render the texture was set
  61763. */
  61764. boundingBoxPosition: Vector3;
  61765. private _boundingBoxSize;
  61766. /**
  61767. * Gets or sets the size of the bounding box associated with the cube texture
  61768. * When defined, the cubemap will switch to local mode
  61769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61770. * @example https://www.babylonjs-playground.com/#RNASML
  61771. */
  61772. set boundingBoxSize(value: Vector3);
  61773. get boundingBoxSize(): Vector3;
  61774. /**
  61775. * Instantiates an HDRTexture from the following parameters.
  61776. *
  61777. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61778. * @param sceneOrEngine The scene or engine the texture will be used in
  61779. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61780. * @param noMipmap Forces to not generate the mipmap if true
  61781. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61782. * @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)
  61783. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61784. */
  61785. 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>);
  61786. /**
  61787. * Get the current class name of the texture useful for serialization or dynamic coding.
  61788. * @returns "HDRCubeTexture"
  61789. */
  61790. getClassName(): string;
  61791. /**
  61792. * Occurs when the file is raw .hdr file.
  61793. */
  61794. private loadTexture;
  61795. clone(): HDRCubeTexture;
  61796. delayLoad(): void;
  61797. /**
  61798. * Get the texture reflection matrix used to rotate/transform the reflection.
  61799. * @returns the reflection matrix
  61800. */
  61801. getReflectionTextureMatrix(): Matrix;
  61802. /**
  61803. * Set the texture reflection matrix used to rotate/transform the reflection.
  61804. * @param value Define the reflection matrix to set
  61805. */
  61806. setReflectionTextureMatrix(value: Matrix): void;
  61807. /**
  61808. * Parses a JSON representation of an HDR Texture in order to create the texture
  61809. * @param parsedTexture Define the JSON representation
  61810. * @param scene Define the scene the texture should be created in
  61811. * @param rootUrl Define the root url in case we need to load relative dependencies
  61812. * @returns the newly created texture after parsing
  61813. */
  61814. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61815. serialize(): any;
  61816. }
  61817. }
  61818. declare module "babylonjs/Physics/physicsEngine" {
  61819. import { Nullable } from "babylonjs/types";
  61820. import { Vector3 } from "babylonjs/Maths/math.vector";
  61821. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61822. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61823. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61824. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61825. /**
  61826. * Class used to control physics engine
  61827. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61828. */
  61829. export class PhysicsEngine implements IPhysicsEngine {
  61830. private _physicsPlugin;
  61831. /**
  61832. * Global value used to control the smallest number supported by the simulation
  61833. */
  61834. static Epsilon: number;
  61835. private _impostors;
  61836. private _joints;
  61837. private _subTimeStep;
  61838. /**
  61839. * Gets the gravity vector used by the simulation
  61840. */
  61841. gravity: Vector3;
  61842. /**
  61843. * Factory used to create the default physics plugin.
  61844. * @returns The default physics plugin
  61845. */
  61846. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61847. /**
  61848. * Creates a new Physics Engine
  61849. * @param gravity defines the gravity vector used by the simulation
  61850. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61851. */
  61852. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61853. /**
  61854. * Sets the gravity vector used by the simulation
  61855. * @param gravity defines the gravity vector to use
  61856. */
  61857. setGravity(gravity: Vector3): void;
  61858. /**
  61859. * Set the time step of the physics engine.
  61860. * Default is 1/60.
  61861. * To slow it down, enter 1/600 for example.
  61862. * To speed it up, 1/30
  61863. * @param newTimeStep defines the new timestep to apply to this world.
  61864. */
  61865. setTimeStep(newTimeStep?: number): void;
  61866. /**
  61867. * Get the time step of the physics engine.
  61868. * @returns the current time step
  61869. */
  61870. getTimeStep(): number;
  61871. /**
  61872. * Set the sub time step of the physics engine.
  61873. * Default is 0 meaning there is no sub steps
  61874. * To increase physics resolution precision, set a small value (like 1 ms)
  61875. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61876. */
  61877. setSubTimeStep(subTimeStep?: number): void;
  61878. /**
  61879. * Get the sub time step of the physics engine.
  61880. * @returns the current sub time step
  61881. */
  61882. getSubTimeStep(): number;
  61883. /**
  61884. * Release all resources
  61885. */
  61886. dispose(): void;
  61887. /**
  61888. * Gets the name of the current physics plugin
  61889. * @returns the name of the plugin
  61890. */
  61891. getPhysicsPluginName(): string;
  61892. /**
  61893. * Adding a new impostor for the impostor tracking.
  61894. * This will be done by the impostor itself.
  61895. * @param impostor the impostor to add
  61896. */
  61897. addImpostor(impostor: PhysicsImpostor): void;
  61898. /**
  61899. * Remove an impostor from the engine.
  61900. * This impostor and its mesh will not longer be updated by the physics engine.
  61901. * @param impostor the impostor to remove
  61902. */
  61903. removeImpostor(impostor: PhysicsImpostor): void;
  61904. /**
  61905. * Add a joint to the physics engine
  61906. * @param mainImpostor defines the main impostor to which the joint is added.
  61907. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61908. * @param joint defines the joint that will connect both impostors.
  61909. */
  61910. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61911. /**
  61912. * Removes a joint from the simulation
  61913. * @param mainImpostor defines the impostor used with the joint
  61914. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61915. * @param joint defines the joint to remove
  61916. */
  61917. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61918. /**
  61919. * Called by the scene. No need to call it.
  61920. * @param delta defines the timespam between frames
  61921. */
  61922. _step(delta: number): void;
  61923. /**
  61924. * Gets the current plugin used to run the simulation
  61925. * @returns current plugin
  61926. */
  61927. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61928. /**
  61929. * Gets the list of physic impostors
  61930. * @returns an array of PhysicsImpostor
  61931. */
  61932. getImpostors(): Array<PhysicsImpostor>;
  61933. /**
  61934. * Gets the impostor for a physics enabled object
  61935. * @param object defines the object impersonated by the impostor
  61936. * @returns the PhysicsImpostor or null if not found
  61937. */
  61938. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61939. /**
  61940. * Gets the impostor for a physics body object
  61941. * @param body defines physics body used by the impostor
  61942. * @returns the PhysicsImpostor or null if not found
  61943. */
  61944. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61945. /**
  61946. * Does a raycast in the physics world
  61947. * @param from when should the ray start?
  61948. * @param to when should the ray end?
  61949. * @returns PhysicsRaycastResult
  61950. */
  61951. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61952. }
  61953. }
  61954. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61955. import { Nullable } from "babylonjs/types";
  61956. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61958. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61959. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61960. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61961. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61962. /** @hidden */
  61963. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61964. private _useDeltaForWorldStep;
  61965. world: any;
  61966. name: string;
  61967. private _physicsMaterials;
  61968. private _fixedTimeStep;
  61969. private _cannonRaycastResult;
  61970. private _raycastResult;
  61971. private _physicsBodysToRemoveAfterStep;
  61972. private _firstFrame;
  61973. BJSCANNON: any;
  61974. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61975. setGravity(gravity: Vector3): void;
  61976. setTimeStep(timeStep: number): void;
  61977. getTimeStep(): number;
  61978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61979. private _removeMarkedPhysicsBodiesFromWorld;
  61980. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61981. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61982. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61983. private _processChildMeshes;
  61984. removePhysicsBody(impostor: PhysicsImpostor): void;
  61985. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61986. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61987. private _addMaterial;
  61988. private _checkWithEpsilon;
  61989. private _createShape;
  61990. private _createHeightmap;
  61991. private _minus90X;
  61992. private _plus90X;
  61993. private _tmpPosition;
  61994. private _tmpDeltaPosition;
  61995. private _tmpUnityRotation;
  61996. private _updatePhysicsBodyTransformation;
  61997. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61998. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61999. isSupported(): boolean;
  62000. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62001. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62002. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62003. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62004. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62005. getBodyMass(impostor: PhysicsImpostor): number;
  62006. getBodyFriction(impostor: PhysicsImpostor): number;
  62007. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62008. getBodyRestitution(impostor: PhysicsImpostor): number;
  62009. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62010. sleepBody(impostor: PhysicsImpostor): void;
  62011. wakeUpBody(impostor: PhysicsImpostor): void;
  62012. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62013. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62014. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62015. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62016. getRadius(impostor: PhysicsImpostor): number;
  62017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62018. dispose(): void;
  62019. private _extendNamespace;
  62020. /**
  62021. * Does a raycast in the physics world
  62022. * @param from when should the ray start?
  62023. * @param to when should the ray end?
  62024. * @returns PhysicsRaycastResult
  62025. */
  62026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62027. }
  62028. }
  62029. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62030. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62031. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62032. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62034. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62035. import { Nullable } from "babylonjs/types";
  62036. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62037. /** @hidden */
  62038. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62039. private _useDeltaForWorldStep;
  62040. world: any;
  62041. name: string;
  62042. BJSOIMO: any;
  62043. private _raycastResult;
  62044. private _fixedTimeStep;
  62045. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62046. setGravity(gravity: Vector3): void;
  62047. setTimeStep(timeStep: number): void;
  62048. getTimeStep(): number;
  62049. private _tmpImpostorsArray;
  62050. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62051. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62052. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62053. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62054. private _tmpPositionVector;
  62055. removePhysicsBody(impostor: PhysicsImpostor): void;
  62056. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62057. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62058. isSupported(): boolean;
  62059. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62060. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62061. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62062. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62063. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62064. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62065. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62066. getBodyMass(impostor: PhysicsImpostor): number;
  62067. getBodyFriction(impostor: PhysicsImpostor): number;
  62068. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62069. getBodyRestitution(impostor: PhysicsImpostor): number;
  62070. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62071. sleepBody(impostor: PhysicsImpostor): void;
  62072. wakeUpBody(impostor: PhysicsImpostor): void;
  62073. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62074. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62075. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62076. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62077. getRadius(impostor: PhysicsImpostor): number;
  62078. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62079. dispose(): void;
  62080. /**
  62081. * Does a raycast in the physics world
  62082. * @param from when should the ray start?
  62083. * @param to when should the ray end?
  62084. * @returns PhysicsRaycastResult
  62085. */
  62086. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62087. }
  62088. }
  62089. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62090. import { Nullable } from "babylonjs/types";
  62091. import { Scene } from "babylonjs/scene";
  62092. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62093. import { Color4 } from "babylonjs/Maths/math.color";
  62094. import { Mesh } from "babylonjs/Meshes/mesh";
  62095. /**
  62096. * Class containing static functions to help procedurally build meshes
  62097. */
  62098. export class RibbonBuilder {
  62099. /**
  62100. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62101. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62102. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62103. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62104. * * 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
  62105. * * 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
  62106. * * 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
  62107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62110. * * 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
  62111. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62112. * * 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
  62113. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62115. * @param name defines the name of the mesh
  62116. * @param options defines the options used to create the mesh
  62117. * @param scene defines the hosting scene
  62118. * @returns the ribbon mesh
  62119. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62121. */
  62122. static CreateRibbon(name: string, options: {
  62123. pathArray: Vector3[][];
  62124. closeArray?: boolean;
  62125. closePath?: boolean;
  62126. offset?: number;
  62127. updatable?: boolean;
  62128. sideOrientation?: number;
  62129. frontUVs?: Vector4;
  62130. backUVs?: Vector4;
  62131. instance?: Mesh;
  62132. invertUV?: boolean;
  62133. uvs?: Vector2[];
  62134. colors?: Color4[];
  62135. }, scene?: Nullable<Scene>): Mesh;
  62136. }
  62137. }
  62138. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62139. import { Nullable } from "babylonjs/types";
  62140. import { Scene } from "babylonjs/scene";
  62141. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62142. import { Mesh } from "babylonjs/Meshes/mesh";
  62143. /**
  62144. * Class containing static functions to help procedurally build meshes
  62145. */
  62146. export class ShapeBuilder {
  62147. /**
  62148. * 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.
  62149. * * 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.
  62150. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62151. * * 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.
  62152. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62153. * * 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
  62154. * * 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
  62155. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62160. * @param name defines the name of the mesh
  62161. * @param options defines the options used to create the mesh
  62162. * @param scene defines the hosting scene
  62163. * @returns the extruded shape mesh
  62164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62166. */
  62167. static ExtrudeShape(name: string, options: {
  62168. shape: Vector3[];
  62169. path: Vector3[];
  62170. scale?: number;
  62171. rotation?: number;
  62172. cap?: number;
  62173. updatable?: boolean;
  62174. sideOrientation?: number;
  62175. frontUVs?: Vector4;
  62176. backUVs?: Vector4;
  62177. instance?: Mesh;
  62178. invertUV?: boolean;
  62179. }, scene?: Nullable<Scene>): Mesh;
  62180. /**
  62181. * Creates an custom extruded shape mesh.
  62182. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62183. * * 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.
  62184. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62185. * * 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
  62186. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62187. * * 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
  62188. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62189. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62190. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62191. * * 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
  62192. * * 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
  62193. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62198. * @param name defines the name of the mesh
  62199. * @param options defines the options used to create the mesh
  62200. * @param scene defines the hosting scene
  62201. * @returns the custom extruded shape mesh
  62202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62205. */
  62206. static ExtrudeShapeCustom(name: string, options: {
  62207. shape: Vector3[];
  62208. path: Vector3[];
  62209. scaleFunction?: any;
  62210. rotationFunction?: any;
  62211. ribbonCloseArray?: boolean;
  62212. ribbonClosePath?: boolean;
  62213. cap?: number;
  62214. updatable?: boolean;
  62215. sideOrientation?: number;
  62216. frontUVs?: Vector4;
  62217. backUVs?: Vector4;
  62218. instance?: Mesh;
  62219. invertUV?: boolean;
  62220. }, scene?: Nullable<Scene>): Mesh;
  62221. private static _ExtrudeShapeGeneric;
  62222. }
  62223. }
  62224. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62225. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62226. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62227. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62228. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62229. import { Nullable } from "babylonjs/types";
  62230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62231. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62232. /**
  62233. * AmmoJS Physics plugin
  62234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62235. * @see https://github.com/kripken/ammo.js/
  62236. */
  62237. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62238. private _useDeltaForWorldStep;
  62239. /**
  62240. * Reference to the Ammo library
  62241. */
  62242. bjsAMMO: any;
  62243. /**
  62244. * Created ammoJS world which physics bodies are added to
  62245. */
  62246. world: any;
  62247. /**
  62248. * Name of the plugin
  62249. */
  62250. name: string;
  62251. private _timeStep;
  62252. private _fixedTimeStep;
  62253. private _maxSteps;
  62254. private _tmpQuaternion;
  62255. private _tmpAmmoTransform;
  62256. private _tmpAmmoQuaternion;
  62257. private _tmpAmmoConcreteContactResultCallback;
  62258. private _collisionConfiguration;
  62259. private _dispatcher;
  62260. private _overlappingPairCache;
  62261. private _solver;
  62262. private _softBodySolver;
  62263. private _tmpAmmoVectorA;
  62264. private _tmpAmmoVectorB;
  62265. private _tmpAmmoVectorC;
  62266. private _tmpAmmoVectorD;
  62267. private _tmpContactCallbackResult;
  62268. private _tmpAmmoVectorRCA;
  62269. private _tmpAmmoVectorRCB;
  62270. private _raycastResult;
  62271. private static readonly DISABLE_COLLISION_FLAG;
  62272. private static readonly KINEMATIC_FLAG;
  62273. private static readonly DISABLE_DEACTIVATION_FLAG;
  62274. /**
  62275. * Initializes the ammoJS plugin
  62276. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62277. * @param ammoInjection can be used to inject your own ammo reference
  62278. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62279. */
  62280. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62281. /**
  62282. * Sets the gravity of the physics world (m/(s^2))
  62283. * @param gravity Gravity to set
  62284. */
  62285. setGravity(gravity: Vector3): void;
  62286. /**
  62287. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62288. * @param timeStep timestep to use in seconds
  62289. */
  62290. setTimeStep(timeStep: number): void;
  62291. /**
  62292. * 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)
  62293. * @param fixedTimeStep fixedTimeStep to use in seconds
  62294. */
  62295. setFixedTimeStep(fixedTimeStep: number): void;
  62296. /**
  62297. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62298. * @param maxSteps the maximum number of steps by the physics engine per frame
  62299. */
  62300. setMaxSteps(maxSteps: number): void;
  62301. /**
  62302. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62303. * @returns the current timestep in seconds
  62304. */
  62305. getTimeStep(): number;
  62306. /**
  62307. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62308. */
  62309. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62310. private _isImpostorInContact;
  62311. private _isImpostorPairInContact;
  62312. private _stepSimulation;
  62313. /**
  62314. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62315. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62316. * After the step the babylon meshes are set to the position of the physics imposters
  62317. * @param delta amount of time to step forward
  62318. * @param impostors array of imposters to update before/after the step
  62319. */
  62320. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62321. /**
  62322. * Update babylon mesh to match physics world object
  62323. * @param impostor imposter to match
  62324. */
  62325. private _afterSoftStep;
  62326. /**
  62327. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62328. * @param impostor imposter to match
  62329. */
  62330. private _ropeStep;
  62331. /**
  62332. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62333. * @param impostor imposter to match
  62334. */
  62335. private _softbodyOrClothStep;
  62336. private _tmpMatrix;
  62337. /**
  62338. * Applies an impulse on the imposter
  62339. * @param impostor imposter to apply impulse to
  62340. * @param force amount of force to be applied to the imposter
  62341. * @param contactPoint the location to apply the impulse on the imposter
  62342. */
  62343. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62344. /**
  62345. * Applies a force on the imposter
  62346. * @param impostor imposter to apply force
  62347. * @param force amount of force to be applied to the imposter
  62348. * @param contactPoint the location to apply the force on the imposter
  62349. */
  62350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62351. /**
  62352. * Creates a physics body using the plugin
  62353. * @param impostor the imposter to create the physics body on
  62354. */
  62355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62356. /**
  62357. * Removes the physics body from the imposter and disposes of the body's memory
  62358. * @param impostor imposter to remove the physics body from
  62359. */
  62360. removePhysicsBody(impostor: PhysicsImpostor): void;
  62361. /**
  62362. * Generates a joint
  62363. * @param impostorJoint the imposter joint to create the joint with
  62364. */
  62365. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62366. /**
  62367. * Removes a joint
  62368. * @param impostorJoint the imposter joint to remove the joint from
  62369. */
  62370. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62371. private _addMeshVerts;
  62372. /**
  62373. * Initialise the soft body vertices to match its object's (mesh) vertices
  62374. * Softbody vertices (nodes) are in world space and to match this
  62375. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62376. * @param impostor to create the softbody for
  62377. */
  62378. private _softVertexData;
  62379. /**
  62380. * Create an impostor's soft body
  62381. * @param impostor to create the softbody for
  62382. */
  62383. private _createSoftbody;
  62384. /**
  62385. * Create cloth for an impostor
  62386. * @param impostor to create the softbody for
  62387. */
  62388. private _createCloth;
  62389. /**
  62390. * Create rope for an impostor
  62391. * @param impostor to create the softbody for
  62392. */
  62393. private _createRope;
  62394. /**
  62395. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62396. * @param impostor to create the custom physics shape for
  62397. */
  62398. private _createCustom;
  62399. private _addHullVerts;
  62400. private _createShape;
  62401. /**
  62402. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62403. * @param impostor imposter containing the physics body and babylon object
  62404. */
  62405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62406. /**
  62407. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62408. * @param impostor imposter containing the physics body and babylon object
  62409. * @param newPosition new position
  62410. * @param newRotation new rotation
  62411. */
  62412. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62413. /**
  62414. * If this plugin is supported
  62415. * @returns true if its supported
  62416. */
  62417. isSupported(): boolean;
  62418. /**
  62419. * Sets the linear velocity of the physics body
  62420. * @param impostor imposter to set the velocity on
  62421. * @param velocity velocity to set
  62422. */
  62423. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62424. /**
  62425. * Sets the angular velocity of the physics body
  62426. * @param impostor imposter to set the velocity on
  62427. * @param velocity velocity to set
  62428. */
  62429. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62430. /**
  62431. * gets the linear velocity
  62432. * @param impostor imposter to get linear velocity from
  62433. * @returns linear velocity
  62434. */
  62435. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62436. /**
  62437. * gets the angular velocity
  62438. * @param impostor imposter to get angular velocity from
  62439. * @returns angular velocity
  62440. */
  62441. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62442. /**
  62443. * Sets the mass of physics body
  62444. * @param impostor imposter to set the mass on
  62445. * @param mass mass to set
  62446. */
  62447. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62448. /**
  62449. * Gets the mass of the physics body
  62450. * @param impostor imposter to get the mass from
  62451. * @returns mass
  62452. */
  62453. getBodyMass(impostor: PhysicsImpostor): number;
  62454. /**
  62455. * Gets friction of the impostor
  62456. * @param impostor impostor to get friction from
  62457. * @returns friction value
  62458. */
  62459. getBodyFriction(impostor: PhysicsImpostor): number;
  62460. /**
  62461. * Sets friction of the impostor
  62462. * @param impostor impostor to set friction on
  62463. * @param friction friction value
  62464. */
  62465. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62466. /**
  62467. * Gets restitution of the impostor
  62468. * @param impostor impostor to get restitution from
  62469. * @returns restitution value
  62470. */
  62471. getBodyRestitution(impostor: PhysicsImpostor): number;
  62472. /**
  62473. * Sets resitution of the impostor
  62474. * @param impostor impostor to set resitution on
  62475. * @param restitution resitution value
  62476. */
  62477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62478. /**
  62479. * Gets pressure inside the impostor
  62480. * @param impostor impostor to get pressure from
  62481. * @returns pressure value
  62482. */
  62483. getBodyPressure(impostor: PhysicsImpostor): number;
  62484. /**
  62485. * Sets pressure inside a soft body impostor
  62486. * Cloth and rope must remain 0 pressure
  62487. * @param impostor impostor to set pressure on
  62488. * @param pressure pressure value
  62489. */
  62490. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62491. /**
  62492. * Gets stiffness of the impostor
  62493. * @param impostor impostor to get stiffness from
  62494. * @returns pressure value
  62495. */
  62496. getBodyStiffness(impostor: PhysicsImpostor): number;
  62497. /**
  62498. * Sets stiffness of the impostor
  62499. * @param impostor impostor to set stiffness on
  62500. * @param stiffness stiffness value from 0 to 1
  62501. */
  62502. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62503. /**
  62504. * Gets velocityIterations of the impostor
  62505. * @param impostor impostor to get velocity iterations from
  62506. * @returns velocityIterations value
  62507. */
  62508. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62509. /**
  62510. * Sets velocityIterations of the impostor
  62511. * @param impostor impostor to set velocity iterations on
  62512. * @param velocityIterations velocityIterations value
  62513. */
  62514. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62515. /**
  62516. * Gets positionIterations of the impostor
  62517. * @param impostor impostor to get position iterations from
  62518. * @returns positionIterations value
  62519. */
  62520. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62521. /**
  62522. * Sets positionIterations of the impostor
  62523. * @param impostor impostor to set position on
  62524. * @param positionIterations positionIterations value
  62525. */
  62526. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62527. /**
  62528. * Append an anchor to a cloth object
  62529. * @param impostor is the cloth impostor to add anchor to
  62530. * @param otherImpostor is the rigid impostor to anchor to
  62531. * @param width ratio across width from 0 to 1
  62532. * @param height ratio up height from 0 to 1
  62533. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62534. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62535. */
  62536. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62537. /**
  62538. * Append an hook to a rope object
  62539. * @param impostor is the rope impostor to add hook to
  62540. * @param otherImpostor is the rigid impostor to hook to
  62541. * @param length ratio along the rope from 0 to 1
  62542. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62543. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62544. */
  62545. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62546. /**
  62547. * Sleeps the physics body and stops it from being active
  62548. * @param impostor impostor to sleep
  62549. */
  62550. sleepBody(impostor: PhysicsImpostor): void;
  62551. /**
  62552. * Activates the physics body
  62553. * @param impostor impostor to activate
  62554. */
  62555. wakeUpBody(impostor: PhysicsImpostor): void;
  62556. /**
  62557. * Updates the distance parameters of the joint
  62558. * @param joint joint to update
  62559. * @param maxDistance maximum distance of the joint
  62560. * @param minDistance minimum distance of the joint
  62561. */
  62562. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62563. /**
  62564. * Sets a motor on the joint
  62565. * @param joint joint to set motor on
  62566. * @param speed speed of the motor
  62567. * @param maxForce maximum force of the motor
  62568. * @param motorIndex index of the motor
  62569. */
  62570. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62571. /**
  62572. * Sets the motors limit
  62573. * @param joint joint to set limit on
  62574. * @param upperLimit upper limit
  62575. * @param lowerLimit lower limit
  62576. */
  62577. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62578. /**
  62579. * Syncs the position and rotation of a mesh with the impostor
  62580. * @param mesh mesh to sync
  62581. * @param impostor impostor to update the mesh with
  62582. */
  62583. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62584. /**
  62585. * Gets the radius of the impostor
  62586. * @param impostor impostor to get radius from
  62587. * @returns the radius
  62588. */
  62589. getRadius(impostor: PhysicsImpostor): number;
  62590. /**
  62591. * Gets the box size of the impostor
  62592. * @param impostor impostor to get box size from
  62593. * @param result the resulting box size
  62594. */
  62595. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62596. /**
  62597. * Disposes of the impostor
  62598. */
  62599. dispose(): void;
  62600. /**
  62601. * Does a raycast in the physics world
  62602. * @param from when should the ray start?
  62603. * @param to when should the ray end?
  62604. * @returns PhysicsRaycastResult
  62605. */
  62606. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62607. }
  62608. }
  62609. declare module "babylonjs/Probes/reflectionProbe" {
  62610. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62611. import { Vector3 } from "babylonjs/Maths/math.vector";
  62612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62613. import { Nullable } from "babylonjs/types";
  62614. import { Scene } from "babylonjs/scene";
  62615. module "babylonjs/abstractScene" {
  62616. interface AbstractScene {
  62617. /**
  62618. * The list of reflection probes added to the scene
  62619. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62620. */
  62621. reflectionProbes: Array<ReflectionProbe>;
  62622. /**
  62623. * Removes the given reflection probe from this scene.
  62624. * @param toRemove The reflection probe to remove
  62625. * @returns The index of the removed reflection probe
  62626. */
  62627. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62628. /**
  62629. * Adds the given reflection probe to this scene.
  62630. * @param newReflectionProbe The reflection probe to add
  62631. */
  62632. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62633. }
  62634. }
  62635. /**
  62636. * Class used to generate realtime reflection / refraction cube textures
  62637. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62638. */
  62639. export class ReflectionProbe {
  62640. /** defines the name of the probe */
  62641. name: string;
  62642. private _scene;
  62643. private _renderTargetTexture;
  62644. private _projectionMatrix;
  62645. private _viewMatrix;
  62646. private _target;
  62647. private _add;
  62648. private _attachedMesh;
  62649. private _invertYAxis;
  62650. /** Gets or sets probe position (center of the cube map) */
  62651. position: Vector3;
  62652. /**
  62653. * Creates a new reflection probe
  62654. * @param name defines the name of the probe
  62655. * @param size defines the texture resolution (for each face)
  62656. * @param scene defines the hosting scene
  62657. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62658. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62659. */
  62660. constructor(
  62661. /** defines the name of the probe */
  62662. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62663. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62664. get samples(): number;
  62665. set samples(value: number);
  62666. /** Gets or sets the refresh rate to use (on every frame by default) */
  62667. get refreshRate(): number;
  62668. set refreshRate(value: number);
  62669. /**
  62670. * Gets the hosting scene
  62671. * @returns a Scene
  62672. */
  62673. getScene(): Scene;
  62674. /** Gets the internal CubeTexture used to render to */
  62675. get cubeTexture(): RenderTargetTexture;
  62676. /** Gets the list of meshes to render */
  62677. get renderList(): Nullable<AbstractMesh[]>;
  62678. /**
  62679. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62680. * @param mesh defines the mesh to attach to
  62681. */
  62682. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62683. /**
  62684. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62685. * @param renderingGroupId The rendering group id corresponding to its index
  62686. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62687. */
  62688. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62689. /**
  62690. * Clean all associated resources
  62691. */
  62692. dispose(): void;
  62693. /**
  62694. * Converts the reflection probe information to a readable string for debug purpose.
  62695. * @param fullDetails Supports for multiple levels of logging within scene loading
  62696. * @returns the human readable reflection probe info
  62697. */
  62698. toString(fullDetails?: boolean): string;
  62699. /**
  62700. * Get the class name of the relfection probe.
  62701. * @returns "ReflectionProbe"
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62706. * @returns The JSON representation of the texture
  62707. */
  62708. serialize(): any;
  62709. /**
  62710. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62711. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62712. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62713. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62714. * @returns The parsed reflection probe if successful
  62715. */
  62716. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62717. }
  62718. }
  62719. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62720. /** @hidden */
  62721. export var _BabylonLoaderRegistered: boolean;
  62722. /**
  62723. * Helps setting up some configuration for the babylon file loader.
  62724. */
  62725. export class BabylonFileLoaderConfiguration {
  62726. /**
  62727. * The loader does not allow injecting custom physix engine into the plugins.
  62728. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62729. * So you could set this variable to your engine import to make it work.
  62730. */
  62731. static LoaderInjectedPhysicsEngine: any;
  62732. }
  62733. }
  62734. declare module "babylonjs/Loading/Plugins/index" {
  62735. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62736. }
  62737. declare module "babylonjs/Loading/index" {
  62738. export * from "babylonjs/Loading/loadingScreen";
  62739. export * from "babylonjs/Loading/Plugins/index";
  62740. export * from "babylonjs/Loading/sceneLoader";
  62741. export * from "babylonjs/Loading/sceneLoaderFlags";
  62742. }
  62743. declare module "babylonjs/Materials/Background/index" {
  62744. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62745. }
  62746. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62747. import { Scene } from "babylonjs/scene";
  62748. import { Color3 } from "babylonjs/Maths/math.color";
  62749. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62751. /**
  62752. * The Physically based simple base material of BJS.
  62753. *
  62754. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62755. * It is used as the base class for both the specGloss and metalRough conventions.
  62756. */
  62757. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62758. /**
  62759. * Number of Simultaneous lights allowed on the material.
  62760. */
  62761. maxSimultaneousLights: number;
  62762. /**
  62763. * If sets to true, disables all the lights affecting the material.
  62764. */
  62765. disableLighting: boolean;
  62766. /**
  62767. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62768. */
  62769. environmentTexture: BaseTexture;
  62770. /**
  62771. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62772. */
  62773. invertNormalMapX: boolean;
  62774. /**
  62775. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62776. */
  62777. invertNormalMapY: boolean;
  62778. /**
  62779. * Normal map used in the model.
  62780. */
  62781. normalTexture: BaseTexture;
  62782. /**
  62783. * Emissivie color used to self-illuminate the model.
  62784. */
  62785. emissiveColor: Color3;
  62786. /**
  62787. * Emissivie texture used to self-illuminate the model.
  62788. */
  62789. emissiveTexture: BaseTexture;
  62790. /**
  62791. * Occlusion Channel Strenght.
  62792. */
  62793. occlusionStrength: number;
  62794. /**
  62795. * Occlusion Texture of the material (adding extra occlusion effects).
  62796. */
  62797. occlusionTexture: BaseTexture;
  62798. /**
  62799. * Defines the alpha limits in alpha test mode.
  62800. */
  62801. alphaCutOff: number;
  62802. /**
  62803. * Gets the current double sided mode.
  62804. */
  62805. get doubleSided(): boolean;
  62806. /**
  62807. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62808. */
  62809. set doubleSided(value: boolean);
  62810. /**
  62811. * Stores the pre-calculated light information of a mesh in a texture.
  62812. */
  62813. lightmapTexture: BaseTexture;
  62814. /**
  62815. * If true, the light map contains occlusion information instead of lighting info.
  62816. */
  62817. useLightmapAsShadowmap: boolean;
  62818. /**
  62819. * Instantiates a new PBRMaterial instance.
  62820. *
  62821. * @param name The material name
  62822. * @param scene The scene the material will be use in.
  62823. */
  62824. constructor(name: string, scene: Scene);
  62825. getClassName(): string;
  62826. }
  62827. }
  62828. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62829. import { Scene } from "babylonjs/scene";
  62830. import { Color3 } from "babylonjs/Maths/math.color";
  62831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62832. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62833. /**
  62834. * The PBR material of BJS following the metal roughness convention.
  62835. *
  62836. * This fits to the PBR convention in the GLTF definition:
  62837. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62838. */
  62839. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62840. /**
  62841. * The base color has two different interpretations depending on the value of metalness.
  62842. * When the material is a metal, the base color is the specific measured reflectance value
  62843. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62844. * of the material.
  62845. */
  62846. baseColor: Color3;
  62847. /**
  62848. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62849. * well as opacity information in the alpha channel.
  62850. */
  62851. baseTexture: BaseTexture;
  62852. /**
  62853. * Specifies the metallic scalar value of the material.
  62854. * Can also be used to scale the metalness values of the metallic texture.
  62855. */
  62856. metallic: number;
  62857. /**
  62858. * Specifies the roughness scalar value of the material.
  62859. * Can also be used to scale the roughness values of the metallic texture.
  62860. */
  62861. roughness: number;
  62862. /**
  62863. * Texture containing both the metallic value in the B channel and the
  62864. * roughness value in the G channel to keep better precision.
  62865. */
  62866. metallicRoughnessTexture: BaseTexture;
  62867. /**
  62868. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62869. *
  62870. * @param name The material name
  62871. * @param scene The scene the material will be use in.
  62872. */
  62873. constructor(name: string, scene: Scene);
  62874. /**
  62875. * Return the currrent class name of the material.
  62876. */
  62877. getClassName(): string;
  62878. /**
  62879. * Makes a duplicate of the current material.
  62880. * @param name - name to use for the new material.
  62881. */
  62882. clone(name: string): PBRMetallicRoughnessMaterial;
  62883. /**
  62884. * Serialize the material to a parsable JSON object.
  62885. */
  62886. serialize(): any;
  62887. /**
  62888. * Parses a JSON object correponding to the serialize function.
  62889. */
  62890. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62891. }
  62892. }
  62893. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62894. import { Scene } from "babylonjs/scene";
  62895. import { Color3 } from "babylonjs/Maths/math.color";
  62896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62897. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62898. /**
  62899. * The PBR material of BJS following the specular glossiness convention.
  62900. *
  62901. * This fits to the PBR convention in the GLTF definition:
  62902. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62903. */
  62904. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62905. /**
  62906. * Specifies the diffuse color of the material.
  62907. */
  62908. diffuseColor: Color3;
  62909. /**
  62910. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62911. * channel.
  62912. */
  62913. diffuseTexture: BaseTexture;
  62914. /**
  62915. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62916. */
  62917. specularColor: Color3;
  62918. /**
  62919. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62920. */
  62921. glossiness: number;
  62922. /**
  62923. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62924. */
  62925. specularGlossinessTexture: BaseTexture;
  62926. /**
  62927. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62928. *
  62929. * @param name The material name
  62930. * @param scene The scene the material will be use in.
  62931. */
  62932. constructor(name: string, scene: Scene);
  62933. /**
  62934. * Return the currrent class name of the material.
  62935. */
  62936. getClassName(): string;
  62937. /**
  62938. * Makes a duplicate of the current material.
  62939. * @param name - name to use for the new material.
  62940. */
  62941. clone(name: string): PBRSpecularGlossinessMaterial;
  62942. /**
  62943. * Serialize the material to a parsable JSON object.
  62944. */
  62945. serialize(): any;
  62946. /**
  62947. * Parses a JSON object correponding to the serialize function.
  62948. */
  62949. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62950. }
  62951. }
  62952. declare module "babylonjs/Materials/PBR/index" {
  62953. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62954. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62955. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62956. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62957. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62958. }
  62959. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62960. import { Nullable } from "babylonjs/types";
  62961. import { Scene } from "babylonjs/scene";
  62962. import { Matrix } from "babylonjs/Maths/math.vector";
  62963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62964. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62965. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62966. /**
  62967. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62968. * It can help converting any input color in a desired output one. This can then be used to create effects
  62969. * from sepia, black and white to sixties or futuristic rendering...
  62970. *
  62971. * The only supported format is currently 3dl.
  62972. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62973. */
  62974. export class ColorGradingTexture extends BaseTexture {
  62975. /**
  62976. * The texture URL.
  62977. */
  62978. url: string;
  62979. /**
  62980. * Empty line regex stored for GC.
  62981. */
  62982. private static _noneEmptyLineRegex;
  62983. private _textureMatrix;
  62984. private _onLoad;
  62985. /**
  62986. * Instantiates a ColorGradingTexture from the following parameters.
  62987. *
  62988. * @param url The location of the color gradind data (currently only supporting 3dl)
  62989. * @param sceneOrEngine The scene or engine the texture will be used in
  62990. * @param onLoad defines a callback triggered when the texture has been loaded
  62991. */
  62992. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62993. /**
  62994. * Fires the onload event from the constructor if requested.
  62995. */
  62996. private _triggerOnLoad;
  62997. /**
  62998. * Returns the texture matrix used in most of the material.
  62999. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63000. */
  63001. getTextureMatrix(): Matrix;
  63002. /**
  63003. * Occurs when the file being loaded is a .3dl LUT file.
  63004. */
  63005. private load3dlTexture;
  63006. /**
  63007. * Starts the loading process of the texture.
  63008. */
  63009. private loadTexture;
  63010. /**
  63011. * Clones the color gradind texture.
  63012. */
  63013. clone(): ColorGradingTexture;
  63014. /**
  63015. * Called during delayed load for textures.
  63016. */
  63017. delayLoad(): void;
  63018. /**
  63019. * Parses a color grading texture serialized by Babylon.
  63020. * @param parsedTexture The texture information being parsedTexture
  63021. * @param scene The scene to load the texture in
  63022. * @param rootUrl The root url of the data assets to load
  63023. * @return A color gradind texture
  63024. */
  63025. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63026. /**
  63027. * Serializes the LUT texture to json format.
  63028. */
  63029. serialize(): any;
  63030. }
  63031. }
  63032. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63034. import { Scene } from "babylonjs/scene";
  63035. import { Nullable } from "babylonjs/types";
  63036. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63037. /**
  63038. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63039. */
  63040. export class EquiRectangularCubeTexture extends BaseTexture {
  63041. /** The six faces of the cube. */
  63042. private static _FacesMapping;
  63043. private _noMipmap;
  63044. private _onLoad;
  63045. private _onError;
  63046. /** The size of the cubemap. */
  63047. private _size;
  63048. /** The buffer of the image. */
  63049. private _buffer;
  63050. /** The width of the input image. */
  63051. private _width;
  63052. /** The height of the input image. */
  63053. private _height;
  63054. /** The URL to the image. */
  63055. url: string;
  63056. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63057. coordinatesMode: number;
  63058. /**
  63059. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63060. * @param url The location of the image
  63061. * @param scene The scene the texture will be used in
  63062. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63063. * @param noMipmap Forces to not generate the mipmap if true
  63064. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63065. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63066. * @param onLoad — defines a callback called when texture is loaded
  63067. * @param onError — defines a callback called if there is an error
  63068. */
  63069. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63070. /**
  63071. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63072. */
  63073. private loadImage;
  63074. /**
  63075. * Convert the image buffer into a cubemap and create a CubeTexture.
  63076. */
  63077. private loadTexture;
  63078. /**
  63079. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63080. * @param buffer The ArrayBuffer that should be converted.
  63081. * @returns The buffer as Float32Array.
  63082. */
  63083. private getFloat32ArrayFromArrayBuffer;
  63084. /**
  63085. * Get the current class name of the texture useful for serialization or dynamic coding.
  63086. * @returns "EquiRectangularCubeTexture"
  63087. */
  63088. getClassName(): string;
  63089. /**
  63090. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63091. * @returns A clone of the current EquiRectangularCubeTexture.
  63092. */
  63093. clone(): EquiRectangularCubeTexture;
  63094. }
  63095. }
  63096. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63097. import { Nullable } from "babylonjs/types";
  63098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63099. import { Matrix } from "babylonjs/Maths/math.vector";
  63100. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63101. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63102. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63103. import { Scene } from "babylonjs/scene";
  63104. /**
  63105. * Defines the options related to the creation of an HtmlElementTexture
  63106. */
  63107. export interface IHtmlElementTextureOptions {
  63108. /**
  63109. * Defines wether mip maps should be created or not.
  63110. */
  63111. generateMipMaps?: boolean;
  63112. /**
  63113. * Defines the sampling mode of the texture.
  63114. */
  63115. samplingMode?: number;
  63116. /**
  63117. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63118. */
  63119. engine: Nullable<ThinEngine>;
  63120. /**
  63121. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63122. */
  63123. scene: Nullable<Scene>;
  63124. }
  63125. /**
  63126. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63127. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63128. * is automatically managed.
  63129. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63130. * in your application.
  63131. *
  63132. * As the update is not automatic, you need to call them manually.
  63133. */
  63134. export class HtmlElementTexture extends BaseTexture {
  63135. /**
  63136. * The texture URL.
  63137. */
  63138. element: HTMLVideoElement | HTMLCanvasElement;
  63139. private static readonly DefaultOptions;
  63140. private _textureMatrix;
  63141. private _isVideo;
  63142. private _generateMipMaps;
  63143. private _samplingMode;
  63144. /**
  63145. * Instantiates a HtmlElementTexture from the following parameters.
  63146. *
  63147. * @param name Defines the name of the texture
  63148. * @param element Defines the video or canvas the texture is filled with
  63149. * @param options Defines the other none mandatory texture creation options
  63150. */
  63151. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63152. private _createInternalTexture;
  63153. /**
  63154. * Returns the texture matrix used in most of the material.
  63155. */
  63156. getTextureMatrix(): Matrix;
  63157. /**
  63158. * Updates the content of the texture.
  63159. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63160. */
  63161. update(invertY?: Nullable<boolean>): void;
  63162. }
  63163. }
  63164. declare module "babylonjs/Misc/tga" {
  63165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63166. /**
  63167. * Based on jsTGALoader - Javascript loader for TGA file
  63168. * By Vincent Thibault
  63169. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63170. */
  63171. export class TGATools {
  63172. private static _TYPE_INDEXED;
  63173. private static _TYPE_RGB;
  63174. private static _TYPE_GREY;
  63175. private static _TYPE_RLE_INDEXED;
  63176. private static _TYPE_RLE_RGB;
  63177. private static _TYPE_RLE_GREY;
  63178. private static _ORIGIN_MASK;
  63179. private static _ORIGIN_SHIFT;
  63180. private static _ORIGIN_BL;
  63181. private static _ORIGIN_BR;
  63182. private static _ORIGIN_UL;
  63183. private static _ORIGIN_UR;
  63184. /**
  63185. * Gets the header of a TGA file
  63186. * @param data defines the TGA data
  63187. * @returns the header
  63188. */
  63189. static GetTGAHeader(data: Uint8Array): any;
  63190. /**
  63191. * Uploads TGA content to a Babylon Texture
  63192. * @hidden
  63193. */
  63194. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63195. /** @hidden */
  63196. 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;
  63197. /** @hidden */
  63198. 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;
  63199. /** @hidden */
  63200. 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;
  63201. /** @hidden */
  63202. 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;
  63203. /** @hidden */
  63204. 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;
  63205. /** @hidden */
  63206. 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;
  63207. }
  63208. }
  63209. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63210. import { Nullable } from "babylonjs/types";
  63211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63212. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63213. /**
  63214. * Implementation of the TGA Texture Loader.
  63215. * @hidden
  63216. */
  63217. export class _TGATextureLoader implements IInternalTextureLoader {
  63218. /**
  63219. * Defines wether the loader supports cascade loading the different faces.
  63220. */
  63221. readonly supportCascades: boolean;
  63222. /**
  63223. * This returns if the loader support the current file information.
  63224. * @param extension defines the file extension of the file being loaded
  63225. * @returns true if the loader can load the specified file
  63226. */
  63227. canLoad(extension: string): boolean;
  63228. /**
  63229. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63230. * @param data contains the texture data
  63231. * @param texture defines the BabylonJS internal texture
  63232. * @param createPolynomials will be true if polynomials have been requested
  63233. * @param onLoad defines the callback to trigger once the texture is ready
  63234. * @param onError defines the callback to trigger in case of error
  63235. */
  63236. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63237. /**
  63238. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63239. * @param data contains the texture data
  63240. * @param texture defines the BabylonJS internal texture
  63241. * @param callback defines the method to call once ready to upload
  63242. */
  63243. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63244. }
  63245. }
  63246. declare module "babylonjs/Misc/basis" {
  63247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63248. /**
  63249. * Info about the .basis files
  63250. */
  63251. class BasisFileInfo {
  63252. /**
  63253. * If the file has alpha
  63254. */
  63255. hasAlpha: boolean;
  63256. /**
  63257. * Info about each image of the basis file
  63258. */
  63259. images: Array<{
  63260. levels: Array<{
  63261. width: number;
  63262. height: number;
  63263. transcodedPixels: ArrayBufferView;
  63264. }>;
  63265. }>;
  63266. }
  63267. /**
  63268. * Result of transcoding a basis file
  63269. */
  63270. class TranscodeResult {
  63271. /**
  63272. * Info about the .basis file
  63273. */
  63274. fileInfo: BasisFileInfo;
  63275. /**
  63276. * Format to use when loading the file
  63277. */
  63278. format: number;
  63279. }
  63280. /**
  63281. * Configuration options for the Basis transcoder
  63282. */
  63283. export class BasisTranscodeConfiguration {
  63284. /**
  63285. * Supported compression formats used to determine the supported output format of the transcoder
  63286. */
  63287. supportedCompressionFormats?: {
  63288. /**
  63289. * etc1 compression format
  63290. */
  63291. etc1?: boolean;
  63292. /**
  63293. * s3tc compression format
  63294. */
  63295. s3tc?: boolean;
  63296. /**
  63297. * pvrtc compression format
  63298. */
  63299. pvrtc?: boolean;
  63300. /**
  63301. * etc2 compression format
  63302. */
  63303. etc2?: boolean;
  63304. };
  63305. /**
  63306. * If mipmap levels should be loaded for transcoded images (Default: true)
  63307. */
  63308. loadMipmapLevels?: boolean;
  63309. /**
  63310. * Index of a single image to load (Default: all images)
  63311. */
  63312. loadSingleImage?: number;
  63313. }
  63314. /**
  63315. * Used to load .Basis files
  63316. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63317. */
  63318. export class BasisTools {
  63319. private static _IgnoreSupportedFormats;
  63320. /**
  63321. * URL to use when loading the basis transcoder
  63322. */
  63323. static JSModuleURL: string;
  63324. /**
  63325. * URL to use when loading the wasm module for the transcoder
  63326. */
  63327. static WasmModuleURL: string;
  63328. /**
  63329. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63330. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63331. * @returns internal format corresponding to the Basis format
  63332. */
  63333. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63334. private static _WorkerPromise;
  63335. private static _Worker;
  63336. private static _actionId;
  63337. private static _CreateWorkerAsync;
  63338. /**
  63339. * Transcodes a loaded image file to compressed pixel data
  63340. * @param data image data to transcode
  63341. * @param config configuration options for the transcoding
  63342. * @returns a promise resulting in the transcoded image
  63343. */
  63344. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63345. /**
  63346. * Loads a texture from the transcode result
  63347. * @param texture texture load to
  63348. * @param transcodeResult the result of transcoding the basis file to load from
  63349. */
  63350. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63351. }
  63352. }
  63353. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63354. import { Nullable } from "babylonjs/types";
  63355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63356. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63357. /**
  63358. * Loader for .basis file format
  63359. */
  63360. export class _BasisTextureLoader implements IInternalTextureLoader {
  63361. /**
  63362. * Defines whether the loader supports cascade loading the different faces.
  63363. */
  63364. readonly supportCascades: boolean;
  63365. /**
  63366. * This returns if the loader support the current file information.
  63367. * @param extension defines the file extension of the file being loaded
  63368. * @returns true if the loader can load the specified file
  63369. */
  63370. canLoad(extension: string): boolean;
  63371. /**
  63372. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63373. * @param data contains the texture data
  63374. * @param texture defines the BabylonJS internal texture
  63375. * @param createPolynomials will be true if polynomials have been requested
  63376. * @param onLoad defines the callback to trigger once the texture is ready
  63377. * @param onError defines the callback to trigger in case of error
  63378. */
  63379. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63380. /**
  63381. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63382. * @param data contains the texture data
  63383. * @param texture defines the BabylonJS internal texture
  63384. * @param callback defines the method to call once ready to upload
  63385. */
  63386. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63387. }
  63388. }
  63389. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63390. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63391. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63392. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63393. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63394. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63395. }
  63396. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63397. import { Vector2 } from "babylonjs/Maths/math.vector";
  63398. /**
  63399. * Defines the basic options interface of a TexturePacker Frame
  63400. */
  63401. export interface ITexturePackerFrame {
  63402. /**
  63403. * The frame ID
  63404. */
  63405. id: number;
  63406. /**
  63407. * The frames Scale
  63408. */
  63409. scale: Vector2;
  63410. /**
  63411. * The Frames offset
  63412. */
  63413. offset: Vector2;
  63414. }
  63415. /**
  63416. * This is a support class for frame Data on texture packer sets.
  63417. */
  63418. export class TexturePackerFrame implements ITexturePackerFrame {
  63419. /**
  63420. * The frame ID
  63421. */
  63422. id: number;
  63423. /**
  63424. * The frames Scale
  63425. */
  63426. scale: Vector2;
  63427. /**
  63428. * The Frames offset
  63429. */
  63430. offset: Vector2;
  63431. /**
  63432. * Initializes a texture package frame.
  63433. * @param id The numerical frame identifier
  63434. * @param scale Scalar Vector2 for UV frame
  63435. * @param offset Vector2 for the frame position in UV units.
  63436. * @returns TexturePackerFrame
  63437. */
  63438. constructor(id: number, scale: Vector2, offset: Vector2);
  63439. }
  63440. }
  63441. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63443. import { Scene } from "babylonjs/scene";
  63444. import { Nullable } from "babylonjs/types";
  63445. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63446. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63447. /**
  63448. * Defines the basic options interface of a TexturePacker
  63449. */
  63450. export interface ITexturePackerOptions {
  63451. /**
  63452. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63453. */
  63454. map?: string[];
  63455. /**
  63456. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63457. */
  63458. uvsIn?: string;
  63459. /**
  63460. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63461. */
  63462. uvsOut?: string;
  63463. /**
  63464. * number representing the layout style. Defaults to LAYOUT_STRIP
  63465. */
  63466. layout?: number;
  63467. /**
  63468. * number of columns if using custom column count layout(2). This defaults to 4.
  63469. */
  63470. colnum?: number;
  63471. /**
  63472. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63473. */
  63474. updateInputMeshes?: boolean;
  63475. /**
  63476. * boolean flag to dispose all the source textures. Defaults to true.
  63477. */
  63478. disposeSources?: boolean;
  63479. /**
  63480. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63481. */
  63482. fillBlanks?: boolean;
  63483. /**
  63484. * string value representing the context fill style color. Defaults to 'black'.
  63485. */
  63486. customFillColor?: string;
  63487. /**
  63488. * Width and Height Value of each Frame in the TexturePacker Sets
  63489. */
  63490. frameSize?: number;
  63491. /**
  63492. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63493. */
  63494. paddingRatio?: number;
  63495. /**
  63496. * Number that declares the fill method for the padding gutter.
  63497. */
  63498. paddingMode?: number;
  63499. /**
  63500. * If in SUBUV_COLOR padding mode what color to use.
  63501. */
  63502. paddingColor?: Color3 | Color4;
  63503. }
  63504. /**
  63505. * Defines the basic interface of a TexturePacker JSON File
  63506. */
  63507. export interface ITexturePackerJSON {
  63508. /**
  63509. * The frame ID
  63510. */
  63511. name: string;
  63512. /**
  63513. * The base64 channel data
  63514. */
  63515. sets: any;
  63516. /**
  63517. * The options of the Packer
  63518. */
  63519. options: ITexturePackerOptions;
  63520. /**
  63521. * The frame data of the Packer
  63522. */
  63523. frames: Array<number>;
  63524. }
  63525. /**
  63526. * This is a support class that generates a series of packed texture sets.
  63527. * @see https://doc.babylonjs.com/babylon101/materials
  63528. */
  63529. export class TexturePacker {
  63530. /** Packer Layout Constant 0 */
  63531. static readonly LAYOUT_STRIP: number;
  63532. /** Packer Layout Constant 1 */
  63533. static readonly LAYOUT_POWER2: number;
  63534. /** Packer Layout Constant 2 */
  63535. static readonly LAYOUT_COLNUM: number;
  63536. /** Packer Layout Constant 0 */
  63537. static readonly SUBUV_WRAP: number;
  63538. /** Packer Layout Constant 1 */
  63539. static readonly SUBUV_EXTEND: number;
  63540. /** Packer Layout Constant 2 */
  63541. static readonly SUBUV_COLOR: number;
  63542. /** The Name of the Texture Package */
  63543. name: string;
  63544. /** The scene scope of the TexturePacker */
  63545. scene: Scene;
  63546. /** The Meshes to target */
  63547. meshes: AbstractMesh[];
  63548. /** Arguments passed with the Constructor */
  63549. options: ITexturePackerOptions;
  63550. /** The promise that is started upon initialization */
  63551. promise: Nullable<Promise<TexturePacker | string>>;
  63552. /** The Container object for the channel sets that are generated */
  63553. sets: object;
  63554. /** The Container array for the frames that are generated */
  63555. frames: TexturePackerFrame[];
  63556. /** The expected number of textures the system is parsing. */
  63557. private _expecting;
  63558. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63559. private _paddingValue;
  63560. /**
  63561. * Initializes a texture package series from an array of meshes or a single mesh.
  63562. * @param name The name of the package
  63563. * @param meshes The target meshes to compose the package from
  63564. * @param options The arguments that texture packer should follow while building.
  63565. * @param scene The scene which the textures are scoped to.
  63566. * @returns TexturePacker
  63567. */
  63568. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63569. /**
  63570. * Starts the package process
  63571. * @param resolve The promises resolution function
  63572. * @returns TexturePacker
  63573. */
  63574. private _createFrames;
  63575. /**
  63576. * Calculates the Size of the Channel Sets
  63577. * @returns Vector2
  63578. */
  63579. private _calculateSize;
  63580. /**
  63581. * Calculates the UV data for the frames.
  63582. * @param baseSize the base frameSize
  63583. * @param padding the base frame padding
  63584. * @param dtSize size of the Dynamic Texture for that channel
  63585. * @param dtUnits is 1/dtSize
  63586. * @param update flag to update the input meshes
  63587. */
  63588. private _calculateMeshUVFrames;
  63589. /**
  63590. * Calculates the frames Offset.
  63591. * @param index of the frame
  63592. * @returns Vector2
  63593. */
  63594. private _getFrameOffset;
  63595. /**
  63596. * Updates a Mesh to the frame data
  63597. * @param mesh that is the target
  63598. * @param frameID or the frame index
  63599. */
  63600. private _updateMeshUV;
  63601. /**
  63602. * Updates a Meshes materials to use the texture packer channels
  63603. * @param m is the mesh to target
  63604. * @param force all channels on the packer to be set.
  63605. */
  63606. private _updateTextureReferences;
  63607. /**
  63608. * Public method to set a Mesh to a frame
  63609. * @param m that is the target
  63610. * @param frameID or the frame index
  63611. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63612. */
  63613. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63614. /**
  63615. * Starts the async promise to compile the texture packer.
  63616. * @returns Promise<void>
  63617. */
  63618. processAsync(): Promise<void>;
  63619. /**
  63620. * Disposes all textures associated with this packer
  63621. */
  63622. dispose(): void;
  63623. /**
  63624. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63625. * @param imageType is the image type to use.
  63626. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63627. */
  63628. download(imageType?: string, quality?: number): void;
  63629. /**
  63630. * Public method to load a texturePacker JSON file.
  63631. * @param data of the JSON file in string format.
  63632. */
  63633. updateFromJSON(data: string): void;
  63634. }
  63635. }
  63636. declare module "babylonjs/Materials/Textures/Packer/index" {
  63637. export * from "babylonjs/Materials/Textures/Packer/packer";
  63638. export * from "babylonjs/Materials/Textures/Packer/frame";
  63639. }
  63640. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63641. import { Scene } from "babylonjs/scene";
  63642. import { Texture } from "babylonjs/Materials/Textures/texture";
  63643. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63644. /**
  63645. * 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.
  63646. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63647. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63648. */
  63649. export class CustomProceduralTexture extends ProceduralTexture {
  63650. private _animate;
  63651. private _time;
  63652. private _config;
  63653. private _texturePath;
  63654. /**
  63655. * Instantiates a new Custom Procedural Texture.
  63656. * 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.
  63657. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63658. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63659. * @param name Define the name of the texture
  63660. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63661. * @param size Define the size of the texture to create
  63662. * @param scene Define the scene the texture belongs to
  63663. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63664. * @param generateMipMaps Define if the texture should creates mip maps or not
  63665. */
  63666. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63667. private _loadJson;
  63668. /**
  63669. * Is the texture ready to be used ? (rendered at least once)
  63670. * @returns true if ready, otherwise, false.
  63671. */
  63672. isReady(): boolean;
  63673. /**
  63674. * Render the texture to its associated render target.
  63675. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63676. */
  63677. render(useCameraPostProcess?: boolean): void;
  63678. /**
  63679. * Update the list of dependant textures samplers in the shader.
  63680. */
  63681. updateTextures(): void;
  63682. /**
  63683. * Update the uniform values of the procedural texture in the shader.
  63684. */
  63685. updateShaderUniforms(): void;
  63686. /**
  63687. * Define if the texture animates or not.
  63688. */
  63689. get animate(): boolean;
  63690. set animate(value: boolean);
  63691. }
  63692. }
  63693. declare module "babylonjs/Shaders/noise.fragment" {
  63694. /** @hidden */
  63695. export var noisePixelShader: {
  63696. name: string;
  63697. shader: string;
  63698. };
  63699. }
  63700. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63701. import { Nullable } from "babylonjs/types";
  63702. import { Scene } from "babylonjs/scene";
  63703. import { Texture } from "babylonjs/Materials/Textures/texture";
  63704. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63705. import "babylonjs/Shaders/noise.fragment";
  63706. /**
  63707. * Class used to generate noise procedural textures
  63708. */
  63709. export class NoiseProceduralTexture extends ProceduralTexture {
  63710. private _time;
  63711. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63712. brightness: number;
  63713. /** Defines the number of octaves to process */
  63714. octaves: number;
  63715. /** Defines the level of persistence (0.8 by default) */
  63716. persistence: number;
  63717. /** Gets or sets animation speed factor (default is 1) */
  63718. animationSpeedFactor: number;
  63719. /**
  63720. * Creates a new NoiseProceduralTexture
  63721. * @param name defines the name fo the texture
  63722. * @param size defines the size of the texture (default is 256)
  63723. * @param scene defines the hosting scene
  63724. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63725. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63726. */
  63727. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63728. private _updateShaderUniforms;
  63729. protected _getDefines(): string;
  63730. /** Generate the current state of the procedural texture */
  63731. render(useCameraPostProcess?: boolean): void;
  63732. /**
  63733. * Serializes this noise procedural texture
  63734. * @returns a serialized noise procedural texture object
  63735. */
  63736. serialize(): any;
  63737. /**
  63738. * Clone the texture.
  63739. * @returns the cloned texture
  63740. */
  63741. clone(): NoiseProceduralTexture;
  63742. /**
  63743. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63744. * @param parsedTexture defines parsed texture data
  63745. * @param scene defines the current scene
  63746. * @param rootUrl defines the root URL containing noise procedural texture information
  63747. * @returns a parsed NoiseProceduralTexture
  63748. */
  63749. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63750. }
  63751. }
  63752. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63753. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63754. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63755. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63756. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63757. }
  63758. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63759. import { Nullable } from "babylonjs/types";
  63760. import { Scene } from "babylonjs/scene";
  63761. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63763. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63764. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63765. /**
  63766. * Raw cube texture where the raw buffers are passed in
  63767. */
  63768. export class RawCubeTexture extends CubeTexture {
  63769. /**
  63770. * Creates a cube texture where the raw buffers are passed in.
  63771. * @param scene defines the scene the texture is attached to
  63772. * @param data defines the array of data to use to create each face
  63773. * @param size defines the size of the textures
  63774. * @param format defines the format of the data
  63775. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63776. * @param generateMipMaps defines if the engine should generate the mip levels
  63777. * @param invertY defines if data must be stored with Y axis inverted
  63778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63779. * @param compression defines the compression used (null by default)
  63780. */
  63781. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63782. /**
  63783. * Updates the raw cube texture.
  63784. * @param data defines the data to store
  63785. * @param format defines the data format
  63786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63787. * @param invertY defines if data must be stored with Y axis inverted
  63788. * @param compression defines the compression used (null by default)
  63789. * @param level defines which level of the texture to update
  63790. */
  63791. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63792. /**
  63793. * Updates a raw cube texture with RGBD encoded data.
  63794. * @param data defines the array of data [mipmap][face] to use to create each face
  63795. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63796. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63797. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63798. * @returns a promsie that resolves when the operation is complete
  63799. */
  63800. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63801. /**
  63802. * Clones the raw cube texture.
  63803. * @return a new cube texture
  63804. */
  63805. clone(): CubeTexture;
  63806. /** @hidden */
  63807. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63808. }
  63809. }
  63810. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63811. import { Scene } from "babylonjs/scene";
  63812. import { Texture } from "babylonjs/Materials/Textures/texture";
  63813. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63814. /**
  63815. * Class used to store 2D array textures containing user data
  63816. */
  63817. export class RawTexture2DArray extends Texture {
  63818. /** Gets or sets the texture format to use */
  63819. format: number;
  63820. /**
  63821. * Create a new RawTexture2DArray
  63822. * @param data defines the data of the texture
  63823. * @param width defines the width of the texture
  63824. * @param height defines the height of the texture
  63825. * @param depth defines the number of layers of the texture
  63826. * @param format defines the texture format to use
  63827. * @param scene defines the hosting scene
  63828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63829. * @param invertY defines if texture must be stored with Y axis inverted
  63830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63832. */
  63833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63834. /** Gets or sets the texture format to use */
  63835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63836. /**
  63837. * Update the texture with new data
  63838. * @param data defines the data to store in the texture
  63839. */
  63840. update(data: ArrayBufferView): void;
  63841. }
  63842. }
  63843. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63844. import { Scene } from "babylonjs/scene";
  63845. import { Texture } from "babylonjs/Materials/Textures/texture";
  63846. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63847. /**
  63848. * Class used to store 3D textures containing user data
  63849. */
  63850. export class RawTexture3D extends Texture {
  63851. /** Gets or sets the texture format to use */
  63852. format: number;
  63853. /**
  63854. * Create a new RawTexture3D
  63855. * @param data defines the data of the texture
  63856. * @param width defines the width of the texture
  63857. * @param height defines the height of the texture
  63858. * @param depth defines the depth of the texture
  63859. * @param format defines the texture format to use
  63860. * @param scene defines the hosting scene
  63861. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63862. * @param invertY defines if texture must be stored with Y axis inverted
  63863. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63864. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63865. */
  63866. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63867. /** Gets or sets the texture format to use */
  63868. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63869. /**
  63870. * Update the texture with new data
  63871. * @param data defines the data to store in the texture
  63872. */
  63873. update(data: ArrayBufferView): void;
  63874. }
  63875. }
  63876. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63877. import { Scene } from "babylonjs/scene";
  63878. import { Plane } from "babylonjs/Maths/math.plane";
  63879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63880. /**
  63881. * Creates a refraction texture used by refraction channel of the standard material.
  63882. * It is like a mirror but to see through a material.
  63883. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63884. */
  63885. export class RefractionTexture extends RenderTargetTexture {
  63886. /**
  63887. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63888. * 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.
  63889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63890. */
  63891. refractionPlane: Plane;
  63892. /**
  63893. * Define how deep under the surface we should see.
  63894. */
  63895. depth: number;
  63896. /**
  63897. * Creates a refraction texture used by refraction channel of the standard material.
  63898. * It is like a mirror but to see through a material.
  63899. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63900. * @param name Define the texture name
  63901. * @param size Define the size of the underlying texture
  63902. * @param scene Define the scene the refraction belongs to
  63903. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63904. */
  63905. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63906. /**
  63907. * Clone the refraction texture.
  63908. * @returns the cloned texture
  63909. */
  63910. clone(): RefractionTexture;
  63911. /**
  63912. * Serialize the texture to a JSON representation you could use in Parse later on
  63913. * @returns the serialized JSON representation
  63914. */
  63915. serialize(): any;
  63916. }
  63917. }
  63918. declare module "babylonjs/Materials/Textures/index" {
  63919. export * from "babylonjs/Materials/Textures/baseTexture";
  63920. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63921. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63922. export * from "babylonjs/Materials/Textures/cubeTexture";
  63923. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63924. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63925. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63926. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63927. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63928. export * from "babylonjs/Materials/Textures/internalTexture";
  63929. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63930. export * from "babylonjs/Materials/Textures/Loaders/index";
  63931. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63932. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63933. export * from "babylonjs/Materials/Textures/Packer/index";
  63934. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63935. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63936. export * from "babylonjs/Materials/Textures/rawTexture";
  63937. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63938. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63939. export * from "babylonjs/Materials/Textures/refractionTexture";
  63940. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63941. export * from "babylonjs/Materials/Textures/texture";
  63942. export * from "babylonjs/Materials/Textures/videoTexture";
  63943. }
  63944. declare module "babylonjs/Materials/Node/Enums/index" {
  63945. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63946. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63947. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63948. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63949. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63950. }
  63951. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63955. import { Mesh } from "babylonjs/Meshes/mesh";
  63956. import { Effect } from "babylonjs/Materials/effect";
  63957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63958. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63959. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63960. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63961. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63962. /**
  63963. * Block used to add support for vertex skinning (bones)
  63964. */
  63965. export class BonesBlock extends NodeMaterialBlock {
  63966. /**
  63967. * Creates a new BonesBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Initialize the block and prepare the context for build
  63973. * @param state defines the state that will be used for the build
  63974. */
  63975. initialize(state: NodeMaterialBuildState): void;
  63976. /**
  63977. * Gets the current class name
  63978. * @returns the class name
  63979. */
  63980. getClassName(): string;
  63981. /**
  63982. * Gets the matrix indices input component
  63983. */
  63984. get matricesIndices(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the matrix weights input component
  63987. */
  63988. get matricesWeights(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the extra matrix indices input component
  63991. */
  63992. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the extra matrix weights input component
  63995. */
  63996. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the world input component
  63999. */
  64000. get world(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the output component
  64003. */
  64004. get output(): NodeMaterialConnectionPoint;
  64005. autoConfigure(material: NodeMaterial): void;
  64006. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64007. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64009. protected _buildBlock(state: NodeMaterialBuildState): this;
  64010. }
  64011. }
  64012. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64019. /**
  64020. * Block used to add support for instances
  64021. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64022. */
  64023. export class InstancesBlock extends NodeMaterialBlock {
  64024. /**
  64025. * Creates a new InstancesBlock
  64026. * @param name defines the block name
  64027. */
  64028. constructor(name: string);
  64029. /**
  64030. * Gets the current class name
  64031. * @returns the class name
  64032. */
  64033. getClassName(): string;
  64034. /**
  64035. * Gets the first world row input component
  64036. */
  64037. get world0(): NodeMaterialConnectionPoint;
  64038. /**
  64039. * Gets the second world row input component
  64040. */
  64041. get world1(): NodeMaterialConnectionPoint;
  64042. /**
  64043. * Gets the third world row input component
  64044. */
  64045. get world2(): NodeMaterialConnectionPoint;
  64046. /**
  64047. * Gets the forth world row input component
  64048. */
  64049. get world3(): NodeMaterialConnectionPoint;
  64050. /**
  64051. * Gets the world input component
  64052. */
  64053. get world(): NodeMaterialConnectionPoint;
  64054. /**
  64055. * Gets the output component
  64056. */
  64057. get output(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the isntanceID component
  64060. */
  64061. get instanceID(): NodeMaterialConnectionPoint;
  64062. autoConfigure(material: NodeMaterial): void;
  64063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64064. protected _buildBlock(state: NodeMaterialBuildState): this;
  64065. }
  64066. }
  64067. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64072. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64073. import { Effect } from "babylonjs/Materials/effect";
  64074. import { Mesh } from "babylonjs/Meshes/mesh";
  64075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64077. /**
  64078. * Block used to add morph targets support to vertex shader
  64079. */
  64080. export class MorphTargetsBlock extends NodeMaterialBlock {
  64081. private _repeatableContentAnchor;
  64082. /**
  64083. * Create a new MorphTargetsBlock
  64084. * @param name defines the block name
  64085. */
  64086. constructor(name: string);
  64087. /**
  64088. * Gets the current class name
  64089. * @returns the class name
  64090. */
  64091. getClassName(): string;
  64092. /**
  64093. * Gets the position input component
  64094. */
  64095. get position(): NodeMaterialConnectionPoint;
  64096. /**
  64097. * Gets the normal input component
  64098. */
  64099. get normal(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the tangent input component
  64102. */
  64103. get tangent(): NodeMaterialConnectionPoint;
  64104. /**
  64105. * Gets the tangent input component
  64106. */
  64107. get uv(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the position output component
  64110. */
  64111. get positionOutput(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the normal output component
  64114. */
  64115. get normalOutput(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the tangent output component
  64118. */
  64119. get tangentOutput(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the tangent output component
  64122. */
  64123. get uvOutput(): NodeMaterialConnectionPoint;
  64124. initialize(state: NodeMaterialBuildState): void;
  64125. autoConfigure(material: NodeMaterial): void;
  64126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64127. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64128. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64129. protected _buildBlock(state: NodeMaterialBuildState): this;
  64130. }
  64131. }
  64132. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64136. import { Nullable } from "babylonjs/types";
  64137. import { Scene } from "babylonjs/scene";
  64138. import { Effect } from "babylonjs/Materials/effect";
  64139. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64140. import { Mesh } from "babylonjs/Meshes/mesh";
  64141. import { Light } from "babylonjs/Lights/light";
  64142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64143. /**
  64144. * Block used to get data information from a light
  64145. */
  64146. export class LightInformationBlock extends NodeMaterialBlock {
  64147. private _lightDataUniformName;
  64148. private _lightColorUniformName;
  64149. private _lightTypeDefineName;
  64150. /**
  64151. * Gets or sets the light associated with this block
  64152. */
  64153. light: Nullable<Light>;
  64154. /**
  64155. * Creates a new LightInformationBlock
  64156. * @param name defines the block name
  64157. */
  64158. constructor(name: string);
  64159. /**
  64160. * Gets the current class name
  64161. * @returns the class name
  64162. */
  64163. getClassName(): string;
  64164. /**
  64165. * Gets the world position input component
  64166. */
  64167. get worldPosition(): NodeMaterialConnectionPoint;
  64168. /**
  64169. * Gets the direction output component
  64170. */
  64171. get direction(): NodeMaterialConnectionPoint;
  64172. /**
  64173. * Gets the direction output component
  64174. */
  64175. get color(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the direction output component
  64178. */
  64179. get intensity(): NodeMaterialConnectionPoint;
  64180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64182. protected _buildBlock(state: NodeMaterialBuildState): this;
  64183. serialize(): any;
  64184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64185. }
  64186. }
  64187. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64188. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64189. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64190. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64191. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64192. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64193. }
  64194. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64199. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64200. import { Effect } from "babylonjs/Materials/effect";
  64201. import { Mesh } from "babylonjs/Meshes/mesh";
  64202. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64203. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64204. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64205. /**
  64206. * Block used to add image processing support to fragment shader
  64207. */
  64208. export class ImageProcessingBlock extends NodeMaterialBlock {
  64209. /**
  64210. * Create a new ImageProcessingBlock
  64211. * @param name defines the block name
  64212. */
  64213. constructor(name: string);
  64214. /**
  64215. * Gets the current class name
  64216. * @returns the class name
  64217. */
  64218. getClassName(): string;
  64219. /**
  64220. * Gets the color input component
  64221. */
  64222. get color(): NodeMaterialConnectionPoint;
  64223. /**
  64224. * Gets the output component
  64225. */
  64226. get output(): NodeMaterialConnectionPoint;
  64227. /**
  64228. * Initialize the block and prepare the context for build
  64229. * @param state defines the state that will be used for the build
  64230. */
  64231. initialize(state: NodeMaterialBuildState): void;
  64232. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64235. protected _buildBlock(state: NodeMaterialBuildState): this;
  64236. }
  64237. }
  64238. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64242. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64244. import { Effect } from "babylonjs/Materials/effect";
  64245. import { Mesh } from "babylonjs/Meshes/mesh";
  64246. import { Scene } from "babylonjs/scene";
  64247. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64248. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64249. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64250. /**
  64251. * Block used to pertub normals based on a normal map
  64252. */
  64253. export class PerturbNormalBlock extends NodeMaterialBlock {
  64254. private _tangentSpaceParameterName;
  64255. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64256. invertX: boolean;
  64257. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64258. invertY: boolean;
  64259. /**
  64260. * Create a new PerturbNormalBlock
  64261. * @param name defines the block name
  64262. */
  64263. constructor(name: string);
  64264. /**
  64265. * Gets the current class name
  64266. * @returns the class name
  64267. */
  64268. getClassName(): string;
  64269. /**
  64270. * Gets the world position input component
  64271. */
  64272. get worldPosition(): NodeMaterialConnectionPoint;
  64273. /**
  64274. * Gets the world normal input component
  64275. */
  64276. get worldNormal(): NodeMaterialConnectionPoint;
  64277. /**
  64278. * Gets the world tangent input component
  64279. */
  64280. get worldTangent(): NodeMaterialConnectionPoint;
  64281. /**
  64282. * Gets the uv input component
  64283. */
  64284. get uv(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the normal map color input component
  64287. */
  64288. get normalMapColor(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the strength input component
  64291. */
  64292. get strength(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the output component
  64295. */
  64296. get output(): NodeMaterialConnectionPoint;
  64297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64299. autoConfigure(material: NodeMaterial): void;
  64300. protected _buildBlock(state: NodeMaterialBuildState): this;
  64301. protected _dumpPropertiesCode(): string;
  64302. serialize(): any;
  64303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64304. }
  64305. }
  64306. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64310. /**
  64311. * Block used to discard a pixel if a value is smaller than a cutoff
  64312. */
  64313. export class DiscardBlock extends NodeMaterialBlock {
  64314. /**
  64315. * Create a new DiscardBlock
  64316. * @param name defines the block name
  64317. */
  64318. constructor(name: string);
  64319. /**
  64320. * Gets the current class name
  64321. * @returns the class name
  64322. */
  64323. getClassName(): string;
  64324. /**
  64325. * Gets the color input component
  64326. */
  64327. get value(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the cutoff input component
  64330. */
  64331. get cutoff(): NodeMaterialConnectionPoint;
  64332. protected _buildBlock(state: NodeMaterialBuildState): this;
  64333. }
  64334. }
  64335. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64336. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64338. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64339. /**
  64340. * Block used to test if the fragment shader is front facing
  64341. */
  64342. export class FrontFacingBlock extends NodeMaterialBlock {
  64343. /**
  64344. * Creates a new FrontFacingBlock
  64345. * @param name defines the block name
  64346. */
  64347. constructor(name: string);
  64348. /**
  64349. * Gets the current class name
  64350. * @returns the class name
  64351. */
  64352. getClassName(): string;
  64353. /**
  64354. * Gets the output component
  64355. */
  64356. get output(): NodeMaterialConnectionPoint;
  64357. protected _buildBlock(state: NodeMaterialBuildState): this;
  64358. }
  64359. }
  64360. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64364. /**
  64365. * Block used to get the derivative value on x and y of a given input
  64366. */
  64367. export class DerivativeBlock extends NodeMaterialBlock {
  64368. /**
  64369. * Create a new DerivativeBlock
  64370. * @param name defines the block name
  64371. */
  64372. constructor(name: string);
  64373. /**
  64374. * Gets the current class name
  64375. * @returns the class name
  64376. */
  64377. getClassName(): string;
  64378. /**
  64379. * Gets the input component
  64380. */
  64381. get input(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the derivative output on x
  64384. */
  64385. get dx(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the derivative output on y
  64388. */
  64389. get dy(): NodeMaterialConnectionPoint;
  64390. protected _buildBlock(state: NodeMaterialBuildState): this;
  64391. }
  64392. }
  64393. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64397. /**
  64398. * Block used to make gl_FragCoord available
  64399. */
  64400. export class FragCoordBlock extends NodeMaterialBlock {
  64401. /**
  64402. * Creates a new FragCoordBlock
  64403. * @param name defines the block name
  64404. */
  64405. constructor(name: string);
  64406. /**
  64407. * Gets the current class name
  64408. * @returns the class name
  64409. */
  64410. getClassName(): string;
  64411. /**
  64412. * Gets the xy component
  64413. */
  64414. get xy(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the xyz component
  64417. */
  64418. get xyz(): NodeMaterialConnectionPoint;
  64419. /**
  64420. * Gets the xyzw component
  64421. */
  64422. get xyzw(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the x component
  64425. */
  64426. get x(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the y component
  64429. */
  64430. get y(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the z component
  64433. */
  64434. get z(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the w component
  64437. */
  64438. get output(): NodeMaterialConnectionPoint;
  64439. protected writeOutputs(state: NodeMaterialBuildState): string;
  64440. protected _buildBlock(state: NodeMaterialBuildState): this;
  64441. }
  64442. }
  64443. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64447. import { Effect } from "babylonjs/Materials/effect";
  64448. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64449. import { Mesh } from "babylonjs/Meshes/mesh";
  64450. /**
  64451. * Block used to get the screen sizes
  64452. */
  64453. export class ScreenSizeBlock extends NodeMaterialBlock {
  64454. private _varName;
  64455. private _scene;
  64456. /**
  64457. * Creates a new ScreenSizeBlock
  64458. * @param name defines the block name
  64459. */
  64460. constructor(name: string);
  64461. /**
  64462. * Gets the current class name
  64463. * @returns the class name
  64464. */
  64465. getClassName(): string;
  64466. /**
  64467. * Gets the xy component
  64468. */
  64469. get xy(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the x component
  64472. */
  64473. get x(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the y component
  64476. */
  64477. get y(): NodeMaterialConnectionPoint;
  64478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64479. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64480. protected _buildBlock(state: NodeMaterialBuildState): this;
  64481. }
  64482. }
  64483. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64484. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64485. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64486. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64487. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64488. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64489. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64490. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64491. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64492. }
  64493. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64496. import { Mesh } from "babylonjs/Meshes/mesh";
  64497. import { Effect } from "babylonjs/Materials/effect";
  64498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64500. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64502. /**
  64503. * Block used to add support for scene fog
  64504. */
  64505. export class FogBlock extends NodeMaterialBlock {
  64506. private _fogDistanceName;
  64507. private _fogParameters;
  64508. /**
  64509. * Create a new FogBlock
  64510. * @param name defines the block name
  64511. */
  64512. constructor(name: string);
  64513. /**
  64514. * Gets the current class name
  64515. * @returns the class name
  64516. */
  64517. getClassName(): string;
  64518. /**
  64519. * Gets the world position input component
  64520. */
  64521. get worldPosition(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the view input component
  64524. */
  64525. get view(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the color input component
  64528. */
  64529. get input(): NodeMaterialConnectionPoint;
  64530. /**
  64531. * Gets the fog color input component
  64532. */
  64533. get fogColor(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the output component
  64536. */
  64537. get output(): NodeMaterialConnectionPoint;
  64538. autoConfigure(material: NodeMaterial): void;
  64539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64541. protected _buildBlock(state: NodeMaterialBuildState): this;
  64542. }
  64543. }
  64544. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64549. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64550. import { Effect } from "babylonjs/Materials/effect";
  64551. import { Mesh } from "babylonjs/Meshes/mesh";
  64552. import { Light } from "babylonjs/Lights/light";
  64553. import { Nullable } from "babylonjs/types";
  64554. import { Scene } from "babylonjs/scene";
  64555. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64556. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64557. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64561. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64562. /**
  64563. * Block used to add light in the fragment shader
  64564. */
  64565. export class LightBlock extends NodeMaterialBlock {
  64566. private _lightId;
  64567. /**
  64568. * Gets or sets the light associated with this block
  64569. */
  64570. light: Nullable<Light>;
  64571. /**
  64572. * Create a new LightBlock
  64573. * @param name defines the block name
  64574. */
  64575. constructor(name: string);
  64576. /**
  64577. * Gets the current class name
  64578. * @returns the class name
  64579. */
  64580. getClassName(): string;
  64581. /**
  64582. * Gets the world position input component
  64583. */
  64584. get worldPosition(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the world normal input component
  64587. */
  64588. get worldNormal(): NodeMaterialConnectionPoint;
  64589. /**
  64590. * Gets the camera (or eye) position component
  64591. */
  64592. get cameraPosition(): NodeMaterialConnectionPoint;
  64593. /**
  64594. * Gets the glossiness component
  64595. */
  64596. get glossiness(): NodeMaterialConnectionPoint;
  64597. /**
  64598. * Gets the glossinness power component
  64599. */
  64600. get glossPower(): NodeMaterialConnectionPoint;
  64601. /**
  64602. * Gets the diffuse color component
  64603. */
  64604. get diffuseColor(): NodeMaterialConnectionPoint;
  64605. /**
  64606. * Gets the specular color component
  64607. */
  64608. get specularColor(): NodeMaterialConnectionPoint;
  64609. /**
  64610. * Gets the diffuse output component
  64611. */
  64612. get diffuseOutput(): NodeMaterialConnectionPoint;
  64613. /**
  64614. * Gets the specular output component
  64615. */
  64616. get specularOutput(): NodeMaterialConnectionPoint;
  64617. /**
  64618. * Gets the shadow output component
  64619. */
  64620. get shadow(): NodeMaterialConnectionPoint;
  64621. autoConfigure(material: NodeMaterial): void;
  64622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64623. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64624. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64625. private _injectVertexCode;
  64626. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64627. serialize(): any;
  64628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64629. }
  64630. }
  64631. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64634. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64635. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64636. /**
  64637. * Block used to read a reflection texture from a sampler
  64638. */
  64639. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64640. /**
  64641. * Create a new ReflectionTextureBlock
  64642. * @param name defines the block name
  64643. */
  64644. constructor(name: string);
  64645. /**
  64646. * Gets the current class name
  64647. * @returns the class name
  64648. */
  64649. getClassName(): string;
  64650. /**
  64651. * Gets the world position input component
  64652. */
  64653. get position(): NodeMaterialConnectionPoint;
  64654. /**
  64655. * Gets the world position input component
  64656. */
  64657. get worldPosition(): NodeMaterialConnectionPoint;
  64658. /**
  64659. * Gets the world normal input component
  64660. */
  64661. get worldNormal(): NodeMaterialConnectionPoint;
  64662. /**
  64663. * Gets the world input component
  64664. */
  64665. get world(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the camera (or eye) position component
  64668. */
  64669. get cameraPosition(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the view input component
  64672. */
  64673. get view(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the rgb output component
  64676. */
  64677. get rgb(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the r output component
  64680. */
  64681. get r(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the g output component
  64684. */
  64685. get g(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the b output component
  64688. */
  64689. get b(): NodeMaterialConnectionPoint;
  64690. autoConfigure(material: NodeMaterial): void;
  64691. protected _buildBlock(state: NodeMaterialBuildState): this;
  64692. }
  64693. }
  64694. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64695. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64697. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64698. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64699. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64700. }
  64701. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64702. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64703. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64704. }
  64705. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64709. /**
  64710. * Block used to add 2 vectors
  64711. */
  64712. export class AddBlock extends NodeMaterialBlock {
  64713. /**
  64714. * Creates a new AddBlock
  64715. * @param name defines the block name
  64716. */
  64717. constructor(name: string);
  64718. /**
  64719. * Gets the current class name
  64720. * @returns the class name
  64721. */
  64722. getClassName(): string;
  64723. /**
  64724. * Gets the left operand input component
  64725. */
  64726. get left(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the right operand input component
  64729. */
  64730. get right(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the output component
  64733. */
  64734. get output(): NodeMaterialConnectionPoint;
  64735. protected _buildBlock(state: NodeMaterialBuildState): this;
  64736. }
  64737. }
  64738. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64742. /**
  64743. * Block used to scale a vector by a float
  64744. */
  64745. export class ScaleBlock extends NodeMaterialBlock {
  64746. /**
  64747. * Creates a new ScaleBlock
  64748. * @param name defines the block name
  64749. */
  64750. constructor(name: string);
  64751. /**
  64752. * Gets the current class name
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Gets the input component
  64758. */
  64759. get input(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the factor input component
  64762. */
  64763. get factor(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the output component
  64766. */
  64767. get output(): NodeMaterialConnectionPoint;
  64768. protected _buildBlock(state: NodeMaterialBuildState): this;
  64769. }
  64770. }
  64771. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64775. import { Scene } from "babylonjs/scene";
  64776. /**
  64777. * Block used to clamp a float
  64778. */
  64779. export class ClampBlock extends NodeMaterialBlock {
  64780. /** Gets or sets the minimum range */
  64781. minimum: number;
  64782. /** Gets or sets the maximum range */
  64783. maximum: number;
  64784. /**
  64785. * Creates a new ClampBlock
  64786. * @param name defines the block name
  64787. */
  64788. constructor(name: string);
  64789. /**
  64790. * Gets the current class name
  64791. * @returns the class name
  64792. */
  64793. getClassName(): string;
  64794. /**
  64795. * Gets the value input component
  64796. */
  64797. get value(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the output component
  64800. */
  64801. get output(): NodeMaterialConnectionPoint;
  64802. protected _buildBlock(state: NodeMaterialBuildState): this;
  64803. protected _dumpPropertiesCode(): string;
  64804. serialize(): any;
  64805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64806. }
  64807. }
  64808. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64812. /**
  64813. * Block used to apply a cross product between 2 vectors
  64814. */
  64815. export class CrossBlock extends NodeMaterialBlock {
  64816. /**
  64817. * Creates a new CrossBlock
  64818. * @param name defines the block name
  64819. */
  64820. constructor(name: string);
  64821. /**
  64822. * Gets the current class name
  64823. * @returns the class name
  64824. */
  64825. getClassName(): string;
  64826. /**
  64827. * Gets the left operand input component
  64828. */
  64829. get left(): NodeMaterialConnectionPoint;
  64830. /**
  64831. * Gets the right operand input component
  64832. */
  64833. get right(): NodeMaterialConnectionPoint;
  64834. /**
  64835. * Gets the output component
  64836. */
  64837. get output(): NodeMaterialConnectionPoint;
  64838. protected _buildBlock(state: NodeMaterialBuildState): this;
  64839. }
  64840. }
  64841. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64845. /**
  64846. * Block used to apply a dot product between 2 vectors
  64847. */
  64848. export class DotBlock extends NodeMaterialBlock {
  64849. /**
  64850. * Creates a new DotBlock
  64851. * @param name defines the block name
  64852. */
  64853. constructor(name: string);
  64854. /**
  64855. * Gets the current class name
  64856. * @returns the class name
  64857. */
  64858. getClassName(): string;
  64859. /**
  64860. * Gets the left operand input component
  64861. */
  64862. get left(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the right operand input component
  64865. */
  64866. get right(): NodeMaterialConnectionPoint;
  64867. /**
  64868. * Gets the output component
  64869. */
  64870. get output(): NodeMaterialConnectionPoint;
  64871. protected _buildBlock(state: NodeMaterialBuildState): this;
  64872. }
  64873. }
  64874. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64878. /**
  64879. * Block used to normalize a vector
  64880. */
  64881. export class NormalizeBlock extends NodeMaterialBlock {
  64882. /**
  64883. * Creates a new NormalizeBlock
  64884. * @param name defines the block name
  64885. */
  64886. constructor(name: string);
  64887. /**
  64888. * Gets the current class name
  64889. * @returns the class name
  64890. */
  64891. getClassName(): string;
  64892. /**
  64893. * Gets the input component
  64894. */
  64895. get input(): NodeMaterialConnectionPoint;
  64896. /**
  64897. * Gets the output component
  64898. */
  64899. get output(): NodeMaterialConnectionPoint;
  64900. protected _buildBlock(state: NodeMaterialBuildState): this;
  64901. }
  64902. }
  64903. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64907. import { Scene } from "babylonjs/scene";
  64908. /**
  64909. * Operations supported by the Trigonometry block
  64910. */
  64911. export enum TrigonometryBlockOperations {
  64912. /** Cos */
  64913. Cos = 0,
  64914. /** Sin */
  64915. Sin = 1,
  64916. /** Abs */
  64917. Abs = 2,
  64918. /** Exp */
  64919. Exp = 3,
  64920. /** Exp2 */
  64921. Exp2 = 4,
  64922. /** Round */
  64923. Round = 5,
  64924. /** Floor */
  64925. Floor = 6,
  64926. /** Ceiling */
  64927. Ceiling = 7,
  64928. /** Square root */
  64929. Sqrt = 8,
  64930. /** Log */
  64931. Log = 9,
  64932. /** Tangent */
  64933. Tan = 10,
  64934. /** Arc tangent */
  64935. ArcTan = 11,
  64936. /** Arc cosinus */
  64937. ArcCos = 12,
  64938. /** Arc sinus */
  64939. ArcSin = 13,
  64940. /** Fraction */
  64941. Fract = 14,
  64942. /** Sign */
  64943. Sign = 15,
  64944. /** To radians (from degrees) */
  64945. Radians = 16,
  64946. /** To degrees (from radians) */
  64947. Degrees = 17
  64948. }
  64949. /**
  64950. * Block used to apply trigonometry operation to floats
  64951. */
  64952. export class TrigonometryBlock extends NodeMaterialBlock {
  64953. /**
  64954. * Gets or sets the operation applied by the block
  64955. */
  64956. operation: TrigonometryBlockOperations;
  64957. /**
  64958. * Creates a new TrigonometryBlock
  64959. * @param name defines the block name
  64960. */
  64961. constructor(name: string);
  64962. /**
  64963. * Gets the current class name
  64964. * @returns the class name
  64965. */
  64966. getClassName(): string;
  64967. /**
  64968. * Gets the input component
  64969. */
  64970. get input(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the output component
  64973. */
  64974. get output(): NodeMaterialConnectionPoint;
  64975. protected _buildBlock(state: NodeMaterialBuildState): this;
  64976. serialize(): any;
  64977. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64978. protected _dumpPropertiesCode(): string;
  64979. }
  64980. }
  64981. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64985. /**
  64986. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64987. */
  64988. export class ColorMergerBlock extends NodeMaterialBlock {
  64989. /**
  64990. * Create a new ColorMergerBlock
  64991. * @param name defines the block name
  64992. */
  64993. constructor(name: string);
  64994. /**
  64995. * Gets the current class name
  64996. * @returns the class name
  64997. */
  64998. getClassName(): string;
  64999. /**
  65000. * Gets the rgb component (input)
  65001. */
  65002. get rgbIn(): NodeMaterialConnectionPoint;
  65003. /**
  65004. * Gets the r component (input)
  65005. */
  65006. get r(): NodeMaterialConnectionPoint;
  65007. /**
  65008. * Gets the g component (input)
  65009. */
  65010. get g(): NodeMaterialConnectionPoint;
  65011. /**
  65012. * Gets the b component (input)
  65013. */
  65014. get b(): NodeMaterialConnectionPoint;
  65015. /**
  65016. * Gets the a component (input)
  65017. */
  65018. get a(): NodeMaterialConnectionPoint;
  65019. /**
  65020. * Gets the rgba component (output)
  65021. */
  65022. get rgba(): NodeMaterialConnectionPoint;
  65023. /**
  65024. * Gets the rgb component (output)
  65025. */
  65026. get rgbOut(): NodeMaterialConnectionPoint;
  65027. /**
  65028. * Gets the rgb component (output)
  65029. * @deprecated Please use rgbOut instead.
  65030. */
  65031. get rgb(): NodeMaterialConnectionPoint;
  65032. protected _buildBlock(state: NodeMaterialBuildState): this;
  65033. }
  65034. }
  65035. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65039. /**
  65040. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65041. */
  65042. export class VectorSplitterBlock extends NodeMaterialBlock {
  65043. /**
  65044. * Create a new VectorSplitterBlock
  65045. * @param name defines the block name
  65046. */
  65047. constructor(name: string);
  65048. /**
  65049. * Gets the current class name
  65050. * @returns the class name
  65051. */
  65052. getClassName(): string;
  65053. /**
  65054. * Gets the xyzw component (input)
  65055. */
  65056. get xyzw(): NodeMaterialConnectionPoint;
  65057. /**
  65058. * Gets the xyz component (input)
  65059. */
  65060. get xyzIn(): NodeMaterialConnectionPoint;
  65061. /**
  65062. * Gets the xy component (input)
  65063. */
  65064. get xyIn(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the xyz component (output)
  65067. */
  65068. get xyzOut(): NodeMaterialConnectionPoint;
  65069. /**
  65070. * Gets the xy component (output)
  65071. */
  65072. get xyOut(): NodeMaterialConnectionPoint;
  65073. /**
  65074. * Gets the x component (output)
  65075. */
  65076. get x(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the y component (output)
  65079. */
  65080. get y(): NodeMaterialConnectionPoint;
  65081. /**
  65082. * Gets the z component (output)
  65083. */
  65084. get z(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the w component (output)
  65087. */
  65088. get w(): NodeMaterialConnectionPoint;
  65089. protected _inputRename(name: string): string;
  65090. protected _outputRename(name: string): string;
  65091. protected _buildBlock(state: NodeMaterialBuildState): this;
  65092. }
  65093. }
  65094. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65098. /**
  65099. * Block used to lerp between 2 values
  65100. */
  65101. export class LerpBlock extends NodeMaterialBlock {
  65102. /**
  65103. * Creates a new LerpBlock
  65104. * @param name defines the block name
  65105. */
  65106. constructor(name: string);
  65107. /**
  65108. * Gets the current class name
  65109. * @returns the class name
  65110. */
  65111. getClassName(): string;
  65112. /**
  65113. * Gets the left operand input component
  65114. */
  65115. get left(): NodeMaterialConnectionPoint;
  65116. /**
  65117. * Gets the right operand input component
  65118. */
  65119. get right(): NodeMaterialConnectionPoint;
  65120. /**
  65121. * Gets the gradient operand input component
  65122. */
  65123. get gradient(): NodeMaterialConnectionPoint;
  65124. /**
  65125. * Gets the output component
  65126. */
  65127. get output(): NodeMaterialConnectionPoint;
  65128. protected _buildBlock(state: NodeMaterialBuildState): this;
  65129. }
  65130. }
  65131. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65135. /**
  65136. * Block used to divide 2 vectors
  65137. */
  65138. export class DivideBlock extends NodeMaterialBlock {
  65139. /**
  65140. * Creates a new DivideBlock
  65141. * @param name defines the block name
  65142. */
  65143. constructor(name: string);
  65144. /**
  65145. * Gets the current class name
  65146. * @returns the class name
  65147. */
  65148. getClassName(): string;
  65149. /**
  65150. * Gets the left operand input component
  65151. */
  65152. get left(): NodeMaterialConnectionPoint;
  65153. /**
  65154. * Gets the right operand input component
  65155. */
  65156. get right(): NodeMaterialConnectionPoint;
  65157. /**
  65158. * Gets the output component
  65159. */
  65160. get output(): NodeMaterialConnectionPoint;
  65161. protected _buildBlock(state: NodeMaterialBuildState): this;
  65162. }
  65163. }
  65164. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65168. /**
  65169. * Block used to subtract 2 vectors
  65170. */
  65171. export class SubtractBlock extends NodeMaterialBlock {
  65172. /**
  65173. * Creates a new SubtractBlock
  65174. * @param name defines the block name
  65175. */
  65176. constructor(name: string);
  65177. /**
  65178. * Gets the current class name
  65179. * @returns the class name
  65180. */
  65181. getClassName(): string;
  65182. /**
  65183. * Gets the left operand input component
  65184. */
  65185. get left(): NodeMaterialConnectionPoint;
  65186. /**
  65187. * Gets the right operand input component
  65188. */
  65189. get right(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the output component
  65192. */
  65193. get output(): NodeMaterialConnectionPoint;
  65194. protected _buildBlock(state: NodeMaterialBuildState): this;
  65195. }
  65196. }
  65197. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65201. /**
  65202. * Block used to step a value
  65203. */
  65204. export class StepBlock extends NodeMaterialBlock {
  65205. /**
  65206. * Creates a new StepBlock
  65207. * @param name defines the block name
  65208. */
  65209. constructor(name: string);
  65210. /**
  65211. * Gets the current class name
  65212. * @returns the class name
  65213. */
  65214. getClassName(): string;
  65215. /**
  65216. * Gets the value operand input component
  65217. */
  65218. get value(): NodeMaterialConnectionPoint;
  65219. /**
  65220. * Gets the edge operand input component
  65221. */
  65222. get edge(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the output component
  65225. */
  65226. get output(): NodeMaterialConnectionPoint;
  65227. protected _buildBlock(state: NodeMaterialBuildState): this;
  65228. }
  65229. }
  65230. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65234. /**
  65235. * Block used to get the opposite (1 - x) of a value
  65236. */
  65237. export class OneMinusBlock extends NodeMaterialBlock {
  65238. /**
  65239. * Creates a new OneMinusBlock
  65240. * @param name defines the block name
  65241. */
  65242. constructor(name: string);
  65243. /**
  65244. * Gets the current class name
  65245. * @returns the class name
  65246. */
  65247. getClassName(): string;
  65248. /**
  65249. * Gets the input component
  65250. */
  65251. get input(): NodeMaterialConnectionPoint;
  65252. /**
  65253. * Gets the output component
  65254. */
  65255. get output(): NodeMaterialConnectionPoint;
  65256. protected _buildBlock(state: NodeMaterialBuildState): this;
  65257. }
  65258. }
  65259. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65263. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65264. /**
  65265. * Block used to get the view direction
  65266. */
  65267. export class ViewDirectionBlock extends NodeMaterialBlock {
  65268. /**
  65269. * Creates a new ViewDirectionBlock
  65270. * @param name defines the block name
  65271. */
  65272. constructor(name: string);
  65273. /**
  65274. * Gets the current class name
  65275. * @returns the class name
  65276. */
  65277. getClassName(): string;
  65278. /**
  65279. * Gets the world position component
  65280. */
  65281. get worldPosition(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the camera position component
  65284. */
  65285. get cameraPosition(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the output component
  65288. */
  65289. get output(): NodeMaterialConnectionPoint;
  65290. autoConfigure(material: NodeMaterial): void;
  65291. protected _buildBlock(state: NodeMaterialBuildState): this;
  65292. }
  65293. }
  65294. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65298. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65299. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65300. /**
  65301. * Block used to compute fresnel value
  65302. */
  65303. export class FresnelBlock extends NodeMaterialBlock {
  65304. /**
  65305. * Create a new FresnelBlock
  65306. * @param name defines the block name
  65307. */
  65308. constructor(name: string);
  65309. /**
  65310. * Gets the current class name
  65311. * @returns the class name
  65312. */
  65313. getClassName(): string;
  65314. /**
  65315. * Gets the world normal input component
  65316. */
  65317. get worldNormal(): NodeMaterialConnectionPoint;
  65318. /**
  65319. * Gets the view direction input component
  65320. */
  65321. get viewDirection(): NodeMaterialConnectionPoint;
  65322. /**
  65323. * Gets the bias input component
  65324. */
  65325. get bias(): NodeMaterialConnectionPoint;
  65326. /**
  65327. * Gets the camera (or eye) position component
  65328. */
  65329. get power(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the fresnel output component
  65332. */
  65333. get fresnel(): NodeMaterialConnectionPoint;
  65334. autoConfigure(material: NodeMaterial): void;
  65335. protected _buildBlock(state: NodeMaterialBuildState): this;
  65336. }
  65337. }
  65338. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65341. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65342. /**
  65343. * Block used to get the max of 2 values
  65344. */
  65345. export class MaxBlock extends NodeMaterialBlock {
  65346. /**
  65347. * Creates a new MaxBlock
  65348. * @param name defines the block name
  65349. */
  65350. constructor(name: string);
  65351. /**
  65352. * Gets the current class name
  65353. * @returns the class name
  65354. */
  65355. getClassName(): string;
  65356. /**
  65357. * Gets the left operand input component
  65358. */
  65359. get left(): NodeMaterialConnectionPoint;
  65360. /**
  65361. * Gets the right operand input component
  65362. */
  65363. get right(): NodeMaterialConnectionPoint;
  65364. /**
  65365. * Gets the output component
  65366. */
  65367. get output(): NodeMaterialConnectionPoint;
  65368. protected _buildBlock(state: NodeMaterialBuildState): this;
  65369. }
  65370. }
  65371. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65375. /**
  65376. * Block used to get the min of 2 values
  65377. */
  65378. export class MinBlock extends NodeMaterialBlock {
  65379. /**
  65380. * Creates a new MinBlock
  65381. * @param name defines the block name
  65382. */
  65383. constructor(name: string);
  65384. /**
  65385. * Gets the current class name
  65386. * @returns the class name
  65387. */
  65388. getClassName(): string;
  65389. /**
  65390. * Gets the left operand input component
  65391. */
  65392. get left(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the right operand input component
  65395. */
  65396. get right(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the output component
  65399. */
  65400. get output(): NodeMaterialConnectionPoint;
  65401. protected _buildBlock(state: NodeMaterialBuildState): this;
  65402. }
  65403. }
  65404. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65408. /**
  65409. * Block used to get the distance between 2 values
  65410. */
  65411. export class DistanceBlock extends NodeMaterialBlock {
  65412. /**
  65413. * Creates a new DistanceBlock
  65414. * @param name defines the block name
  65415. */
  65416. constructor(name: string);
  65417. /**
  65418. * Gets the current class name
  65419. * @returns the class name
  65420. */
  65421. getClassName(): string;
  65422. /**
  65423. * Gets the left operand input component
  65424. */
  65425. get left(): NodeMaterialConnectionPoint;
  65426. /**
  65427. * Gets the right operand input component
  65428. */
  65429. get right(): NodeMaterialConnectionPoint;
  65430. /**
  65431. * Gets the output component
  65432. */
  65433. get output(): NodeMaterialConnectionPoint;
  65434. protected _buildBlock(state: NodeMaterialBuildState): this;
  65435. }
  65436. }
  65437. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65441. /**
  65442. * Block used to get the length of a vector
  65443. */
  65444. export class LengthBlock extends NodeMaterialBlock {
  65445. /**
  65446. * Creates a new LengthBlock
  65447. * @param name defines the block name
  65448. */
  65449. constructor(name: string);
  65450. /**
  65451. * Gets the current class name
  65452. * @returns the class name
  65453. */
  65454. getClassName(): string;
  65455. /**
  65456. * Gets the value input component
  65457. */
  65458. get value(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the output component
  65461. */
  65462. get output(): NodeMaterialConnectionPoint;
  65463. protected _buildBlock(state: NodeMaterialBuildState): this;
  65464. }
  65465. }
  65466. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65470. /**
  65471. * Block used to get negative version of a value (i.e. x * -1)
  65472. */
  65473. export class NegateBlock extends NodeMaterialBlock {
  65474. /**
  65475. * Creates a new NegateBlock
  65476. * @param name defines the block name
  65477. */
  65478. constructor(name: string);
  65479. /**
  65480. * Gets the current class name
  65481. * @returns the class name
  65482. */
  65483. getClassName(): string;
  65484. /**
  65485. * Gets the value input component
  65486. */
  65487. get value(): NodeMaterialConnectionPoint;
  65488. /**
  65489. * Gets the output component
  65490. */
  65491. get output(): NodeMaterialConnectionPoint;
  65492. protected _buildBlock(state: NodeMaterialBuildState): this;
  65493. }
  65494. }
  65495. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65499. /**
  65500. * Block used to get the value of the first parameter raised to the power of the second
  65501. */
  65502. export class PowBlock extends NodeMaterialBlock {
  65503. /**
  65504. * Creates a new PowBlock
  65505. * @param name defines the block name
  65506. */
  65507. constructor(name: string);
  65508. /**
  65509. * Gets the current class name
  65510. * @returns the class name
  65511. */
  65512. getClassName(): string;
  65513. /**
  65514. * Gets the value operand input component
  65515. */
  65516. get value(): NodeMaterialConnectionPoint;
  65517. /**
  65518. * Gets the power operand input component
  65519. */
  65520. get power(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the output component
  65523. */
  65524. get output(): NodeMaterialConnectionPoint;
  65525. protected _buildBlock(state: NodeMaterialBuildState): this;
  65526. }
  65527. }
  65528. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65533. /**
  65534. * Block used to get a random number
  65535. */
  65536. export class RandomNumberBlock extends NodeMaterialBlock {
  65537. /**
  65538. * Creates a new RandomNumberBlock
  65539. * @param name defines the block name
  65540. */
  65541. constructor(name: string);
  65542. /**
  65543. * Gets the current class name
  65544. * @returns the class name
  65545. */
  65546. getClassName(): string;
  65547. /**
  65548. * Gets the seed input component
  65549. */
  65550. get seed(): NodeMaterialConnectionPoint;
  65551. /**
  65552. * Gets the output component
  65553. */
  65554. get output(): NodeMaterialConnectionPoint;
  65555. protected _buildBlock(state: NodeMaterialBuildState): this;
  65556. }
  65557. }
  65558. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65560. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65561. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65562. /**
  65563. * Block used to compute arc tangent of 2 values
  65564. */
  65565. export class ArcTan2Block extends NodeMaterialBlock {
  65566. /**
  65567. * Creates a new ArcTan2Block
  65568. * @param name defines the block name
  65569. */
  65570. constructor(name: string);
  65571. /**
  65572. * Gets the current class name
  65573. * @returns the class name
  65574. */
  65575. getClassName(): string;
  65576. /**
  65577. * Gets the x operand input component
  65578. */
  65579. get x(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the y operand input component
  65582. */
  65583. get y(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the output component
  65586. */
  65587. get output(): NodeMaterialConnectionPoint;
  65588. protected _buildBlock(state: NodeMaterialBuildState): this;
  65589. }
  65590. }
  65591. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65595. /**
  65596. * Block used to smooth step a value
  65597. */
  65598. export class SmoothStepBlock extends NodeMaterialBlock {
  65599. /**
  65600. * Creates a new SmoothStepBlock
  65601. * @param name defines the block name
  65602. */
  65603. constructor(name: string);
  65604. /**
  65605. * Gets the current class name
  65606. * @returns the class name
  65607. */
  65608. getClassName(): string;
  65609. /**
  65610. * Gets the value operand input component
  65611. */
  65612. get value(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the first edge operand input component
  65615. */
  65616. get edge0(): NodeMaterialConnectionPoint;
  65617. /**
  65618. * Gets the second edge operand input component
  65619. */
  65620. get edge1(): NodeMaterialConnectionPoint;
  65621. /**
  65622. * Gets the output component
  65623. */
  65624. get output(): NodeMaterialConnectionPoint;
  65625. protected _buildBlock(state: NodeMaterialBuildState): this;
  65626. }
  65627. }
  65628. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65632. /**
  65633. * Block used to get the reciprocal (1 / x) of a value
  65634. */
  65635. export class ReciprocalBlock extends NodeMaterialBlock {
  65636. /**
  65637. * Creates a new ReciprocalBlock
  65638. * @param name defines the block name
  65639. */
  65640. constructor(name: string);
  65641. /**
  65642. * Gets the current class name
  65643. * @returns the class name
  65644. */
  65645. getClassName(): string;
  65646. /**
  65647. * Gets the input component
  65648. */
  65649. get input(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the output component
  65652. */
  65653. get output(): NodeMaterialConnectionPoint;
  65654. protected _buildBlock(state: NodeMaterialBuildState): this;
  65655. }
  65656. }
  65657. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65661. /**
  65662. * Block used to replace a color by another one
  65663. */
  65664. export class ReplaceColorBlock extends NodeMaterialBlock {
  65665. /**
  65666. * Creates a new ReplaceColorBlock
  65667. * @param name defines the block name
  65668. */
  65669. constructor(name: string);
  65670. /**
  65671. * Gets the current class name
  65672. * @returns the class name
  65673. */
  65674. getClassName(): string;
  65675. /**
  65676. * Gets the value input component
  65677. */
  65678. get value(): NodeMaterialConnectionPoint;
  65679. /**
  65680. * Gets the reference input component
  65681. */
  65682. get reference(): NodeMaterialConnectionPoint;
  65683. /**
  65684. * Gets the distance input component
  65685. */
  65686. get distance(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the replacement input component
  65689. */
  65690. get replacement(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the output component
  65693. */
  65694. get output(): NodeMaterialConnectionPoint;
  65695. protected _buildBlock(state: NodeMaterialBuildState): this;
  65696. }
  65697. }
  65698. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65702. /**
  65703. * Block used to posterize a value
  65704. * @see https://en.wikipedia.org/wiki/Posterization
  65705. */
  65706. export class PosterizeBlock extends NodeMaterialBlock {
  65707. /**
  65708. * Creates a new PosterizeBlock
  65709. * @param name defines the block name
  65710. */
  65711. constructor(name: string);
  65712. /**
  65713. * Gets the current class name
  65714. * @returns the class name
  65715. */
  65716. getClassName(): string;
  65717. /**
  65718. * Gets the value input component
  65719. */
  65720. get value(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the steps input component
  65723. */
  65724. get steps(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the output component
  65727. */
  65728. get output(): NodeMaterialConnectionPoint;
  65729. protected _buildBlock(state: NodeMaterialBuildState): this;
  65730. }
  65731. }
  65732. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65736. import { Scene } from "babylonjs/scene";
  65737. /**
  65738. * Operations supported by the Wave block
  65739. */
  65740. export enum WaveBlockKind {
  65741. /** SawTooth */
  65742. SawTooth = 0,
  65743. /** Square */
  65744. Square = 1,
  65745. /** Triangle */
  65746. Triangle = 2
  65747. }
  65748. /**
  65749. * Block used to apply wave operation to floats
  65750. */
  65751. export class WaveBlock extends NodeMaterialBlock {
  65752. /**
  65753. * Gets or sets the kibnd of wave to be applied by the block
  65754. */
  65755. kind: WaveBlockKind;
  65756. /**
  65757. * Creates a new WaveBlock
  65758. * @param name defines the block name
  65759. */
  65760. constructor(name: string);
  65761. /**
  65762. * Gets the current class name
  65763. * @returns the class name
  65764. */
  65765. getClassName(): string;
  65766. /**
  65767. * Gets the input component
  65768. */
  65769. get input(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the output component
  65772. */
  65773. get output(): NodeMaterialConnectionPoint;
  65774. protected _buildBlock(state: NodeMaterialBuildState): this;
  65775. serialize(): any;
  65776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65777. }
  65778. }
  65779. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65783. import { Color3 } from "babylonjs/Maths/math.color";
  65784. import { Scene } from "babylonjs/scene";
  65785. /**
  65786. * Class used to store a color step for the GradientBlock
  65787. */
  65788. export class GradientBlockColorStep {
  65789. /**
  65790. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65791. */
  65792. step: number;
  65793. /**
  65794. * Gets or sets the color associated with this step
  65795. */
  65796. color: Color3;
  65797. /**
  65798. * Creates a new GradientBlockColorStep
  65799. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65800. * @param color defines the color associated with this step
  65801. */
  65802. constructor(
  65803. /**
  65804. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65805. */
  65806. step: number,
  65807. /**
  65808. * Gets or sets the color associated with this step
  65809. */
  65810. color: Color3);
  65811. }
  65812. /**
  65813. * Block used to return a color from a gradient based on an input value between 0 and 1
  65814. */
  65815. export class GradientBlock extends NodeMaterialBlock {
  65816. /**
  65817. * Gets or sets the list of color steps
  65818. */
  65819. colorSteps: GradientBlockColorStep[];
  65820. /**
  65821. * Creates a new GradientBlock
  65822. * @param name defines the block name
  65823. */
  65824. constructor(name: string);
  65825. /**
  65826. * Gets the current class name
  65827. * @returns the class name
  65828. */
  65829. getClassName(): string;
  65830. /**
  65831. * Gets the gradient input component
  65832. */
  65833. get gradient(): NodeMaterialConnectionPoint;
  65834. /**
  65835. * Gets the output component
  65836. */
  65837. get output(): NodeMaterialConnectionPoint;
  65838. private _writeColorConstant;
  65839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65840. serialize(): any;
  65841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65842. protected _dumpPropertiesCode(): string;
  65843. }
  65844. }
  65845. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65849. /**
  65850. * Block used to normalize lerp between 2 values
  65851. */
  65852. export class NLerpBlock extends NodeMaterialBlock {
  65853. /**
  65854. * Creates a new NLerpBlock
  65855. * @param name defines the block name
  65856. */
  65857. constructor(name: string);
  65858. /**
  65859. * Gets the current class name
  65860. * @returns the class name
  65861. */
  65862. getClassName(): string;
  65863. /**
  65864. * Gets the left operand input component
  65865. */
  65866. get left(): NodeMaterialConnectionPoint;
  65867. /**
  65868. * Gets the right operand input component
  65869. */
  65870. get right(): NodeMaterialConnectionPoint;
  65871. /**
  65872. * Gets the gradient operand input component
  65873. */
  65874. get gradient(): NodeMaterialConnectionPoint;
  65875. /**
  65876. * Gets the output component
  65877. */
  65878. get output(): NodeMaterialConnectionPoint;
  65879. protected _buildBlock(state: NodeMaterialBuildState): this;
  65880. }
  65881. }
  65882. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65886. import { Scene } from "babylonjs/scene";
  65887. /**
  65888. * block used to Generate a Worley Noise 3D Noise Pattern
  65889. */
  65890. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65891. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65892. manhattanDistance: boolean;
  65893. /**
  65894. * Creates a new WorleyNoise3DBlock
  65895. * @param name defines the block name
  65896. */
  65897. constructor(name: string);
  65898. /**
  65899. * Gets the current class name
  65900. * @returns the class name
  65901. */
  65902. getClassName(): string;
  65903. /**
  65904. * Gets the seed input component
  65905. */
  65906. get seed(): NodeMaterialConnectionPoint;
  65907. /**
  65908. * Gets the jitter input component
  65909. */
  65910. get jitter(): NodeMaterialConnectionPoint;
  65911. /**
  65912. * Gets the output component
  65913. */
  65914. get output(): NodeMaterialConnectionPoint;
  65915. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65916. /**
  65917. * Exposes the properties to the UI?
  65918. */
  65919. protected _dumpPropertiesCode(): string;
  65920. /**
  65921. * Exposes the properties to the Seralize?
  65922. */
  65923. serialize(): any;
  65924. /**
  65925. * Exposes the properties to the deseralize?
  65926. */
  65927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65928. }
  65929. }
  65930. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65934. /**
  65935. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65936. */
  65937. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65938. /**
  65939. * Creates a new SimplexPerlin3DBlock
  65940. * @param name defines the block name
  65941. */
  65942. constructor(name: string);
  65943. /**
  65944. * Gets the current class name
  65945. * @returns the class name
  65946. */
  65947. getClassName(): string;
  65948. /**
  65949. * Gets the seed operand input component
  65950. */
  65951. get seed(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the output component
  65954. */
  65955. get output(): NodeMaterialConnectionPoint;
  65956. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65957. }
  65958. }
  65959. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65963. /**
  65964. * Block used to blend normals
  65965. */
  65966. export class NormalBlendBlock extends NodeMaterialBlock {
  65967. /**
  65968. * Creates a new NormalBlendBlock
  65969. * @param name defines the block name
  65970. */
  65971. constructor(name: string);
  65972. /**
  65973. * Gets the current class name
  65974. * @returns the class name
  65975. */
  65976. getClassName(): string;
  65977. /**
  65978. * Gets the first input component
  65979. */
  65980. get normalMap0(): NodeMaterialConnectionPoint;
  65981. /**
  65982. * Gets the second input component
  65983. */
  65984. get normalMap1(): NodeMaterialConnectionPoint;
  65985. /**
  65986. * Gets the output component
  65987. */
  65988. get output(): NodeMaterialConnectionPoint;
  65989. protected _buildBlock(state: NodeMaterialBuildState): this;
  65990. }
  65991. }
  65992. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65995. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65996. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65997. /**
  65998. * Block used to rotate a 2d vector by a given angle
  65999. */
  66000. export class Rotate2dBlock extends NodeMaterialBlock {
  66001. /**
  66002. * Creates a new Rotate2dBlock
  66003. * @param name defines the block name
  66004. */
  66005. constructor(name: string);
  66006. /**
  66007. * Gets the current class name
  66008. * @returns the class name
  66009. */
  66010. getClassName(): string;
  66011. /**
  66012. * Gets the input vector
  66013. */
  66014. get input(): NodeMaterialConnectionPoint;
  66015. /**
  66016. * Gets the input angle
  66017. */
  66018. get angle(): NodeMaterialConnectionPoint;
  66019. /**
  66020. * Gets the output component
  66021. */
  66022. get output(): NodeMaterialConnectionPoint;
  66023. autoConfigure(material: NodeMaterial): void;
  66024. protected _buildBlock(state: NodeMaterialBuildState): this;
  66025. }
  66026. }
  66027. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66031. /**
  66032. * Block used to get the reflected vector from a direction and a normal
  66033. */
  66034. export class ReflectBlock extends NodeMaterialBlock {
  66035. /**
  66036. * Creates a new ReflectBlock
  66037. * @param name defines the block name
  66038. */
  66039. constructor(name: string);
  66040. /**
  66041. * Gets the current class name
  66042. * @returns the class name
  66043. */
  66044. getClassName(): string;
  66045. /**
  66046. * Gets the incident component
  66047. */
  66048. get incident(): NodeMaterialConnectionPoint;
  66049. /**
  66050. * Gets the normal component
  66051. */
  66052. get normal(): NodeMaterialConnectionPoint;
  66053. /**
  66054. * Gets the output component
  66055. */
  66056. get output(): NodeMaterialConnectionPoint;
  66057. protected _buildBlock(state: NodeMaterialBuildState): this;
  66058. }
  66059. }
  66060. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66064. /**
  66065. * Block used to get the refracted vector from a direction and a normal
  66066. */
  66067. export class RefractBlock extends NodeMaterialBlock {
  66068. /**
  66069. * Creates a new RefractBlock
  66070. * @param name defines the block name
  66071. */
  66072. constructor(name: string);
  66073. /**
  66074. * Gets the current class name
  66075. * @returns the class name
  66076. */
  66077. getClassName(): string;
  66078. /**
  66079. * Gets the incident component
  66080. */
  66081. get incident(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the normal component
  66084. */
  66085. get normal(): NodeMaterialConnectionPoint;
  66086. /**
  66087. * Gets the index of refraction component
  66088. */
  66089. get ior(): NodeMaterialConnectionPoint;
  66090. /**
  66091. * Gets the output component
  66092. */
  66093. get output(): NodeMaterialConnectionPoint;
  66094. protected _buildBlock(state: NodeMaterialBuildState): this;
  66095. }
  66096. }
  66097. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66101. /**
  66102. * Block used to desaturate a color
  66103. */
  66104. export class DesaturateBlock extends NodeMaterialBlock {
  66105. /**
  66106. * Creates a new DesaturateBlock
  66107. * @param name defines the block name
  66108. */
  66109. constructor(name: string);
  66110. /**
  66111. * Gets the current class name
  66112. * @returns the class name
  66113. */
  66114. getClassName(): string;
  66115. /**
  66116. * Gets the color operand input component
  66117. */
  66118. get color(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the level operand input component
  66121. */
  66122. get level(): NodeMaterialConnectionPoint;
  66123. /**
  66124. * Gets the output component
  66125. */
  66126. get output(): NodeMaterialConnectionPoint;
  66127. protected _buildBlock(state: NodeMaterialBuildState): this;
  66128. }
  66129. }
  66130. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66134. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66135. import { Nullable } from "babylonjs/types";
  66136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66137. import { Scene } from "babylonjs/scene";
  66138. /**
  66139. * Block used to implement the ambient occlusion module of the PBR material
  66140. */
  66141. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66142. /**
  66143. * Create a new AmbientOcclusionBlock
  66144. * @param name defines the block name
  66145. */
  66146. constructor(name: string);
  66147. /**
  66148. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66149. */
  66150. useAmbientInGrayScale: boolean;
  66151. /**
  66152. * Initialize the block and prepare the context for build
  66153. * @param state defines the state that will be used for the build
  66154. */
  66155. initialize(state: NodeMaterialBuildState): void;
  66156. /**
  66157. * Gets the current class name
  66158. * @returns the class name
  66159. */
  66160. getClassName(): string;
  66161. /**
  66162. * Gets the texture input component
  66163. */
  66164. get texture(): NodeMaterialConnectionPoint;
  66165. /**
  66166. * Gets the texture intensity component
  66167. */
  66168. get intensity(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the direct light intensity input component
  66171. */
  66172. get directLightIntensity(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the ambient occlusion object output component
  66175. */
  66176. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the main code of the block (fragment side)
  66179. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66180. * @returns the shader code
  66181. */
  66182. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66183. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66184. protected _buildBlock(state: NodeMaterialBuildState): this;
  66185. protected _dumpPropertiesCode(): string;
  66186. serialize(): any;
  66187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66188. }
  66189. }
  66190. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66193. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66194. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66196. import { Nullable } from "babylonjs/types";
  66197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66198. import { Mesh } from "babylonjs/Meshes/mesh";
  66199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66200. import { Effect } from "babylonjs/Materials/effect";
  66201. import { Scene } from "babylonjs/scene";
  66202. /**
  66203. * Block used to implement the reflection module of the PBR material
  66204. */
  66205. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66206. /** @hidden */
  66207. _defineLODReflectionAlpha: string;
  66208. /** @hidden */
  66209. _defineLinearSpecularReflection: string;
  66210. private _vEnvironmentIrradianceName;
  66211. /** @hidden */
  66212. _vReflectionMicrosurfaceInfosName: string;
  66213. /** @hidden */
  66214. _vReflectionInfosName: string;
  66215. /** @hidden */
  66216. _vReflectionFilteringInfoName: string;
  66217. private _scene;
  66218. /**
  66219. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66220. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66221. * It's less burden on the user side in the editor part.
  66222. */
  66223. /** @hidden */
  66224. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66225. /** @hidden */
  66226. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66227. /** @hidden */
  66228. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66229. /**
  66230. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66231. * diffuse part of the IBL.
  66232. */
  66233. useSphericalHarmonics: boolean;
  66234. /**
  66235. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66236. */
  66237. forceIrradianceInFragment: boolean;
  66238. /**
  66239. * Create a new ReflectionBlock
  66240. * @param name defines the block name
  66241. */
  66242. constructor(name: string);
  66243. /**
  66244. * Gets the current class name
  66245. * @returns the class name
  66246. */
  66247. getClassName(): string;
  66248. /**
  66249. * Gets the position input component
  66250. */
  66251. get position(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the world position input component
  66254. */
  66255. get worldPosition(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the world normal input component
  66258. */
  66259. get worldNormal(): NodeMaterialConnectionPoint;
  66260. /**
  66261. * Gets the world input component
  66262. */
  66263. get world(): NodeMaterialConnectionPoint;
  66264. /**
  66265. * Gets the camera (or eye) position component
  66266. */
  66267. get cameraPosition(): NodeMaterialConnectionPoint;
  66268. /**
  66269. * Gets the view input component
  66270. */
  66271. get view(): NodeMaterialConnectionPoint;
  66272. /**
  66273. * Gets the color input component
  66274. */
  66275. get color(): NodeMaterialConnectionPoint;
  66276. /**
  66277. * Gets the reflection object output component
  66278. */
  66279. get reflection(): NodeMaterialConnectionPoint;
  66280. /**
  66281. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66282. */
  66283. get hasTexture(): boolean;
  66284. /**
  66285. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66286. */
  66287. get reflectionColor(): string;
  66288. protected _getTexture(): Nullable<BaseTexture>;
  66289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66290. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66291. /**
  66292. * Gets the code to inject in the vertex shader
  66293. * @param state current state of the node material building
  66294. * @returns the shader code
  66295. */
  66296. handleVertexSide(state: NodeMaterialBuildState): string;
  66297. /**
  66298. * Gets the main code of the block (fragment side)
  66299. * @param state current state of the node material building
  66300. * @param normalVarName name of the existing variable corresponding to the normal
  66301. * @returns the shader code
  66302. */
  66303. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66304. protected _buildBlock(state: NodeMaterialBuildState): this;
  66305. protected _dumpPropertiesCode(): string;
  66306. serialize(): any;
  66307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66308. }
  66309. }
  66310. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66314. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66316. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66317. import { Scene } from "babylonjs/scene";
  66318. import { Nullable } from "babylonjs/types";
  66319. /**
  66320. * Block used to implement the sheen module of the PBR material
  66321. */
  66322. export class SheenBlock extends NodeMaterialBlock {
  66323. /**
  66324. * Create a new SheenBlock
  66325. * @param name defines the block name
  66326. */
  66327. constructor(name: string);
  66328. /**
  66329. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66330. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66331. * making it easier to setup and tweak the effect
  66332. */
  66333. albedoScaling: boolean;
  66334. /**
  66335. * Defines if the sheen is linked to the sheen color.
  66336. */
  66337. linkSheenWithAlbedo: boolean;
  66338. /**
  66339. * Initialize the block and prepare the context for build
  66340. * @param state defines the state that will be used for the build
  66341. */
  66342. initialize(state: NodeMaterialBuildState): void;
  66343. /**
  66344. * Gets the current class name
  66345. * @returns the class name
  66346. */
  66347. getClassName(): string;
  66348. /**
  66349. * Gets the intensity input component
  66350. */
  66351. get intensity(): NodeMaterialConnectionPoint;
  66352. /**
  66353. * Gets the color input component
  66354. */
  66355. get color(): NodeMaterialConnectionPoint;
  66356. /**
  66357. * Gets the roughness input component
  66358. */
  66359. get roughness(): NodeMaterialConnectionPoint;
  66360. /**
  66361. * Gets the sheen object output component
  66362. */
  66363. get sheen(): NodeMaterialConnectionPoint;
  66364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66365. /**
  66366. * Gets the main code of the block (fragment side)
  66367. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66368. * @returns the shader code
  66369. */
  66370. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66371. protected _buildBlock(state: NodeMaterialBuildState): this;
  66372. protected _dumpPropertiesCode(): string;
  66373. serialize(): any;
  66374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66375. }
  66376. }
  66377. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66378. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66383. import { Scene } from "babylonjs/scene";
  66384. import { Nullable } from "babylonjs/types";
  66385. import { Mesh } from "babylonjs/Meshes/mesh";
  66386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66387. import { Effect } from "babylonjs/Materials/effect";
  66388. /**
  66389. * Block used to implement the reflectivity module of the PBR material
  66390. */
  66391. export class ReflectivityBlock extends NodeMaterialBlock {
  66392. private _metallicReflectanceColor;
  66393. private _metallicF0Factor;
  66394. /** @hidden */
  66395. _vMetallicReflectanceFactorsName: string;
  66396. /**
  66397. * The property below is set by the main PBR block prior to calling methods of this class.
  66398. */
  66399. /** @hidden */
  66400. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66401. /**
  66402. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66403. */
  66404. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66405. /**
  66406. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66407. */
  66408. useMetallnessFromMetallicTextureBlue: boolean;
  66409. /**
  66410. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66411. */
  66412. useRoughnessFromMetallicTextureAlpha: boolean;
  66413. /**
  66414. * Specifies if the metallic texture contains the roughness information in its green channel.
  66415. */
  66416. useRoughnessFromMetallicTextureGreen: boolean;
  66417. /**
  66418. * Create a new ReflectivityBlock
  66419. * @param name defines the block name
  66420. */
  66421. constructor(name: string);
  66422. /**
  66423. * Initialize the block and prepare the context for build
  66424. * @param state defines the state that will be used for the build
  66425. */
  66426. initialize(state: NodeMaterialBuildState): void;
  66427. /**
  66428. * Gets the current class name
  66429. * @returns the class name
  66430. */
  66431. getClassName(): string;
  66432. /**
  66433. * Gets the metallic input component
  66434. */
  66435. get metallic(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the roughness input component
  66438. */
  66439. get roughness(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the texture input component
  66442. */
  66443. get texture(): NodeMaterialConnectionPoint;
  66444. /**
  66445. * Gets the reflectivity object output component
  66446. */
  66447. get reflectivity(): NodeMaterialConnectionPoint;
  66448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66449. /**
  66450. * Gets the main code of the block (fragment side)
  66451. * @param state current state of the node material building
  66452. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66453. * @returns the shader code
  66454. */
  66455. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66457. protected _buildBlock(state: NodeMaterialBuildState): this;
  66458. protected _dumpPropertiesCode(): string;
  66459. serialize(): any;
  66460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66461. }
  66462. }
  66463. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66464. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66469. /**
  66470. * Block used to implement the anisotropy module of the PBR material
  66471. */
  66472. export class AnisotropyBlock extends NodeMaterialBlock {
  66473. /**
  66474. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66475. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66476. * It's less burden on the user side in the editor part.
  66477. */
  66478. /** @hidden */
  66479. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66480. /** @hidden */
  66481. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66482. /**
  66483. * Create a new AnisotropyBlock
  66484. * @param name defines the block name
  66485. */
  66486. constructor(name: string);
  66487. /**
  66488. * Initialize the block and prepare the context for build
  66489. * @param state defines the state that will be used for the build
  66490. */
  66491. initialize(state: NodeMaterialBuildState): void;
  66492. /**
  66493. * Gets the current class name
  66494. * @returns the class name
  66495. */
  66496. getClassName(): string;
  66497. /**
  66498. * Gets the intensity input component
  66499. */
  66500. get intensity(): NodeMaterialConnectionPoint;
  66501. /**
  66502. * Gets the direction input component
  66503. */
  66504. get direction(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the texture input component
  66507. */
  66508. get texture(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the uv input component
  66511. */
  66512. get uv(): NodeMaterialConnectionPoint;
  66513. /**
  66514. * Gets the worldTangent input component
  66515. */
  66516. get worldTangent(): NodeMaterialConnectionPoint;
  66517. /**
  66518. * Gets the anisotropy object output component
  66519. */
  66520. get anisotropy(): NodeMaterialConnectionPoint;
  66521. private _generateTBNSpace;
  66522. /**
  66523. * Gets the main code of the block (fragment side)
  66524. * @param state current state of the node material building
  66525. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66526. * @returns the shader code
  66527. */
  66528. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66530. protected _buildBlock(state: NodeMaterialBuildState): this;
  66531. }
  66532. }
  66533. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66537. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66539. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66540. import { Nullable } from "babylonjs/types";
  66541. import { Mesh } from "babylonjs/Meshes/mesh";
  66542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66543. import { Effect } from "babylonjs/Materials/effect";
  66544. /**
  66545. * Block used to implement the clear coat module of the PBR material
  66546. */
  66547. export class ClearCoatBlock extends NodeMaterialBlock {
  66548. private _scene;
  66549. /**
  66550. * Create a new ClearCoatBlock
  66551. * @param name defines the block name
  66552. */
  66553. constructor(name: string);
  66554. /**
  66555. * Initialize the block and prepare the context for build
  66556. * @param state defines the state that will be used for the build
  66557. */
  66558. initialize(state: NodeMaterialBuildState): void;
  66559. /**
  66560. * Gets the current class name
  66561. * @returns the class name
  66562. */
  66563. getClassName(): string;
  66564. /**
  66565. * Gets the intensity input component
  66566. */
  66567. get intensity(): NodeMaterialConnectionPoint;
  66568. /**
  66569. * Gets the roughness input component
  66570. */
  66571. get roughness(): NodeMaterialConnectionPoint;
  66572. /**
  66573. * Gets the ior input component
  66574. */
  66575. get ior(): NodeMaterialConnectionPoint;
  66576. /**
  66577. * Gets the texture input component
  66578. */
  66579. get texture(): NodeMaterialConnectionPoint;
  66580. /**
  66581. * Gets the bump texture input component
  66582. */
  66583. get bumpTexture(): NodeMaterialConnectionPoint;
  66584. /**
  66585. * Gets the uv input component
  66586. */
  66587. get uv(): NodeMaterialConnectionPoint;
  66588. /**
  66589. * Gets the tint color input component
  66590. */
  66591. get tintColor(): NodeMaterialConnectionPoint;
  66592. /**
  66593. * Gets the tint "at distance" input component
  66594. */
  66595. get tintAtDistance(): NodeMaterialConnectionPoint;
  66596. /**
  66597. * Gets the tint thickness input component
  66598. */
  66599. get tintThickness(): NodeMaterialConnectionPoint;
  66600. /**
  66601. * Gets the world tangent input component
  66602. */
  66603. get worldTangent(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the clear coat object output component
  66606. */
  66607. get clearcoat(): NodeMaterialConnectionPoint;
  66608. autoConfigure(material: NodeMaterial): void;
  66609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66611. private _generateTBNSpace;
  66612. /**
  66613. * Gets the main code of the block (fragment side)
  66614. * @param state current state of the node material building
  66615. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66616. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66617. * @param worldPosVarName name of the variable holding the world position
  66618. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66619. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66620. * @param worldNormalVarName name of the variable holding the world normal
  66621. * @returns the shader code
  66622. */
  66623. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66624. protected _buildBlock(state: NodeMaterialBuildState): this;
  66625. }
  66626. }
  66627. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66631. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66633. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66634. import { Nullable } from "babylonjs/types";
  66635. /**
  66636. * Block used to implement the sub surface module of the PBR material
  66637. */
  66638. export class SubSurfaceBlock extends NodeMaterialBlock {
  66639. /**
  66640. * Create a new SubSurfaceBlock
  66641. * @param name defines the block name
  66642. */
  66643. constructor(name: string);
  66644. /**
  66645. * Stores the intensity of the different subsurface effects in the thickness texture.
  66646. * * the green channel is the translucency intensity.
  66647. * * the blue channel is the scattering intensity.
  66648. * * the alpha channel is the refraction intensity.
  66649. */
  66650. useMaskFromThicknessTexture: boolean;
  66651. /**
  66652. * Initialize the block and prepare the context for build
  66653. * @param state defines the state that will be used for the build
  66654. */
  66655. initialize(state: NodeMaterialBuildState): void;
  66656. /**
  66657. * Gets the current class name
  66658. * @returns the class name
  66659. */
  66660. getClassName(): string;
  66661. /**
  66662. * Gets the min thickness input component
  66663. */
  66664. get minThickness(): NodeMaterialConnectionPoint;
  66665. /**
  66666. * Gets the max thickness input component
  66667. */
  66668. get maxThickness(): NodeMaterialConnectionPoint;
  66669. /**
  66670. * Gets the thickness texture component
  66671. */
  66672. get thicknessTexture(): NodeMaterialConnectionPoint;
  66673. /**
  66674. * Gets the tint color input component
  66675. */
  66676. get tintColor(): NodeMaterialConnectionPoint;
  66677. /**
  66678. * Gets the translucency intensity input component
  66679. */
  66680. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66681. /**
  66682. * Gets the translucency diffusion distance input component
  66683. */
  66684. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66685. /**
  66686. * Gets the refraction object parameters
  66687. */
  66688. get refraction(): NodeMaterialConnectionPoint;
  66689. /**
  66690. * Gets the sub surface object output component
  66691. */
  66692. get subsurface(): NodeMaterialConnectionPoint;
  66693. autoConfigure(material: NodeMaterial): void;
  66694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66695. /**
  66696. * Gets the main code of the block (fragment side)
  66697. * @param state current state of the node material building
  66698. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66699. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66700. * @param worldPosVarName name of the variable holding the world position
  66701. * @returns the shader code
  66702. */
  66703. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66704. protected _buildBlock(state: NodeMaterialBuildState): this;
  66705. }
  66706. }
  66707. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66711. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66712. import { Light } from "babylonjs/Lights/light";
  66713. import { Nullable } from "babylonjs/types";
  66714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66715. import { Effect } from "babylonjs/Materials/effect";
  66716. import { Mesh } from "babylonjs/Meshes/mesh";
  66717. import { Scene } from "babylonjs/scene";
  66718. /**
  66719. * Block used to implement the PBR metallic/roughness model
  66720. */
  66721. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66722. /**
  66723. * Gets or sets the light associated with this block
  66724. */
  66725. light: Nullable<Light>;
  66726. private _lightId;
  66727. private _scene;
  66728. private _environmentBRDFTexture;
  66729. private _environmentBrdfSamplerName;
  66730. private _vNormalWName;
  66731. private _invertNormalName;
  66732. /**
  66733. * Create a new ReflectionBlock
  66734. * @param name defines the block name
  66735. */
  66736. constructor(name: string);
  66737. /**
  66738. * Intensity of the direct lights e.g. the four lights available in your scene.
  66739. * This impacts both the direct diffuse and specular highlights.
  66740. */
  66741. directIntensity: number;
  66742. /**
  66743. * Intensity of the environment e.g. how much the environment will light the object
  66744. * either through harmonics for rough material or through the refelction for shiny ones.
  66745. */
  66746. environmentIntensity: number;
  66747. /**
  66748. * This is a special control allowing the reduction of the specular highlights coming from the
  66749. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66750. */
  66751. specularIntensity: number;
  66752. /**
  66753. * Defines the falloff type used in this material.
  66754. * It by default is Physical.
  66755. */
  66756. lightFalloff: number;
  66757. /**
  66758. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66759. */
  66760. useAlphaFromAlbedoTexture: boolean;
  66761. /**
  66762. * Specifies that alpha test should be used
  66763. */
  66764. useAlphaTest: boolean;
  66765. /**
  66766. * Defines the alpha limits in alpha test mode.
  66767. */
  66768. alphaTestCutoff: number;
  66769. /**
  66770. * Specifies that alpha blending should be used
  66771. */
  66772. useAlphaBlending: boolean;
  66773. /**
  66774. * Defines if the alpha value should be determined via the rgb values.
  66775. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66776. */
  66777. opacityRGB: boolean;
  66778. /**
  66779. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66780. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66781. */
  66782. useRadianceOverAlpha: boolean;
  66783. /**
  66784. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66785. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66786. */
  66787. useSpecularOverAlpha: boolean;
  66788. /**
  66789. * Enables specular anti aliasing in the PBR shader.
  66790. * It will both interacts on the Geometry for analytical and IBL lighting.
  66791. * It also prefilter the roughness map based on the bump values.
  66792. */
  66793. enableSpecularAntiAliasing: boolean;
  66794. /**
  66795. * Enables realtime filtering on the texture.
  66796. */
  66797. realTimeFiltering: boolean;
  66798. /**
  66799. * Quality switch for realtime filtering
  66800. */
  66801. realTimeFilteringQuality: number;
  66802. /**
  66803. * Defines if the material uses energy conservation.
  66804. */
  66805. useEnergyConservation: boolean;
  66806. /**
  66807. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66808. * too much the area relying on ambient texture to define their ambient occlusion.
  66809. */
  66810. useRadianceOcclusion: boolean;
  66811. /**
  66812. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66813. * makes the reflect vector face the model (under horizon).
  66814. */
  66815. useHorizonOcclusion: boolean;
  66816. /**
  66817. * If set to true, no lighting calculations will be applied.
  66818. */
  66819. unlit: boolean;
  66820. /**
  66821. * Force normal to face away from face.
  66822. */
  66823. forceNormalForward: boolean;
  66824. /**
  66825. * Defines the material debug mode.
  66826. * It helps seeing only some components of the material while troubleshooting.
  66827. */
  66828. debugMode: number;
  66829. /**
  66830. * Specify from where on screen the debug mode should start.
  66831. * The value goes from -1 (full screen) to 1 (not visible)
  66832. * It helps with side by side comparison against the final render
  66833. * This defaults to 0
  66834. */
  66835. debugLimit: number;
  66836. /**
  66837. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66838. * You can use the factor to better multiply the final value.
  66839. */
  66840. debugFactor: number;
  66841. /**
  66842. * Initialize the block and prepare the context for build
  66843. * @param state defines the state that will be used for the build
  66844. */
  66845. initialize(state: NodeMaterialBuildState): void;
  66846. /**
  66847. * Gets the current class name
  66848. * @returns the class name
  66849. */
  66850. getClassName(): string;
  66851. /**
  66852. * Gets the world position input component
  66853. */
  66854. get worldPosition(): NodeMaterialConnectionPoint;
  66855. /**
  66856. * Gets the world normal input component
  66857. */
  66858. get worldNormal(): NodeMaterialConnectionPoint;
  66859. /**
  66860. * Gets the perturbed normal input component
  66861. */
  66862. get perturbedNormal(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the camera position input component
  66865. */
  66866. get cameraPosition(): NodeMaterialConnectionPoint;
  66867. /**
  66868. * Gets the base color input component
  66869. */
  66870. get baseColor(): NodeMaterialConnectionPoint;
  66871. /**
  66872. * Gets the opacity texture input component
  66873. */
  66874. get opacityTexture(): NodeMaterialConnectionPoint;
  66875. /**
  66876. * Gets the ambient color input component
  66877. */
  66878. get ambientColor(): NodeMaterialConnectionPoint;
  66879. /**
  66880. * Gets the reflectivity object parameters
  66881. */
  66882. get reflectivity(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the ambient occlusion object parameters
  66885. */
  66886. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the reflection object parameters
  66889. */
  66890. get reflection(): NodeMaterialConnectionPoint;
  66891. /**
  66892. * Gets the sheen object parameters
  66893. */
  66894. get sheen(): NodeMaterialConnectionPoint;
  66895. /**
  66896. * Gets the clear coat object parameters
  66897. */
  66898. get clearcoat(): NodeMaterialConnectionPoint;
  66899. /**
  66900. * Gets the sub surface object parameters
  66901. */
  66902. get subsurface(): NodeMaterialConnectionPoint;
  66903. /**
  66904. * Gets the anisotropy object parameters
  66905. */
  66906. get anisotropy(): NodeMaterialConnectionPoint;
  66907. /**
  66908. * Gets the ambient output component
  66909. */
  66910. get ambient(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the diffuse output component
  66913. */
  66914. get diffuse(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the specular output component
  66917. */
  66918. get specular(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the sheen output component
  66921. */
  66922. get sheenDir(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the clear coat output component
  66925. */
  66926. get clearcoatDir(): NodeMaterialConnectionPoint;
  66927. /**
  66928. * Gets the indirect diffuse output component
  66929. */
  66930. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the indirect specular output component
  66933. */
  66934. get specularIndirect(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the indirect sheen output component
  66937. */
  66938. get sheenIndirect(): NodeMaterialConnectionPoint;
  66939. /**
  66940. * Gets the indirect clear coat output component
  66941. */
  66942. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the refraction output component
  66945. */
  66946. get refraction(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the global lighting output component
  66949. */
  66950. get lighting(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the shadow output component
  66953. */
  66954. get shadow(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the alpha output component
  66957. */
  66958. get alpha(): NodeMaterialConnectionPoint;
  66959. autoConfigure(material: NodeMaterial): void;
  66960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66961. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66963. private _injectVertexCode;
  66964. /**
  66965. * Gets the code corresponding to the albedo/opacity module
  66966. * @returns the shader code
  66967. */
  66968. getAlbedoOpacityCode(): string;
  66969. protected _buildBlock(state: NodeMaterialBuildState): this;
  66970. protected _dumpPropertiesCode(): string;
  66971. serialize(): any;
  66972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66973. }
  66974. }
  66975. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66976. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66977. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66978. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66979. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66980. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66981. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66982. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66983. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66984. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66985. }
  66986. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66987. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66988. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66989. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66990. }
  66991. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66995. /**
  66996. * Block used to compute value of one parameter modulo another
  66997. */
  66998. export class ModBlock extends NodeMaterialBlock {
  66999. /**
  67000. * Creates a new ModBlock
  67001. * @param name defines the block name
  67002. */
  67003. constructor(name: string);
  67004. /**
  67005. * Gets the current class name
  67006. * @returns the class name
  67007. */
  67008. getClassName(): string;
  67009. /**
  67010. * Gets the left operand input component
  67011. */
  67012. get left(): NodeMaterialConnectionPoint;
  67013. /**
  67014. * Gets the right operand input component
  67015. */
  67016. get right(): NodeMaterialConnectionPoint;
  67017. /**
  67018. * Gets the output component
  67019. */
  67020. get output(): NodeMaterialConnectionPoint;
  67021. protected _buildBlock(state: NodeMaterialBuildState): this;
  67022. }
  67023. }
  67024. declare module "babylonjs/Materials/Node/Blocks/index" {
  67025. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67026. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67027. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67028. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67029. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67030. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67031. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67032. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67033. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67034. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67035. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67036. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67037. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67038. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67039. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67040. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67041. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67042. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67043. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67044. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67045. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67046. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67047. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67048. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67049. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67050. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67051. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67052. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67053. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67054. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67055. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67056. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67057. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67058. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67059. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67060. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67061. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67062. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67063. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67064. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67065. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67066. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67067. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67068. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67069. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67070. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67071. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67072. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67073. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67074. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67075. }
  67076. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67077. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67078. }
  67079. declare module "babylonjs/Materials/Node/index" {
  67080. export * from "babylonjs/Materials/Node/Enums/index";
  67081. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67082. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67083. export * from "babylonjs/Materials/Node/nodeMaterial";
  67084. export * from "babylonjs/Materials/Node/Blocks/index";
  67085. export * from "babylonjs/Materials/Node/Optimizers/index";
  67086. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67087. }
  67088. declare module "babylonjs/Materials/index" {
  67089. export * from "babylonjs/Materials/Background/index";
  67090. export * from "babylonjs/Materials/colorCurves";
  67091. export * from "babylonjs/Materials/iEffectFallbacks";
  67092. export * from "babylonjs/Materials/effectFallbacks";
  67093. export * from "babylonjs/Materials/effect";
  67094. export * from "babylonjs/Materials/fresnelParameters";
  67095. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67096. export * from "babylonjs/Materials/material";
  67097. export * from "babylonjs/Materials/materialDefines";
  67098. export * from "babylonjs/Materials/materialHelper";
  67099. export * from "babylonjs/Materials/multiMaterial";
  67100. export * from "babylonjs/Materials/PBR/index";
  67101. export * from "babylonjs/Materials/pushMaterial";
  67102. export * from "babylonjs/Materials/shaderMaterial";
  67103. export * from "babylonjs/Materials/standardMaterial";
  67104. export * from "babylonjs/Materials/Textures/index";
  67105. export * from "babylonjs/Materials/uniformBuffer";
  67106. export * from "babylonjs/Materials/materialFlags";
  67107. export * from "babylonjs/Materials/Node/index";
  67108. export * from "babylonjs/Materials/effectRenderer";
  67109. export * from "babylonjs/Materials/shadowDepthWrapper";
  67110. }
  67111. declare module "babylonjs/Maths/index" {
  67112. export * from "babylonjs/Maths/math.scalar";
  67113. export * from "babylonjs/Maths/math";
  67114. export * from "babylonjs/Maths/sphericalPolynomial";
  67115. }
  67116. declare module "babylonjs/Misc/workerPool" {
  67117. import { IDisposable } from "babylonjs/scene";
  67118. /**
  67119. * Helper class to push actions to a pool of workers.
  67120. */
  67121. export class WorkerPool implements IDisposable {
  67122. private _workerInfos;
  67123. private _pendingActions;
  67124. /**
  67125. * Constructor
  67126. * @param workers Array of workers to use for actions
  67127. */
  67128. constructor(workers: Array<Worker>);
  67129. /**
  67130. * Terminates all workers and clears any pending actions.
  67131. */
  67132. dispose(): void;
  67133. /**
  67134. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67135. * pended until a worker has completed its action.
  67136. * @param action The action to perform. Call onComplete when the action is complete.
  67137. */
  67138. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67139. private _execute;
  67140. }
  67141. }
  67142. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67143. import { IDisposable } from "babylonjs/scene";
  67144. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67145. /**
  67146. * Configuration for Draco compression
  67147. */
  67148. export interface IDracoCompressionConfiguration {
  67149. /**
  67150. * Configuration for the decoder.
  67151. */
  67152. decoder: {
  67153. /**
  67154. * The url to the WebAssembly module.
  67155. */
  67156. wasmUrl?: string;
  67157. /**
  67158. * The url to the WebAssembly binary.
  67159. */
  67160. wasmBinaryUrl?: string;
  67161. /**
  67162. * The url to the fallback JavaScript module.
  67163. */
  67164. fallbackUrl?: string;
  67165. };
  67166. }
  67167. /**
  67168. * Draco compression (https://google.github.io/draco/)
  67169. *
  67170. * This class wraps the Draco module.
  67171. *
  67172. * **Encoder**
  67173. *
  67174. * The encoder is not currently implemented.
  67175. *
  67176. * **Decoder**
  67177. *
  67178. * 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.
  67179. *
  67180. * To update the configuration, use the following code:
  67181. * ```javascript
  67182. * DracoCompression.Configuration = {
  67183. * decoder: {
  67184. * wasmUrl: "<url to the WebAssembly library>",
  67185. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67186. * fallbackUrl: "<url to the fallback JavaScript library>",
  67187. * }
  67188. * };
  67189. * ```
  67190. *
  67191. * 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.
  67192. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67193. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67194. *
  67195. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67196. * ```javascript
  67197. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67198. * ```
  67199. *
  67200. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67201. */
  67202. export class DracoCompression implements IDisposable {
  67203. private _workerPoolPromise?;
  67204. private _decoderModulePromise?;
  67205. /**
  67206. * The configuration. Defaults to the following urls:
  67207. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67208. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67209. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67210. */
  67211. static Configuration: IDracoCompressionConfiguration;
  67212. /**
  67213. * Returns true if the decoder configuration is available.
  67214. */
  67215. static get DecoderAvailable(): boolean;
  67216. /**
  67217. * Default number of workers to create when creating the draco compression object.
  67218. */
  67219. static DefaultNumWorkers: number;
  67220. private static GetDefaultNumWorkers;
  67221. private static _Default;
  67222. /**
  67223. * Default instance for the draco compression object.
  67224. */
  67225. static get Default(): DracoCompression;
  67226. /**
  67227. * Constructor
  67228. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67229. */
  67230. constructor(numWorkers?: number);
  67231. /**
  67232. * Stop all async operations and release resources.
  67233. */
  67234. dispose(): void;
  67235. /**
  67236. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67237. * @returns a promise that resolves when ready
  67238. */
  67239. whenReadyAsync(): Promise<void>;
  67240. /**
  67241. * Decode Draco compressed mesh data to vertex data.
  67242. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67243. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67244. * @returns A promise that resolves with the decoded vertex data
  67245. */
  67246. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67247. [kind: string]: number;
  67248. }): Promise<VertexData>;
  67249. }
  67250. }
  67251. declare module "babylonjs/Meshes/Compression/index" {
  67252. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67253. }
  67254. declare module "babylonjs/Meshes/csg" {
  67255. import { Nullable } from "babylonjs/types";
  67256. import { Scene } from "babylonjs/scene";
  67257. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67258. import { Mesh } from "babylonjs/Meshes/mesh";
  67259. import { Material } from "babylonjs/Materials/material";
  67260. /**
  67261. * Class for building Constructive Solid Geometry
  67262. */
  67263. export class CSG {
  67264. private polygons;
  67265. /**
  67266. * The world matrix
  67267. */
  67268. matrix: Matrix;
  67269. /**
  67270. * Stores the position
  67271. */
  67272. position: Vector3;
  67273. /**
  67274. * Stores the rotation
  67275. */
  67276. rotation: Vector3;
  67277. /**
  67278. * Stores the rotation quaternion
  67279. */
  67280. rotationQuaternion: Nullable<Quaternion>;
  67281. /**
  67282. * Stores the scaling vector
  67283. */
  67284. scaling: Vector3;
  67285. /**
  67286. * Convert the Mesh to CSG
  67287. * @param mesh The Mesh to convert to CSG
  67288. * @returns A new CSG from the Mesh
  67289. */
  67290. static FromMesh(mesh: Mesh): CSG;
  67291. /**
  67292. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67293. * @param polygons Polygons used to construct a CSG solid
  67294. */
  67295. private static FromPolygons;
  67296. /**
  67297. * Clones, or makes a deep copy, of the CSG
  67298. * @returns A new CSG
  67299. */
  67300. clone(): CSG;
  67301. /**
  67302. * Unions this CSG with another CSG
  67303. * @param csg The CSG to union against this CSG
  67304. * @returns The unioned CSG
  67305. */
  67306. union(csg: CSG): CSG;
  67307. /**
  67308. * Unions this CSG with another CSG in place
  67309. * @param csg The CSG to union against this CSG
  67310. */
  67311. unionInPlace(csg: CSG): void;
  67312. /**
  67313. * Subtracts this CSG with another CSG
  67314. * @param csg The CSG to subtract against this CSG
  67315. * @returns A new CSG
  67316. */
  67317. subtract(csg: CSG): CSG;
  67318. /**
  67319. * Subtracts this CSG with another CSG in place
  67320. * @param csg The CSG to subtact against this CSG
  67321. */
  67322. subtractInPlace(csg: CSG): void;
  67323. /**
  67324. * Intersect this CSG with another CSG
  67325. * @param csg The CSG to intersect against this CSG
  67326. * @returns A new CSG
  67327. */
  67328. intersect(csg: CSG): CSG;
  67329. /**
  67330. * Intersects this CSG with another CSG in place
  67331. * @param csg The CSG to intersect against this CSG
  67332. */
  67333. intersectInPlace(csg: CSG): void;
  67334. /**
  67335. * Return a new CSG solid with solid and empty space switched. This solid is
  67336. * not modified.
  67337. * @returns A new CSG solid with solid and empty space switched
  67338. */
  67339. inverse(): CSG;
  67340. /**
  67341. * Inverses the CSG in place
  67342. */
  67343. inverseInPlace(): void;
  67344. /**
  67345. * This is used to keep meshes transformations so they can be restored
  67346. * when we build back a Babylon Mesh
  67347. * NB : All CSG operations are performed in world coordinates
  67348. * @param csg The CSG to copy the transform attributes from
  67349. * @returns This CSG
  67350. */
  67351. copyTransformAttributes(csg: CSG): CSG;
  67352. /**
  67353. * Build Raw mesh from CSG
  67354. * Coordinates here are in world space
  67355. * @param name The name of the mesh geometry
  67356. * @param scene The Scene
  67357. * @param keepSubMeshes Specifies if the submeshes should be kept
  67358. * @returns A new Mesh
  67359. */
  67360. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67361. /**
  67362. * Build Mesh from CSG taking material and transforms into account
  67363. * @param name The name of the Mesh
  67364. * @param material The material of the Mesh
  67365. * @param scene The Scene
  67366. * @param keepSubMeshes Specifies if submeshes should be kept
  67367. * @returns The new Mesh
  67368. */
  67369. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67370. }
  67371. }
  67372. declare module "babylonjs/Meshes/trailMesh" {
  67373. import { Mesh } from "babylonjs/Meshes/mesh";
  67374. import { Scene } from "babylonjs/scene";
  67375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67376. /**
  67377. * Class used to create a trail following a mesh
  67378. */
  67379. export class TrailMesh extends Mesh {
  67380. private _generator;
  67381. private _autoStart;
  67382. private _running;
  67383. private _diameter;
  67384. private _length;
  67385. private _sectionPolygonPointsCount;
  67386. private _sectionVectors;
  67387. private _sectionNormalVectors;
  67388. private _beforeRenderObserver;
  67389. /**
  67390. * @constructor
  67391. * @param name The value used by scene.getMeshByName() to do a lookup.
  67392. * @param generator The mesh or transform node to generate a trail.
  67393. * @param scene The scene to add this mesh to.
  67394. * @param diameter Diameter of trailing mesh. Default is 1.
  67395. * @param length Length of trailing mesh. Default is 60.
  67396. * @param autoStart Automatically start trailing mesh. Default true.
  67397. */
  67398. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67399. /**
  67400. * "TrailMesh"
  67401. * @returns "TrailMesh"
  67402. */
  67403. getClassName(): string;
  67404. private _createMesh;
  67405. /**
  67406. * Start trailing mesh.
  67407. */
  67408. start(): void;
  67409. /**
  67410. * Stop trailing mesh.
  67411. */
  67412. stop(): void;
  67413. /**
  67414. * Update trailing mesh geometry.
  67415. */
  67416. update(): void;
  67417. /**
  67418. * Returns a new TrailMesh object.
  67419. * @param name is a string, the name given to the new mesh
  67420. * @param newGenerator use new generator object for cloned trail mesh
  67421. * @returns a new mesh
  67422. */
  67423. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67424. /**
  67425. * Serializes this trail mesh
  67426. * @param serializationObject object to write serialization to
  67427. */
  67428. serialize(serializationObject: any): void;
  67429. /**
  67430. * Parses a serialized trail mesh
  67431. * @param parsedMesh the serialized mesh
  67432. * @param scene the scene to create the trail mesh in
  67433. * @returns the created trail mesh
  67434. */
  67435. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67436. }
  67437. }
  67438. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67439. import { Nullable } from "babylonjs/types";
  67440. import { Scene } from "babylonjs/scene";
  67441. import { Vector4 } from "babylonjs/Maths/math.vector";
  67442. import { Color4 } from "babylonjs/Maths/math.color";
  67443. import { Mesh } from "babylonjs/Meshes/mesh";
  67444. /**
  67445. * Class containing static functions to help procedurally build meshes
  67446. */
  67447. export class TiledBoxBuilder {
  67448. /**
  67449. * Creates a box mesh
  67450. * 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)
  67451. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67455. * @param name defines the name of the mesh
  67456. * @param options defines the options used to create the mesh
  67457. * @param scene defines the hosting scene
  67458. * @returns the box mesh
  67459. */
  67460. static CreateTiledBox(name: string, options: {
  67461. pattern?: number;
  67462. width?: number;
  67463. height?: number;
  67464. depth?: number;
  67465. tileSize?: number;
  67466. tileWidth?: number;
  67467. tileHeight?: number;
  67468. alignHorizontal?: number;
  67469. alignVertical?: number;
  67470. faceUV?: Vector4[];
  67471. faceColors?: Color4[];
  67472. sideOrientation?: number;
  67473. updatable?: boolean;
  67474. }, scene?: Nullable<Scene>): Mesh;
  67475. }
  67476. }
  67477. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67478. import { Vector4 } from "babylonjs/Maths/math.vector";
  67479. import { Mesh } from "babylonjs/Meshes/mesh";
  67480. /**
  67481. * Class containing static functions to help procedurally build meshes
  67482. */
  67483. export class TorusKnotBuilder {
  67484. /**
  67485. * Creates a torus knot mesh
  67486. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67487. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67488. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67489. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67493. * @param name defines the name of the mesh
  67494. * @param options defines the options used to create the mesh
  67495. * @param scene defines the hosting scene
  67496. * @returns the torus knot mesh
  67497. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67498. */
  67499. static CreateTorusKnot(name: string, options: {
  67500. radius?: number;
  67501. tube?: number;
  67502. radialSegments?: number;
  67503. tubularSegments?: number;
  67504. p?: number;
  67505. q?: number;
  67506. updatable?: boolean;
  67507. sideOrientation?: number;
  67508. frontUVs?: Vector4;
  67509. backUVs?: Vector4;
  67510. }, scene: any): Mesh;
  67511. }
  67512. }
  67513. declare module "babylonjs/Meshes/polygonMesh" {
  67514. import { Scene } from "babylonjs/scene";
  67515. import { Vector2 } from "babylonjs/Maths/math.vector";
  67516. import { Mesh } from "babylonjs/Meshes/mesh";
  67517. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67518. import { Path2 } from "babylonjs/Maths/math.path";
  67519. /**
  67520. * Polygon
  67521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67522. */
  67523. export class Polygon {
  67524. /**
  67525. * Creates a rectangle
  67526. * @param xmin bottom X coord
  67527. * @param ymin bottom Y coord
  67528. * @param xmax top X coord
  67529. * @param ymax top Y coord
  67530. * @returns points that make the resulting rectation
  67531. */
  67532. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67533. /**
  67534. * Creates a circle
  67535. * @param radius radius of circle
  67536. * @param cx scale in x
  67537. * @param cy scale in y
  67538. * @param numberOfSides number of sides that make up the circle
  67539. * @returns points that make the resulting circle
  67540. */
  67541. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67542. /**
  67543. * Creates a polygon from input string
  67544. * @param input Input polygon data
  67545. * @returns the parsed points
  67546. */
  67547. static Parse(input: string): Vector2[];
  67548. /**
  67549. * Starts building a polygon from x and y coordinates
  67550. * @param x x coordinate
  67551. * @param y y coordinate
  67552. * @returns the started path2
  67553. */
  67554. static StartingAt(x: number, y: number): Path2;
  67555. }
  67556. /**
  67557. * Builds a polygon
  67558. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67559. */
  67560. export class PolygonMeshBuilder {
  67561. private _points;
  67562. private _outlinepoints;
  67563. private _holes;
  67564. private _name;
  67565. private _scene;
  67566. private _epoints;
  67567. private _eholes;
  67568. private _addToepoint;
  67569. /**
  67570. * Babylon reference to the earcut plugin.
  67571. */
  67572. bjsEarcut: any;
  67573. /**
  67574. * Creates a PolygonMeshBuilder
  67575. * @param name name of the builder
  67576. * @param contours Path of the polygon
  67577. * @param scene scene to add to when creating the mesh
  67578. * @param earcutInjection can be used to inject your own earcut reference
  67579. */
  67580. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67581. /**
  67582. * Adds a whole within the polygon
  67583. * @param hole Array of points defining the hole
  67584. * @returns this
  67585. */
  67586. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67587. /**
  67588. * Creates the polygon
  67589. * @param updatable If the mesh should be updatable
  67590. * @param depth The depth of the mesh created
  67591. * @returns the created mesh
  67592. */
  67593. build(updatable?: boolean, depth?: number): Mesh;
  67594. /**
  67595. * Creates the polygon
  67596. * @param depth The depth of the mesh created
  67597. * @returns the created VertexData
  67598. */
  67599. buildVertexData(depth?: number): VertexData;
  67600. /**
  67601. * Adds a side to the polygon
  67602. * @param positions points that make the polygon
  67603. * @param normals normals of the polygon
  67604. * @param uvs uvs of the polygon
  67605. * @param indices indices of the polygon
  67606. * @param bounds bounds of the polygon
  67607. * @param points points of the polygon
  67608. * @param depth depth of the polygon
  67609. * @param flip flip of the polygon
  67610. */
  67611. private addSide;
  67612. }
  67613. }
  67614. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67615. import { Scene } from "babylonjs/scene";
  67616. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67617. import { Color4 } from "babylonjs/Maths/math.color";
  67618. import { Mesh } from "babylonjs/Meshes/mesh";
  67619. import { Nullable } from "babylonjs/types";
  67620. /**
  67621. * Class containing static functions to help procedurally build meshes
  67622. */
  67623. export class PolygonBuilder {
  67624. /**
  67625. * Creates a polygon mesh
  67626. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67627. * * 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
  67628. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67631. * * Remember you can only change the shape positions, not their number when updating a polygon
  67632. * @param name defines the name of the mesh
  67633. * @param options defines the options used to create the mesh
  67634. * @param scene defines the hosting scene
  67635. * @param earcutInjection can be used to inject your own earcut reference
  67636. * @returns the polygon mesh
  67637. */
  67638. static CreatePolygon(name: string, options: {
  67639. shape: Vector3[];
  67640. holes?: Vector3[][];
  67641. depth?: number;
  67642. faceUV?: Vector4[];
  67643. faceColors?: Color4[];
  67644. updatable?: boolean;
  67645. sideOrientation?: number;
  67646. frontUVs?: Vector4;
  67647. backUVs?: Vector4;
  67648. wrap?: boolean;
  67649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67650. /**
  67651. * Creates an extruded polygon mesh, with depth in the Y direction.
  67652. * * 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)
  67653. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67654. * @param name defines the name of the mesh
  67655. * @param options defines the options used to create the mesh
  67656. * @param scene defines the hosting scene
  67657. * @param earcutInjection can be used to inject your own earcut reference
  67658. * @returns the polygon mesh
  67659. */
  67660. static ExtrudePolygon(name: string, options: {
  67661. shape: Vector3[];
  67662. holes?: Vector3[][];
  67663. depth?: number;
  67664. faceUV?: Vector4[];
  67665. faceColors?: Color4[];
  67666. updatable?: boolean;
  67667. sideOrientation?: number;
  67668. frontUVs?: Vector4;
  67669. backUVs?: Vector4;
  67670. wrap?: boolean;
  67671. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67672. }
  67673. }
  67674. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67675. import { Scene } from "babylonjs/scene";
  67676. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67677. import { Mesh } from "babylonjs/Meshes/mesh";
  67678. import { Nullable } from "babylonjs/types";
  67679. /**
  67680. * Class containing static functions to help procedurally build meshes
  67681. */
  67682. export class LatheBuilder {
  67683. /**
  67684. * Creates lathe mesh.
  67685. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67686. * * 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
  67687. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67688. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67689. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67690. * * 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
  67691. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67692. * * 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
  67693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67697. * @param name defines the name of the mesh
  67698. * @param options defines the options used to create the mesh
  67699. * @param scene defines the hosting scene
  67700. * @returns the lathe mesh
  67701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67702. */
  67703. static CreateLathe(name: string, options: {
  67704. shape: Vector3[];
  67705. radius?: number;
  67706. tessellation?: number;
  67707. clip?: number;
  67708. arc?: number;
  67709. closed?: boolean;
  67710. updatable?: boolean;
  67711. sideOrientation?: number;
  67712. frontUVs?: Vector4;
  67713. backUVs?: Vector4;
  67714. cap?: number;
  67715. invertUV?: boolean;
  67716. }, scene?: Nullable<Scene>): Mesh;
  67717. }
  67718. }
  67719. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67720. import { Nullable } from "babylonjs/types";
  67721. import { Scene } from "babylonjs/scene";
  67722. import { Vector4 } from "babylonjs/Maths/math.vector";
  67723. import { Mesh } from "babylonjs/Meshes/mesh";
  67724. /**
  67725. * Class containing static functions to help procedurally build meshes
  67726. */
  67727. export class TiledPlaneBuilder {
  67728. /**
  67729. * Creates a tiled plane mesh
  67730. * * The parameter `pattern` will, depending on value, do nothing or
  67731. * * * flip (reflect about central vertical) alternate tiles across and up
  67732. * * * flip every tile on alternate rows
  67733. * * * rotate (180 degs) alternate tiles across and up
  67734. * * * rotate every tile on alternate rows
  67735. * * * flip and rotate alternate tiles across and up
  67736. * * * flip and rotate every tile on alternate rows
  67737. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67738. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67741. * * 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)
  67742. * * 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)
  67743. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67744. * @param name defines the name of the mesh
  67745. * @param options defines the options used to create the mesh
  67746. * @param scene defines the hosting scene
  67747. * @returns the box mesh
  67748. */
  67749. static CreateTiledPlane(name: string, options: {
  67750. pattern?: number;
  67751. tileSize?: number;
  67752. tileWidth?: number;
  67753. tileHeight?: number;
  67754. size?: number;
  67755. width?: number;
  67756. height?: number;
  67757. alignHorizontal?: number;
  67758. alignVertical?: number;
  67759. sideOrientation?: number;
  67760. frontUVs?: Vector4;
  67761. backUVs?: Vector4;
  67762. updatable?: boolean;
  67763. }, scene?: Nullable<Scene>): Mesh;
  67764. }
  67765. }
  67766. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67767. import { Nullable } from "babylonjs/types";
  67768. import { Scene } from "babylonjs/scene";
  67769. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67770. import { Mesh } from "babylonjs/Meshes/mesh";
  67771. /**
  67772. * Class containing static functions to help procedurally build meshes
  67773. */
  67774. export class TubeBuilder {
  67775. /**
  67776. * Creates a tube mesh.
  67777. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67778. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67779. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67780. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67781. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67782. * * 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)
  67783. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67784. * * 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
  67785. * * 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
  67786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67790. * @param name defines the name of the mesh
  67791. * @param options defines the options used to create the mesh
  67792. * @param scene defines the hosting scene
  67793. * @returns the tube mesh
  67794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67795. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67796. */
  67797. static CreateTube(name: string, options: {
  67798. path: Vector3[];
  67799. radius?: number;
  67800. tessellation?: number;
  67801. radiusFunction?: {
  67802. (i: number, distance: number): number;
  67803. };
  67804. cap?: number;
  67805. arc?: number;
  67806. updatable?: boolean;
  67807. sideOrientation?: number;
  67808. frontUVs?: Vector4;
  67809. backUVs?: Vector4;
  67810. instance?: Mesh;
  67811. invertUV?: boolean;
  67812. }, scene?: Nullable<Scene>): Mesh;
  67813. }
  67814. }
  67815. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67816. import { Scene } from "babylonjs/scene";
  67817. import { Vector4 } from "babylonjs/Maths/math.vector";
  67818. import { Mesh } from "babylonjs/Meshes/mesh";
  67819. import { Nullable } from "babylonjs/types";
  67820. /**
  67821. * Class containing static functions to help procedurally build meshes
  67822. */
  67823. export class IcoSphereBuilder {
  67824. /**
  67825. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67826. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67827. * * 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`)
  67828. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67829. * * 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
  67830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67833. * @param name defines the name of the mesh
  67834. * @param options defines the options used to create the mesh
  67835. * @param scene defines the hosting scene
  67836. * @returns the icosahedron mesh
  67837. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67838. */
  67839. static CreateIcoSphere(name: string, options: {
  67840. radius?: number;
  67841. radiusX?: number;
  67842. radiusY?: number;
  67843. radiusZ?: number;
  67844. flat?: boolean;
  67845. subdivisions?: number;
  67846. sideOrientation?: number;
  67847. frontUVs?: Vector4;
  67848. backUVs?: Vector4;
  67849. updatable?: boolean;
  67850. }, scene?: Nullable<Scene>): Mesh;
  67851. }
  67852. }
  67853. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67854. import { Vector3 } from "babylonjs/Maths/math.vector";
  67855. import { Mesh } from "babylonjs/Meshes/mesh";
  67856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67857. /**
  67858. * Class containing static functions to help procedurally build meshes
  67859. */
  67860. export class DecalBuilder {
  67861. /**
  67862. * Creates a decal mesh.
  67863. * 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
  67864. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67865. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67866. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67867. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67868. * @param name defines the name of the mesh
  67869. * @param sourceMesh defines the mesh where the decal must be applied
  67870. * @param options defines the options used to create the mesh
  67871. * @param scene defines the hosting scene
  67872. * @returns the decal mesh
  67873. * @see https://doc.babylonjs.com/how_to/decals
  67874. */
  67875. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67876. position?: Vector3;
  67877. normal?: Vector3;
  67878. size?: Vector3;
  67879. angle?: number;
  67880. }): Mesh;
  67881. }
  67882. }
  67883. declare module "babylonjs/Meshes/meshBuilder" {
  67884. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67885. import { Nullable } from "babylonjs/types";
  67886. import { Scene } from "babylonjs/scene";
  67887. import { Mesh } from "babylonjs/Meshes/mesh";
  67888. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67889. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67891. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67892. import { Plane } from "babylonjs/Maths/math.plane";
  67893. /**
  67894. * Class containing static functions to help procedurally build meshes
  67895. */
  67896. export class MeshBuilder {
  67897. /**
  67898. * Creates a box mesh
  67899. * * The parameter `size` sets the size (float) of each box side (default 1)
  67900. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67901. * * 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)
  67902. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67906. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67907. * @param name defines the name of the mesh
  67908. * @param options defines the options used to create the mesh
  67909. * @param scene defines the hosting scene
  67910. * @returns the box mesh
  67911. */
  67912. static CreateBox(name: string, options: {
  67913. size?: number;
  67914. width?: number;
  67915. height?: number;
  67916. depth?: number;
  67917. faceUV?: Vector4[];
  67918. faceColors?: Color4[];
  67919. sideOrientation?: number;
  67920. frontUVs?: Vector4;
  67921. backUVs?: Vector4;
  67922. wrap?: boolean;
  67923. topBaseAt?: number;
  67924. bottomBaseAt?: number;
  67925. updatable?: boolean;
  67926. }, scene?: Nullable<Scene>): Mesh;
  67927. /**
  67928. * Creates a tiled box mesh
  67929. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67931. * @param name defines the name of the mesh
  67932. * @param options defines the options used to create the mesh
  67933. * @param scene defines the hosting scene
  67934. * @returns the tiled box mesh
  67935. */
  67936. static CreateTiledBox(name: string, options: {
  67937. pattern?: number;
  67938. size?: number;
  67939. width?: number;
  67940. height?: number;
  67941. depth: number;
  67942. tileSize?: number;
  67943. tileWidth?: number;
  67944. tileHeight?: number;
  67945. faceUV?: Vector4[];
  67946. faceColors?: Color4[];
  67947. alignHorizontal?: number;
  67948. alignVertical?: number;
  67949. sideOrientation?: number;
  67950. updatable?: boolean;
  67951. }, scene?: Nullable<Scene>): Mesh;
  67952. /**
  67953. * Creates a sphere mesh
  67954. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67955. * * 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`)
  67956. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67957. * * 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
  67958. * * 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)
  67959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67962. * @param name defines the name of the mesh
  67963. * @param options defines the options used to create the mesh
  67964. * @param scene defines the hosting scene
  67965. * @returns the sphere mesh
  67966. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67967. */
  67968. static CreateSphere(name: string, options: {
  67969. segments?: number;
  67970. diameter?: number;
  67971. diameterX?: number;
  67972. diameterY?: number;
  67973. diameterZ?: number;
  67974. arc?: number;
  67975. slice?: number;
  67976. sideOrientation?: number;
  67977. frontUVs?: Vector4;
  67978. backUVs?: Vector4;
  67979. updatable?: boolean;
  67980. }, scene?: Nullable<Scene>): Mesh;
  67981. /**
  67982. * Creates a plane polygonal mesh. By default, this is a disc
  67983. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67984. * * 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
  67985. * * 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
  67986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67989. * @param name defines the name of the mesh
  67990. * @param options defines the options used to create the mesh
  67991. * @param scene defines the hosting scene
  67992. * @returns the plane polygonal mesh
  67993. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67994. */
  67995. static CreateDisc(name: string, options: {
  67996. radius?: number;
  67997. tessellation?: number;
  67998. arc?: number;
  67999. updatable?: boolean;
  68000. sideOrientation?: number;
  68001. frontUVs?: Vector4;
  68002. backUVs?: Vector4;
  68003. }, scene?: Nullable<Scene>): Mesh;
  68004. /**
  68005. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68006. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68007. * * 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`)
  68008. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68009. * * 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
  68010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68013. * @param name defines the name of the mesh
  68014. * @param options defines the options used to create the mesh
  68015. * @param scene defines the hosting scene
  68016. * @returns the icosahedron mesh
  68017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68018. */
  68019. static CreateIcoSphere(name: string, options: {
  68020. radius?: number;
  68021. radiusX?: number;
  68022. radiusY?: number;
  68023. radiusZ?: number;
  68024. flat?: boolean;
  68025. subdivisions?: number;
  68026. sideOrientation?: number;
  68027. frontUVs?: Vector4;
  68028. backUVs?: Vector4;
  68029. updatable?: boolean;
  68030. }, scene?: Nullable<Scene>): Mesh;
  68031. /**
  68032. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68033. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68034. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68035. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68036. * * 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
  68037. * * 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
  68038. * * 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
  68039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68042. * * 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
  68043. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68044. * * 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
  68045. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68047. * @param name defines the name of the mesh
  68048. * @param options defines the options used to create the mesh
  68049. * @param scene defines the hosting scene
  68050. * @returns the ribbon mesh
  68051. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68053. */
  68054. static CreateRibbon(name: string, options: {
  68055. pathArray: Vector3[][];
  68056. closeArray?: boolean;
  68057. closePath?: boolean;
  68058. offset?: number;
  68059. updatable?: boolean;
  68060. sideOrientation?: number;
  68061. frontUVs?: Vector4;
  68062. backUVs?: Vector4;
  68063. instance?: Mesh;
  68064. invertUV?: boolean;
  68065. uvs?: Vector2[];
  68066. colors?: Color4[];
  68067. }, scene?: Nullable<Scene>): Mesh;
  68068. /**
  68069. * Creates a cylinder or a cone mesh
  68070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68072. * * 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.
  68073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68077. * * 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).
  68078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68079. * * 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).
  68080. * * 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
  68081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68082. * * 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
  68083. * * 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.
  68084. * * If `enclose` is false, a ring surface is one element.
  68085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68086. * * 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
  68087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68090. * @param name defines the name of the mesh
  68091. * @param options defines the options used to create the mesh
  68092. * @param scene defines the hosting scene
  68093. * @returns the cylinder mesh
  68094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68095. */
  68096. static CreateCylinder(name: string, options: {
  68097. height?: number;
  68098. diameterTop?: number;
  68099. diameterBottom?: number;
  68100. diameter?: number;
  68101. tessellation?: number;
  68102. subdivisions?: number;
  68103. arc?: number;
  68104. faceColors?: Color4[];
  68105. faceUV?: Vector4[];
  68106. updatable?: boolean;
  68107. hasRings?: boolean;
  68108. enclose?: boolean;
  68109. cap?: number;
  68110. sideOrientation?: number;
  68111. frontUVs?: Vector4;
  68112. backUVs?: Vector4;
  68113. }, scene?: Nullable<Scene>): Mesh;
  68114. /**
  68115. * Creates a torus mesh
  68116. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68117. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68118. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68122. * @param name defines the name of the mesh
  68123. * @param options defines the options used to create the mesh
  68124. * @param scene defines the hosting scene
  68125. * @returns the torus mesh
  68126. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68127. */
  68128. static CreateTorus(name: string, options: {
  68129. diameter?: number;
  68130. thickness?: number;
  68131. tessellation?: number;
  68132. updatable?: boolean;
  68133. sideOrientation?: number;
  68134. frontUVs?: Vector4;
  68135. backUVs?: Vector4;
  68136. }, scene?: Nullable<Scene>): Mesh;
  68137. /**
  68138. * Creates a torus knot mesh
  68139. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68140. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68141. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68142. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68146. * @param name defines the name of the mesh
  68147. * @param options defines the options used to create the mesh
  68148. * @param scene defines the hosting scene
  68149. * @returns the torus knot mesh
  68150. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68151. */
  68152. static CreateTorusKnot(name: string, options: {
  68153. radius?: number;
  68154. tube?: number;
  68155. radialSegments?: number;
  68156. tubularSegments?: number;
  68157. p?: number;
  68158. q?: number;
  68159. updatable?: boolean;
  68160. sideOrientation?: number;
  68161. frontUVs?: Vector4;
  68162. backUVs?: Vector4;
  68163. }, scene?: Nullable<Scene>): Mesh;
  68164. /**
  68165. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68166. * * 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
  68167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68168. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68169. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68170. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68172. * * 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
  68173. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68176. * @param name defines the name of the new line system
  68177. * @param options defines the options used to create the line system
  68178. * @param scene defines the hosting scene
  68179. * @returns a new line system mesh
  68180. */
  68181. static CreateLineSystem(name: string, options: {
  68182. lines: Vector3[][];
  68183. updatable?: boolean;
  68184. instance?: Nullable<LinesMesh>;
  68185. colors?: Nullable<Color4[][]>;
  68186. useVertexAlpha?: boolean;
  68187. }, scene: Nullable<Scene>): LinesMesh;
  68188. /**
  68189. * Creates a line mesh
  68190. * 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
  68191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68192. * * The parameter `points` is an array successive Vector3
  68193. * * 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
  68194. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68195. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68196. * * When updating an instance, remember that only point positions can change, not the number of points
  68197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68199. * @param name defines the name of the new line system
  68200. * @param options defines the options used to create the line system
  68201. * @param scene defines the hosting scene
  68202. * @returns a new line mesh
  68203. */
  68204. static CreateLines(name: string, options: {
  68205. points: Vector3[];
  68206. updatable?: boolean;
  68207. instance?: Nullable<LinesMesh>;
  68208. colors?: Color4[];
  68209. useVertexAlpha?: boolean;
  68210. }, scene?: Nullable<Scene>): LinesMesh;
  68211. /**
  68212. * Creates a dashed line mesh
  68213. * * 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
  68214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68215. * * The parameter `points` is an array successive Vector3
  68216. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68217. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68218. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68219. * * 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
  68220. * * When updating an instance, remember that only point positions can change, not the number of points
  68221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68222. * @param name defines the name of the mesh
  68223. * @param options defines the options used to create the mesh
  68224. * @param scene defines the hosting scene
  68225. * @returns the dashed line mesh
  68226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68227. */
  68228. static CreateDashedLines(name: string, options: {
  68229. points: Vector3[];
  68230. dashSize?: number;
  68231. gapSize?: number;
  68232. dashNb?: number;
  68233. updatable?: boolean;
  68234. instance?: LinesMesh;
  68235. }, scene?: Nullable<Scene>): LinesMesh;
  68236. /**
  68237. * 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.
  68238. * * 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.
  68239. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68240. * * 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.
  68241. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68242. * * 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
  68243. * * 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
  68244. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68249. * @param name defines the name of the mesh
  68250. * @param options defines the options used to create the mesh
  68251. * @param scene defines the hosting scene
  68252. * @returns the extruded shape mesh
  68253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68255. */
  68256. static ExtrudeShape(name: string, options: {
  68257. shape: Vector3[];
  68258. path: Vector3[];
  68259. scale?: number;
  68260. rotation?: number;
  68261. cap?: number;
  68262. updatable?: boolean;
  68263. sideOrientation?: number;
  68264. frontUVs?: Vector4;
  68265. backUVs?: Vector4;
  68266. instance?: Mesh;
  68267. invertUV?: boolean;
  68268. }, scene?: Nullable<Scene>): Mesh;
  68269. /**
  68270. * Creates an custom extruded shape mesh.
  68271. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68272. * * 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.
  68273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68274. * * 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
  68275. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68276. * * 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
  68277. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68278. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68279. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68280. * * 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
  68281. * * 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
  68282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68287. * @param name defines the name of the mesh
  68288. * @param options defines the options used to create the mesh
  68289. * @param scene defines the hosting scene
  68290. * @returns the custom extruded shape mesh
  68291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68292. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68294. */
  68295. static ExtrudeShapeCustom(name: string, options: {
  68296. shape: Vector3[];
  68297. path: Vector3[];
  68298. scaleFunction?: any;
  68299. rotationFunction?: any;
  68300. ribbonCloseArray?: boolean;
  68301. ribbonClosePath?: boolean;
  68302. cap?: number;
  68303. updatable?: boolean;
  68304. sideOrientation?: number;
  68305. frontUVs?: Vector4;
  68306. backUVs?: Vector4;
  68307. instance?: Mesh;
  68308. invertUV?: boolean;
  68309. }, scene?: Nullable<Scene>): Mesh;
  68310. /**
  68311. * Creates lathe mesh.
  68312. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68313. * * 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
  68314. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68315. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68316. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68317. * * 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
  68318. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68319. * * 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
  68320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68324. * @param name defines the name of the mesh
  68325. * @param options defines the options used to create the mesh
  68326. * @param scene defines the hosting scene
  68327. * @returns the lathe mesh
  68328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68329. */
  68330. static CreateLathe(name: string, options: {
  68331. shape: Vector3[];
  68332. radius?: number;
  68333. tessellation?: number;
  68334. clip?: number;
  68335. arc?: number;
  68336. closed?: boolean;
  68337. updatable?: boolean;
  68338. sideOrientation?: number;
  68339. frontUVs?: Vector4;
  68340. backUVs?: Vector4;
  68341. cap?: number;
  68342. invertUV?: boolean;
  68343. }, scene?: Nullable<Scene>): Mesh;
  68344. /**
  68345. * Creates a tiled plane mesh
  68346. * * You can set a limited pattern arrangement with the tiles
  68347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68350. * @param name defines the name of the mesh
  68351. * @param options defines the options used to create the mesh
  68352. * @param scene defines the hosting scene
  68353. * @returns the plane mesh
  68354. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68355. */
  68356. static CreateTiledPlane(name: string, options: {
  68357. pattern?: number;
  68358. tileSize?: number;
  68359. tileWidth?: number;
  68360. tileHeight?: number;
  68361. size?: number;
  68362. width?: number;
  68363. height?: number;
  68364. alignHorizontal?: number;
  68365. alignVertical?: number;
  68366. sideOrientation?: number;
  68367. frontUVs?: Vector4;
  68368. backUVs?: Vector4;
  68369. updatable?: boolean;
  68370. }, scene?: Nullable<Scene>): Mesh;
  68371. /**
  68372. * Creates a plane mesh
  68373. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68374. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68375. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68379. * @param name defines the name of the mesh
  68380. * @param options defines the options used to create the mesh
  68381. * @param scene defines the hosting scene
  68382. * @returns the plane mesh
  68383. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68384. */
  68385. static CreatePlane(name: string, options: {
  68386. size?: number;
  68387. width?: number;
  68388. height?: number;
  68389. sideOrientation?: number;
  68390. frontUVs?: Vector4;
  68391. backUVs?: Vector4;
  68392. updatable?: boolean;
  68393. sourcePlane?: Plane;
  68394. }, scene?: Nullable<Scene>): Mesh;
  68395. /**
  68396. * Creates a ground mesh
  68397. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68398. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68400. * @param name defines the name of the mesh
  68401. * @param options defines the options used to create the mesh
  68402. * @param scene defines the hosting scene
  68403. * @returns the ground mesh
  68404. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68405. */
  68406. static CreateGround(name: string, options: {
  68407. width?: number;
  68408. height?: number;
  68409. subdivisions?: number;
  68410. subdivisionsX?: number;
  68411. subdivisionsY?: number;
  68412. updatable?: boolean;
  68413. }, scene?: Nullable<Scene>): Mesh;
  68414. /**
  68415. * Creates a tiled ground mesh
  68416. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68417. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68418. * * 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
  68419. * * 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
  68420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68421. * @param name defines the name of the mesh
  68422. * @param options defines the options used to create the mesh
  68423. * @param scene defines the hosting scene
  68424. * @returns the tiled ground mesh
  68425. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68426. */
  68427. static CreateTiledGround(name: string, options: {
  68428. xmin: number;
  68429. zmin: number;
  68430. xmax: number;
  68431. zmax: number;
  68432. subdivisions?: {
  68433. w: number;
  68434. h: number;
  68435. };
  68436. precision?: {
  68437. w: number;
  68438. h: number;
  68439. };
  68440. updatable?: boolean;
  68441. }, scene?: Nullable<Scene>): Mesh;
  68442. /**
  68443. * Creates a ground mesh from a height map
  68444. * * The parameter `url` sets the URL of the height map image resource.
  68445. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68446. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68447. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68448. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68449. * * 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.
  68450. * * 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).
  68451. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68453. * @param name defines the name of the mesh
  68454. * @param url defines the url to the height map
  68455. * @param options defines the options used to create the mesh
  68456. * @param scene defines the hosting scene
  68457. * @returns the ground mesh
  68458. * @see https://doc.babylonjs.com/babylon101/height_map
  68459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68460. */
  68461. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68462. width?: number;
  68463. height?: number;
  68464. subdivisions?: number;
  68465. minHeight?: number;
  68466. maxHeight?: number;
  68467. colorFilter?: Color3;
  68468. alphaFilter?: number;
  68469. updatable?: boolean;
  68470. onReady?: (mesh: GroundMesh) => void;
  68471. }, scene?: Nullable<Scene>): GroundMesh;
  68472. /**
  68473. * Creates a polygon mesh
  68474. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68475. * * 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
  68476. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68479. * * Remember you can only change the shape positions, not their number when updating a polygon
  68480. * @param name defines the name of the mesh
  68481. * @param options defines the options used to create the mesh
  68482. * @param scene defines the hosting scene
  68483. * @param earcutInjection can be used to inject your own earcut reference
  68484. * @returns the polygon mesh
  68485. */
  68486. static CreatePolygon(name: string, options: {
  68487. shape: Vector3[];
  68488. holes?: Vector3[][];
  68489. depth?: number;
  68490. faceUV?: Vector4[];
  68491. faceColors?: Color4[];
  68492. updatable?: boolean;
  68493. sideOrientation?: number;
  68494. frontUVs?: Vector4;
  68495. backUVs?: Vector4;
  68496. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68497. /**
  68498. * Creates an extruded polygon mesh, with depth in the Y direction.
  68499. * * 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)
  68500. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68501. * @param name defines the name of the mesh
  68502. * @param options defines the options used to create the mesh
  68503. * @param scene defines the hosting scene
  68504. * @param earcutInjection can be used to inject your own earcut reference
  68505. * @returns the polygon mesh
  68506. */
  68507. static ExtrudePolygon(name: string, options: {
  68508. shape: Vector3[];
  68509. holes?: Vector3[][];
  68510. depth?: number;
  68511. faceUV?: Vector4[];
  68512. faceColors?: Color4[];
  68513. updatable?: boolean;
  68514. sideOrientation?: number;
  68515. frontUVs?: Vector4;
  68516. backUVs?: Vector4;
  68517. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68518. /**
  68519. * Creates a tube mesh.
  68520. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68521. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68522. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68523. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68524. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68525. * * 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)
  68526. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68527. * * 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
  68528. * * 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
  68529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68533. * @param name defines the name of the mesh
  68534. * @param options defines the options used to create the mesh
  68535. * @param scene defines the hosting scene
  68536. * @returns the tube mesh
  68537. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68538. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68539. */
  68540. static CreateTube(name: string, options: {
  68541. path: Vector3[];
  68542. radius?: number;
  68543. tessellation?: number;
  68544. radiusFunction?: {
  68545. (i: number, distance: number): number;
  68546. };
  68547. cap?: number;
  68548. arc?: number;
  68549. updatable?: boolean;
  68550. sideOrientation?: number;
  68551. frontUVs?: Vector4;
  68552. backUVs?: Vector4;
  68553. instance?: Mesh;
  68554. invertUV?: boolean;
  68555. }, scene?: Nullable<Scene>): Mesh;
  68556. /**
  68557. * Creates a polyhedron mesh
  68558. * * 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
  68559. * * The parameter `size` (positive float, default 1) sets the polygon size
  68560. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68561. * * 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`
  68562. * * 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
  68563. * * 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)`)
  68564. * * 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
  68565. * * 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
  68566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68569. * @param name defines the name of the mesh
  68570. * @param options defines the options used to create the mesh
  68571. * @param scene defines the hosting scene
  68572. * @returns the polyhedron mesh
  68573. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68574. */
  68575. static CreatePolyhedron(name: string, options: {
  68576. type?: number;
  68577. size?: number;
  68578. sizeX?: number;
  68579. sizeY?: number;
  68580. sizeZ?: number;
  68581. custom?: any;
  68582. faceUV?: Vector4[];
  68583. faceColors?: Color4[];
  68584. flat?: boolean;
  68585. updatable?: boolean;
  68586. sideOrientation?: number;
  68587. frontUVs?: Vector4;
  68588. backUVs?: Vector4;
  68589. }, scene?: Nullable<Scene>): Mesh;
  68590. /**
  68591. * Creates a decal mesh.
  68592. * 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
  68593. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68594. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68595. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68596. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68597. * @param name defines the name of the mesh
  68598. * @param sourceMesh defines the mesh where the decal must be applied
  68599. * @param options defines the options used to create the mesh
  68600. * @param scene defines the hosting scene
  68601. * @returns the decal mesh
  68602. * @see https://doc.babylonjs.com/how_to/decals
  68603. */
  68604. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68605. position?: Vector3;
  68606. normal?: Vector3;
  68607. size?: Vector3;
  68608. angle?: number;
  68609. }): Mesh;
  68610. }
  68611. }
  68612. declare module "babylonjs/Meshes/meshSimplification" {
  68613. import { Mesh } from "babylonjs/Meshes/mesh";
  68614. /**
  68615. * A simplifier interface for future simplification implementations
  68616. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68617. */
  68618. export interface ISimplifier {
  68619. /**
  68620. * Simplification of a given mesh according to the given settings.
  68621. * Since this requires computation, it is assumed that the function runs async.
  68622. * @param settings The settings of the simplification, including quality and distance
  68623. * @param successCallback A callback that will be called after the mesh was simplified.
  68624. * @param errorCallback in case of an error, this callback will be called. optional.
  68625. */
  68626. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68627. }
  68628. /**
  68629. * Expected simplification settings.
  68630. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68632. */
  68633. export interface ISimplificationSettings {
  68634. /**
  68635. * Gets or sets the expected quality
  68636. */
  68637. quality: number;
  68638. /**
  68639. * Gets or sets the distance when this optimized version should be used
  68640. */
  68641. distance: number;
  68642. /**
  68643. * Gets an already optimized mesh
  68644. */
  68645. optimizeMesh?: boolean;
  68646. }
  68647. /**
  68648. * Class used to specify simplification options
  68649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68650. */
  68651. export class SimplificationSettings implements ISimplificationSettings {
  68652. /** expected quality */
  68653. quality: number;
  68654. /** distance when this optimized version should be used */
  68655. distance: number;
  68656. /** already optimized mesh */
  68657. optimizeMesh?: boolean | undefined;
  68658. /**
  68659. * Creates a SimplificationSettings
  68660. * @param quality expected quality
  68661. * @param distance distance when this optimized version should be used
  68662. * @param optimizeMesh already optimized mesh
  68663. */
  68664. constructor(
  68665. /** expected quality */
  68666. quality: number,
  68667. /** distance when this optimized version should be used */
  68668. distance: number,
  68669. /** already optimized mesh */
  68670. optimizeMesh?: boolean | undefined);
  68671. }
  68672. /**
  68673. * Interface used to define a simplification task
  68674. */
  68675. export interface ISimplificationTask {
  68676. /**
  68677. * Array of settings
  68678. */
  68679. settings: Array<ISimplificationSettings>;
  68680. /**
  68681. * Simplification type
  68682. */
  68683. simplificationType: SimplificationType;
  68684. /**
  68685. * Mesh to simplify
  68686. */
  68687. mesh: Mesh;
  68688. /**
  68689. * Callback called on success
  68690. */
  68691. successCallback?: () => void;
  68692. /**
  68693. * Defines if parallel processing can be used
  68694. */
  68695. parallelProcessing: boolean;
  68696. }
  68697. /**
  68698. * Queue used to order the simplification tasks
  68699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68700. */
  68701. export class SimplificationQueue {
  68702. private _simplificationArray;
  68703. /**
  68704. * Gets a boolean indicating that the process is still running
  68705. */
  68706. running: boolean;
  68707. /**
  68708. * Creates a new queue
  68709. */
  68710. constructor();
  68711. /**
  68712. * Adds a new simplification task
  68713. * @param task defines a task to add
  68714. */
  68715. addTask(task: ISimplificationTask): void;
  68716. /**
  68717. * Execute next task
  68718. */
  68719. executeNext(): void;
  68720. /**
  68721. * Execute a simplification task
  68722. * @param task defines the task to run
  68723. */
  68724. runSimplification(task: ISimplificationTask): void;
  68725. private getSimplifier;
  68726. }
  68727. /**
  68728. * The implemented types of simplification
  68729. * At the moment only Quadratic Error Decimation is implemented
  68730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68731. */
  68732. export enum SimplificationType {
  68733. /** Quadratic error decimation */
  68734. QUADRATIC = 0
  68735. }
  68736. /**
  68737. * An implementation of the Quadratic Error simplification algorithm.
  68738. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68739. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68740. * @author RaananW
  68741. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68742. */
  68743. export class QuadraticErrorSimplification implements ISimplifier {
  68744. private _mesh;
  68745. private triangles;
  68746. private vertices;
  68747. private references;
  68748. private _reconstructedMesh;
  68749. /** Gets or sets the number pf sync interations */
  68750. syncIterations: number;
  68751. /** Gets or sets the aggressiveness of the simplifier */
  68752. aggressiveness: number;
  68753. /** Gets or sets the number of allowed iterations for decimation */
  68754. decimationIterations: number;
  68755. /** Gets or sets the espilon to use for bounding box computation */
  68756. boundingBoxEpsilon: number;
  68757. /**
  68758. * Creates a new QuadraticErrorSimplification
  68759. * @param _mesh defines the target mesh
  68760. */
  68761. constructor(_mesh: Mesh);
  68762. /**
  68763. * Simplification of a given mesh according to the given settings.
  68764. * Since this requires computation, it is assumed that the function runs async.
  68765. * @param settings The settings of the simplification, including quality and distance
  68766. * @param successCallback A callback that will be called after the mesh was simplified.
  68767. */
  68768. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68769. private runDecimation;
  68770. private initWithMesh;
  68771. private init;
  68772. private reconstructMesh;
  68773. private initDecimatedMesh;
  68774. private isFlipped;
  68775. private updateTriangles;
  68776. private identifyBorder;
  68777. private updateMesh;
  68778. private vertexError;
  68779. private calculateError;
  68780. }
  68781. }
  68782. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68783. import { Scene } from "babylonjs/scene";
  68784. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68785. import { ISceneComponent } from "babylonjs/sceneComponent";
  68786. module "babylonjs/scene" {
  68787. interface Scene {
  68788. /** @hidden (Backing field) */
  68789. _simplificationQueue: SimplificationQueue;
  68790. /**
  68791. * Gets or sets the simplification queue attached to the scene
  68792. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68793. */
  68794. simplificationQueue: SimplificationQueue;
  68795. }
  68796. }
  68797. module "babylonjs/Meshes/mesh" {
  68798. interface Mesh {
  68799. /**
  68800. * Simplify the mesh according to the given array of settings.
  68801. * Function will return immediately and will simplify async
  68802. * @param settings a collection of simplification settings
  68803. * @param parallelProcessing should all levels calculate parallel or one after the other
  68804. * @param simplificationType the type of simplification to run
  68805. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68806. * @returns the current mesh
  68807. */
  68808. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68809. }
  68810. }
  68811. /**
  68812. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68813. * created in a scene
  68814. */
  68815. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68816. /**
  68817. * The component name helpfull to identify the component in the list of scene components.
  68818. */
  68819. readonly name: string;
  68820. /**
  68821. * The scene the component belongs to.
  68822. */
  68823. scene: Scene;
  68824. /**
  68825. * Creates a new instance of the component for the given scene
  68826. * @param scene Defines the scene to register the component in
  68827. */
  68828. constructor(scene: Scene);
  68829. /**
  68830. * Registers the component in a given scene
  68831. */
  68832. register(): void;
  68833. /**
  68834. * Rebuilds the elements related to this component in case of
  68835. * context lost for instance.
  68836. */
  68837. rebuild(): void;
  68838. /**
  68839. * Disposes the component and the associated ressources
  68840. */
  68841. dispose(): void;
  68842. private _beforeCameraUpdate;
  68843. }
  68844. }
  68845. declare module "babylonjs/Meshes/Builders/index" {
  68846. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68847. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68848. export * from "babylonjs/Meshes/Builders/discBuilder";
  68849. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68850. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68851. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68852. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68853. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68854. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68855. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68856. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68857. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68858. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68859. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68860. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68861. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68862. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68863. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68864. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68865. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68866. }
  68867. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68868. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68869. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68870. import { Matrix } from "babylonjs/Maths/math.vector";
  68871. module "babylonjs/Meshes/mesh" {
  68872. interface Mesh {
  68873. /**
  68874. * Creates a new thin instance
  68875. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68876. * @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
  68877. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68878. */
  68879. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68880. /**
  68881. * Adds the transformation (matrix) of the current mesh as a thin instance
  68882. * @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
  68883. * @returns the thin instance index number
  68884. */
  68885. thinInstanceAddSelf(refresh: boolean): number;
  68886. /**
  68887. * Registers a custom attribute to be used with thin instances
  68888. * @param kind name of the attribute
  68889. * @param stride size in floats of the attribute
  68890. */
  68891. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68892. /**
  68893. * Sets the matrix of a thin instance
  68894. * @param index index of the thin instance
  68895. * @param matrix matrix to set
  68896. * @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
  68897. */
  68898. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68899. /**
  68900. * Sets the value of a custom attribute for a thin instance
  68901. * @param kind name of the attribute
  68902. * @param index index of the thin instance
  68903. * @param value value to set
  68904. * @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
  68905. */
  68906. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68907. /**
  68908. * 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.
  68909. */
  68910. thinInstanceCount: number;
  68911. /**
  68912. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68913. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68914. * @param buffer buffer to set
  68915. * @param stride size in floats of each value of the buffer
  68916. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68917. */
  68918. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68919. /**
  68920. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68921. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68922. */
  68923. thinInstanceBufferUpdated(kind: string): void;
  68924. /**
  68925. * Refreshes the bounding info, taking into account all the thin instances defined
  68926. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68927. */
  68928. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68929. /** @hidden */
  68930. _thinInstanceInitializeUserStorage(): void;
  68931. /** @hidden */
  68932. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68933. /** @hidden */
  68934. _userThinInstanceBuffersStorage: {
  68935. data: {
  68936. [key: string]: Float32Array;
  68937. };
  68938. sizes: {
  68939. [key: string]: number;
  68940. };
  68941. vertexBuffers: {
  68942. [key: string]: Nullable<VertexBuffer>;
  68943. };
  68944. strides: {
  68945. [key: string]: number;
  68946. };
  68947. };
  68948. }
  68949. }
  68950. }
  68951. declare module "babylonjs/Meshes/index" {
  68952. export * from "babylonjs/Meshes/abstractMesh";
  68953. export * from "babylonjs/Meshes/buffer";
  68954. export * from "babylonjs/Meshes/Compression/index";
  68955. export * from "babylonjs/Meshes/csg";
  68956. export * from "babylonjs/Meshes/geometry";
  68957. export * from "babylonjs/Meshes/groundMesh";
  68958. export * from "babylonjs/Meshes/trailMesh";
  68959. export * from "babylonjs/Meshes/instancedMesh";
  68960. export * from "babylonjs/Meshes/linesMesh";
  68961. export * from "babylonjs/Meshes/mesh";
  68962. export * from "babylonjs/Meshes/mesh.vertexData";
  68963. export * from "babylonjs/Meshes/meshBuilder";
  68964. export * from "babylonjs/Meshes/meshSimplification";
  68965. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68966. export * from "babylonjs/Meshes/polygonMesh";
  68967. export * from "babylonjs/Meshes/subMesh";
  68968. export * from "babylonjs/Meshes/meshLODLevel";
  68969. export * from "babylonjs/Meshes/transformNode";
  68970. export * from "babylonjs/Meshes/Builders/index";
  68971. export * from "babylonjs/Meshes/dataBuffer";
  68972. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68973. import "babylonjs/Meshes/thinInstanceMesh";
  68974. export * from "babylonjs/Meshes/thinInstanceMesh";
  68975. }
  68976. declare module "babylonjs/Morph/index" {
  68977. export * from "babylonjs/Morph/morphTarget";
  68978. export * from "babylonjs/Morph/morphTargetManager";
  68979. }
  68980. declare module "babylonjs/Navigation/INavigationEngine" {
  68981. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68982. import { Vector3 } from "babylonjs/Maths/math";
  68983. import { Mesh } from "babylonjs/Meshes/mesh";
  68984. import { Scene } from "babylonjs/scene";
  68985. /**
  68986. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68987. */
  68988. export interface INavigationEnginePlugin {
  68989. /**
  68990. * plugin name
  68991. */
  68992. name: string;
  68993. /**
  68994. * Creates a navigation mesh
  68995. * @param meshes array of all the geometry used to compute the navigatio mesh
  68996. * @param parameters bunch of parameters used to filter geometry
  68997. */
  68998. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68999. /**
  69000. * Create a navigation mesh debug mesh
  69001. * @param scene is where the mesh will be added
  69002. * @returns debug display mesh
  69003. */
  69004. createDebugNavMesh(scene: Scene): Mesh;
  69005. /**
  69006. * Get a navigation mesh constrained position, closest to the parameter position
  69007. * @param position world position
  69008. * @returns the closest point to position constrained by the navigation mesh
  69009. */
  69010. getClosestPoint(position: Vector3): Vector3;
  69011. /**
  69012. * Get a navigation mesh constrained position, closest to the parameter position
  69013. * @param position world position
  69014. * @param result output the closest point to position constrained by the navigation mesh
  69015. */
  69016. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69017. /**
  69018. * Get a navigation mesh constrained position, within a particular radius
  69019. * @param position world position
  69020. * @param maxRadius the maximum distance to the constrained world position
  69021. * @returns the closest point to position constrained by the navigation mesh
  69022. */
  69023. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69024. /**
  69025. * Get a navigation mesh constrained position, within a particular radius
  69026. * @param position world position
  69027. * @param maxRadius the maximum distance to the constrained world position
  69028. * @param result output the closest point to position constrained by the navigation mesh
  69029. */
  69030. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69031. /**
  69032. * Compute the final position from a segment made of destination-position
  69033. * @param position world position
  69034. * @param destination world position
  69035. * @returns the resulting point along the navmesh
  69036. */
  69037. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69038. /**
  69039. * Compute the final position from a segment made of destination-position
  69040. * @param position world position
  69041. * @param destination world position
  69042. * @param result output the resulting point along the navmesh
  69043. */
  69044. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69045. /**
  69046. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69047. * @param start world position
  69048. * @param end world position
  69049. * @returns array containing world position composing the path
  69050. */
  69051. computePath(start: Vector3, end: Vector3): Vector3[];
  69052. /**
  69053. * If this plugin is supported
  69054. * @returns true if plugin is supported
  69055. */
  69056. isSupported(): boolean;
  69057. /**
  69058. * Create a new Crowd so you can add agents
  69059. * @param maxAgents the maximum agent count in the crowd
  69060. * @param maxAgentRadius the maximum radius an agent can have
  69061. * @param scene to attach the crowd to
  69062. * @returns the crowd you can add agents to
  69063. */
  69064. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69065. /**
  69066. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69067. * The queries will try to find a solution within those bounds
  69068. * default is (1,1,1)
  69069. * @param extent x,y,z value that define the extent around the queries point of reference
  69070. */
  69071. setDefaultQueryExtent(extent: Vector3): void;
  69072. /**
  69073. * Get the Bounding box extent specified by setDefaultQueryExtent
  69074. * @returns the box extent values
  69075. */
  69076. getDefaultQueryExtent(): Vector3;
  69077. /**
  69078. * build the navmesh from a previously saved state using getNavmeshData
  69079. * @param data the Uint8Array returned by getNavmeshData
  69080. */
  69081. buildFromNavmeshData(data: Uint8Array): void;
  69082. /**
  69083. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69084. * @returns data the Uint8Array that can be saved and reused
  69085. */
  69086. getNavmeshData(): Uint8Array;
  69087. /**
  69088. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69089. * @param result output the box extent values
  69090. */
  69091. getDefaultQueryExtentToRef(result: Vector3): void;
  69092. /**
  69093. * Release all resources
  69094. */
  69095. dispose(): void;
  69096. }
  69097. /**
  69098. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69099. */
  69100. export interface ICrowd {
  69101. /**
  69102. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69103. * You can attach anything to that node. The node position is updated in the scene update tick.
  69104. * @param pos world position that will be constrained by the navigation mesh
  69105. * @param parameters agent parameters
  69106. * @param transform hooked to the agent that will be update by the scene
  69107. * @returns agent index
  69108. */
  69109. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69110. /**
  69111. * Returns the agent position in world space
  69112. * @param index agent index returned by addAgent
  69113. * @returns world space position
  69114. */
  69115. getAgentPosition(index: number): Vector3;
  69116. /**
  69117. * Gets the agent position result in world space
  69118. * @param index agent index returned by addAgent
  69119. * @param result output world space position
  69120. */
  69121. getAgentPositionToRef(index: number, result: Vector3): void;
  69122. /**
  69123. * Gets the agent velocity in world space
  69124. * @param index agent index returned by addAgent
  69125. * @returns world space velocity
  69126. */
  69127. getAgentVelocity(index: number): Vector3;
  69128. /**
  69129. * Gets the agent velocity result in world space
  69130. * @param index agent index returned by addAgent
  69131. * @param result output world space velocity
  69132. */
  69133. getAgentVelocityToRef(index: number, result: Vector3): void;
  69134. /**
  69135. * remove a particular agent previously created
  69136. * @param index agent index returned by addAgent
  69137. */
  69138. removeAgent(index: number): void;
  69139. /**
  69140. * get the list of all agents attached to this crowd
  69141. * @returns list of agent indices
  69142. */
  69143. getAgents(): number[];
  69144. /**
  69145. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69146. * @param deltaTime in seconds
  69147. */
  69148. update(deltaTime: number): void;
  69149. /**
  69150. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69151. * @param index agent index returned by addAgent
  69152. * @param destination targeted world position
  69153. */
  69154. agentGoto(index: number, destination: Vector3): void;
  69155. /**
  69156. * Teleport the agent to a new position
  69157. * @param index agent index returned by addAgent
  69158. * @param destination targeted world position
  69159. */
  69160. agentTeleport(index: number, destination: Vector3): void;
  69161. /**
  69162. * Update agent parameters
  69163. * @param index agent index returned by addAgent
  69164. * @param parameters agent parameters
  69165. */
  69166. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69167. /**
  69168. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69169. * The queries will try to find a solution within those bounds
  69170. * default is (1,1,1)
  69171. * @param extent x,y,z value that define the extent around the queries point of reference
  69172. */
  69173. setDefaultQueryExtent(extent: Vector3): void;
  69174. /**
  69175. * Get the Bounding box extent specified by setDefaultQueryExtent
  69176. * @returns the box extent values
  69177. */
  69178. getDefaultQueryExtent(): Vector3;
  69179. /**
  69180. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69181. * @param result output the box extent values
  69182. */
  69183. getDefaultQueryExtentToRef(result: Vector3): void;
  69184. /**
  69185. * Release all resources
  69186. */
  69187. dispose(): void;
  69188. }
  69189. /**
  69190. * Configures an agent
  69191. */
  69192. export interface IAgentParameters {
  69193. /**
  69194. * Agent radius. [Limit: >= 0]
  69195. */
  69196. radius: number;
  69197. /**
  69198. * Agent height. [Limit: > 0]
  69199. */
  69200. height: number;
  69201. /**
  69202. * Maximum allowed acceleration. [Limit: >= 0]
  69203. */
  69204. maxAcceleration: number;
  69205. /**
  69206. * Maximum allowed speed. [Limit: >= 0]
  69207. */
  69208. maxSpeed: number;
  69209. /**
  69210. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69211. */
  69212. collisionQueryRange: number;
  69213. /**
  69214. * The path visibility optimization range. [Limit: > 0]
  69215. */
  69216. pathOptimizationRange: number;
  69217. /**
  69218. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69219. */
  69220. separationWeight: number;
  69221. }
  69222. /**
  69223. * Configures the navigation mesh creation
  69224. */
  69225. export interface INavMeshParameters {
  69226. /**
  69227. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69228. */
  69229. cs: number;
  69230. /**
  69231. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69232. */
  69233. ch: number;
  69234. /**
  69235. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69236. */
  69237. walkableSlopeAngle: number;
  69238. /**
  69239. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69240. * be considered walkable. [Limit: >= 3] [Units: vx]
  69241. */
  69242. walkableHeight: number;
  69243. /**
  69244. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69245. */
  69246. walkableClimb: number;
  69247. /**
  69248. * The distance to erode/shrink the walkable area of the heightfield away from
  69249. * obstructions. [Limit: >=0] [Units: vx]
  69250. */
  69251. walkableRadius: number;
  69252. /**
  69253. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69254. */
  69255. maxEdgeLen: number;
  69256. /**
  69257. * The maximum distance a simplfied contour's border edges should deviate
  69258. * the original raw contour. [Limit: >=0] [Units: vx]
  69259. */
  69260. maxSimplificationError: number;
  69261. /**
  69262. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69263. */
  69264. minRegionArea: number;
  69265. /**
  69266. * Any regions with a span count smaller than this value will, if possible,
  69267. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69268. */
  69269. mergeRegionArea: number;
  69270. /**
  69271. * The maximum number of vertices allowed for polygons generated during the
  69272. * contour to polygon conversion process. [Limit: >= 3]
  69273. */
  69274. maxVertsPerPoly: number;
  69275. /**
  69276. * Sets the sampling distance to use when generating the detail mesh.
  69277. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69278. */
  69279. detailSampleDist: number;
  69280. /**
  69281. * The maximum distance the detail mesh surface should deviate from heightfield
  69282. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69283. */
  69284. detailSampleMaxError: number;
  69285. }
  69286. }
  69287. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69288. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69289. import { Mesh } from "babylonjs/Meshes/mesh";
  69290. import { Scene } from "babylonjs/scene";
  69291. import { Vector3 } from "babylonjs/Maths/math";
  69292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69293. /**
  69294. * RecastJS navigation plugin
  69295. */
  69296. export class RecastJSPlugin implements INavigationEnginePlugin {
  69297. /**
  69298. * Reference to the Recast library
  69299. */
  69300. bjsRECAST: any;
  69301. /**
  69302. * plugin name
  69303. */
  69304. name: string;
  69305. /**
  69306. * the first navmesh created. We might extend this to support multiple navmeshes
  69307. */
  69308. navMesh: any;
  69309. /**
  69310. * Initializes the recastJS plugin
  69311. * @param recastInjection can be used to inject your own recast reference
  69312. */
  69313. constructor(recastInjection?: any);
  69314. /**
  69315. * Creates a navigation mesh
  69316. * @param meshes array of all the geometry used to compute the navigatio mesh
  69317. * @param parameters bunch of parameters used to filter geometry
  69318. */
  69319. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69320. /**
  69321. * Create a navigation mesh debug mesh
  69322. * @param scene is where the mesh will be added
  69323. * @returns debug display mesh
  69324. */
  69325. createDebugNavMesh(scene: Scene): Mesh;
  69326. /**
  69327. * Get a navigation mesh constrained position, closest to the parameter position
  69328. * @param position world position
  69329. * @returns the closest point to position constrained by the navigation mesh
  69330. */
  69331. getClosestPoint(position: Vector3): Vector3;
  69332. /**
  69333. * Get a navigation mesh constrained position, closest to the parameter position
  69334. * @param position world position
  69335. * @param result output the closest point to position constrained by the navigation mesh
  69336. */
  69337. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69338. /**
  69339. * Get a navigation mesh constrained position, within a particular radius
  69340. * @param position world position
  69341. * @param maxRadius the maximum distance to the constrained world position
  69342. * @returns the closest point to position constrained by the navigation mesh
  69343. */
  69344. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69345. /**
  69346. * Get a navigation mesh constrained position, within a particular radius
  69347. * @param position world position
  69348. * @param maxRadius the maximum distance to the constrained world position
  69349. * @param result output the closest point to position constrained by the navigation mesh
  69350. */
  69351. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69352. /**
  69353. * Compute the final position from a segment made of destination-position
  69354. * @param position world position
  69355. * @param destination world position
  69356. * @returns the resulting point along the navmesh
  69357. */
  69358. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69359. /**
  69360. * Compute the final position from a segment made of destination-position
  69361. * @param position world position
  69362. * @param destination world position
  69363. * @param result output the resulting point along the navmesh
  69364. */
  69365. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69366. /**
  69367. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69368. * @param start world position
  69369. * @param end world position
  69370. * @returns array containing world position composing the path
  69371. */
  69372. computePath(start: Vector3, end: Vector3): Vector3[];
  69373. /**
  69374. * Create a new Crowd so you can add agents
  69375. * @param maxAgents the maximum agent count in the crowd
  69376. * @param maxAgentRadius the maximum radius an agent can have
  69377. * @param scene to attach the crowd to
  69378. * @returns the crowd you can add agents to
  69379. */
  69380. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69381. /**
  69382. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69383. * The queries will try to find a solution within those bounds
  69384. * default is (1,1,1)
  69385. * @param extent x,y,z value that define the extent around the queries point of reference
  69386. */
  69387. setDefaultQueryExtent(extent: Vector3): void;
  69388. /**
  69389. * Get the Bounding box extent specified by setDefaultQueryExtent
  69390. * @returns the box extent values
  69391. */
  69392. getDefaultQueryExtent(): Vector3;
  69393. /**
  69394. * build the navmesh from a previously saved state using getNavmeshData
  69395. * @param data the Uint8Array returned by getNavmeshData
  69396. */
  69397. buildFromNavmeshData(data: Uint8Array): void;
  69398. /**
  69399. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69400. * @returns data the Uint8Array that can be saved and reused
  69401. */
  69402. getNavmeshData(): Uint8Array;
  69403. /**
  69404. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69405. * @param result output the box extent values
  69406. */
  69407. getDefaultQueryExtentToRef(result: Vector3): void;
  69408. /**
  69409. * Disposes
  69410. */
  69411. dispose(): void;
  69412. /**
  69413. * If this plugin is supported
  69414. * @returns true if plugin is supported
  69415. */
  69416. isSupported(): boolean;
  69417. }
  69418. /**
  69419. * Recast detour crowd implementation
  69420. */
  69421. export class RecastJSCrowd implements ICrowd {
  69422. /**
  69423. * Recast/detour plugin
  69424. */
  69425. bjsRECASTPlugin: RecastJSPlugin;
  69426. /**
  69427. * Link to the detour crowd
  69428. */
  69429. recastCrowd: any;
  69430. /**
  69431. * One transform per agent
  69432. */
  69433. transforms: TransformNode[];
  69434. /**
  69435. * All agents created
  69436. */
  69437. agents: number[];
  69438. /**
  69439. * Link to the scene is kept to unregister the crowd from the scene
  69440. */
  69441. private _scene;
  69442. /**
  69443. * Observer for crowd updates
  69444. */
  69445. private _onBeforeAnimationsObserver;
  69446. /**
  69447. * Constructor
  69448. * @param plugin recastJS plugin
  69449. * @param maxAgents the maximum agent count in the crowd
  69450. * @param maxAgentRadius the maximum radius an agent can have
  69451. * @param scene to attach the crowd to
  69452. * @returns the crowd you can add agents to
  69453. */
  69454. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69455. /**
  69456. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69457. * You can attach anything to that node. The node position is updated in the scene update tick.
  69458. * @param pos world position that will be constrained by the navigation mesh
  69459. * @param parameters agent parameters
  69460. * @param transform hooked to the agent that will be update by the scene
  69461. * @returns agent index
  69462. */
  69463. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69464. /**
  69465. * Returns the agent position in world space
  69466. * @param index agent index returned by addAgent
  69467. * @returns world space position
  69468. */
  69469. getAgentPosition(index: number): Vector3;
  69470. /**
  69471. * Returns the agent position result in world space
  69472. * @param index agent index returned by addAgent
  69473. * @param result output world space position
  69474. */
  69475. getAgentPositionToRef(index: number, result: Vector3): void;
  69476. /**
  69477. * Returns the agent velocity in world space
  69478. * @param index agent index returned by addAgent
  69479. * @returns world space velocity
  69480. */
  69481. getAgentVelocity(index: number): Vector3;
  69482. /**
  69483. * Returns the agent velocity result in world space
  69484. * @param index agent index returned by addAgent
  69485. * @param result output world space velocity
  69486. */
  69487. getAgentVelocityToRef(index: number, result: Vector3): void;
  69488. /**
  69489. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69490. * @param index agent index returned by addAgent
  69491. * @param destination targeted world position
  69492. */
  69493. agentGoto(index: number, destination: Vector3): void;
  69494. /**
  69495. * Teleport the agent to a new position
  69496. * @param index agent index returned by addAgent
  69497. * @param destination targeted world position
  69498. */
  69499. agentTeleport(index: number, destination: Vector3): void;
  69500. /**
  69501. * Update agent parameters
  69502. * @param index agent index returned by addAgent
  69503. * @param parameters agent parameters
  69504. */
  69505. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69506. /**
  69507. * remove a particular agent previously created
  69508. * @param index agent index returned by addAgent
  69509. */
  69510. removeAgent(index: number): void;
  69511. /**
  69512. * get the list of all agents attached to this crowd
  69513. * @returns list of agent indices
  69514. */
  69515. getAgents(): number[];
  69516. /**
  69517. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69518. * @param deltaTime in seconds
  69519. */
  69520. update(deltaTime: number): void;
  69521. /**
  69522. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69523. * The queries will try to find a solution within those bounds
  69524. * default is (1,1,1)
  69525. * @param extent x,y,z value that define the extent around the queries point of reference
  69526. */
  69527. setDefaultQueryExtent(extent: Vector3): void;
  69528. /**
  69529. * Get the Bounding box extent specified by setDefaultQueryExtent
  69530. * @returns the box extent values
  69531. */
  69532. getDefaultQueryExtent(): Vector3;
  69533. /**
  69534. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69535. * @param result output the box extent values
  69536. */
  69537. getDefaultQueryExtentToRef(result: Vector3): void;
  69538. /**
  69539. * Release all resources
  69540. */
  69541. dispose(): void;
  69542. }
  69543. }
  69544. declare module "babylonjs/Navigation/Plugins/index" {
  69545. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69546. }
  69547. declare module "babylonjs/Navigation/index" {
  69548. export * from "babylonjs/Navigation/INavigationEngine";
  69549. export * from "babylonjs/Navigation/Plugins/index";
  69550. }
  69551. declare module "babylonjs/Offline/database" {
  69552. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69553. /**
  69554. * Class used to enable access to IndexedDB
  69555. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69556. */
  69557. export class Database implements IOfflineProvider {
  69558. private _callbackManifestChecked;
  69559. private _currentSceneUrl;
  69560. private _db;
  69561. private _enableSceneOffline;
  69562. private _enableTexturesOffline;
  69563. private _manifestVersionFound;
  69564. private _mustUpdateRessources;
  69565. private _hasReachedQuota;
  69566. private _isSupported;
  69567. private _idbFactory;
  69568. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69569. private static IsUASupportingBlobStorage;
  69570. /**
  69571. * Gets a boolean indicating if Database storate is enabled (off by default)
  69572. */
  69573. static IDBStorageEnabled: boolean;
  69574. /**
  69575. * Gets a boolean indicating if scene must be saved in the database
  69576. */
  69577. get enableSceneOffline(): boolean;
  69578. /**
  69579. * Gets a boolean indicating if textures must be saved in the database
  69580. */
  69581. get enableTexturesOffline(): boolean;
  69582. /**
  69583. * Creates a new Database
  69584. * @param urlToScene defines the url to load the scene
  69585. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69586. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69587. */
  69588. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69589. private static _ParseURL;
  69590. private static _ReturnFullUrlLocation;
  69591. private _checkManifestFile;
  69592. /**
  69593. * Open the database and make it available
  69594. * @param successCallback defines the callback to call on success
  69595. * @param errorCallback defines the callback to call on error
  69596. */
  69597. open(successCallback: () => void, errorCallback: () => void): void;
  69598. /**
  69599. * Loads an image from the database
  69600. * @param url defines the url to load from
  69601. * @param image defines the target DOM image
  69602. */
  69603. loadImage(url: string, image: HTMLImageElement): void;
  69604. private _loadImageFromDBAsync;
  69605. private _saveImageIntoDBAsync;
  69606. private _checkVersionFromDB;
  69607. private _loadVersionFromDBAsync;
  69608. private _saveVersionIntoDBAsync;
  69609. /**
  69610. * Loads a file from database
  69611. * @param url defines the URL to load from
  69612. * @param sceneLoaded defines a callback to call on success
  69613. * @param progressCallBack defines a callback to call when progress changed
  69614. * @param errorCallback defines a callback to call on error
  69615. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69616. */
  69617. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69618. private _loadFileAsync;
  69619. private _saveFileAsync;
  69620. /**
  69621. * Validates if xhr data is correct
  69622. * @param xhr defines the request to validate
  69623. * @param dataType defines the expected data type
  69624. * @returns true if data is correct
  69625. */
  69626. private static _ValidateXHRData;
  69627. }
  69628. }
  69629. declare module "babylonjs/Offline/index" {
  69630. export * from "babylonjs/Offline/database";
  69631. export * from "babylonjs/Offline/IOfflineProvider";
  69632. }
  69633. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69634. /** @hidden */
  69635. export var gpuUpdateParticlesPixelShader: {
  69636. name: string;
  69637. shader: string;
  69638. };
  69639. }
  69640. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69641. /** @hidden */
  69642. export var gpuUpdateParticlesVertexShader: {
  69643. name: string;
  69644. shader: string;
  69645. };
  69646. }
  69647. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69648. /** @hidden */
  69649. export var clipPlaneFragmentDeclaration2: {
  69650. name: string;
  69651. shader: string;
  69652. };
  69653. }
  69654. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69655. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69656. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69657. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69658. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69659. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69660. /** @hidden */
  69661. export var gpuRenderParticlesPixelShader: {
  69662. name: string;
  69663. shader: string;
  69664. };
  69665. }
  69666. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69667. /** @hidden */
  69668. export var clipPlaneVertexDeclaration2: {
  69669. name: string;
  69670. shader: string;
  69671. };
  69672. }
  69673. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69674. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69675. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69676. /** @hidden */
  69677. export var gpuRenderParticlesVertexShader: {
  69678. name: string;
  69679. shader: string;
  69680. };
  69681. }
  69682. declare module "babylonjs/Particles/gpuParticleSystem" {
  69683. import { Nullable } from "babylonjs/types";
  69684. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69685. import { Observable } from "babylonjs/Misc/observable";
  69686. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69687. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69688. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69689. import { Scene, IDisposable } from "babylonjs/scene";
  69690. import { Effect } from "babylonjs/Materials/effect";
  69691. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69692. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69693. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69694. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69695. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69696. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69697. /**
  69698. * This represents a GPU particle system in Babylon
  69699. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69700. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69701. */
  69702. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69703. /**
  69704. * The layer mask we are rendering the particles through.
  69705. */
  69706. layerMask: number;
  69707. private _capacity;
  69708. private _activeCount;
  69709. private _currentActiveCount;
  69710. private _accumulatedCount;
  69711. private _renderEffect;
  69712. private _updateEffect;
  69713. private _buffer0;
  69714. private _buffer1;
  69715. private _spriteBuffer;
  69716. private _updateVAO;
  69717. private _renderVAO;
  69718. private _targetIndex;
  69719. private _sourceBuffer;
  69720. private _targetBuffer;
  69721. private _engine;
  69722. private _currentRenderId;
  69723. private _started;
  69724. private _stopped;
  69725. private _timeDelta;
  69726. private _randomTexture;
  69727. private _randomTexture2;
  69728. private _attributesStrideSize;
  69729. private _updateEffectOptions;
  69730. private _randomTextureSize;
  69731. private _actualFrame;
  69732. private _customEffect;
  69733. private readonly _rawTextureWidth;
  69734. /**
  69735. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69736. */
  69737. static get IsSupported(): boolean;
  69738. /**
  69739. * An event triggered when the system is disposed.
  69740. */
  69741. onDisposeObservable: Observable<IParticleSystem>;
  69742. /**
  69743. * Gets the maximum number of particles active at the same time.
  69744. * @returns The max number of active particles.
  69745. */
  69746. getCapacity(): number;
  69747. /**
  69748. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69749. * to override the particles.
  69750. */
  69751. forceDepthWrite: boolean;
  69752. /**
  69753. * Gets or set the number of active particles
  69754. */
  69755. get activeParticleCount(): number;
  69756. set activeParticleCount(value: number);
  69757. private _preWarmDone;
  69758. /**
  69759. * Specifies if the particles are updated in emitter local space or world space.
  69760. */
  69761. isLocal: boolean;
  69762. /**
  69763. * Is this system ready to be used/rendered
  69764. * @return true if the system is ready
  69765. */
  69766. isReady(): boolean;
  69767. /**
  69768. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69769. * @returns True if it has been started, otherwise false.
  69770. */
  69771. isStarted(): boolean;
  69772. /**
  69773. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69774. * @returns True if it has been stopped, otherwise false.
  69775. */
  69776. isStopped(): boolean;
  69777. /**
  69778. * Gets a boolean indicating that the system is stopping
  69779. * @returns true if the system is currently stopping
  69780. */
  69781. isStopping(): boolean;
  69782. /**
  69783. * Gets the number of particles active at the same time.
  69784. * @returns The number of active particles.
  69785. */
  69786. getActiveCount(): number;
  69787. /**
  69788. * Starts the particle system and begins to emit
  69789. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69790. */
  69791. start(delay?: number): void;
  69792. /**
  69793. * Stops the particle system.
  69794. */
  69795. stop(): void;
  69796. /**
  69797. * Remove all active particles
  69798. */
  69799. reset(): void;
  69800. /**
  69801. * Returns the string "GPUParticleSystem"
  69802. * @returns a string containing the class name
  69803. */
  69804. getClassName(): string;
  69805. /**
  69806. * Gets the custom effect used to render the particles
  69807. * @param blendMode Blend mode for which the effect should be retrieved
  69808. * @returns The effect
  69809. */
  69810. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69811. /**
  69812. * Sets the custom effect used to render the particles
  69813. * @param effect The effect to set
  69814. * @param blendMode Blend mode for which the effect should be set
  69815. */
  69816. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69817. /** @hidden */
  69818. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69819. /**
  69820. * Observable that will be called just before the particles are drawn
  69821. */
  69822. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69823. /**
  69824. * Gets the name of the particle vertex shader
  69825. */
  69826. get vertexShaderName(): string;
  69827. private _colorGradientsTexture;
  69828. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69829. /**
  69830. * Adds a new color gradient
  69831. * @param gradient defines the gradient to use (between 0 and 1)
  69832. * @param color1 defines the color to affect to the specified gradient
  69833. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69834. * @returns the current particle system
  69835. */
  69836. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69837. private _refreshColorGradient;
  69838. /** Force the system to rebuild all gradients that need to be resync */
  69839. forceRefreshGradients(): void;
  69840. /**
  69841. * Remove a specific color gradient
  69842. * @param gradient defines the gradient to remove
  69843. * @returns the current particle system
  69844. */
  69845. removeColorGradient(gradient: number): GPUParticleSystem;
  69846. private _angularSpeedGradientsTexture;
  69847. private _sizeGradientsTexture;
  69848. private _velocityGradientsTexture;
  69849. private _limitVelocityGradientsTexture;
  69850. private _dragGradientsTexture;
  69851. private _addFactorGradient;
  69852. /**
  69853. * Adds a new size gradient
  69854. * @param gradient defines the gradient to use (between 0 and 1)
  69855. * @param factor defines the size factor to affect to the specified gradient
  69856. * @returns the current particle system
  69857. */
  69858. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69859. /**
  69860. * Remove a specific size gradient
  69861. * @param gradient defines the gradient to remove
  69862. * @returns the current particle system
  69863. */
  69864. removeSizeGradient(gradient: number): GPUParticleSystem;
  69865. private _refreshFactorGradient;
  69866. /**
  69867. * Adds a new angular speed gradient
  69868. * @param gradient defines the gradient to use (between 0 and 1)
  69869. * @param factor defines the angular speed to affect to the specified gradient
  69870. * @returns the current particle system
  69871. */
  69872. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69873. /**
  69874. * Remove a specific angular speed gradient
  69875. * @param gradient defines the gradient to remove
  69876. * @returns the current particle system
  69877. */
  69878. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69879. /**
  69880. * Adds a new velocity gradient
  69881. * @param gradient defines the gradient to use (between 0 and 1)
  69882. * @param factor defines the velocity to affect to the specified gradient
  69883. * @returns the current particle system
  69884. */
  69885. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69886. /**
  69887. * Remove a specific velocity gradient
  69888. * @param gradient defines the gradient to remove
  69889. * @returns the current particle system
  69890. */
  69891. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69892. /**
  69893. * Adds a new limit velocity gradient
  69894. * @param gradient defines the gradient to use (between 0 and 1)
  69895. * @param factor defines the limit velocity value to affect to the specified gradient
  69896. * @returns the current particle system
  69897. */
  69898. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69899. /**
  69900. * Remove a specific limit velocity gradient
  69901. * @param gradient defines the gradient to remove
  69902. * @returns the current particle system
  69903. */
  69904. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69905. /**
  69906. * Adds a new drag gradient
  69907. * @param gradient defines the gradient to use (between 0 and 1)
  69908. * @param factor defines the drag value to affect to the specified gradient
  69909. * @returns the current particle system
  69910. */
  69911. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69912. /**
  69913. * Remove a specific drag gradient
  69914. * @param gradient defines the gradient to remove
  69915. * @returns the current particle system
  69916. */
  69917. removeDragGradient(gradient: number): GPUParticleSystem;
  69918. /**
  69919. * Not supported by GPUParticleSystem
  69920. * @param gradient defines the gradient to use (between 0 and 1)
  69921. * @param factor defines the emit rate value to affect to the specified gradient
  69922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69923. * @returns the current particle system
  69924. */
  69925. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69926. /**
  69927. * Not supported by GPUParticleSystem
  69928. * @param gradient defines the gradient to remove
  69929. * @returns the current particle system
  69930. */
  69931. removeEmitRateGradient(gradient: number): IParticleSystem;
  69932. /**
  69933. * Not supported by GPUParticleSystem
  69934. * @param gradient defines the gradient to use (between 0 and 1)
  69935. * @param factor defines the start size value to affect to the specified gradient
  69936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69937. * @returns the current particle system
  69938. */
  69939. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69940. /**
  69941. * Not supported by GPUParticleSystem
  69942. * @param gradient defines the gradient to remove
  69943. * @returns the current particle system
  69944. */
  69945. removeStartSizeGradient(gradient: number): IParticleSystem;
  69946. /**
  69947. * Not supported by GPUParticleSystem
  69948. * @param gradient defines the gradient to use (between 0 and 1)
  69949. * @param min defines the color remap minimal range
  69950. * @param max defines the color remap maximal range
  69951. * @returns the current particle system
  69952. */
  69953. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69954. /**
  69955. * Not supported by GPUParticleSystem
  69956. * @param gradient defines the gradient to remove
  69957. * @returns the current particle system
  69958. */
  69959. removeColorRemapGradient(): IParticleSystem;
  69960. /**
  69961. * Not supported by GPUParticleSystem
  69962. * @param gradient defines the gradient to use (between 0 and 1)
  69963. * @param min defines the alpha remap minimal range
  69964. * @param max defines the alpha remap maximal range
  69965. * @returns the current particle system
  69966. */
  69967. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69968. /**
  69969. * Not supported by GPUParticleSystem
  69970. * @param gradient defines the gradient to remove
  69971. * @returns the current particle system
  69972. */
  69973. removeAlphaRemapGradient(): IParticleSystem;
  69974. /**
  69975. * Not supported by GPUParticleSystem
  69976. * @param gradient defines the gradient to use (between 0 and 1)
  69977. * @param color defines the color to affect to the specified gradient
  69978. * @returns the current particle system
  69979. */
  69980. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69981. /**
  69982. * Not supported by GPUParticleSystem
  69983. * @param gradient defines the gradient to remove
  69984. * @returns the current particle system
  69985. */
  69986. removeRampGradient(): IParticleSystem;
  69987. /**
  69988. * Not supported by GPUParticleSystem
  69989. * @returns the list of ramp gradients
  69990. */
  69991. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69992. /**
  69993. * Not supported by GPUParticleSystem
  69994. * Gets or sets a boolean indicating that ramp gradients must be used
  69995. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69996. */
  69997. get useRampGradients(): boolean;
  69998. set useRampGradients(value: boolean);
  69999. /**
  70000. * Not supported by GPUParticleSystem
  70001. * @param gradient defines the gradient to use (between 0 and 1)
  70002. * @param factor defines the life time factor to affect to the specified gradient
  70003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70004. * @returns the current particle system
  70005. */
  70006. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70007. /**
  70008. * Not supported by GPUParticleSystem
  70009. * @param gradient defines the gradient to remove
  70010. * @returns the current particle system
  70011. */
  70012. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70013. /**
  70014. * Instantiates a GPU particle system.
  70015. * 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.
  70016. * @param name The name of the particle system
  70017. * @param options The options used to create the system
  70018. * @param scene The scene the particle system belongs to
  70019. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70020. * @param customEffect a custom effect used to change the way particles are rendered by default
  70021. */
  70022. constructor(name: string, options: Partial<{
  70023. capacity: number;
  70024. randomTextureSize: number;
  70025. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70026. protected _reset(): void;
  70027. private _createUpdateVAO;
  70028. private _createRenderVAO;
  70029. private _initialize;
  70030. /** @hidden */
  70031. _recreateUpdateEffect(): void;
  70032. private _getEffect;
  70033. /**
  70034. * Fill the defines array according to the current settings of the particle system
  70035. * @param defines Array to be updated
  70036. * @param blendMode blend mode to take into account when updating the array
  70037. */
  70038. fillDefines(defines: Array<string>, blendMode?: number): void;
  70039. /**
  70040. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70041. * @param uniforms Uniforms array to fill
  70042. * @param attributes Attributes array to fill
  70043. * @param samplers Samplers array to fill
  70044. */
  70045. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70046. /** @hidden */
  70047. _recreateRenderEffect(): Effect;
  70048. /**
  70049. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70050. * @param preWarm defines if we are in the pre-warmimg phase
  70051. */
  70052. animate(preWarm?: boolean): void;
  70053. private _createFactorGradientTexture;
  70054. private _createSizeGradientTexture;
  70055. private _createAngularSpeedGradientTexture;
  70056. private _createVelocityGradientTexture;
  70057. private _createLimitVelocityGradientTexture;
  70058. private _createDragGradientTexture;
  70059. private _createColorGradientTexture;
  70060. /**
  70061. * Renders the particle system in its current state
  70062. * @param preWarm defines if the system should only update the particles but not render them
  70063. * @returns the current number of particles
  70064. */
  70065. render(preWarm?: boolean): number;
  70066. /**
  70067. * Rebuilds the particle system
  70068. */
  70069. rebuild(): void;
  70070. private _releaseBuffers;
  70071. private _releaseVAOs;
  70072. /**
  70073. * Disposes the particle system and free the associated resources
  70074. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70075. */
  70076. dispose(disposeTexture?: boolean): void;
  70077. /**
  70078. * Clones the particle system.
  70079. * @param name The name of the cloned object
  70080. * @param newEmitter The new emitter to use
  70081. * @returns the cloned particle system
  70082. */
  70083. clone(name: string, newEmitter: any): GPUParticleSystem;
  70084. /**
  70085. * Serializes the particle system to a JSON object
  70086. * @param serializeTexture defines if the texture must be serialized as well
  70087. * @returns the JSON object
  70088. */
  70089. serialize(serializeTexture?: boolean): any;
  70090. /**
  70091. * Parses a JSON object to create a GPU particle system.
  70092. * @param parsedParticleSystem The JSON object to parse
  70093. * @param scene The scene to create the particle system in
  70094. * @param rootUrl The root url to use to load external dependencies like texture
  70095. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70096. * @returns the parsed GPU particle system
  70097. */
  70098. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70099. }
  70100. }
  70101. declare module "babylonjs/Particles/particleSystemSet" {
  70102. import { Nullable } from "babylonjs/types";
  70103. import { Color3 } from "babylonjs/Maths/math.color";
  70104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70106. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70107. import { Scene, IDisposable } from "babylonjs/scene";
  70108. /**
  70109. * Represents a set of particle systems working together to create a specific effect
  70110. */
  70111. export class ParticleSystemSet implements IDisposable {
  70112. /**
  70113. * Gets or sets base Assets URL
  70114. */
  70115. static BaseAssetsUrl: string;
  70116. private _emitterCreationOptions;
  70117. private _emitterNode;
  70118. /**
  70119. * Gets the particle system list
  70120. */
  70121. systems: IParticleSystem[];
  70122. /**
  70123. * Gets the emitter node used with this set
  70124. */
  70125. get emitterNode(): Nullable<TransformNode>;
  70126. /**
  70127. * Creates a new emitter mesh as a sphere
  70128. * @param options defines the options used to create the sphere
  70129. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70130. * @param scene defines the hosting scene
  70131. */
  70132. setEmitterAsSphere(options: {
  70133. diameter: number;
  70134. segments: number;
  70135. color: Color3;
  70136. }, renderingGroupId: number, scene: Scene): void;
  70137. /**
  70138. * Starts all particle systems of the set
  70139. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70140. */
  70141. start(emitter?: AbstractMesh): void;
  70142. /**
  70143. * Release all associated resources
  70144. */
  70145. dispose(): void;
  70146. /**
  70147. * Serialize the set into a JSON compatible object
  70148. * @param serializeTexture defines if the texture must be serialized as well
  70149. * @returns a JSON compatible representation of the set
  70150. */
  70151. serialize(serializeTexture?: boolean): any;
  70152. /**
  70153. * Parse a new ParticleSystemSet from a serialized source
  70154. * @param data defines a JSON compatible representation of the set
  70155. * @param scene defines the hosting scene
  70156. * @param gpu defines if we want GPU particles or CPU particles
  70157. * @returns a new ParticleSystemSet
  70158. */
  70159. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70160. }
  70161. }
  70162. declare module "babylonjs/Particles/particleHelper" {
  70163. import { Nullable } from "babylonjs/types";
  70164. import { Scene } from "babylonjs/scene";
  70165. import { Vector3 } from "babylonjs/Maths/math.vector";
  70166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70167. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70168. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70169. /**
  70170. * This class is made for on one-liner static method to help creating particle system set.
  70171. */
  70172. export class ParticleHelper {
  70173. /**
  70174. * Gets or sets base Assets URL
  70175. */
  70176. static BaseAssetsUrl: string;
  70177. /** Define the Url to load snippets */
  70178. static SnippetUrl: string;
  70179. /**
  70180. * Create a default particle system that you can tweak
  70181. * @param emitter defines the emitter to use
  70182. * @param capacity defines the system capacity (default is 500 particles)
  70183. * @param scene defines the hosting scene
  70184. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70185. * @returns the new Particle system
  70186. */
  70187. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70188. /**
  70189. * This is the main static method (one-liner) of this helper to create different particle systems
  70190. * @param type This string represents the type to the particle system to create
  70191. * @param scene The scene where the particle system should live
  70192. * @param gpu If the system will use gpu
  70193. * @returns the ParticleSystemSet created
  70194. */
  70195. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70196. /**
  70197. * Static function used to export a particle system to a ParticleSystemSet variable.
  70198. * Please note that the emitter shape is not exported
  70199. * @param systems defines the particle systems to export
  70200. * @returns the created particle system set
  70201. */
  70202. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70203. /**
  70204. * Creates a particle system from a snippet saved in a remote file
  70205. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70206. * @param url defines the url to load from
  70207. * @param scene defines the hosting scene
  70208. * @param gpu If the system will use gpu
  70209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70210. * @returns a promise that will resolve to the new particle system
  70211. */
  70212. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70213. /**
  70214. * Creates a particle system from a snippet saved by the particle system editor
  70215. * @param snippetId defines the snippet to load
  70216. * @param scene defines the hosting scene
  70217. * @param gpu If the system will use gpu
  70218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70219. * @returns a promise that will resolve to the new particle system
  70220. */
  70221. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70222. }
  70223. }
  70224. declare module "babylonjs/Particles/particleSystemComponent" {
  70225. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70226. import { Effect } from "babylonjs/Materials/effect";
  70227. import "babylonjs/Shaders/particles.vertex";
  70228. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70229. module "babylonjs/Engines/engine" {
  70230. interface Engine {
  70231. /**
  70232. * Create an effect to use with particle systems.
  70233. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70234. * the particle system for which you want to create a custom effect in the last parameter
  70235. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70236. * @param uniformsNames defines a list of attribute names
  70237. * @param samplers defines an array of string used to represent textures
  70238. * @param defines defines the string containing the defines to use to compile the shaders
  70239. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70240. * @param onCompiled defines a function to call when the effect creation is successful
  70241. * @param onError defines a function to call when the effect creation has failed
  70242. * @param particleSystem the particle system you want to create the effect for
  70243. * @returns the new Effect
  70244. */
  70245. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70246. }
  70247. }
  70248. module "babylonjs/Meshes/mesh" {
  70249. interface Mesh {
  70250. /**
  70251. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70252. * @returns an array of IParticleSystem
  70253. */
  70254. getEmittedParticleSystems(): IParticleSystem[];
  70255. /**
  70256. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70257. * @returns an array of IParticleSystem
  70258. */
  70259. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70260. }
  70261. }
  70262. }
  70263. declare module "babylonjs/Particles/pointsCloudSystem" {
  70264. import { Color4 } from "babylonjs/Maths/math";
  70265. import { Mesh } from "babylonjs/Meshes/mesh";
  70266. import { Scene, IDisposable } from "babylonjs/scene";
  70267. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70268. /** Defines the 4 color options */
  70269. export enum PointColor {
  70270. /** color value */
  70271. Color = 2,
  70272. /** uv value */
  70273. UV = 1,
  70274. /** random value */
  70275. Random = 0,
  70276. /** stated value */
  70277. Stated = 3
  70278. }
  70279. /**
  70280. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70281. * 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.
  70282. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70283. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70284. *
  70285. * Full documentation here : TO BE ENTERED
  70286. */
  70287. export class PointsCloudSystem implements IDisposable {
  70288. /**
  70289. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70290. * Example : var p = SPS.particles[i];
  70291. */
  70292. particles: CloudPoint[];
  70293. /**
  70294. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70295. */
  70296. nbParticles: number;
  70297. /**
  70298. * This a counter for your own usage. It's not set by any SPS functions.
  70299. */
  70300. counter: number;
  70301. /**
  70302. * The PCS name. This name is also given to the underlying mesh.
  70303. */
  70304. name: string;
  70305. /**
  70306. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70307. */
  70308. mesh: Mesh;
  70309. /**
  70310. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70311. * Please read :
  70312. */
  70313. vars: any;
  70314. /**
  70315. * @hidden
  70316. */
  70317. _size: number;
  70318. private _scene;
  70319. private _promises;
  70320. private _positions;
  70321. private _indices;
  70322. private _normals;
  70323. private _colors;
  70324. private _uvs;
  70325. private _indices32;
  70326. private _positions32;
  70327. private _colors32;
  70328. private _uvs32;
  70329. private _updatable;
  70330. private _isVisibilityBoxLocked;
  70331. private _alwaysVisible;
  70332. private _groups;
  70333. private _groupCounter;
  70334. private _computeParticleColor;
  70335. private _computeParticleTexture;
  70336. private _computeParticleRotation;
  70337. private _computeBoundingBox;
  70338. private _isReady;
  70339. /**
  70340. * Creates a PCS (Points Cloud System) object
  70341. * @param name (String) is the PCS name, this will be the underlying mesh name
  70342. * @param pointSize (number) is the size for each point
  70343. * @param scene (Scene) is the scene in which the PCS is added
  70344. * @param options defines the options of the PCS e.g.
  70345. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70346. */
  70347. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70348. updatable?: boolean;
  70349. });
  70350. /**
  70351. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70352. * If no points were added to the PCS, the returned mesh is just a single point.
  70353. * @returns a promise for the created mesh
  70354. */
  70355. buildMeshAsync(): Promise<Mesh>;
  70356. /**
  70357. * @hidden
  70358. */
  70359. private _buildMesh;
  70360. private _addParticle;
  70361. private _randomUnitVector;
  70362. private _getColorIndicesForCoord;
  70363. private _setPointsColorOrUV;
  70364. private _colorFromTexture;
  70365. private _calculateDensity;
  70366. /**
  70367. * Adds points to the PCS in random positions within a unit sphere
  70368. * @param nb (positive integer) the number of particles to be created from this model
  70369. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70370. * @returns the number of groups in the system
  70371. */
  70372. addPoints(nb: number, pointFunction?: any): number;
  70373. /**
  70374. * Adds points to the PCS from the surface of the model shape
  70375. * @param mesh is any Mesh object that will be used as a surface model for the points
  70376. * @param nb (positive integer) the number of particles to be created from this model
  70377. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70378. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70379. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70380. * @returns the number of groups in the system
  70381. */
  70382. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70383. /**
  70384. * Adds points to the PCS inside the model shape
  70385. * @param mesh is any Mesh object that will be used as a surface model for the points
  70386. * @param nb (positive integer) the number of particles to be created from this model
  70387. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70388. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70389. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70390. * @returns the number of groups in the system
  70391. */
  70392. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70393. /**
  70394. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70395. * This method calls `updateParticle()` for each particle of the SPS.
  70396. * For an animated SPS, it is usually called within the render loop.
  70397. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70398. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70399. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70400. * @returns the PCS.
  70401. */
  70402. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70403. /**
  70404. * Disposes the PCS.
  70405. */
  70406. dispose(): void;
  70407. /**
  70408. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70409. * doc :
  70410. * @returns the PCS.
  70411. */
  70412. refreshVisibleSize(): PointsCloudSystem;
  70413. /**
  70414. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70415. * @param size the size (float) of the visibility box
  70416. * note : this doesn't lock the PCS mesh bounding box.
  70417. * doc :
  70418. */
  70419. setVisibilityBox(size: number): void;
  70420. /**
  70421. * Gets whether the PCS is always visible or not
  70422. * doc :
  70423. */
  70424. get isAlwaysVisible(): boolean;
  70425. /**
  70426. * Sets the PCS as always visible or not
  70427. * doc :
  70428. */
  70429. set isAlwaysVisible(val: boolean);
  70430. /**
  70431. * Tells to `setParticles()` to compute the particle rotations or not
  70432. * Default value : false. The PCS is faster when it's set to false
  70433. * Note : particle rotations are only applied to parent particles
  70434. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70435. */
  70436. set computeParticleRotation(val: boolean);
  70437. /**
  70438. * Tells to `setParticles()` to compute the particle colors or not.
  70439. * Default value : true. The PCS is faster when it's set to false.
  70440. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70441. */
  70442. set computeParticleColor(val: boolean);
  70443. set computeParticleTexture(val: boolean);
  70444. /**
  70445. * Gets if `setParticles()` computes the particle colors or not.
  70446. * Default value : false. The PCS is faster when it's set to false.
  70447. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70448. */
  70449. get computeParticleColor(): boolean;
  70450. /**
  70451. * Gets if `setParticles()` computes the particle textures or not.
  70452. * Default value : false. The PCS is faster when it's set to false.
  70453. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70454. */
  70455. get computeParticleTexture(): boolean;
  70456. /**
  70457. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70458. */
  70459. set computeBoundingBox(val: boolean);
  70460. /**
  70461. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70462. */
  70463. get computeBoundingBox(): boolean;
  70464. /**
  70465. * This function does nothing. It may be overwritten to set all the particle first values.
  70466. * The PCS doesn't call this function, you may have to call it by your own.
  70467. * doc :
  70468. */
  70469. initParticles(): void;
  70470. /**
  70471. * This function does nothing. It may be overwritten to recycle a particle
  70472. * The PCS doesn't call this function, you can to call it
  70473. * doc :
  70474. * @param particle The particle to recycle
  70475. * @returns the recycled particle
  70476. */
  70477. recycleParticle(particle: CloudPoint): CloudPoint;
  70478. /**
  70479. * Updates a particle : this function should be overwritten by the user.
  70480. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70481. * doc :
  70482. * @example : just set a particle position or velocity and recycle conditions
  70483. * @param particle The particle to update
  70484. * @returns the updated particle
  70485. */
  70486. updateParticle(particle: CloudPoint): CloudPoint;
  70487. /**
  70488. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70489. * This does nothing and may be overwritten by the user.
  70490. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70491. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70492. * @param update the boolean update value actually passed to setParticles()
  70493. */
  70494. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70495. /**
  70496. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70497. * This will be passed three parameters.
  70498. * This does nothing and may be overwritten by the user.
  70499. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70500. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70501. * @param update the boolean update value actually passed to setParticles()
  70502. */
  70503. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70504. }
  70505. }
  70506. declare module "babylonjs/Particles/cloudPoint" {
  70507. import { Nullable } from "babylonjs/types";
  70508. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70509. import { Mesh } from "babylonjs/Meshes/mesh";
  70510. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70511. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70512. /**
  70513. * Represents one particle of a points cloud system.
  70514. */
  70515. export class CloudPoint {
  70516. /**
  70517. * particle global index
  70518. */
  70519. idx: number;
  70520. /**
  70521. * The color of the particle
  70522. */
  70523. color: Nullable<Color4>;
  70524. /**
  70525. * The world space position of the particle.
  70526. */
  70527. position: Vector3;
  70528. /**
  70529. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70530. */
  70531. rotation: Vector3;
  70532. /**
  70533. * The world space rotation quaternion of the particle.
  70534. */
  70535. rotationQuaternion: Nullable<Quaternion>;
  70536. /**
  70537. * The uv of the particle.
  70538. */
  70539. uv: Nullable<Vector2>;
  70540. /**
  70541. * The current speed of the particle.
  70542. */
  70543. velocity: Vector3;
  70544. /**
  70545. * The pivot point in the particle local space.
  70546. */
  70547. pivot: Vector3;
  70548. /**
  70549. * Must the particle be translated from its pivot point in its local space ?
  70550. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70551. * Default : false
  70552. */
  70553. translateFromPivot: boolean;
  70554. /**
  70555. * Index of this particle in the global "positions" array (Internal use)
  70556. * @hidden
  70557. */
  70558. _pos: number;
  70559. /**
  70560. * @hidden Index of this particle in the global "indices" array (Internal use)
  70561. */
  70562. _ind: number;
  70563. /**
  70564. * Group this particle belongs to
  70565. */
  70566. _group: PointsGroup;
  70567. /**
  70568. * Group id of this particle
  70569. */
  70570. groupId: number;
  70571. /**
  70572. * Index of the particle in its group id (Internal use)
  70573. */
  70574. idxInGroup: number;
  70575. /**
  70576. * @hidden Particle BoundingInfo object (Internal use)
  70577. */
  70578. _boundingInfo: BoundingInfo;
  70579. /**
  70580. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70581. */
  70582. _pcs: PointsCloudSystem;
  70583. /**
  70584. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70585. */
  70586. _stillInvisible: boolean;
  70587. /**
  70588. * @hidden Last computed particle rotation matrix
  70589. */
  70590. _rotationMatrix: number[];
  70591. /**
  70592. * Parent particle Id, if any.
  70593. * Default null.
  70594. */
  70595. parentId: Nullable<number>;
  70596. /**
  70597. * @hidden Internal global position in the PCS.
  70598. */
  70599. _globalPosition: Vector3;
  70600. /**
  70601. * Creates a Point Cloud object.
  70602. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70603. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70604. * @param group (PointsGroup) is the group the particle belongs to
  70605. * @param groupId (integer) is the group identifier in the PCS.
  70606. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70607. * @param pcs defines the PCS it is associated to
  70608. */
  70609. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70610. /**
  70611. * get point size
  70612. */
  70613. get size(): Vector3;
  70614. /**
  70615. * Set point size
  70616. */
  70617. set size(scale: Vector3);
  70618. /**
  70619. * Legacy support, changed quaternion to rotationQuaternion
  70620. */
  70621. get quaternion(): Nullable<Quaternion>;
  70622. /**
  70623. * Legacy support, changed quaternion to rotationQuaternion
  70624. */
  70625. set quaternion(q: Nullable<Quaternion>);
  70626. /**
  70627. * Returns a boolean. True if the particle intersects a mesh, else false
  70628. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70629. * @param target is the object (point or mesh) what the intersection is computed against
  70630. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70631. * @returns true if it intersects
  70632. */
  70633. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70634. /**
  70635. * get the rotation matrix of the particle
  70636. * @hidden
  70637. */
  70638. getRotationMatrix(m: Matrix): void;
  70639. }
  70640. /**
  70641. * Represents a group of points in a points cloud system
  70642. * * PCS internal tool, don't use it manually.
  70643. */
  70644. export class PointsGroup {
  70645. /**
  70646. * The group id
  70647. * @hidden
  70648. */
  70649. groupID: number;
  70650. /**
  70651. * image data for group (internal use)
  70652. * @hidden
  70653. */
  70654. _groupImageData: Nullable<ArrayBufferView>;
  70655. /**
  70656. * Image Width (internal use)
  70657. * @hidden
  70658. */
  70659. _groupImgWidth: number;
  70660. /**
  70661. * Image Height (internal use)
  70662. * @hidden
  70663. */
  70664. _groupImgHeight: number;
  70665. /**
  70666. * Custom position function (internal use)
  70667. * @hidden
  70668. */
  70669. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70670. /**
  70671. * density per facet for surface points
  70672. * @hidden
  70673. */
  70674. _groupDensity: number[];
  70675. /**
  70676. * Only when points are colored by texture carries pointer to texture list array
  70677. * @hidden
  70678. */
  70679. _textureNb: number;
  70680. /**
  70681. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70682. * PCS internal tool, don't use it manually.
  70683. * @hidden
  70684. */
  70685. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70686. }
  70687. }
  70688. declare module "babylonjs/Particles/index" {
  70689. export * from "babylonjs/Particles/baseParticleSystem";
  70690. export * from "babylonjs/Particles/EmitterTypes/index";
  70691. export * from "babylonjs/Particles/gpuParticleSystem";
  70692. export * from "babylonjs/Particles/IParticleSystem";
  70693. export * from "babylonjs/Particles/particle";
  70694. export * from "babylonjs/Particles/particleHelper";
  70695. export * from "babylonjs/Particles/particleSystem";
  70696. import "babylonjs/Particles/particleSystemComponent";
  70697. export * from "babylonjs/Particles/particleSystemComponent";
  70698. export * from "babylonjs/Particles/particleSystemSet";
  70699. export * from "babylonjs/Particles/solidParticle";
  70700. export * from "babylonjs/Particles/solidParticleSystem";
  70701. export * from "babylonjs/Particles/cloudPoint";
  70702. export * from "babylonjs/Particles/pointsCloudSystem";
  70703. export * from "babylonjs/Particles/subEmitter";
  70704. }
  70705. declare module "babylonjs/Physics/physicsEngineComponent" {
  70706. import { Nullable } from "babylonjs/types";
  70707. import { Observable, Observer } from "babylonjs/Misc/observable";
  70708. import { Vector3 } from "babylonjs/Maths/math.vector";
  70709. import { Mesh } from "babylonjs/Meshes/mesh";
  70710. import { ISceneComponent } from "babylonjs/sceneComponent";
  70711. import { Scene } from "babylonjs/scene";
  70712. import { Node } from "babylonjs/node";
  70713. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70714. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70715. module "babylonjs/scene" {
  70716. interface Scene {
  70717. /** @hidden (Backing field) */
  70718. _physicsEngine: Nullable<IPhysicsEngine>;
  70719. /** @hidden */
  70720. _physicsTimeAccumulator: number;
  70721. /**
  70722. * Gets the current physics engine
  70723. * @returns a IPhysicsEngine or null if none attached
  70724. */
  70725. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70726. /**
  70727. * Enables physics to the current scene
  70728. * @param gravity defines the scene's gravity for the physics engine
  70729. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70730. * @return a boolean indicating if the physics engine was initialized
  70731. */
  70732. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70733. /**
  70734. * Disables and disposes the physics engine associated with the scene
  70735. */
  70736. disablePhysicsEngine(): void;
  70737. /**
  70738. * Gets a boolean indicating if there is an active physics engine
  70739. * @returns a boolean indicating if there is an active physics engine
  70740. */
  70741. isPhysicsEnabled(): boolean;
  70742. /**
  70743. * Deletes a physics compound impostor
  70744. * @param compound defines the compound to delete
  70745. */
  70746. deleteCompoundImpostor(compound: any): void;
  70747. /**
  70748. * An event triggered when physic simulation is about to be run
  70749. */
  70750. onBeforePhysicsObservable: Observable<Scene>;
  70751. /**
  70752. * An event triggered when physic simulation has been done
  70753. */
  70754. onAfterPhysicsObservable: Observable<Scene>;
  70755. }
  70756. }
  70757. module "babylonjs/Meshes/abstractMesh" {
  70758. interface AbstractMesh {
  70759. /** @hidden */
  70760. _physicsImpostor: Nullable<PhysicsImpostor>;
  70761. /**
  70762. * Gets or sets impostor used for physic simulation
  70763. * @see http://doc.babylonjs.com/features/physics_engine
  70764. */
  70765. physicsImpostor: Nullable<PhysicsImpostor>;
  70766. /**
  70767. * Gets the current physics impostor
  70768. * @see http://doc.babylonjs.com/features/physics_engine
  70769. * @returns a physics impostor or null
  70770. */
  70771. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70772. /** Apply a physic impulse to the mesh
  70773. * @param force defines the force to apply
  70774. * @param contactPoint defines where to apply the force
  70775. * @returns the current mesh
  70776. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70777. */
  70778. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70779. /**
  70780. * Creates a physic joint between two meshes
  70781. * @param otherMesh defines the other mesh to use
  70782. * @param pivot1 defines the pivot to use on this mesh
  70783. * @param pivot2 defines the pivot to use on the other mesh
  70784. * @param options defines additional options (can be plugin dependent)
  70785. * @returns the current mesh
  70786. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70787. */
  70788. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70789. /** @hidden */
  70790. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70791. }
  70792. }
  70793. /**
  70794. * Defines the physics engine scene component responsible to manage a physics engine
  70795. */
  70796. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70797. /**
  70798. * The component name helpful to identify the component in the list of scene components.
  70799. */
  70800. readonly name: string;
  70801. /**
  70802. * The scene the component belongs to.
  70803. */
  70804. scene: Scene;
  70805. /**
  70806. * Creates a new instance of the component for the given scene
  70807. * @param scene Defines the scene to register the component in
  70808. */
  70809. constructor(scene: Scene);
  70810. /**
  70811. * Registers the component in a given scene
  70812. */
  70813. register(): void;
  70814. /**
  70815. * Rebuilds the elements related to this component in case of
  70816. * context lost for instance.
  70817. */
  70818. rebuild(): void;
  70819. /**
  70820. * Disposes the component and the associated ressources
  70821. */
  70822. dispose(): void;
  70823. }
  70824. }
  70825. declare module "babylonjs/Physics/physicsHelper" {
  70826. import { Nullable } from "babylonjs/types";
  70827. import { Vector3 } from "babylonjs/Maths/math.vector";
  70828. import { Mesh } from "babylonjs/Meshes/mesh";
  70829. import { Scene } from "babylonjs/scene";
  70830. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70831. /**
  70832. * A helper for physics simulations
  70833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70834. */
  70835. export class PhysicsHelper {
  70836. private _scene;
  70837. private _physicsEngine;
  70838. /**
  70839. * Initializes the Physics helper
  70840. * @param scene Babylon.js scene
  70841. */
  70842. constructor(scene: Scene);
  70843. /**
  70844. * Applies a radial explosion impulse
  70845. * @param origin the origin of the explosion
  70846. * @param radiusOrEventOptions the radius or the options of radial explosion
  70847. * @param strength the explosion strength
  70848. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70849. * @returns A physics radial explosion event, or null
  70850. */
  70851. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70852. /**
  70853. * Applies a radial explosion force
  70854. * @param origin the origin of the explosion
  70855. * @param radiusOrEventOptions the radius or the options of radial explosion
  70856. * @param strength the explosion strength
  70857. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70858. * @returns A physics radial explosion event, or null
  70859. */
  70860. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70861. /**
  70862. * Creates a gravitational field
  70863. * @param origin the origin of the explosion
  70864. * @param radiusOrEventOptions the radius or the options of radial explosion
  70865. * @param strength the explosion strength
  70866. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70867. * @returns A physics gravitational field event, or null
  70868. */
  70869. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70870. /**
  70871. * Creates a physics updraft event
  70872. * @param origin the origin of the updraft
  70873. * @param radiusOrEventOptions the radius or the options of the updraft
  70874. * @param strength the strength of the updraft
  70875. * @param height the height of the updraft
  70876. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70877. * @returns A physics updraft event, or null
  70878. */
  70879. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70880. /**
  70881. * Creates a physics vortex event
  70882. * @param origin the of the vortex
  70883. * @param radiusOrEventOptions the radius or the options of the vortex
  70884. * @param strength the strength of the vortex
  70885. * @param height the height of the vortex
  70886. * @returns a Physics vortex event, or null
  70887. * A physics vortex event or null
  70888. */
  70889. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70890. }
  70891. /**
  70892. * Represents a physics radial explosion event
  70893. */
  70894. class PhysicsRadialExplosionEvent {
  70895. private _scene;
  70896. private _options;
  70897. private _sphere;
  70898. private _dataFetched;
  70899. /**
  70900. * Initializes a radial explosioin event
  70901. * @param _scene BabylonJS scene
  70902. * @param _options The options for the vortex event
  70903. */
  70904. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70905. /**
  70906. * Returns the data related to the radial explosion event (sphere).
  70907. * @returns The radial explosion event data
  70908. */
  70909. getData(): PhysicsRadialExplosionEventData;
  70910. /**
  70911. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70912. * @param impostor A physics imposter
  70913. * @param origin the origin of the explosion
  70914. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70915. */
  70916. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70917. /**
  70918. * Triggers affecterd impostors callbacks
  70919. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70920. */
  70921. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70922. /**
  70923. * Disposes the sphere.
  70924. * @param force Specifies if the sphere should be disposed by force
  70925. */
  70926. dispose(force?: boolean): void;
  70927. /*** Helpers ***/
  70928. private _prepareSphere;
  70929. private _intersectsWithSphere;
  70930. }
  70931. /**
  70932. * Represents a gravitational field event
  70933. */
  70934. class PhysicsGravitationalFieldEvent {
  70935. private _physicsHelper;
  70936. private _scene;
  70937. private _origin;
  70938. private _options;
  70939. private _tickCallback;
  70940. private _sphere;
  70941. private _dataFetched;
  70942. /**
  70943. * Initializes the physics gravitational field event
  70944. * @param _physicsHelper A physics helper
  70945. * @param _scene BabylonJS scene
  70946. * @param _origin The origin position of the gravitational field event
  70947. * @param _options The options for the vortex event
  70948. */
  70949. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70950. /**
  70951. * Returns the data related to the gravitational field event (sphere).
  70952. * @returns A gravitational field event
  70953. */
  70954. getData(): PhysicsGravitationalFieldEventData;
  70955. /**
  70956. * Enables the gravitational field.
  70957. */
  70958. enable(): void;
  70959. /**
  70960. * Disables the gravitational field.
  70961. */
  70962. disable(): void;
  70963. /**
  70964. * Disposes the sphere.
  70965. * @param force The force to dispose from the gravitational field event
  70966. */
  70967. dispose(force?: boolean): void;
  70968. private _tick;
  70969. }
  70970. /**
  70971. * Represents a physics updraft event
  70972. */
  70973. class PhysicsUpdraftEvent {
  70974. private _scene;
  70975. private _origin;
  70976. private _options;
  70977. private _physicsEngine;
  70978. private _originTop;
  70979. private _originDirection;
  70980. private _tickCallback;
  70981. private _cylinder;
  70982. private _cylinderPosition;
  70983. private _dataFetched;
  70984. /**
  70985. * Initializes the physics updraft event
  70986. * @param _scene BabylonJS scene
  70987. * @param _origin The origin position of the updraft
  70988. * @param _options The options for the updraft event
  70989. */
  70990. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70991. /**
  70992. * Returns the data related to the updraft event (cylinder).
  70993. * @returns A physics updraft event
  70994. */
  70995. getData(): PhysicsUpdraftEventData;
  70996. /**
  70997. * Enables the updraft.
  70998. */
  70999. enable(): void;
  71000. /**
  71001. * Disables the updraft.
  71002. */
  71003. disable(): void;
  71004. /**
  71005. * Disposes the cylinder.
  71006. * @param force Specifies if the updraft should be disposed by force
  71007. */
  71008. dispose(force?: boolean): void;
  71009. private getImpostorHitData;
  71010. private _tick;
  71011. /*** Helpers ***/
  71012. private _prepareCylinder;
  71013. private _intersectsWithCylinder;
  71014. }
  71015. /**
  71016. * Represents a physics vortex event
  71017. */
  71018. class PhysicsVortexEvent {
  71019. private _scene;
  71020. private _origin;
  71021. private _options;
  71022. private _physicsEngine;
  71023. private _originTop;
  71024. private _tickCallback;
  71025. private _cylinder;
  71026. private _cylinderPosition;
  71027. private _dataFetched;
  71028. /**
  71029. * Initializes the physics vortex event
  71030. * @param _scene The BabylonJS scene
  71031. * @param _origin The origin position of the vortex
  71032. * @param _options The options for the vortex event
  71033. */
  71034. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71035. /**
  71036. * Returns the data related to the vortex event (cylinder).
  71037. * @returns The physics vortex event data
  71038. */
  71039. getData(): PhysicsVortexEventData;
  71040. /**
  71041. * Enables the vortex.
  71042. */
  71043. enable(): void;
  71044. /**
  71045. * Disables the cortex.
  71046. */
  71047. disable(): void;
  71048. /**
  71049. * Disposes the sphere.
  71050. * @param force
  71051. */
  71052. dispose(force?: boolean): void;
  71053. private getImpostorHitData;
  71054. private _tick;
  71055. /*** Helpers ***/
  71056. private _prepareCylinder;
  71057. private _intersectsWithCylinder;
  71058. }
  71059. /**
  71060. * Options fot the radial explosion event
  71061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71062. */
  71063. export class PhysicsRadialExplosionEventOptions {
  71064. /**
  71065. * The radius of the sphere for the radial explosion.
  71066. */
  71067. radius: number;
  71068. /**
  71069. * The strenth of the explosion.
  71070. */
  71071. strength: number;
  71072. /**
  71073. * The strenght of the force in correspondence to the distance of the affected object
  71074. */
  71075. falloff: PhysicsRadialImpulseFalloff;
  71076. /**
  71077. * Sphere options for the radial explosion.
  71078. */
  71079. sphere: {
  71080. segments: number;
  71081. diameter: number;
  71082. };
  71083. /**
  71084. * Sphere options for the radial explosion.
  71085. */
  71086. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71087. }
  71088. /**
  71089. * Options fot the updraft event
  71090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71091. */
  71092. export class PhysicsUpdraftEventOptions {
  71093. /**
  71094. * The radius of the cylinder for the vortex
  71095. */
  71096. radius: number;
  71097. /**
  71098. * The strenth of the updraft.
  71099. */
  71100. strength: number;
  71101. /**
  71102. * The height of the cylinder for the updraft.
  71103. */
  71104. height: number;
  71105. /**
  71106. * The mode for the the updraft.
  71107. */
  71108. updraftMode: PhysicsUpdraftMode;
  71109. }
  71110. /**
  71111. * Options fot the vortex event
  71112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71113. */
  71114. export class PhysicsVortexEventOptions {
  71115. /**
  71116. * The radius of the cylinder for the vortex
  71117. */
  71118. radius: number;
  71119. /**
  71120. * The strenth of the vortex.
  71121. */
  71122. strength: number;
  71123. /**
  71124. * The height of the cylinder for the vortex.
  71125. */
  71126. height: number;
  71127. /**
  71128. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71129. */
  71130. centripetalForceThreshold: number;
  71131. /**
  71132. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71133. */
  71134. centripetalForceMultiplier: number;
  71135. /**
  71136. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71137. */
  71138. centrifugalForceMultiplier: number;
  71139. /**
  71140. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71141. */
  71142. updraftForceMultiplier: number;
  71143. }
  71144. /**
  71145. * The strenght of the force in correspondence to the distance of the affected object
  71146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71147. */
  71148. export enum PhysicsRadialImpulseFalloff {
  71149. /** Defines that impulse is constant in strength across it's whole radius */
  71150. Constant = 0,
  71151. /** Defines that impulse gets weaker if it's further from the origin */
  71152. Linear = 1
  71153. }
  71154. /**
  71155. * The strength of the force in correspondence to the distance of the affected object
  71156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71157. */
  71158. export enum PhysicsUpdraftMode {
  71159. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71160. Center = 0,
  71161. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71162. Perpendicular = 1
  71163. }
  71164. /**
  71165. * Interface for a physics hit data
  71166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71167. */
  71168. export interface PhysicsHitData {
  71169. /**
  71170. * The force applied at the contact point
  71171. */
  71172. force: Vector3;
  71173. /**
  71174. * The contact point
  71175. */
  71176. contactPoint: Vector3;
  71177. /**
  71178. * The distance from the origin to the contact point
  71179. */
  71180. distanceFromOrigin: number;
  71181. }
  71182. /**
  71183. * Interface for radial explosion event data
  71184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71185. */
  71186. export interface PhysicsRadialExplosionEventData {
  71187. /**
  71188. * A sphere used for the radial explosion event
  71189. */
  71190. sphere: Mesh;
  71191. }
  71192. /**
  71193. * Interface for gravitational field event data
  71194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71195. */
  71196. export interface PhysicsGravitationalFieldEventData {
  71197. /**
  71198. * A sphere mesh used for the gravitational field event
  71199. */
  71200. sphere: Mesh;
  71201. }
  71202. /**
  71203. * Interface for updraft event data
  71204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71205. */
  71206. export interface PhysicsUpdraftEventData {
  71207. /**
  71208. * A cylinder used for the updraft event
  71209. */
  71210. cylinder: Mesh;
  71211. }
  71212. /**
  71213. * Interface for vortex event data
  71214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71215. */
  71216. export interface PhysicsVortexEventData {
  71217. /**
  71218. * A cylinder used for the vortex event
  71219. */
  71220. cylinder: Mesh;
  71221. }
  71222. /**
  71223. * Interface for an affected physics impostor
  71224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71225. */
  71226. export interface PhysicsAffectedImpostorWithData {
  71227. /**
  71228. * The impostor affected by the effect
  71229. */
  71230. impostor: PhysicsImpostor;
  71231. /**
  71232. * The data about the hit/horce from the explosion
  71233. */
  71234. hitData: PhysicsHitData;
  71235. }
  71236. }
  71237. declare module "babylonjs/Physics/Plugins/index" {
  71238. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71239. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71240. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71241. }
  71242. declare module "babylonjs/Physics/index" {
  71243. export * from "babylonjs/Physics/IPhysicsEngine";
  71244. export * from "babylonjs/Physics/physicsEngine";
  71245. export * from "babylonjs/Physics/physicsEngineComponent";
  71246. export * from "babylonjs/Physics/physicsHelper";
  71247. export * from "babylonjs/Physics/physicsImpostor";
  71248. export * from "babylonjs/Physics/physicsJoint";
  71249. export * from "babylonjs/Physics/Plugins/index";
  71250. }
  71251. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71252. /** @hidden */
  71253. export var blackAndWhitePixelShader: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71260. import { Camera } from "babylonjs/Cameras/camera";
  71261. import { Engine } from "babylonjs/Engines/engine";
  71262. import "babylonjs/Shaders/blackAndWhite.fragment";
  71263. /**
  71264. * Post process used to render in black and white
  71265. */
  71266. export class BlackAndWhitePostProcess extends PostProcess {
  71267. /**
  71268. * Linear about to convert he result to black and white (default: 1)
  71269. */
  71270. degree: number;
  71271. /**
  71272. * Creates a black and white post process
  71273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71274. * @param name The name of the effect.
  71275. * @param options The required width/height ratio to downsize to before computing the render pass.
  71276. * @param camera The camera to apply the render pass to.
  71277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71278. * @param engine The engine which the post process will be applied. (default: current engine)
  71279. * @param reusable If the post process can be reused on the same frame. (default: false)
  71280. */
  71281. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71282. }
  71283. }
  71284. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71285. import { Nullable } from "babylonjs/types";
  71286. import { Camera } from "babylonjs/Cameras/camera";
  71287. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71288. import { Engine } from "babylonjs/Engines/engine";
  71289. /**
  71290. * This represents a set of one or more post processes in Babylon.
  71291. * A post process can be used to apply a shader to a texture after it is rendered.
  71292. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71293. */
  71294. export class PostProcessRenderEffect {
  71295. private _postProcesses;
  71296. private _getPostProcesses;
  71297. private _singleInstance;
  71298. private _cameras;
  71299. private _indicesForCamera;
  71300. /**
  71301. * Name of the effect
  71302. * @hidden
  71303. */
  71304. _name: string;
  71305. /**
  71306. * Instantiates a post process render effect.
  71307. * A post process can be used to apply a shader to a texture after it is rendered.
  71308. * @param engine The engine the effect is tied to
  71309. * @param name The name of the effect
  71310. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71311. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71312. */
  71313. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71314. /**
  71315. * Checks if all the post processes in the effect are supported.
  71316. */
  71317. get isSupported(): boolean;
  71318. /**
  71319. * Updates the current state of the effect
  71320. * @hidden
  71321. */
  71322. _update(): void;
  71323. /**
  71324. * Attaches the effect on cameras
  71325. * @param cameras The camera to attach to.
  71326. * @hidden
  71327. */
  71328. _attachCameras(cameras: Camera): void;
  71329. /**
  71330. * Attaches the effect on cameras
  71331. * @param cameras The camera to attach to.
  71332. * @hidden
  71333. */
  71334. _attachCameras(cameras: Camera[]): void;
  71335. /**
  71336. * Detaches the effect on cameras
  71337. * @param cameras The camera to detatch from.
  71338. * @hidden
  71339. */
  71340. _detachCameras(cameras: Camera): void;
  71341. /**
  71342. * Detatches the effect on cameras
  71343. * @param cameras The camera to detatch from.
  71344. * @hidden
  71345. */
  71346. _detachCameras(cameras: Camera[]): void;
  71347. /**
  71348. * Enables the effect on given cameras
  71349. * @param cameras The camera to enable.
  71350. * @hidden
  71351. */
  71352. _enable(cameras: Camera): void;
  71353. /**
  71354. * Enables the effect on given cameras
  71355. * @param cameras The camera to enable.
  71356. * @hidden
  71357. */
  71358. _enable(cameras: Nullable<Camera[]>): void;
  71359. /**
  71360. * Disables the effect on the given cameras
  71361. * @param cameras The camera to disable.
  71362. * @hidden
  71363. */
  71364. _disable(cameras: Camera): void;
  71365. /**
  71366. * Disables the effect on the given cameras
  71367. * @param cameras The camera to disable.
  71368. * @hidden
  71369. */
  71370. _disable(cameras: Nullable<Camera[]>): void;
  71371. /**
  71372. * Gets a list of the post processes contained in the effect.
  71373. * @param camera The camera to get the post processes on.
  71374. * @returns The list of the post processes in the effect.
  71375. */
  71376. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71377. }
  71378. }
  71379. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71380. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71381. /** @hidden */
  71382. export var extractHighlightsPixelShader: {
  71383. name: string;
  71384. shader: string;
  71385. };
  71386. }
  71387. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71388. import { Nullable } from "babylonjs/types";
  71389. import { Camera } from "babylonjs/Cameras/camera";
  71390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71391. import { Engine } from "babylonjs/Engines/engine";
  71392. import "babylonjs/Shaders/extractHighlights.fragment";
  71393. /**
  71394. * 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.
  71395. */
  71396. export class ExtractHighlightsPostProcess extends PostProcess {
  71397. /**
  71398. * The luminance threshold, pixels below this value will be set to black.
  71399. */
  71400. threshold: number;
  71401. /** @hidden */
  71402. _exposure: number;
  71403. /**
  71404. * Post process which has the input texture to be used when performing highlight extraction
  71405. * @hidden
  71406. */
  71407. _inputPostProcess: Nullable<PostProcess>;
  71408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71409. }
  71410. }
  71411. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71412. /** @hidden */
  71413. export var bloomMergePixelShader: {
  71414. name: string;
  71415. shader: string;
  71416. };
  71417. }
  71418. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71420. import { Nullable } from "babylonjs/types";
  71421. import { Engine } from "babylonjs/Engines/engine";
  71422. import { Camera } from "babylonjs/Cameras/camera";
  71423. import "babylonjs/Shaders/bloomMerge.fragment";
  71424. /**
  71425. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71426. */
  71427. export class BloomMergePostProcess extends PostProcess {
  71428. /** Weight of the bloom to be added to the original input. */
  71429. weight: number;
  71430. /**
  71431. * Creates a new instance of @see BloomMergePostProcess
  71432. * @param name The name of the effect.
  71433. * @param originalFromInput Post process which's input will be used for the merge.
  71434. * @param blurred Blurred highlights post process which's output will be used.
  71435. * @param weight Weight of the bloom to be added to the original input.
  71436. * @param options The required width/height ratio to downsize to before computing the render pass.
  71437. * @param camera The camera to apply the render pass to.
  71438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71439. * @param engine The engine which the post process will be applied. (default: current engine)
  71440. * @param reusable If the post process can be reused on the same frame. (default: false)
  71441. * @param textureType Type of textures used when performing the post process. (default: 0)
  71442. * @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)
  71443. */
  71444. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71445. /** Weight of the bloom to be added to the original input. */
  71446. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71447. }
  71448. }
  71449. declare module "babylonjs/PostProcesses/bloomEffect" {
  71450. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71452. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71453. import { Camera } from "babylonjs/Cameras/camera";
  71454. import { Scene } from "babylonjs/scene";
  71455. /**
  71456. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71457. */
  71458. export class BloomEffect extends PostProcessRenderEffect {
  71459. private bloomScale;
  71460. /**
  71461. * @hidden Internal
  71462. */
  71463. _effects: Array<PostProcess>;
  71464. /**
  71465. * @hidden Internal
  71466. */
  71467. _downscale: ExtractHighlightsPostProcess;
  71468. private _blurX;
  71469. private _blurY;
  71470. private _merge;
  71471. /**
  71472. * The luminance threshold to find bright areas of the image to bloom.
  71473. */
  71474. get threshold(): number;
  71475. set threshold(value: number);
  71476. /**
  71477. * The strength of the bloom.
  71478. */
  71479. get weight(): number;
  71480. set weight(value: number);
  71481. /**
  71482. * Specifies the size of the bloom blur kernel, relative to the final output size
  71483. */
  71484. get kernel(): number;
  71485. set kernel(value: number);
  71486. /**
  71487. * Creates a new instance of @see BloomEffect
  71488. * @param scene The scene the effect belongs to.
  71489. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71490. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71491. * @param bloomWeight The the strength of bloom.
  71492. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71493. * @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)
  71494. */
  71495. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71496. /**
  71497. * Disposes each of the internal effects for a given camera.
  71498. * @param camera The camera to dispose the effect on.
  71499. */
  71500. disposeEffects(camera: Camera): void;
  71501. /**
  71502. * @hidden Internal
  71503. */
  71504. _updateEffects(): void;
  71505. /**
  71506. * Internal
  71507. * @returns if all the contained post processes are ready.
  71508. * @hidden
  71509. */
  71510. _isReady(): boolean;
  71511. }
  71512. }
  71513. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71514. /** @hidden */
  71515. export var chromaticAberrationPixelShader: {
  71516. name: string;
  71517. shader: string;
  71518. };
  71519. }
  71520. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71521. import { Vector2 } from "babylonjs/Maths/math.vector";
  71522. import { Nullable } from "babylonjs/types";
  71523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71524. import { Camera } from "babylonjs/Cameras/camera";
  71525. import { Engine } from "babylonjs/Engines/engine";
  71526. import "babylonjs/Shaders/chromaticAberration.fragment";
  71527. /**
  71528. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71529. */
  71530. export class ChromaticAberrationPostProcess extends PostProcess {
  71531. /**
  71532. * The amount of seperation of rgb channels (default: 30)
  71533. */
  71534. aberrationAmount: number;
  71535. /**
  71536. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71537. */
  71538. radialIntensity: number;
  71539. /**
  71540. * 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))
  71541. */
  71542. direction: Vector2;
  71543. /**
  71544. * 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))
  71545. */
  71546. centerPosition: Vector2;
  71547. /**
  71548. * Creates a new instance ChromaticAberrationPostProcess
  71549. * @param name The name of the effect.
  71550. * @param screenWidth The width of the screen to apply the effect on.
  71551. * @param screenHeight The height of the screen to apply the effect on.
  71552. * @param options The required width/height ratio to downsize to before computing the render pass.
  71553. * @param camera The camera to apply the render pass to.
  71554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71555. * @param engine The engine which the post process will be applied. (default: current engine)
  71556. * @param reusable If the post process can be reused on the same frame. (default: false)
  71557. * @param textureType Type of textures used when performing the post process. (default: 0)
  71558. * @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)
  71559. */
  71560. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71561. }
  71562. }
  71563. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71564. /** @hidden */
  71565. export var circleOfConfusionPixelShader: {
  71566. name: string;
  71567. shader: string;
  71568. };
  71569. }
  71570. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71571. import { Nullable } from "babylonjs/types";
  71572. import { Engine } from "babylonjs/Engines/engine";
  71573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71575. import { Camera } from "babylonjs/Cameras/camera";
  71576. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71577. /**
  71578. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71579. */
  71580. export class CircleOfConfusionPostProcess extends PostProcess {
  71581. /**
  71582. * 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.
  71583. */
  71584. lensSize: number;
  71585. /**
  71586. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71587. */
  71588. fStop: number;
  71589. /**
  71590. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71591. */
  71592. focusDistance: number;
  71593. /**
  71594. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71595. */
  71596. focalLength: number;
  71597. private _depthTexture;
  71598. /**
  71599. * Creates a new instance CircleOfConfusionPostProcess
  71600. * @param name The name of the effect.
  71601. * @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.
  71602. * @param options The required width/height ratio to downsize to before computing the render pass.
  71603. * @param camera The camera to apply the render pass to.
  71604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71605. * @param engine The engine which the post process will be applied. (default: current engine)
  71606. * @param reusable If the post process can be reused on the same frame. (default: false)
  71607. * @param textureType Type of textures used when performing the post process. (default: 0)
  71608. * @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)
  71609. */
  71610. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71611. /**
  71612. * 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.
  71613. */
  71614. set depthTexture(value: RenderTargetTexture);
  71615. }
  71616. }
  71617. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71618. /** @hidden */
  71619. export var colorCorrectionPixelShader: {
  71620. name: string;
  71621. shader: string;
  71622. };
  71623. }
  71624. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71625. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71626. import { Engine } from "babylonjs/Engines/engine";
  71627. import { Camera } from "babylonjs/Cameras/camera";
  71628. import "babylonjs/Shaders/colorCorrection.fragment";
  71629. /**
  71630. *
  71631. * This post-process allows the modification of rendered colors by using
  71632. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71633. *
  71634. * The object needs to be provided an url to a texture containing the color
  71635. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71636. * Use an image editing software to tweak the LUT to match your needs.
  71637. *
  71638. * For an example of a color LUT, see here:
  71639. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71640. * For explanations on color grading, see here:
  71641. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71642. *
  71643. */
  71644. export class ColorCorrectionPostProcess extends PostProcess {
  71645. private _colorTableTexture;
  71646. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71647. }
  71648. }
  71649. declare module "babylonjs/Shaders/convolution.fragment" {
  71650. /** @hidden */
  71651. export var convolutionPixelShader: {
  71652. name: string;
  71653. shader: string;
  71654. };
  71655. }
  71656. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71658. import { Nullable } from "babylonjs/types";
  71659. import { Camera } from "babylonjs/Cameras/camera";
  71660. import { Engine } from "babylonjs/Engines/engine";
  71661. import "babylonjs/Shaders/convolution.fragment";
  71662. /**
  71663. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71664. * input texture to perform effects such as edge detection or sharpening
  71665. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71666. */
  71667. export class ConvolutionPostProcess extends PostProcess {
  71668. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71669. kernel: number[];
  71670. /**
  71671. * Creates a new instance ConvolutionPostProcess
  71672. * @param name The name of the effect.
  71673. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71674. * @param options The required width/height ratio to downsize to before computing the render pass.
  71675. * @param camera The camera to apply the render pass to.
  71676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71677. * @param engine The engine which the post process will be applied. (default: current engine)
  71678. * @param reusable If the post process can be reused on the same frame. (default: false)
  71679. * @param textureType Type of textures used when performing the post process. (default: 0)
  71680. */
  71681. constructor(name: string,
  71682. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71683. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71684. /**
  71685. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71686. */
  71687. static EdgeDetect0Kernel: number[];
  71688. /**
  71689. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71690. */
  71691. static EdgeDetect1Kernel: number[];
  71692. /**
  71693. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71694. */
  71695. static EdgeDetect2Kernel: number[];
  71696. /**
  71697. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71698. */
  71699. static SharpenKernel: number[];
  71700. /**
  71701. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71702. */
  71703. static EmbossKernel: number[];
  71704. /**
  71705. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71706. */
  71707. static GaussianKernel: number[];
  71708. }
  71709. }
  71710. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71711. import { Nullable } from "babylonjs/types";
  71712. import { Vector2 } from "babylonjs/Maths/math.vector";
  71713. import { Camera } from "babylonjs/Cameras/camera";
  71714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71715. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71716. import { Engine } from "babylonjs/Engines/engine";
  71717. import { Scene } from "babylonjs/scene";
  71718. /**
  71719. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71720. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71721. * based on samples that have a large difference in distance than the center pixel.
  71722. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71723. */
  71724. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71725. direction: Vector2;
  71726. /**
  71727. * Creates a new instance CircleOfConfusionPostProcess
  71728. * @param name The name of the effect.
  71729. * @param scene The scene the effect belongs to.
  71730. * @param direction The direction the blur should be applied.
  71731. * @param kernel The size of the kernel used to blur.
  71732. * @param options The required width/height ratio to downsize to before computing the render pass.
  71733. * @param camera The camera to apply the render pass to.
  71734. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71735. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71737. * @param engine The engine which the post process will be applied. (default: current engine)
  71738. * @param reusable If the post process can be reused on the same frame. (default: false)
  71739. * @param textureType Type of textures used when performing the post process. (default: 0)
  71740. * @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)
  71741. */
  71742. 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);
  71743. }
  71744. }
  71745. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71746. /** @hidden */
  71747. export var depthOfFieldMergePixelShader: {
  71748. name: string;
  71749. shader: string;
  71750. };
  71751. }
  71752. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71753. import { Nullable } from "babylonjs/types";
  71754. import { Camera } from "babylonjs/Cameras/camera";
  71755. import { Effect } from "babylonjs/Materials/effect";
  71756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71757. import { Engine } from "babylonjs/Engines/engine";
  71758. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71759. /**
  71760. * Options to be set when merging outputs from the default pipeline.
  71761. */
  71762. export class DepthOfFieldMergePostProcessOptions {
  71763. /**
  71764. * The original image to merge on top of
  71765. */
  71766. originalFromInput: PostProcess;
  71767. /**
  71768. * Parameters to perform the merge of the depth of field effect
  71769. */
  71770. depthOfField?: {
  71771. circleOfConfusion: PostProcess;
  71772. blurSteps: Array<PostProcess>;
  71773. };
  71774. /**
  71775. * Parameters to perform the merge of bloom effect
  71776. */
  71777. bloom?: {
  71778. blurred: PostProcess;
  71779. weight: number;
  71780. };
  71781. }
  71782. /**
  71783. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71784. */
  71785. export class DepthOfFieldMergePostProcess extends PostProcess {
  71786. private blurSteps;
  71787. /**
  71788. * Creates a new instance of DepthOfFieldMergePostProcess
  71789. * @param name The name of the effect.
  71790. * @param originalFromInput Post process which's input will be used for the merge.
  71791. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71792. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71793. * @param options The required width/height ratio to downsize to before computing the render pass.
  71794. * @param camera The camera to apply the render pass to.
  71795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71796. * @param engine The engine which the post process will be applied. (default: current engine)
  71797. * @param reusable If the post process can be reused on the same frame. (default: false)
  71798. * @param textureType Type of textures used when performing the post process. (default: 0)
  71799. * @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)
  71800. */
  71801. 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);
  71802. /**
  71803. * Updates the effect with the current post process compile time values and recompiles the shader.
  71804. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71805. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71806. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71807. * @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
  71808. * @param onCompiled Called when the shader has been compiled.
  71809. * @param onError Called if there is an error when compiling a shader.
  71810. */
  71811. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71812. }
  71813. }
  71814. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71815. import { Nullable } from "babylonjs/types";
  71816. import { Camera } from "babylonjs/Cameras/camera";
  71817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71819. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71820. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71821. import { Scene } from "babylonjs/scene";
  71822. /**
  71823. * Specifies the level of max blur that should be applied when using the depth of field effect
  71824. */
  71825. export enum DepthOfFieldEffectBlurLevel {
  71826. /**
  71827. * Subtle blur
  71828. */
  71829. Low = 0,
  71830. /**
  71831. * Medium blur
  71832. */
  71833. Medium = 1,
  71834. /**
  71835. * Large blur
  71836. */
  71837. High = 2
  71838. }
  71839. /**
  71840. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71841. */
  71842. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71843. private _circleOfConfusion;
  71844. /**
  71845. * @hidden Internal, blurs from high to low
  71846. */
  71847. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71848. private _depthOfFieldBlurY;
  71849. private _dofMerge;
  71850. /**
  71851. * @hidden Internal post processes in depth of field effect
  71852. */
  71853. _effects: Array<PostProcess>;
  71854. /**
  71855. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71856. */
  71857. set focalLength(value: number);
  71858. get focalLength(): number;
  71859. /**
  71860. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71861. */
  71862. set fStop(value: number);
  71863. get fStop(): number;
  71864. /**
  71865. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71866. */
  71867. set focusDistance(value: number);
  71868. get focusDistance(): number;
  71869. /**
  71870. * 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.
  71871. */
  71872. set lensSize(value: number);
  71873. get lensSize(): number;
  71874. /**
  71875. * Creates a new instance DepthOfFieldEffect
  71876. * @param scene The scene the effect belongs to.
  71877. * @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.
  71878. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71879. * @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)
  71880. */
  71881. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71882. /**
  71883. * Get the current class name of the current effet
  71884. * @returns "DepthOfFieldEffect"
  71885. */
  71886. getClassName(): string;
  71887. /**
  71888. * 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.
  71889. */
  71890. set depthTexture(value: RenderTargetTexture);
  71891. /**
  71892. * Disposes each of the internal effects for a given camera.
  71893. * @param camera The camera to dispose the effect on.
  71894. */
  71895. disposeEffects(camera: Camera): void;
  71896. /**
  71897. * @hidden Internal
  71898. */
  71899. _updateEffects(): void;
  71900. /**
  71901. * Internal
  71902. * @returns if all the contained post processes are ready.
  71903. * @hidden
  71904. */
  71905. _isReady(): boolean;
  71906. }
  71907. }
  71908. declare module "babylonjs/Shaders/displayPass.fragment" {
  71909. /** @hidden */
  71910. export var displayPassPixelShader: {
  71911. name: string;
  71912. shader: string;
  71913. };
  71914. }
  71915. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71916. import { Nullable } from "babylonjs/types";
  71917. import { Camera } from "babylonjs/Cameras/camera";
  71918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71919. import { Engine } from "babylonjs/Engines/engine";
  71920. import "babylonjs/Shaders/displayPass.fragment";
  71921. /**
  71922. * DisplayPassPostProcess which produces an output the same as it's input
  71923. */
  71924. export class DisplayPassPostProcess extends PostProcess {
  71925. /**
  71926. * Creates the DisplayPassPostProcess
  71927. * @param name The name of the effect.
  71928. * @param options The required width/height ratio to downsize to before computing the render pass.
  71929. * @param camera The camera to apply the render pass to.
  71930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71931. * @param engine The engine which the post process will be applied. (default: current engine)
  71932. * @param reusable If the post process can be reused on the same frame. (default: false)
  71933. */
  71934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71935. }
  71936. }
  71937. declare module "babylonjs/Shaders/filter.fragment" {
  71938. /** @hidden */
  71939. export var filterPixelShader: {
  71940. name: string;
  71941. shader: string;
  71942. };
  71943. }
  71944. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71945. import { Nullable } from "babylonjs/types";
  71946. import { Matrix } from "babylonjs/Maths/math.vector";
  71947. import { Camera } from "babylonjs/Cameras/camera";
  71948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71949. import { Engine } from "babylonjs/Engines/engine";
  71950. import "babylonjs/Shaders/filter.fragment";
  71951. /**
  71952. * Applies a kernel filter to the image
  71953. */
  71954. export class FilterPostProcess extends PostProcess {
  71955. /** The matrix to be applied to the image */
  71956. kernelMatrix: Matrix;
  71957. /**
  71958. *
  71959. * @param name The name of the effect.
  71960. * @param kernelMatrix The matrix to be applied to the image
  71961. * @param options The required width/height ratio to downsize to before computing the render pass.
  71962. * @param camera The camera to apply the render pass to.
  71963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71964. * @param engine The engine which the post process will be applied. (default: current engine)
  71965. * @param reusable If the post process can be reused on the same frame. (default: false)
  71966. */
  71967. constructor(name: string,
  71968. /** The matrix to be applied to the image */
  71969. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71970. }
  71971. }
  71972. declare module "babylonjs/Shaders/fxaa.fragment" {
  71973. /** @hidden */
  71974. export var fxaaPixelShader: {
  71975. name: string;
  71976. shader: string;
  71977. };
  71978. }
  71979. declare module "babylonjs/Shaders/fxaa.vertex" {
  71980. /** @hidden */
  71981. export var fxaaVertexShader: {
  71982. name: string;
  71983. shader: string;
  71984. };
  71985. }
  71986. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71987. import { Nullable } from "babylonjs/types";
  71988. import { Camera } from "babylonjs/Cameras/camera";
  71989. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71990. import { Engine } from "babylonjs/Engines/engine";
  71991. import "babylonjs/Shaders/fxaa.fragment";
  71992. import "babylonjs/Shaders/fxaa.vertex";
  71993. /**
  71994. * Fxaa post process
  71995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71996. */
  71997. export class FxaaPostProcess extends PostProcess {
  71998. /** @hidden */
  71999. texelWidth: number;
  72000. /** @hidden */
  72001. texelHeight: number;
  72002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72003. private _getDefines;
  72004. }
  72005. }
  72006. declare module "babylonjs/Shaders/grain.fragment" {
  72007. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72008. /** @hidden */
  72009. export var grainPixelShader: {
  72010. name: string;
  72011. shader: string;
  72012. };
  72013. }
  72014. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72015. import { Nullable } from "babylonjs/types";
  72016. import { Camera } from "babylonjs/Cameras/camera";
  72017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72018. import { Engine } from "babylonjs/Engines/engine";
  72019. import "babylonjs/Shaders/grain.fragment";
  72020. /**
  72021. * The GrainPostProcess adds noise to the image at mid luminance levels
  72022. */
  72023. export class GrainPostProcess extends PostProcess {
  72024. /**
  72025. * The intensity of the grain added (default: 30)
  72026. */
  72027. intensity: number;
  72028. /**
  72029. * If the grain should be randomized on every frame
  72030. */
  72031. animated: boolean;
  72032. /**
  72033. * Creates a new instance of @see GrainPostProcess
  72034. * @param name The name of the effect.
  72035. * @param options The required width/height ratio to downsize to before computing the render pass.
  72036. * @param camera The camera to apply the render pass to.
  72037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72038. * @param engine The engine which the post process will be applied. (default: current engine)
  72039. * @param reusable If the post process can be reused on the same frame. (default: false)
  72040. * @param textureType Type of textures used when performing the post process. (default: 0)
  72041. * @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)
  72042. */
  72043. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72044. }
  72045. }
  72046. declare module "babylonjs/Shaders/highlights.fragment" {
  72047. /** @hidden */
  72048. export var highlightsPixelShader: {
  72049. name: string;
  72050. shader: string;
  72051. };
  72052. }
  72053. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72054. import { Nullable } from "babylonjs/types";
  72055. import { Camera } from "babylonjs/Cameras/camera";
  72056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72057. import { Engine } from "babylonjs/Engines/engine";
  72058. import "babylonjs/Shaders/highlights.fragment";
  72059. /**
  72060. * Extracts highlights from the image
  72061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72062. */
  72063. export class HighlightsPostProcess extends PostProcess {
  72064. /**
  72065. * Extracts highlights from the image
  72066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72067. * @param name The name of the effect.
  72068. * @param options The required width/height ratio to downsize to before computing the render pass.
  72069. * @param camera The camera to apply the render pass to.
  72070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72071. * @param engine The engine which the post process will be applied. (default: current engine)
  72072. * @param reusable If the post process can be reused on the same frame. (default: false)
  72073. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72074. */
  72075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72076. }
  72077. }
  72078. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72079. /** @hidden */
  72080. export var mrtFragmentDeclaration: {
  72081. name: string;
  72082. shader: string;
  72083. };
  72084. }
  72085. declare module "babylonjs/Shaders/geometry.fragment" {
  72086. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72087. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72088. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72089. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72090. /** @hidden */
  72091. export var geometryPixelShader: {
  72092. name: string;
  72093. shader: string;
  72094. };
  72095. }
  72096. declare module "babylonjs/Shaders/geometry.vertex" {
  72097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72098. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72100. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72102. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72103. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72104. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72105. /** @hidden */
  72106. export var geometryVertexShader: {
  72107. name: string;
  72108. shader: string;
  72109. };
  72110. }
  72111. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72112. import { Matrix } from "babylonjs/Maths/math.vector";
  72113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72114. import { Mesh } from "babylonjs/Meshes/mesh";
  72115. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72116. import { Effect } from "babylonjs/Materials/effect";
  72117. import { Scene } from "babylonjs/scene";
  72118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72119. import "babylonjs/Shaders/geometry.fragment";
  72120. import "babylonjs/Shaders/geometry.vertex";
  72121. /** @hidden */
  72122. interface ISavedTransformationMatrix {
  72123. world: Matrix;
  72124. viewProjection: Matrix;
  72125. }
  72126. /**
  72127. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72128. */
  72129. export class GeometryBufferRenderer {
  72130. /**
  72131. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72132. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72133. */
  72134. static readonly POSITION_TEXTURE_TYPE: number;
  72135. /**
  72136. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72137. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72138. */
  72139. static readonly VELOCITY_TEXTURE_TYPE: number;
  72140. /**
  72141. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72142. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72143. */
  72144. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72145. /**
  72146. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72147. * in order to compute objects velocities when enableVelocity is set to "true"
  72148. * @hidden
  72149. */
  72150. _previousTransformationMatrices: {
  72151. [index: number]: ISavedTransformationMatrix;
  72152. };
  72153. /**
  72154. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72155. * in order to compute objects velocities when enableVelocity is set to "true"
  72156. * @hidden
  72157. */
  72158. _previousBonesTransformationMatrices: {
  72159. [index: number]: Float32Array;
  72160. };
  72161. /**
  72162. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72163. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72164. */
  72165. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72166. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72167. renderTransparentMeshes: boolean;
  72168. private _scene;
  72169. private _multiRenderTarget;
  72170. private _ratio;
  72171. private _enablePosition;
  72172. private _enableVelocity;
  72173. private _enableReflectivity;
  72174. private _positionIndex;
  72175. private _velocityIndex;
  72176. private _reflectivityIndex;
  72177. protected _effect: Effect;
  72178. protected _cachedDefines: string;
  72179. /**
  72180. * Set the render list (meshes to be rendered) used in the G buffer.
  72181. */
  72182. set renderList(meshes: Mesh[]);
  72183. /**
  72184. * Gets wether or not G buffer are supported by the running hardware.
  72185. * This requires draw buffer supports
  72186. */
  72187. get isSupported(): boolean;
  72188. /**
  72189. * Returns the index of the given texture type in the G-Buffer textures array
  72190. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72191. * @returns the index of the given texture type in the G-Buffer textures array
  72192. */
  72193. getTextureIndex(textureType: number): number;
  72194. /**
  72195. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72196. */
  72197. get enablePosition(): boolean;
  72198. /**
  72199. * Sets whether or not objects positions are enabled for the G buffer.
  72200. */
  72201. set enablePosition(enable: boolean);
  72202. /**
  72203. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72204. */
  72205. get enableVelocity(): boolean;
  72206. /**
  72207. * Sets wether or not objects velocities are enabled for the G buffer.
  72208. */
  72209. set enableVelocity(enable: boolean);
  72210. /**
  72211. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72212. */
  72213. get enableReflectivity(): boolean;
  72214. /**
  72215. * Sets wether or not objects roughness are enabled for the G buffer.
  72216. */
  72217. set enableReflectivity(enable: boolean);
  72218. /**
  72219. * Gets the scene associated with the buffer.
  72220. */
  72221. get scene(): Scene;
  72222. /**
  72223. * Gets the ratio used by the buffer during its creation.
  72224. * How big is the buffer related to the main canvas.
  72225. */
  72226. get ratio(): number;
  72227. /** @hidden */
  72228. static _SceneComponentInitialization: (scene: Scene) => void;
  72229. /**
  72230. * Creates a new G Buffer for the scene
  72231. * @param scene The scene the buffer belongs to
  72232. * @param ratio How big is the buffer related to the main canvas.
  72233. */
  72234. constructor(scene: Scene, ratio?: number);
  72235. /**
  72236. * Checks wether everything is ready to render a submesh to the G buffer.
  72237. * @param subMesh the submesh to check readiness for
  72238. * @param useInstances is the mesh drawn using instance or not
  72239. * @returns true if ready otherwise false
  72240. */
  72241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72242. /**
  72243. * Gets the current underlying G Buffer.
  72244. * @returns the buffer
  72245. */
  72246. getGBuffer(): MultiRenderTarget;
  72247. /**
  72248. * Gets the number of samples used to render the buffer (anti aliasing).
  72249. */
  72250. get samples(): number;
  72251. /**
  72252. * Sets the number of samples used to render the buffer (anti aliasing).
  72253. */
  72254. set samples(value: number);
  72255. /**
  72256. * Disposes the renderer and frees up associated resources.
  72257. */
  72258. dispose(): void;
  72259. protected _createRenderTargets(): void;
  72260. private _copyBonesTransformationMatrices;
  72261. }
  72262. }
  72263. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72264. import { Nullable } from "babylonjs/types";
  72265. import { Scene } from "babylonjs/scene";
  72266. import { ISceneComponent } from "babylonjs/sceneComponent";
  72267. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72268. module "babylonjs/scene" {
  72269. interface Scene {
  72270. /** @hidden (Backing field) */
  72271. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72272. /**
  72273. * Gets or Sets the current geometry buffer associated to the scene.
  72274. */
  72275. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72276. /**
  72277. * Enables a GeometryBufferRender and associates it with the scene
  72278. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72279. * @returns the GeometryBufferRenderer
  72280. */
  72281. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72282. /**
  72283. * Disables the GeometryBufferRender associated with the scene
  72284. */
  72285. disableGeometryBufferRenderer(): void;
  72286. }
  72287. }
  72288. /**
  72289. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72290. * in several rendering techniques.
  72291. */
  72292. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72293. /**
  72294. * The component name helpful to identify the component in the list of scene components.
  72295. */
  72296. readonly name: string;
  72297. /**
  72298. * The scene the component belongs to.
  72299. */
  72300. scene: Scene;
  72301. /**
  72302. * Creates a new instance of the component for the given scene
  72303. * @param scene Defines the scene to register the component in
  72304. */
  72305. constructor(scene: Scene);
  72306. /**
  72307. * Registers the component in a given scene
  72308. */
  72309. register(): void;
  72310. /**
  72311. * Rebuilds the elements related to this component in case of
  72312. * context lost for instance.
  72313. */
  72314. rebuild(): void;
  72315. /**
  72316. * Disposes the component and the associated ressources
  72317. */
  72318. dispose(): void;
  72319. private _gatherRenderTargets;
  72320. }
  72321. }
  72322. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72323. /** @hidden */
  72324. export var motionBlurPixelShader: {
  72325. name: string;
  72326. shader: string;
  72327. };
  72328. }
  72329. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72330. import { Nullable } from "babylonjs/types";
  72331. import { Camera } from "babylonjs/Cameras/camera";
  72332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72333. import { Scene } from "babylonjs/scene";
  72334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72335. import "babylonjs/Animations/animatable";
  72336. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72337. import "babylonjs/Shaders/motionBlur.fragment";
  72338. import { Engine } from "babylonjs/Engines/engine";
  72339. /**
  72340. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72341. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72342. * As an example, all you have to do is to create the post-process:
  72343. * var mb = new BABYLON.MotionBlurPostProcess(
  72344. * 'mb', // The name of the effect.
  72345. * scene, // The scene containing the objects to blur according to their velocity.
  72346. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72347. * camera // The camera to apply the render pass to.
  72348. * );
  72349. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72350. */
  72351. export class MotionBlurPostProcess extends PostProcess {
  72352. /**
  72353. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72354. */
  72355. motionStrength: number;
  72356. /**
  72357. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72358. */
  72359. get motionBlurSamples(): number;
  72360. /**
  72361. * Sets the number of iterations to be used for motion blur quality
  72362. */
  72363. set motionBlurSamples(samples: number);
  72364. private _motionBlurSamples;
  72365. private _geometryBufferRenderer;
  72366. /**
  72367. * Creates a new instance MotionBlurPostProcess
  72368. * @param name The name of the effect.
  72369. * @param scene The scene containing the objects to blur according to their velocity.
  72370. * @param options The required width/height ratio to downsize to before computing the render pass.
  72371. * @param camera The camera to apply the render pass to.
  72372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72373. * @param engine The engine which the post process will be applied. (default: current engine)
  72374. * @param reusable If the post process can be reused on the same frame. (default: false)
  72375. * @param textureType Type of textures used when performing the post process. (default: 0)
  72376. * @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)
  72377. */
  72378. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72379. /**
  72380. * Excludes the given skinned mesh from computing bones velocities.
  72381. * 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.
  72382. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72383. */
  72384. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72385. /**
  72386. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72387. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72388. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72389. */
  72390. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72391. /**
  72392. * Disposes the post process.
  72393. * @param camera The camera to dispose the post process on.
  72394. */
  72395. dispose(camera?: Camera): void;
  72396. }
  72397. }
  72398. declare module "babylonjs/Shaders/refraction.fragment" {
  72399. /** @hidden */
  72400. export var refractionPixelShader: {
  72401. name: string;
  72402. shader: string;
  72403. };
  72404. }
  72405. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72406. import { Color3 } from "babylonjs/Maths/math.color";
  72407. import { Camera } from "babylonjs/Cameras/camera";
  72408. import { Texture } from "babylonjs/Materials/Textures/texture";
  72409. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72410. import { Engine } from "babylonjs/Engines/engine";
  72411. import "babylonjs/Shaders/refraction.fragment";
  72412. /**
  72413. * Post process which applies a refractin texture
  72414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72415. */
  72416. export class RefractionPostProcess extends PostProcess {
  72417. /** the base color of the refraction (used to taint the rendering) */
  72418. color: Color3;
  72419. /** simulated refraction depth */
  72420. depth: number;
  72421. /** the coefficient of the base color (0 to remove base color tainting) */
  72422. colorLevel: number;
  72423. private _refTexture;
  72424. private _ownRefractionTexture;
  72425. /**
  72426. * Gets or sets the refraction texture
  72427. * Please note that you are responsible for disposing the texture if you set it manually
  72428. */
  72429. get refractionTexture(): Texture;
  72430. set refractionTexture(value: Texture);
  72431. /**
  72432. * Initializes the RefractionPostProcess
  72433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72434. * @param name The name of the effect.
  72435. * @param refractionTextureUrl Url of the refraction texture to use
  72436. * @param color the base color of the refraction (used to taint the rendering)
  72437. * @param depth simulated refraction depth
  72438. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72439. * @param camera The camera to apply the render pass to.
  72440. * @param options The required width/height ratio to downsize to before computing the render pass.
  72441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72442. * @param engine The engine which the post process will be applied. (default: current engine)
  72443. * @param reusable If the post process can be reused on the same frame. (default: false)
  72444. */
  72445. constructor(name: string, refractionTextureUrl: string,
  72446. /** the base color of the refraction (used to taint the rendering) */
  72447. color: Color3,
  72448. /** simulated refraction depth */
  72449. depth: number,
  72450. /** the coefficient of the base color (0 to remove base color tainting) */
  72451. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72452. /**
  72453. * Disposes of the post process
  72454. * @param camera Camera to dispose post process on
  72455. */
  72456. dispose(camera: Camera): void;
  72457. }
  72458. }
  72459. declare module "babylonjs/Shaders/sharpen.fragment" {
  72460. /** @hidden */
  72461. export var sharpenPixelShader: {
  72462. name: string;
  72463. shader: string;
  72464. };
  72465. }
  72466. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72467. import { Nullable } from "babylonjs/types";
  72468. import { Camera } from "babylonjs/Cameras/camera";
  72469. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72470. import "babylonjs/Shaders/sharpen.fragment";
  72471. import { Engine } from "babylonjs/Engines/engine";
  72472. /**
  72473. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72474. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72475. */
  72476. export class SharpenPostProcess extends PostProcess {
  72477. /**
  72478. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72479. */
  72480. colorAmount: number;
  72481. /**
  72482. * How much sharpness should be applied (default: 0.3)
  72483. */
  72484. edgeAmount: number;
  72485. /**
  72486. * Creates a new instance ConvolutionPostProcess
  72487. * @param name The name of the effect.
  72488. * @param options The required width/height ratio to downsize to before computing the render pass.
  72489. * @param camera The camera to apply the render pass to.
  72490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72491. * @param engine The engine which the post process will be applied. (default: current engine)
  72492. * @param reusable If the post process can be reused on the same frame. (default: false)
  72493. * @param textureType Type of textures used when performing the post process. (default: 0)
  72494. * @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)
  72495. */
  72496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72497. }
  72498. }
  72499. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72500. import { Nullable } from "babylonjs/types";
  72501. import { Camera } from "babylonjs/Cameras/camera";
  72502. import { Engine } from "babylonjs/Engines/engine";
  72503. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72505. /**
  72506. * PostProcessRenderPipeline
  72507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72508. */
  72509. export class PostProcessRenderPipeline {
  72510. private engine;
  72511. private _renderEffects;
  72512. private _renderEffectsForIsolatedPass;
  72513. /**
  72514. * List of inspectable custom properties (used by the Inspector)
  72515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72516. */
  72517. inspectableCustomProperties: IInspectable[];
  72518. /**
  72519. * @hidden
  72520. */
  72521. protected _cameras: Camera[];
  72522. /** @hidden */
  72523. _name: string;
  72524. /**
  72525. * Gets pipeline name
  72526. */
  72527. get name(): string;
  72528. /** Gets the list of attached cameras */
  72529. get cameras(): Camera[];
  72530. /**
  72531. * Initializes a PostProcessRenderPipeline
  72532. * @param engine engine to add the pipeline to
  72533. * @param name name of the pipeline
  72534. */
  72535. constructor(engine: Engine, name: string);
  72536. /**
  72537. * Gets the class name
  72538. * @returns "PostProcessRenderPipeline"
  72539. */
  72540. getClassName(): string;
  72541. /**
  72542. * If all the render effects in the pipeline are supported
  72543. */
  72544. get isSupported(): boolean;
  72545. /**
  72546. * Adds an effect to the pipeline
  72547. * @param renderEffect the effect to add
  72548. */
  72549. addEffect(renderEffect: PostProcessRenderEffect): void;
  72550. /** @hidden */
  72551. _rebuild(): void;
  72552. /** @hidden */
  72553. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72554. /** @hidden */
  72555. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72556. /** @hidden */
  72557. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72558. /** @hidden */
  72559. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72560. /** @hidden */
  72561. _attachCameras(cameras: Camera, unique: boolean): void;
  72562. /** @hidden */
  72563. _attachCameras(cameras: Camera[], unique: boolean): void;
  72564. /** @hidden */
  72565. _detachCameras(cameras: Camera): void;
  72566. /** @hidden */
  72567. _detachCameras(cameras: Nullable<Camera[]>): void;
  72568. /** @hidden */
  72569. _update(): void;
  72570. /** @hidden */
  72571. _reset(): void;
  72572. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72573. /**
  72574. * Disposes of the pipeline
  72575. */
  72576. dispose(): void;
  72577. }
  72578. }
  72579. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72580. import { Camera } from "babylonjs/Cameras/camera";
  72581. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72582. /**
  72583. * PostProcessRenderPipelineManager class
  72584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72585. */
  72586. export class PostProcessRenderPipelineManager {
  72587. private _renderPipelines;
  72588. /**
  72589. * Initializes a PostProcessRenderPipelineManager
  72590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72591. */
  72592. constructor();
  72593. /**
  72594. * Gets the list of supported render pipelines
  72595. */
  72596. get supportedPipelines(): PostProcessRenderPipeline[];
  72597. /**
  72598. * Adds a pipeline to the manager
  72599. * @param renderPipeline The pipeline to add
  72600. */
  72601. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72602. /**
  72603. * Attaches a camera to the pipeline
  72604. * @param renderPipelineName The name of the pipeline to attach to
  72605. * @param cameras the camera to attach
  72606. * @param unique if the camera can be attached multiple times to the pipeline
  72607. */
  72608. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72609. /**
  72610. * Detaches a camera from the pipeline
  72611. * @param renderPipelineName The name of the pipeline to detach from
  72612. * @param cameras the camera to detach
  72613. */
  72614. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72615. /**
  72616. * Enables an effect by name on a pipeline
  72617. * @param renderPipelineName the name of the pipeline to enable the effect in
  72618. * @param renderEffectName the name of the effect to enable
  72619. * @param cameras the cameras that the effect should be enabled on
  72620. */
  72621. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72622. /**
  72623. * Disables an effect by name on a pipeline
  72624. * @param renderPipelineName the name of the pipeline to disable the effect in
  72625. * @param renderEffectName the name of the effect to disable
  72626. * @param cameras the cameras that the effect should be disabled on
  72627. */
  72628. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72629. /**
  72630. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72631. */
  72632. update(): void;
  72633. /** @hidden */
  72634. _rebuild(): void;
  72635. /**
  72636. * Disposes of the manager and pipelines
  72637. */
  72638. dispose(): void;
  72639. }
  72640. }
  72641. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72642. import { ISceneComponent } from "babylonjs/sceneComponent";
  72643. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72644. import { Scene } from "babylonjs/scene";
  72645. module "babylonjs/scene" {
  72646. interface Scene {
  72647. /** @hidden (Backing field) */
  72648. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72649. /**
  72650. * Gets the postprocess render pipeline manager
  72651. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72652. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72653. */
  72654. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72655. }
  72656. }
  72657. /**
  72658. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72659. */
  72660. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72661. /**
  72662. * The component name helpfull to identify the component in the list of scene components.
  72663. */
  72664. readonly name: string;
  72665. /**
  72666. * The scene the component belongs to.
  72667. */
  72668. scene: Scene;
  72669. /**
  72670. * Creates a new instance of the component for the given scene
  72671. * @param scene Defines the scene to register the component in
  72672. */
  72673. constructor(scene: Scene);
  72674. /**
  72675. * Registers the component in a given scene
  72676. */
  72677. register(): void;
  72678. /**
  72679. * Rebuilds the elements related to this component in case of
  72680. * context lost for instance.
  72681. */
  72682. rebuild(): void;
  72683. /**
  72684. * Disposes the component and the associated ressources
  72685. */
  72686. dispose(): void;
  72687. private _gatherRenderTargets;
  72688. }
  72689. }
  72690. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72691. import { Nullable } from "babylonjs/types";
  72692. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72693. import { Camera } from "babylonjs/Cameras/camera";
  72694. import { IDisposable } from "babylonjs/scene";
  72695. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72696. import { Scene } from "babylonjs/scene";
  72697. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72698. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72699. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72700. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72701. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72702. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72703. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72704. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72705. import { Animation } from "babylonjs/Animations/animation";
  72706. /**
  72707. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72708. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72709. */
  72710. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72711. private _scene;
  72712. private _camerasToBeAttached;
  72713. /**
  72714. * ID of the sharpen post process,
  72715. */
  72716. private readonly SharpenPostProcessId;
  72717. /**
  72718. * @ignore
  72719. * ID of the image processing post process;
  72720. */
  72721. readonly ImageProcessingPostProcessId: string;
  72722. /**
  72723. * @ignore
  72724. * ID of the Fast Approximate Anti-Aliasing post process;
  72725. */
  72726. readonly FxaaPostProcessId: string;
  72727. /**
  72728. * ID of the chromatic aberration post process,
  72729. */
  72730. private readonly ChromaticAberrationPostProcessId;
  72731. /**
  72732. * ID of the grain post process
  72733. */
  72734. private readonly GrainPostProcessId;
  72735. /**
  72736. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72737. */
  72738. sharpen: SharpenPostProcess;
  72739. private _sharpenEffect;
  72740. private bloom;
  72741. /**
  72742. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72743. */
  72744. depthOfField: DepthOfFieldEffect;
  72745. /**
  72746. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72747. */
  72748. fxaa: FxaaPostProcess;
  72749. /**
  72750. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72751. */
  72752. imageProcessing: ImageProcessingPostProcess;
  72753. /**
  72754. * Chromatic aberration post process which will shift rgb colors in the image
  72755. */
  72756. chromaticAberration: ChromaticAberrationPostProcess;
  72757. private _chromaticAberrationEffect;
  72758. /**
  72759. * Grain post process which add noise to the image
  72760. */
  72761. grain: GrainPostProcess;
  72762. private _grainEffect;
  72763. /**
  72764. * Glow post process which adds a glow to emissive areas of the image
  72765. */
  72766. private _glowLayer;
  72767. /**
  72768. * Animations which can be used to tweak settings over a period of time
  72769. */
  72770. animations: Animation[];
  72771. private _imageProcessingConfigurationObserver;
  72772. private _sharpenEnabled;
  72773. private _bloomEnabled;
  72774. private _depthOfFieldEnabled;
  72775. private _depthOfFieldBlurLevel;
  72776. private _fxaaEnabled;
  72777. private _imageProcessingEnabled;
  72778. private _defaultPipelineTextureType;
  72779. private _bloomScale;
  72780. private _chromaticAberrationEnabled;
  72781. private _grainEnabled;
  72782. private _buildAllowed;
  72783. /**
  72784. * Gets active scene
  72785. */
  72786. get scene(): Scene;
  72787. /**
  72788. * Enable or disable the sharpen process from the pipeline
  72789. */
  72790. set sharpenEnabled(enabled: boolean);
  72791. get sharpenEnabled(): boolean;
  72792. private _resizeObserver;
  72793. private _hardwareScaleLevel;
  72794. private _bloomKernel;
  72795. /**
  72796. * Specifies the size of the bloom blur kernel, relative to the final output size
  72797. */
  72798. get bloomKernel(): number;
  72799. set bloomKernel(value: number);
  72800. /**
  72801. * Specifies the weight of the bloom in the final rendering
  72802. */
  72803. private _bloomWeight;
  72804. /**
  72805. * Specifies the luma threshold for the area that will be blurred by the bloom
  72806. */
  72807. private _bloomThreshold;
  72808. private _hdr;
  72809. /**
  72810. * The strength of the bloom.
  72811. */
  72812. set bloomWeight(value: number);
  72813. get bloomWeight(): number;
  72814. /**
  72815. * The strength of the bloom.
  72816. */
  72817. set bloomThreshold(value: number);
  72818. get bloomThreshold(): number;
  72819. /**
  72820. * The scale of the bloom, lower value will provide better performance.
  72821. */
  72822. set bloomScale(value: number);
  72823. get bloomScale(): number;
  72824. /**
  72825. * Enable or disable the bloom from the pipeline
  72826. */
  72827. set bloomEnabled(enabled: boolean);
  72828. get bloomEnabled(): boolean;
  72829. private _rebuildBloom;
  72830. /**
  72831. * If the depth of field is enabled.
  72832. */
  72833. get depthOfFieldEnabled(): boolean;
  72834. set depthOfFieldEnabled(enabled: boolean);
  72835. /**
  72836. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72837. */
  72838. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72839. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72840. /**
  72841. * If the anti aliasing is enabled.
  72842. */
  72843. set fxaaEnabled(enabled: boolean);
  72844. get fxaaEnabled(): boolean;
  72845. private _samples;
  72846. /**
  72847. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72848. */
  72849. set samples(sampleCount: number);
  72850. get samples(): number;
  72851. /**
  72852. * If image processing is enabled.
  72853. */
  72854. set imageProcessingEnabled(enabled: boolean);
  72855. get imageProcessingEnabled(): boolean;
  72856. /**
  72857. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72858. */
  72859. set glowLayerEnabled(enabled: boolean);
  72860. get glowLayerEnabled(): boolean;
  72861. /**
  72862. * Gets the glow layer (or null if not defined)
  72863. */
  72864. get glowLayer(): Nullable<GlowLayer>;
  72865. /**
  72866. * Enable or disable the chromaticAberration process from the pipeline
  72867. */
  72868. set chromaticAberrationEnabled(enabled: boolean);
  72869. get chromaticAberrationEnabled(): boolean;
  72870. /**
  72871. * Enable or disable the grain process from the pipeline
  72872. */
  72873. set grainEnabled(enabled: boolean);
  72874. get grainEnabled(): boolean;
  72875. /**
  72876. * @constructor
  72877. * @param name - The rendering pipeline name (default: "")
  72878. * @param hdr - If high dynamic range textures should be used (default: true)
  72879. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72880. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72881. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72882. */
  72883. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72884. /**
  72885. * Get the class name
  72886. * @returns "DefaultRenderingPipeline"
  72887. */
  72888. getClassName(): string;
  72889. /**
  72890. * Force the compilation of the entire pipeline.
  72891. */
  72892. prepare(): void;
  72893. private _hasCleared;
  72894. private _prevPostProcess;
  72895. private _prevPrevPostProcess;
  72896. private _setAutoClearAndTextureSharing;
  72897. private _depthOfFieldSceneObserver;
  72898. private _buildPipeline;
  72899. private _disposePostProcesses;
  72900. /**
  72901. * Adds a camera to the pipeline
  72902. * @param camera the camera to be added
  72903. */
  72904. addCamera(camera: Camera): void;
  72905. /**
  72906. * Removes a camera from the pipeline
  72907. * @param camera the camera to remove
  72908. */
  72909. removeCamera(camera: Camera): void;
  72910. /**
  72911. * Dispose of the pipeline and stop all post processes
  72912. */
  72913. dispose(): void;
  72914. /**
  72915. * Serialize the rendering pipeline (Used when exporting)
  72916. * @returns the serialized object
  72917. */
  72918. serialize(): any;
  72919. /**
  72920. * Parse the serialized pipeline
  72921. * @param source Source pipeline.
  72922. * @param scene The scene to load the pipeline to.
  72923. * @param rootUrl The URL of the serialized pipeline.
  72924. * @returns An instantiated pipeline from the serialized object.
  72925. */
  72926. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72927. }
  72928. }
  72929. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72930. /** @hidden */
  72931. export var lensHighlightsPixelShader: {
  72932. name: string;
  72933. shader: string;
  72934. };
  72935. }
  72936. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72937. /** @hidden */
  72938. export var depthOfFieldPixelShader: {
  72939. name: string;
  72940. shader: string;
  72941. };
  72942. }
  72943. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72944. import { Camera } from "babylonjs/Cameras/camera";
  72945. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72946. import { Scene } from "babylonjs/scene";
  72947. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72948. import "babylonjs/Shaders/chromaticAberration.fragment";
  72949. import "babylonjs/Shaders/lensHighlights.fragment";
  72950. import "babylonjs/Shaders/depthOfField.fragment";
  72951. /**
  72952. * BABYLON.JS Chromatic Aberration GLSL Shader
  72953. * Author: Olivier Guyot
  72954. * Separates very slightly R, G and B colors on the edges of the screen
  72955. * Inspired by Francois Tarlier & Martins Upitis
  72956. */
  72957. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72958. /**
  72959. * @ignore
  72960. * The chromatic aberration PostProcess id in the pipeline
  72961. */
  72962. LensChromaticAberrationEffect: string;
  72963. /**
  72964. * @ignore
  72965. * The highlights enhancing PostProcess id in the pipeline
  72966. */
  72967. HighlightsEnhancingEffect: string;
  72968. /**
  72969. * @ignore
  72970. * The depth-of-field PostProcess id in the pipeline
  72971. */
  72972. LensDepthOfFieldEffect: string;
  72973. private _scene;
  72974. private _depthTexture;
  72975. private _grainTexture;
  72976. private _chromaticAberrationPostProcess;
  72977. private _highlightsPostProcess;
  72978. private _depthOfFieldPostProcess;
  72979. private _edgeBlur;
  72980. private _grainAmount;
  72981. private _chromaticAberration;
  72982. private _distortion;
  72983. private _highlightsGain;
  72984. private _highlightsThreshold;
  72985. private _dofDistance;
  72986. private _dofAperture;
  72987. private _dofDarken;
  72988. private _dofPentagon;
  72989. private _blurNoise;
  72990. /**
  72991. * @constructor
  72992. *
  72993. * Effect parameters are as follow:
  72994. * {
  72995. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72996. * edge_blur: number; // from 0 to x (1 for realism)
  72997. * distortion: number; // from 0 to x (1 for realism)
  72998. * grain_amount: number; // from 0 to 1
  72999. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73000. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73001. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73002. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73003. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73004. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73005. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73006. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73007. * }
  73008. * Note: if an effect parameter is unset, effect is disabled
  73009. *
  73010. * @param name The rendering pipeline name
  73011. * @param parameters - An object containing all parameters (see above)
  73012. * @param scene The scene linked to this pipeline
  73013. * @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)
  73014. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73015. */
  73016. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73017. /**
  73018. * Get the class name
  73019. * @returns "LensRenderingPipeline"
  73020. */
  73021. getClassName(): string;
  73022. /**
  73023. * Gets associated scene
  73024. */
  73025. get scene(): Scene;
  73026. /**
  73027. * Gets or sets the edge blur
  73028. */
  73029. get edgeBlur(): number;
  73030. set edgeBlur(value: number);
  73031. /**
  73032. * Gets or sets the grain amount
  73033. */
  73034. get grainAmount(): number;
  73035. set grainAmount(value: number);
  73036. /**
  73037. * Gets or sets the chromatic aberration amount
  73038. */
  73039. get chromaticAberration(): number;
  73040. set chromaticAberration(value: number);
  73041. /**
  73042. * Gets or sets the depth of field aperture
  73043. */
  73044. get dofAperture(): number;
  73045. set dofAperture(value: number);
  73046. /**
  73047. * Gets or sets the edge distortion
  73048. */
  73049. get edgeDistortion(): number;
  73050. set edgeDistortion(value: number);
  73051. /**
  73052. * Gets or sets the depth of field distortion
  73053. */
  73054. get dofDistortion(): number;
  73055. set dofDistortion(value: number);
  73056. /**
  73057. * Gets or sets the darken out of focus amount
  73058. */
  73059. get darkenOutOfFocus(): number;
  73060. set darkenOutOfFocus(value: number);
  73061. /**
  73062. * Gets or sets a boolean indicating if blur noise is enabled
  73063. */
  73064. get blurNoise(): boolean;
  73065. set blurNoise(value: boolean);
  73066. /**
  73067. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73068. */
  73069. get pentagonBokeh(): boolean;
  73070. set pentagonBokeh(value: boolean);
  73071. /**
  73072. * Gets or sets the highlight grain amount
  73073. */
  73074. get highlightsGain(): number;
  73075. set highlightsGain(value: number);
  73076. /**
  73077. * Gets or sets the highlight threshold
  73078. */
  73079. get highlightsThreshold(): number;
  73080. set highlightsThreshold(value: number);
  73081. /**
  73082. * Sets the amount of blur at the edges
  73083. * @param amount blur amount
  73084. */
  73085. setEdgeBlur(amount: number): void;
  73086. /**
  73087. * Sets edge blur to 0
  73088. */
  73089. disableEdgeBlur(): void;
  73090. /**
  73091. * Sets the amout of grain
  73092. * @param amount Amount of grain
  73093. */
  73094. setGrainAmount(amount: number): void;
  73095. /**
  73096. * Set grain amount to 0
  73097. */
  73098. disableGrain(): void;
  73099. /**
  73100. * Sets the chromatic aberration amount
  73101. * @param amount amount of chromatic aberration
  73102. */
  73103. setChromaticAberration(amount: number): void;
  73104. /**
  73105. * Sets chromatic aberration amount to 0
  73106. */
  73107. disableChromaticAberration(): void;
  73108. /**
  73109. * Sets the EdgeDistortion amount
  73110. * @param amount amount of EdgeDistortion
  73111. */
  73112. setEdgeDistortion(amount: number): void;
  73113. /**
  73114. * Sets edge distortion to 0
  73115. */
  73116. disableEdgeDistortion(): void;
  73117. /**
  73118. * Sets the FocusDistance amount
  73119. * @param amount amount of FocusDistance
  73120. */
  73121. setFocusDistance(amount: number): void;
  73122. /**
  73123. * Disables depth of field
  73124. */
  73125. disableDepthOfField(): void;
  73126. /**
  73127. * Sets the Aperture amount
  73128. * @param amount amount of Aperture
  73129. */
  73130. setAperture(amount: number): void;
  73131. /**
  73132. * Sets the DarkenOutOfFocus amount
  73133. * @param amount amount of DarkenOutOfFocus
  73134. */
  73135. setDarkenOutOfFocus(amount: number): void;
  73136. private _pentagonBokehIsEnabled;
  73137. /**
  73138. * Creates a pentagon bokeh effect
  73139. */
  73140. enablePentagonBokeh(): void;
  73141. /**
  73142. * Disables the pentagon bokeh effect
  73143. */
  73144. disablePentagonBokeh(): void;
  73145. /**
  73146. * Enables noise blur
  73147. */
  73148. enableNoiseBlur(): void;
  73149. /**
  73150. * Disables noise blur
  73151. */
  73152. disableNoiseBlur(): void;
  73153. /**
  73154. * Sets the HighlightsGain amount
  73155. * @param amount amount of HighlightsGain
  73156. */
  73157. setHighlightsGain(amount: number): void;
  73158. /**
  73159. * Sets the HighlightsThreshold amount
  73160. * @param amount amount of HighlightsThreshold
  73161. */
  73162. setHighlightsThreshold(amount: number): void;
  73163. /**
  73164. * Disables highlights
  73165. */
  73166. disableHighlights(): void;
  73167. /**
  73168. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73169. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73170. */
  73171. dispose(disableDepthRender?: boolean): void;
  73172. private _createChromaticAberrationPostProcess;
  73173. private _createHighlightsPostProcess;
  73174. private _createDepthOfFieldPostProcess;
  73175. private _createGrainTexture;
  73176. }
  73177. }
  73178. declare module "babylonjs/Shaders/ssao2.fragment" {
  73179. /** @hidden */
  73180. export var ssao2PixelShader: {
  73181. name: string;
  73182. shader: string;
  73183. };
  73184. }
  73185. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73186. /** @hidden */
  73187. export var ssaoCombinePixelShader: {
  73188. name: string;
  73189. shader: string;
  73190. };
  73191. }
  73192. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73193. import { Camera } from "babylonjs/Cameras/camera";
  73194. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73195. import { Scene } from "babylonjs/scene";
  73196. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73197. import "babylonjs/Shaders/ssao2.fragment";
  73198. import "babylonjs/Shaders/ssaoCombine.fragment";
  73199. /**
  73200. * Render pipeline to produce ssao effect
  73201. */
  73202. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73203. /**
  73204. * @ignore
  73205. * The PassPostProcess id in the pipeline that contains the original scene color
  73206. */
  73207. SSAOOriginalSceneColorEffect: string;
  73208. /**
  73209. * @ignore
  73210. * The SSAO PostProcess id in the pipeline
  73211. */
  73212. SSAORenderEffect: string;
  73213. /**
  73214. * @ignore
  73215. * The horizontal blur PostProcess id in the pipeline
  73216. */
  73217. SSAOBlurHRenderEffect: string;
  73218. /**
  73219. * @ignore
  73220. * The vertical blur PostProcess id in the pipeline
  73221. */
  73222. SSAOBlurVRenderEffect: string;
  73223. /**
  73224. * @ignore
  73225. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73226. */
  73227. SSAOCombineRenderEffect: string;
  73228. /**
  73229. * The output strength of the SSAO post-process. Default value is 1.0.
  73230. */
  73231. totalStrength: number;
  73232. /**
  73233. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73234. */
  73235. maxZ: number;
  73236. /**
  73237. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73238. */
  73239. minZAspect: number;
  73240. private _samples;
  73241. /**
  73242. * Number of samples used for the SSAO calculations. Default value is 8
  73243. */
  73244. set samples(n: number);
  73245. get samples(): number;
  73246. private _textureSamples;
  73247. /**
  73248. * Number of samples to use for antialiasing
  73249. */
  73250. set textureSamples(n: number);
  73251. get textureSamples(): number;
  73252. /**
  73253. * Ratio object used for SSAO ratio and blur ratio
  73254. */
  73255. private _ratio;
  73256. /**
  73257. * Dynamically generated sphere sampler.
  73258. */
  73259. private _sampleSphere;
  73260. /**
  73261. * Blur filter offsets
  73262. */
  73263. private _samplerOffsets;
  73264. private _expensiveBlur;
  73265. /**
  73266. * If bilateral blur should be used
  73267. */
  73268. set expensiveBlur(b: boolean);
  73269. get expensiveBlur(): boolean;
  73270. /**
  73271. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73272. */
  73273. radius: number;
  73274. /**
  73275. * The base color of the SSAO post-process
  73276. * The final result is "base + ssao" between [0, 1]
  73277. */
  73278. base: number;
  73279. /**
  73280. * Support test.
  73281. */
  73282. static get IsSupported(): boolean;
  73283. private _scene;
  73284. private _depthTexture;
  73285. private _normalTexture;
  73286. private _randomTexture;
  73287. private _originalColorPostProcess;
  73288. private _ssaoPostProcess;
  73289. private _blurHPostProcess;
  73290. private _blurVPostProcess;
  73291. private _ssaoCombinePostProcess;
  73292. /**
  73293. * Gets active scene
  73294. */
  73295. get scene(): Scene;
  73296. /**
  73297. * @constructor
  73298. * @param name The rendering pipeline name
  73299. * @param scene The scene linked to this pipeline
  73300. * @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 }
  73301. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73302. */
  73303. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73304. /**
  73305. * Get the class name
  73306. * @returns "SSAO2RenderingPipeline"
  73307. */
  73308. getClassName(): string;
  73309. /**
  73310. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73311. */
  73312. dispose(disableGeometryBufferRenderer?: boolean): void;
  73313. private _createBlurPostProcess;
  73314. /** @hidden */
  73315. _rebuild(): void;
  73316. private _bits;
  73317. private _radicalInverse_VdC;
  73318. private _hammersley;
  73319. private _hemisphereSample_uniform;
  73320. private _generateHemisphere;
  73321. private _createSSAOPostProcess;
  73322. private _createSSAOCombinePostProcess;
  73323. private _createRandomTexture;
  73324. /**
  73325. * Serialize the rendering pipeline (Used when exporting)
  73326. * @returns the serialized object
  73327. */
  73328. serialize(): any;
  73329. /**
  73330. * Parse the serialized pipeline
  73331. * @param source Source pipeline.
  73332. * @param scene The scene to load the pipeline to.
  73333. * @param rootUrl The URL of the serialized pipeline.
  73334. * @returns An instantiated pipeline from the serialized object.
  73335. */
  73336. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73337. }
  73338. }
  73339. declare module "babylonjs/Shaders/ssao.fragment" {
  73340. /** @hidden */
  73341. export var ssaoPixelShader: {
  73342. name: string;
  73343. shader: string;
  73344. };
  73345. }
  73346. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73347. import { Camera } from "babylonjs/Cameras/camera";
  73348. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73349. import { Scene } from "babylonjs/scene";
  73350. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73351. import "babylonjs/Shaders/ssao.fragment";
  73352. import "babylonjs/Shaders/ssaoCombine.fragment";
  73353. /**
  73354. * Render pipeline to produce ssao effect
  73355. */
  73356. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73357. /**
  73358. * @ignore
  73359. * The PassPostProcess id in the pipeline that contains the original scene color
  73360. */
  73361. SSAOOriginalSceneColorEffect: string;
  73362. /**
  73363. * @ignore
  73364. * The SSAO PostProcess id in the pipeline
  73365. */
  73366. SSAORenderEffect: string;
  73367. /**
  73368. * @ignore
  73369. * The horizontal blur PostProcess id in the pipeline
  73370. */
  73371. SSAOBlurHRenderEffect: string;
  73372. /**
  73373. * @ignore
  73374. * The vertical blur PostProcess id in the pipeline
  73375. */
  73376. SSAOBlurVRenderEffect: string;
  73377. /**
  73378. * @ignore
  73379. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73380. */
  73381. SSAOCombineRenderEffect: string;
  73382. /**
  73383. * The output strength of the SSAO post-process. Default value is 1.0.
  73384. */
  73385. totalStrength: number;
  73386. /**
  73387. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73388. */
  73389. radius: number;
  73390. /**
  73391. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73392. * Must not be equal to fallOff and superior to fallOff.
  73393. * Default value is 0.0075
  73394. */
  73395. area: number;
  73396. /**
  73397. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73398. * Must not be equal to area and inferior to area.
  73399. * Default value is 0.000001
  73400. */
  73401. fallOff: number;
  73402. /**
  73403. * The base color of the SSAO post-process
  73404. * The final result is "base + ssao" between [0, 1]
  73405. */
  73406. base: number;
  73407. private _scene;
  73408. private _depthTexture;
  73409. private _randomTexture;
  73410. private _originalColorPostProcess;
  73411. private _ssaoPostProcess;
  73412. private _blurHPostProcess;
  73413. private _blurVPostProcess;
  73414. private _ssaoCombinePostProcess;
  73415. private _firstUpdate;
  73416. /**
  73417. * Gets active scene
  73418. */
  73419. get scene(): Scene;
  73420. /**
  73421. * @constructor
  73422. * @param name - The rendering pipeline name
  73423. * @param scene - The scene linked to this pipeline
  73424. * @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 }
  73425. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73426. */
  73427. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73428. /**
  73429. * Get the class name
  73430. * @returns "SSAORenderingPipeline"
  73431. */
  73432. getClassName(): string;
  73433. /**
  73434. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73435. */
  73436. dispose(disableDepthRender?: boolean): void;
  73437. private _createBlurPostProcess;
  73438. /** @hidden */
  73439. _rebuild(): void;
  73440. private _createSSAOPostProcess;
  73441. private _createSSAOCombinePostProcess;
  73442. private _createRandomTexture;
  73443. }
  73444. }
  73445. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73446. /** @hidden */
  73447. export var screenSpaceReflectionPixelShader: {
  73448. name: string;
  73449. shader: string;
  73450. };
  73451. }
  73452. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73453. import { Nullable } from "babylonjs/types";
  73454. import { Camera } from "babylonjs/Cameras/camera";
  73455. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73456. import { Scene } from "babylonjs/scene";
  73457. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73458. import { Engine } from "babylonjs/Engines/engine";
  73459. /**
  73460. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73461. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73462. */
  73463. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73464. /**
  73465. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73466. */
  73467. threshold: number;
  73468. /**
  73469. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73470. */
  73471. strength: number;
  73472. /**
  73473. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73474. */
  73475. reflectionSpecularFalloffExponent: number;
  73476. /**
  73477. * 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]
  73478. */
  73479. step: number;
  73480. /**
  73481. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73482. */
  73483. roughnessFactor: number;
  73484. private _geometryBufferRenderer;
  73485. private _enableSmoothReflections;
  73486. private _reflectionSamples;
  73487. private _smoothSteps;
  73488. /**
  73489. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73490. * @param name The name of the effect.
  73491. * @param scene The scene containing the objects to calculate reflections.
  73492. * @param options The required width/height ratio to downsize to before computing the render pass.
  73493. * @param camera The camera to apply the render pass to.
  73494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73495. * @param engine The engine which the post process will be applied. (default: current engine)
  73496. * @param reusable If the post process can be reused on the same frame. (default: false)
  73497. * @param textureType Type of textures used when performing the post process. (default: 0)
  73498. * @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)
  73499. */
  73500. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73501. /**
  73502. * Gets wether or not smoothing reflections is enabled.
  73503. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73504. */
  73505. get enableSmoothReflections(): boolean;
  73506. /**
  73507. * Sets wether or not smoothing reflections is enabled.
  73508. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73509. */
  73510. set enableSmoothReflections(enabled: boolean);
  73511. /**
  73512. * Gets the number of samples taken while computing reflections. More samples count is high,
  73513. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73514. */
  73515. get reflectionSamples(): number;
  73516. /**
  73517. * Sets the number of samples taken while computing reflections. More samples count is high,
  73518. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73519. */
  73520. set reflectionSamples(samples: number);
  73521. /**
  73522. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73523. * more the post-process will require GPU power and can generate a drop in FPS.
  73524. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73525. */
  73526. get smoothSteps(): number;
  73527. set smoothSteps(steps: number);
  73528. private _updateEffectDefines;
  73529. }
  73530. }
  73531. declare module "babylonjs/Shaders/standard.fragment" {
  73532. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73533. /** @hidden */
  73534. export var standardPixelShader: {
  73535. name: string;
  73536. shader: string;
  73537. };
  73538. }
  73539. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73540. import { Nullable } from "babylonjs/types";
  73541. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73542. import { Camera } from "babylonjs/Cameras/camera";
  73543. import { Texture } from "babylonjs/Materials/Textures/texture";
  73544. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73545. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73546. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73547. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73548. import { IDisposable } from "babylonjs/scene";
  73549. import { SpotLight } from "babylonjs/Lights/spotLight";
  73550. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73551. import { Scene } from "babylonjs/scene";
  73552. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73553. import { Animation } from "babylonjs/Animations/animation";
  73554. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73555. import "babylonjs/Shaders/standard.fragment";
  73556. /**
  73557. * Standard rendering pipeline
  73558. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73559. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73560. */
  73561. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73562. /**
  73563. * Public members
  73564. */
  73565. /**
  73566. * Post-process which contains the original scene color before the pipeline applies all the effects
  73567. */
  73568. originalPostProcess: Nullable<PostProcess>;
  73569. /**
  73570. * Post-process used to down scale an image x4
  73571. */
  73572. downSampleX4PostProcess: Nullable<PostProcess>;
  73573. /**
  73574. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73575. */
  73576. brightPassPostProcess: Nullable<PostProcess>;
  73577. /**
  73578. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73579. */
  73580. blurHPostProcesses: PostProcess[];
  73581. /**
  73582. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73583. */
  73584. blurVPostProcesses: PostProcess[];
  73585. /**
  73586. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73587. */
  73588. textureAdderPostProcess: Nullable<PostProcess>;
  73589. /**
  73590. * Post-process used to create volumetric lighting effect
  73591. */
  73592. volumetricLightPostProcess: Nullable<PostProcess>;
  73593. /**
  73594. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73595. */
  73596. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73597. /**
  73598. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73599. */
  73600. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73601. /**
  73602. * Post-process used to merge the volumetric light effect and the real scene color
  73603. */
  73604. volumetricLightMergePostProces: Nullable<PostProcess>;
  73605. /**
  73606. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73607. */
  73608. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73609. /**
  73610. * Base post-process used to calculate the average luminance of the final image for HDR
  73611. */
  73612. luminancePostProcess: Nullable<PostProcess>;
  73613. /**
  73614. * Post-processes used to create down sample post-processes in order to get
  73615. * the average luminance of the final image for HDR
  73616. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73617. */
  73618. luminanceDownSamplePostProcesses: PostProcess[];
  73619. /**
  73620. * Post-process used to create a HDR effect (light adaptation)
  73621. */
  73622. hdrPostProcess: Nullable<PostProcess>;
  73623. /**
  73624. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73625. */
  73626. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73627. /**
  73628. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73629. */
  73630. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73631. /**
  73632. * Post-process used to merge the final HDR post-process and the real scene color
  73633. */
  73634. hdrFinalPostProcess: Nullable<PostProcess>;
  73635. /**
  73636. * Post-process used to create a lens flare effect
  73637. */
  73638. lensFlarePostProcess: Nullable<PostProcess>;
  73639. /**
  73640. * Post-process that merges the result of the lens flare post-process and the real scene color
  73641. */
  73642. lensFlareComposePostProcess: Nullable<PostProcess>;
  73643. /**
  73644. * Post-process used to create a motion blur effect
  73645. */
  73646. motionBlurPostProcess: Nullable<PostProcess>;
  73647. /**
  73648. * Post-process used to create a depth of field effect
  73649. */
  73650. depthOfFieldPostProcess: Nullable<PostProcess>;
  73651. /**
  73652. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73653. */
  73654. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73655. /**
  73656. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73657. */
  73658. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73659. /**
  73660. * Represents the brightness threshold in order to configure the illuminated surfaces
  73661. */
  73662. brightThreshold: number;
  73663. /**
  73664. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73665. */
  73666. blurWidth: number;
  73667. /**
  73668. * Sets if the blur for highlighted surfaces must be only horizontal
  73669. */
  73670. horizontalBlur: boolean;
  73671. /**
  73672. * Gets the overall exposure used by the pipeline
  73673. */
  73674. get exposure(): number;
  73675. /**
  73676. * Sets the overall exposure used by the pipeline
  73677. */
  73678. set exposure(value: number);
  73679. /**
  73680. * Texture used typically to simulate "dirty" on camera lens
  73681. */
  73682. lensTexture: Nullable<Texture>;
  73683. /**
  73684. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73685. */
  73686. volumetricLightCoefficient: number;
  73687. /**
  73688. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73689. */
  73690. volumetricLightPower: number;
  73691. /**
  73692. * Used the set the blur intensity to smooth the volumetric lights
  73693. */
  73694. volumetricLightBlurScale: number;
  73695. /**
  73696. * Light (spot or directional) used to generate the volumetric lights rays
  73697. * The source light must have a shadow generate so the pipeline can get its
  73698. * depth map
  73699. */
  73700. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73701. /**
  73702. * For eye adaptation, represents the minimum luminance the eye can see
  73703. */
  73704. hdrMinimumLuminance: number;
  73705. /**
  73706. * For eye adaptation, represents the decrease luminance speed
  73707. */
  73708. hdrDecreaseRate: number;
  73709. /**
  73710. * For eye adaptation, represents the increase luminance speed
  73711. */
  73712. hdrIncreaseRate: number;
  73713. /**
  73714. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73715. */
  73716. get hdrAutoExposure(): boolean;
  73717. /**
  73718. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73719. */
  73720. set hdrAutoExposure(value: boolean);
  73721. /**
  73722. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73723. */
  73724. lensColorTexture: Nullable<Texture>;
  73725. /**
  73726. * The overall strengh for the lens flare effect
  73727. */
  73728. lensFlareStrength: number;
  73729. /**
  73730. * Dispersion coefficient for lens flare ghosts
  73731. */
  73732. lensFlareGhostDispersal: number;
  73733. /**
  73734. * Main lens flare halo width
  73735. */
  73736. lensFlareHaloWidth: number;
  73737. /**
  73738. * Based on the lens distortion effect, defines how much the lens flare result
  73739. * is distorted
  73740. */
  73741. lensFlareDistortionStrength: number;
  73742. /**
  73743. * Configures the blur intensity used for for lens flare (halo)
  73744. */
  73745. lensFlareBlurWidth: number;
  73746. /**
  73747. * Lens star texture must be used to simulate rays on the flares and is available
  73748. * in the documentation
  73749. */
  73750. lensStarTexture: Nullable<Texture>;
  73751. /**
  73752. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73753. * flare effect by taking account of the dirt texture
  73754. */
  73755. lensFlareDirtTexture: Nullable<Texture>;
  73756. /**
  73757. * Represents the focal length for the depth of field effect
  73758. */
  73759. depthOfFieldDistance: number;
  73760. /**
  73761. * Represents the blur intensity for the blurred part of the depth of field effect
  73762. */
  73763. depthOfFieldBlurWidth: number;
  73764. /**
  73765. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73766. */
  73767. get motionStrength(): number;
  73768. /**
  73769. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73770. */
  73771. set motionStrength(strength: number);
  73772. /**
  73773. * Gets wether or not the motion blur post-process is object based or screen based.
  73774. */
  73775. get objectBasedMotionBlur(): boolean;
  73776. /**
  73777. * Sets wether or not the motion blur post-process should be object based or screen based
  73778. */
  73779. set objectBasedMotionBlur(value: boolean);
  73780. /**
  73781. * List of animations for the pipeline (IAnimatable implementation)
  73782. */
  73783. animations: Animation[];
  73784. /**
  73785. * Private members
  73786. */
  73787. private _scene;
  73788. private _currentDepthOfFieldSource;
  73789. private _basePostProcess;
  73790. private _fixedExposure;
  73791. private _currentExposure;
  73792. private _hdrAutoExposure;
  73793. private _hdrCurrentLuminance;
  73794. private _motionStrength;
  73795. private _isObjectBasedMotionBlur;
  73796. private _floatTextureType;
  73797. private _camerasToBeAttached;
  73798. private _ratio;
  73799. private _bloomEnabled;
  73800. private _depthOfFieldEnabled;
  73801. private _vlsEnabled;
  73802. private _lensFlareEnabled;
  73803. private _hdrEnabled;
  73804. private _motionBlurEnabled;
  73805. private _fxaaEnabled;
  73806. private _screenSpaceReflectionsEnabled;
  73807. private _motionBlurSamples;
  73808. private _volumetricLightStepsCount;
  73809. private _samples;
  73810. /**
  73811. * @ignore
  73812. * Specifies if the bloom pipeline is enabled
  73813. */
  73814. get BloomEnabled(): boolean;
  73815. set BloomEnabled(enabled: boolean);
  73816. /**
  73817. * @ignore
  73818. * Specifies if the depth of field pipeline is enabed
  73819. */
  73820. get DepthOfFieldEnabled(): boolean;
  73821. set DepthOfFieldEnabled(enabled: boolean);
  73822. /**
  73823. * @ignore
  73824. * Specifies if the lens flare pipeline is enabed
  73825. */
  73826. get LensFlareEnabled(): boolean;
  73827. set LensFlareEnabled(enabled: boolean);
  73828. /**
  73829. * @ignore
  73830. * Specifies if the HDR pipeline is enabled
  73831. */
  73832. get HDREnabled(): boolean;
  73833. set HDREnabled(enabled: boolean);
  73834. /**
  73835. * @ignore
  73836. * Specifies if the volumetric lights scattering effect is enabled
  73837. */
  73838. get VLSEnabled(): boolean;
  73839. set VLSEnabled(enabled: boolean);
  73840. /**
  73841. * @ignore
  73842. * Specifies if the motion blur effect is enabled
  73843. */
  73844. get MotionBlurEnabled(): boolean;
  73845. set MotionBlurEnabled(enabled: boolean);
  73846. /**
  73847. * Specifies if anti-aliasing is enabled
  73848. */
  73849. get fxaaEnabled(): boolean;
  73850. set fxaaEnabled(enabled: boolean);
  73851. /**
  73852. * Specifies if screen space reflections are enabled.
  73853. */
  73854. get screenSpaceReflectionsEnabled(): boolean;
  73855. set screenSpaceReflectionsEnabled(enabled: boolean);
  73856. /**
  73857. * Specifies the number of steps used to calculate the volumetric lights
  73858. * Typically in interval [50, 200]
  73859. */
  73860. get volumetricLightStepsCount(): number;
  73861. set volumetricLightStepsCount(count: number);
  73862. /**
  73863. * Specifies the number of samples used for the motion blur effect
  73864. * Typically in interval [16, 64]
  73865. */
  73866. get motionBlurSamples(): number;
  73867. set motionBlurSamples(samples: number);
  73868. /**
  73869. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73870. */
  73871. get samples(): number;
  73872. set samples(sampleCount: number);
  73873. /**
  73874. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73875. * @constructor
  73876. * @param name The rendering pipeline name
  73877. * @param scene The scene linked to this pipeline
  73878. * @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)
  73879. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73880. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73881. */
  73882. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73883. private _buildPipeline;
  73884. private _createDownSampleX4PostProcess;
  73885. private _createBrightPassPostProcess;
  73886. private _createBlurPostProcesses;
  73887. private _createTextureAdderPostProcess;
  73888. private _createVolumetricLightPostProcess;
  73889. private _createLuminancePostProcesses;
  73890. private _createHdrPostProcess;
  73891. private _createLensFlarePostProcess;
  73892. private _createDepthOfFieldPostProcess;
  73893. private _createMotionBlurPostProcess;
  73894. private _getDepthTexture;
  73895. private _disposePostProcesses;
  73896. /**
  73897. * Dispose of the pipeline and stop all post processes
  73898. */
  73899. dispose(): void;
  73900. /**
  73901. * Serialize the rendering pipeline (Used when exporting)
  73902. * @returns the serialized object
  73903. */
  73904. serialize(): any;
  73905. /**
  73906. * Parse the serialized pipeline
  73907. * @param source Source pipeline.
  73908. * @param scene The scene to load the pipeline to.
  73909. * @param rootUrl The URL of the serialized pipeline.
  73910. * @returns An instantiated pipeline from the serialized object.
  73911. */
  73912. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73913. /**
  73914. * Luminance steps
  73915. */
  73916. static LuminanceSteps: number;
  73917. }
  73918. }
  73919. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73920. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73921. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73922. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73923. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73924. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73925. }
  73926. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73927. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73928. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73929. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73930. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73931. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73932. }
  73933. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73934. /** @hidden */
  73935. export var stereoscopicInterlacePixelShader: {
  73936. name: string;
  73937. shader: string;
  73938. };
  73939. }
  73940. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73941. import { Camera } from "babylonjs/Cameras/camera";
  73942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73943. import { Engine } from "babylonjs/Engines/engine";
  73944. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73945. /**
  73946. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73947. */
  73948. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73949. private _stepSize;
  73950. private _passedProcess;
  73951. /**
  73952. * Initializes a StereoscopicInterlacePostProcessI
  73953. * @param name The name of the effect.
  73954. * @param rigCameras The rig cameras to be appled to the post process
  73955. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73956. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73958. * @param engine The engine which the post process will be applied. (default: current engine)
  73959. * @param reusable If the post process can be reused on the same frame. (default: false)
  73960. */
  73961. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73962. }
  73963. /**
  73964. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73965. */
  73966. export class StereoscopicInterlacePostProcess extends PostProcess {
  73967. private _stepSize;
  73968. private _passedProcess;
  73969. /**
  73970. * Initializes a StereoscopicInterlacePostProcess
  73971. * @param name The name of the effect.
  73972. * @param rigCameras The rig cameras to be appled to the post process
  73973. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73975. * @param engine The engine which the post process will be applied. (default: current engine)
  73976. * @param reusable If the post process can be reused on the same frame. (default: false)
  73977. */
  73978. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73979. }
  73980. }
  73981. declare module "babylonjs/Shaders/tonemap.fragment" {
  73982. /** @hidden */
  73983. export var tonemapPixelShader: {
  73984. name: string;
  73985. shader: string;
  73986. };
  73987. }
  73988. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73989. import { Camera } from "babylonjs/Cameras/camera";
  73990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73991. import "babylonjs/Shaders/tonemap.fragment";
  73992. import { Engine } from "babylonjs/Engines/engine";
  73993. /** Defines operator used for tonemapping */
  73994. export enum TonemappingOperator {
  73995. /** Hable */
  73996. Hable = 0,
  73997. /** Reinhard */
  73998. Reinhard = 1,
  73999. /** HejiDawson */
  74000. HejiDawson = 2,
  74001. /** Photographic */
  74002. Photographic = 3
  74003. }
  74004. /**
  74005. * Defines a post process to apply tone mapping
  74006. */
  74007. export class TonemapPostProcess extends PostProcess {
  74008. private _operator;
  74009. /** Defines the required exposure adjustement */
  74010. exposureAdjustment: number;
  74011. /**
  74012. * Creates a new TonemapPostProcess
  74013. * @param name defines the name of the postprocess
  74014. * @param _operator defines the operator to use
  74015. * @param exposureAdjustment defines the required exposure adjustement
  74016. * @param camera defines the camera to use (can be null)
  74017. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74018. * @param engine defines the hosting engine (can be ignore if camera is set)
  74019. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74020. */
  74021. constructor(name: string, _operator: TonemappingOperator,
  74022. /** Defines the required exposure adjustement */
  74023. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74024. }
  74025. }
  74026. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74027. /** @hidden */
  74028. export var volumetricLightScatteringPixelShader: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74034. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74037. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74039. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74040. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74041. /** @hidden */
  74042. export var volumetricLightScatteringPassVertexShader: {
  74043. name: string;
  74044. shader: string;
  74045. };
  74046. }
  74047. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74048. /** @hidden */
  74049. export var volumetricLightScatteringPassPixelShader: {
  74050. name: string;
  74051. shader: string;
  74052. };
  74053. }
  74054. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74055. import { Vector3 } from "babylonjs/Maths/math.vector";
  74056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74057. import { Mesh } from "babylonjs/Meshes/mesh";
  74058. import { Camera } from "babylonjs/Cameras/camera";
  74059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74060. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74061. import { Scene } from "babylonjs/scene";
  74062. import "babylonjs/Meshes/Builders/planeBuilder";
  74063. import "babylonjs/Shaders/depth.vertex";
  74064. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74065. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74066. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74067. import { Engine } from "babylonjs/Engines/engine";
  74068. /**
  74069. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74070. */
  74071. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74072. private _volumetricLightScatteringPass;
  74073. private _volumetricLightScatteringRTT;
  74074. private _viewPort;
  74075. private _screenCoordinates;
  74076. private _cachedDefines;
  74077. /**
  74078. * If not undefined, the mesh position is computed from the attached node position
  74079. */
  74080. attachedNode: {
  74081. position: Vector3;
  74082. };
  74083. /**
  74084. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74085. */
  74086. customMeshPosition: Vector3;
  74087. /**
  74088. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74089. */
  74090. useCustomMeshPosition: boolean;
  74091. /**
  74092. * If the post-process should inverse the light scattering direction
  74093. */
  74094. invert: boolean;
  74095. /**
  74096. * The internal mesh used by the post-process
  74097. */
  74098. mesh: Mesh;
  74099. /**
  74100. * @hidden
  74101. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74102. */
  74103. get useDiffuseColor(): boolean;
  74104. set useDiffuseColor(useDiffuseColor: boolean);
  74105. /**
  74106. * Array containing the excluded meshes not rendered in the internal pass
  74107. */
  74108. excludedMeshes: AbstractMesh[];
  74109. /**
  74110. * Controls the overall intensity of the post-process
  74111. */
  74112. exposure: number;
  74113. /**
  74114. * Dissipates each sample's contribution in range [0, 1]
  74115. */
  74116. decay: number;
  74117. /**
  74118. * Controls the overall intensity of each sample
  74119. */
  74120. weight: number;
  74121. /**
  74122. * Controls the density of each sample
  74123. */
  74124. density: number;
  74125. /**
  74126. * @constructor
  74127. * @param name The post-process name
  74128. * @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)
  74129. * @param camera The camera that the post-process will be attached to
  74130. * @param mesh The mesh used to create the light scattering
  74131. * @param samples The post-process quality, default 100
  74132. * @param samplingModeThe post-process filtering mode
  74133. * @param engine The babylon engine
  74134. * @param reusable If the post-process is reusable
  74135. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74136. */
  74137. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74138. /**
  74139. * Returns the string "VolumetricLightScatteringPostProcess"
  74140. * @returns "VolumetricLightScatteringPostProcess"
  74141. */
  74142. getClassName(): string;
  74143. private _isReady;
  74144. /**
  74145. * Sets the new light position for light scattering effect
  74146. * @param position The new custom light position
  74147. */
  74148. setCustomMeshPosition(position: Vector3): void;
  74149. /**
  74150. * Returns the light position for light scattering effect
  74151. * @return Vector3 The custom light position
  74152. */
  74153. getCustomMeshPosition(): Vector3;
  74154. /**
  74155. * Disposes the internal assets and detaches the post-process from the camera
  74156. */
  74157. dispose(camera: Camera): void;
  74158. /**
  74159. * Returns the render target texture used by the post-process
  74160. * @return the render target texture used by the post-process
  74161. */
  74162. getPass(): RenderTargetTexture;
  74163. private _meshExcluded;
  74164. private _createPass;
  74165. private _updateMeshScreenCoordinates;
  74166. /**
  74167. * Creates a default mesh for the Volumeric Light Scattering post-process
  74168. * @param name The mesh name
  74169. * @param scene The scene where to create the mesh
  74170. * @return the default mesh
  74171. */
  74172. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74173. }
  74174. }
  74175. declare module "babylonjs/PostProcesses/index" {
  74176. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74177. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74178. export * from "babylonjs/PostProcesses/bloomEffect";
  74179. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74180. export * from "babylonjs/PostProcesses/blurPostProcess";
  74181. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74182. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74183. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74184. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74185. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74186. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74187. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74188. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74189. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74190. export * from "babylonjs/PostProcesses/filterPostProcess";
  74191. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74192. export * from "babylonjs/PostProcesses/grainPostProcess";
  74193. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74194. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74195. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74196. export * from "babylonjs/PostProcesses/passPostProcess";
  74197. export * from "babylonjs/PostProcesses/postProcess";
  74198. export * from "babylonjs/PostProcesses/postProcessManager";
  74199. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74200. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74201. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74202. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74203. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74204. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74205. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74206. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74207. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74208. }
  74209. declare module "babylonjs/Probes/index" {
  74210. export * from "babylonjs/Probes/reflectionProbe";
  74211. }
  74212. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74213. import { Scene } from "babylonjs/scene";
  74214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74215. import { SmartArray } from "babylonjs/Misc/smartArray";
  74216. import { ISceneComponent } from "babylonjs/sceneComponent";
  74217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74218. import "babylonjs/Meshes/Builders/boxBuilder";
  74219. import "babylonjs/Shaders/color.fragment";
  74220. import "babylonjs/Shaders/color.vertex";
  74221. import { Color3 } from "babylonjs/Maths/math.color";
  74222. import { Observable } from "babylonjs/Misc/observable";
  74223. module "babylonjs/scene" {
  74224. interface Scene {
  74225. /** @hidden (Backing field) */
  74226. _boundingBoxRenderer: BoundingBoxRenderer;
  74227. /** @hidden (Backing field) */
  74228. _forceShowBoundingBoxes: boolean;
  74229. /**
  74230. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74231. */
  74232. forceShowBoundingBoxes: boolean;
  74233. /**
  74234. * Gets the bounding box renderer associated with the scene
  74235. * @returns a BoundingBoxRenderer
  74236. */
  74237. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74238. }
  74239. }
  74240. module "babylonjs/Meshes/abstractMesh" {
  74241. interface AbstractMesh {
  74242. /** @hidden (Backing field) */
  74243. _showBoundingBox: boolean;
  74244. /**
  74245. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74246. */
  74247. showBoundingBox: boolean;
  74248. }
  74249. }
  74250. /**
  74251. * Component responsible of rendering the bounding box of the meshes in a scene.
  74252. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74253. */
  74254. export class BoundingBoxRenderer implements ISceneComponent {
  74255. /**
  74256. * The component name helpfull to identify the component in the list of scene components.
  74257. */
  74258. readonly name: string;
  74259. /**
  74260. * The scene the component belongs to.
  74261. */
  74262. scene: Scene;
  74263. /**
  74264. * Color of the bounding box lines placed in front of an object
  74265. */
  74266. frontColor: Color3;
  74267. /**
  74268. * Color of the bounding box lines placed behind an object
  74269. */
  74270. backColor: Color3;
  74271. /**
  74272. * Defines if the renderer should show the back lines or not
  74273. */
  74274. showBackLines: boolean;
  74275. /**
  74276. * Observable raised before rendering a bounding box
  74277. */
  74278. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74279. /**
  74280. * Observable raised after rendering a bounding box
  74281. */
  74282. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74283. /**
  74284. * @hidden
  74285. */
  74286. renderList: SmartArray<BoundingBox>;
  74287. private _colorShader;
  74288. private _vertexBuffers;
  74289. private _indexBuffer;
  74290. private _fillIndexBuffer;
  74291. private _fillIndexData;
  74292. /**
  74293. * Instantiates a new bounding box renderer in a scene.
  74294. * @param scene the scene the renderer renders in
  74295. */
  74296. constructor(scene: Scene);
  74297. /**
  74298. * Registers the component in a given scene
  74299. */
  74300. register(): void;
  74301. private _evaluateSubMesh;
  74302. private _activeMesh;
  74303. private _prepareRessources;
  74304. private _createIndexBuffer;
  74305. /**
  74306. * Rebuilds the elements related to this component in case of
  74307. * context lost for instance.
  74308. */
  74309. rebuild(): void;
  74310. /**
  74311. * @hidden
  74312. */
  74313. reset(): void;
  74314. /**
  74315. * Render the bounding boxes of a specific rendering group
  74316. * @param renderingGroupId defines the rendering group to render
  74317. */
  74318. render(renderingGroupId: number): void;
  74319. /**
  74320. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74321. * @param mesh Define the mesh to render the occlusion bounding box for
  74322. */
  74323. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74324. /**
  74325. * Dispose and release the resources attached to this renderer.
  74326. */
  74327. dispose(): void;
  74328. }
  74329. }
  74330. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74331. import { Nullable } from "babylonjs/types";
  74332. import { Scene } from "babylonjs/scene";
  74333. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74334. import { Camera } from "babylonjs/Cameras/camera";
  74335. import { ISceneComponent } from "babylonjs/sceneComponent";
  74336. module "babylonjs/scene" {
  74337. interface Scene {
  74338. /** @hidden (Backing field) */
  74339. _depthRenderer: {
  74340. [id: string]: DepthRenderer;
  74341. };
  74342. /**
  74343. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74344. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74345. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74346. * @returns the created depth renderer
  74347. */
  74348. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74349. /**
  74350. * Disables a depth renderer for a given camera
  74351. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74352. */
  74353. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74354. }
  74355. }
  74356. /**
  74357. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74358. * in several rendering techniques.
  74359. */
  74360. export class DepthRendererSceneComponent implements ISceneComponent {
  74361. /**
  74362. * The component name helpfull to identify the component in the list of scene components.
  74363. */
  74364. readonly name: string;
  74365. /**
  74366. * The scene the component belongs to.
  74367. */
  74368. scene: Scene;
  74369. /**
  74370. * Creates a new instance of the component for the given scene
  74371. * @param scene Defines the scene to register the component in
  74372. */
  74373. constructor(scene: Scene);
  74374. /**
  74375. * Registers the component in a given scene
  74376. */
  74377. register(): void;
  74378. /**
  74379. * Rebuilds the elements related to this component in case of
  74380. * context lost for instance.
  74381. */
  74382. rebuild(): void;
  74383. /**
  74384. * Disposes the component and the associated ressources
  74385. */
  74386. dispose(): void;
  74387. private _gatherRenderTargets;
  74388. private _gatherActiveCameraRenderTargets;
  74389. }
  74390. }
  74391. declare module "babylonjs/Shaders/outline.fragment" {
  74392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74393. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74394. /** @hidden */
  74395. export var outlinePixelShader: {
  74396. name: string;
  74397. shader: string;
  74398. };
  74399. }
  74400. declare module "babylonjs/Shaders/outline.vertex" {
  74401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74403. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74404. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74405. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74406. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74407. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74408. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74409. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74410. /** @hidden */
  74411. export var outlineVertexShader: {
  74412. name: string;
  74413. shader: string;
  74414. };
  74415. }
  74416. declare module "babylonjs/Rendering/outlineRenderer" {
  74417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74418. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74419. import { Scene } from "babylonjs/scene";
  74420. import { ISceneComponent } from "babylonjs/sceneComponent";
  74421. import "babylonjs/Shaders/outline.fragment";
  74422. import "babylonjs/Shaders/outline.vertex";
  74423. module "babylonjs/scene" {
  74424. interface Scene {
  74425. /** @hidden */
  74426. _outlineRenderer: OutlineRenderer;
  74427. /**
  74428. * Gets the outline renderer associated with the scene
  74429. * @returns a OutlineRenderer
  74430. */
  74431. getOutlineRenderer(): OutlineRenderer;
  74432. }
  74433. }
  74434. module "babylonjs/Meshes/abstractMesh" {
  74435. interface AbstractMesh {
  74436. /** @hidden (Backing field) */
  74437. _renderOutline: boolean;
  74438. /**
  74439. * Gets or sets a boolean indicating if the outline must be rendered as well
  74440. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74441. */
  74442. renderOutline: boolean;
  74443. /** @hidden (Backing field) */
  74444. _renderOverlay: boolean;
  74445. /**
  74446. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74447. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74448. */
  74449. renderOverlay: boolean;
  74450. }
  74451. }
  74452. /**
  74453. * This class is responsible to draw bothe outline/overlay of meshes.
  74454. * It should not be used directly but through the available method on mesh.
  74455. */
  74456. export class OutlineRenderer implements ISceneComponent {
  74457. /**
  74458. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74459. */
  74460. private static _StencilReference;
  74461. /**
  74462. * The name of the component. Each component must have a unique name.
  74463. */
  74464. name: string;
  74465. /**
  74466. * The scene the component belongs to.
  74467. */
  74468. scene: Scene;
  74469. /**
  74470. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74471. */
  74472. zOffset: number;
  74473. private _engine;
  74474. private _effect;
  74475. private _cachedDefines;
  74476. private _savedDepthWrite;
  74477. /**
  74478. * Instantiates a new outline renderer. (There could be only one per scene).
  74479. * @param scene Defines the scene it belongs to
  74480. */
  74481. constructor(scene: Scene);
  74482. /**
  74483. * Register the component to one instance of a scene.
  74484. */
  74485. register(): void;
  74486. /**
  74487. * Rebuilds the elements related to this component in case of
  74488. * context lost for instance.
  74489. */
  74490. rebuild(): void;
  74491. /**
  74492. * Disposes the component and the associated ressources.
  74493. */
  74494. dispose(): void;
  74495. /**
  74496. * Renders the outline in the canvas.
  74497. * @param subMesh Defines the sumesh to render
  74498. * @param batch Defines the batch of meshes in case of instances
  74499. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74500. */
  74501. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74502. /**
  74503. * Returns whether or not the outline renderer is ready for a given submesh.
  74504. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74505. * @param subMesh Defines the submesh to check readyness for
  74506. * @param useInstances Defines wheter wee are trying to render instances or not
  74507. * @returns true if ready otherwise false
  74508. */
  74509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74510. private _beforeRenderingMesh;
  74511. private _afterRenderingMesh;
  74512. }
  74513. }
  74514. declare module "babylonjs/Rendering/index" {
  74515. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74516. export * from "babylonjs/Rendering/depthRenderer";
  74517. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74518. export * from "babylonjs/Rendering/edgesRenderer";
  74519. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74520. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74521. export * from "babylonjs/Rendering/outlineRenderer";
  74522. export * from "babylonjs/Rendering/renderingGroup";
  74523. export * from "babylonjs/Rendering/renderingManager";
  74524. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74525. }
  74526. declare module "babylonjs/Sprites/ISprites" {
  74527. /**
  74528. * Defines the basic options interface of a Sprite Frame Source Size.
  74529. */
  74530. export interface ISpriteJSONSpriteSourceSize {
  74531. /**
  74532. * number of the original width of the Frame
  74533. */
  74534. w: number;
  74535. /**
  74536. * number of the original height of the Frame
  74537. */
  74538. h: number;
  74539. }
  74540. /**
  74541. * Defines the basic options interface of a Sprite Frame Data.
  74542. */
  74543. export interface ISpriteJSONSpriteFrameData {
  74544. /**
  74545. * number of the x offset of the Frame
  74546. */
  74547. x: number;
  74548. /**
  74549. * number of the y offset of the Frame
  74550. */
  74551. y: number;
  74552. /**
  74553. * number of the width of the Frame
  74554. */
  74555. w: number;
  74556. /**
  74557. * number of the height of the Frame
  74558. */
  74559. h: number;
  74560. }
  74561. /**
  74562. * Defines the basic options interface of a JSON Sprite.
  74563. */
  74564. export interface ISpriteJSONSprite {
  74565. /**
  74566. * string name of the Frame
  74567. */
  74568. filename: string;
  74569. /**
  74570. * ISpriteJSONSpriteFrame basic object of the frame data
  74571. */
  74572. frame: ISpriteJSONSpriteFrameData;
  74573. /**
  74574. * boolean to flag is the frame was rotated.
  74575. */
  74576. rotated: boolean;
  74577. /**
  74578. * boolean to flag is the frame was trimmed.
  74579. */
  74580. trimmed: boolean;
  74581. /**
  74582. * ISpriteJSONSpriteFrame basic object of the source data
  74583. */
  74584. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74585. /**
  74586. * ISpriteJSONSpriteFrame basic object of the source data
  74587. */
  74588. sourceSize: ISpriteJSONSpriteSourceSize;
  74589. }
  74590. /**
  74591. * Defines the basic options interface of a JSON atlas.
  74592. */
  74593. export interface ISpriteJSONAtlas {
  74594. /**
  74595. * Array of objects that contain the frame data.
  74596. */
  74597. frames: Array<ISpriteJSONSprite>;
  74598. /**
  74599. * object basic object containing the sprite meta data.
  74600. */
  74601. meta?: object;
  74602. }
  74603. }
  74604. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74605. /** @hidden */
  74606. export var spriteMapPixelShader: {
  74607. name: string;
  74608. shader: string;
  74609. };
  74610. }
  74611. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74612. /** @hidden */
  74613. export var spriteMapVertexShader: {
  74614. name: string;
  74615. shader: string;
  74616. };
  74617. }
  74618. declare module "babylonjs/Sprites/spriteMap" {
  74619. import { IDisposable, Scene } from "babylonjs/scene";
  74620. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74621. import { Texture } from "babylonjs/Materials/Textures/texture";
  74622. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74623. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74624. import "babylonjs/Meshes/Builders/planeBuilder";
  74625. import "babylonjs/Shaders/spriteMap.fragment";
  74626. import "babylonjs/Shaders/spriteMap.vertex";
  74627. /**
  74628. * Defines the basic options interface of a SpriteMap
  74629. */
  74630. export interface ISpriteMapOptions {
  74631. /**
  74632. * Vector2 of the number of cells in the grid.
  74633. */
  74634. stageSize?: Vector2;
  74635. /**
  74636. * Vector2 of the size of the output plane in World Units.
  74637. */
  74638. outputSize?: Vector2;
  74639. /**
  74640. * Vector3 of the position of the output plane in World Units.
  74641. */
  74642. outputPosition?: Vector3;
  74643. /**
  74644. * Vector3 of the rotation of the output plane.
  74645. */
  74646. outputRotation?: Vector3;
  74647. /**
  74648. * number of layers that the system will reserve in resources.
  74649. */
  74650. layerCount?: number;
  74651. /**
  74652. * number of max animation frames a single cell will reserve in resources.
  74653. */
  74654. maxAnimationFrames?: number;
  74655. /**
  74656. * number cell index of the base tile when the system compiles.
  74657. */
  74658. baseTile?: number;
  74659. /**
  74660. * boolean flip the sprite after its been repositioned by the framing data.
  74661. */
  74662. flipU?: boolean;
  74663. /**
  74664. * Vector3 scalar of the global RGB values of the SpriteMap.
  74665. */
  74666. colorMultiply?: Vector3;
  74667. }
  74668. /**
  74669. * Defines the IDisposable interface in order to be cleanable from resources.
  74670. */
  74671. export interface ISpriteMap extends IDisposable {
  74672. /**
  74673. * String name of the SpriteMap.
  74674. */
  74675. name: string;
  74676. /**
  74677. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74678. */
  74679. atlasJSON: ISpriteJSONAtlas;
  74680. /**
  74681. * Texture of the SpriteMap.
  74682. */
  74683. spriteSheet: Texture;
  74684. /**
  74685. * The parameters to initialize the SpriteMap with.
  74686. */
  74687. options: ISpriteMapOptions;
  74688. }
  74689. /**
  74690. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74691. */
  74692. export class SpriteMap implements ISpriteMap {
  74693. /** The Name of the spriteMap */
  74694. name: string;
  74695. /** The JSON file with the frame and meta data */
  74696. atlasJSON: ISpriteJSONAtlas;
  74697. /** The systems Sprite Sheet Texture */
  74698. spriteSheet: Texture;
  74699. /** Arguments passed with the Constructor */
  74700. options: ISpriteMapOptions;
  74701. /** Public Sprite Storage array, parsed from atlasJSON */
  74702. sprites: Array<ISpriteJSONSprite>;
  74703. /** Returns the Number of Sprites in the System */
  74704. get spriteCount(): number;
  74705. /** Returns the Position of Output Plane*/
  74706. get position(): Vector3;
  74707. /** Returns the Position of Output Plane*/
  74708. set position(v: Vector3);
  74709. /** Returns the Rotation of Output Plane*/
  74710. get rotation(): Vector3;
  74711. /** Returns the Rotation of Output Plane*/
  74712. set rotation(v: Vector3);
  74713. /** Sets the AnimationMap*/
  74714. get animationMap(): RawTexture;
  74715. /** Sets the AnimationMap*/
  74716. set animationMap(v: RawTexture);
  74717. /** Scene that the SpriteMap was created in */
  74718. private _scene;
  74719. /** Texture Buffer of Float32 that holds tile frame data*/
  74720. private _frameMap;
  74721. /** Texture Buffers of Float32 that holds tileMap data*/
  74722. private _tileMaps;
  74723. /** Texture Buffer of Float32 that holds Animation Data*/
  74724. private _animationMap;
  74725. /** Custom ShaderMaterial Central to the System*/
  74726. private _material;
  74727. /** Custom ShaderMaterial Central to the System*/
  74728. private _output;
  74729. /** Systems Time Ticker*/
  74730. private _time;
  74731. /**
  74732. * Creates a new SpriteMap
  74733. * @param name defines the SpriteMaps Name
  74734. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74735. * @param spriteSheet is the Texture that the Sprites are on.
  74736. * @param options a basic deployment configuration
  74737. * @param scene The Scene that the map is deployed on
  74738. */
  74739. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74740. /**
  74741. * Returns tileID location
  74742. * @returns Vector2 the cell position ID
  74743. */
  74744. getTileID(): Vector2;
  74745. /**
  74746. * Gets the UV location of the mouse over the SpriteMap.
  74747. * @returns Vector2 the UV position of the mouse interaction
  74748. */
  74749. getMousePosition(): Vector2;
  74750. /**
  74751. * Creates the "frame" texture Buffer
  74752. * -------------------------------------
  74753. * Structure of frames
  74754. * "filename": "Falling-Water-2.png",
  74755. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74756. * "rotated": true,
  74757. * "trimmed": true,
  74758. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74759. * "sourceSize": {"w":32,"h":32}
  74760. * @returns RawTexture of the frameMap
  74761. */
  74762. private _createFrameBuffer;
  74763. /**
  74764. * Creates the tileMap texture Buffer
  74765. * @param buffer normally and array of numbers, or a false to generate from scratch
  74766. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74767. * @returns RawTexture of the tileMap
  74768. */
  74769. private _createTileBuffer;
  74770. /**
  74771. * Modifies the data of the tileMaps
  74772. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74773. * @param pos is the iVector2 Coordinates of the Tile
  74774. * @param tile The SpriteIndex of the new Tile
  74775. */
  74776. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74777. /**
  74778. * Creates the animationMap texture Buffer
  74779. * @param buffer normally and array of numbers, or a false to generate from scratch
  74780. * @returns RawTexture of the animationMap
  74781. */
  74782. private _createTileAnimationBuffer;
  74783. /**
  74784. * Modifies the data of the animationMap
  74785. * @param cellID is the Index of the Sprite
  74786. * @param _frame is the target Animation frame
  74787. * @param toCell is the Target Index of the next frame of the animation
  74788. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74789. * @param speed is a global scalar of the time variable on the map.
  74790. */
  74791. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74792. /**
  74793. * Exports the .tilemaps file
  74794. */
  74795. saveTileMaps(): void;
  74796. /**
  74797. * Imports the .tilemaps file
  74798. * @param url of the .tilemaps file
  74799. */
  74800. loadTileMaps(url: string): void;
  74801. /**
  74802. * Release associated resources
  74803. */
  74804. dispose(): void;
  74805. }
  74806. }
  74807. declare module "babylonjs/Sprites/spritePackedManager" {
  74808. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74809. import { Scene } from "babylonjs/scene";
  74810. /**
  74811. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74812. * @see http://doc.babylonjs.com/babylon101/sprites
  74813. */
  74814. export class SpritePackedManager extends SpriteManager {
  74815. /** defines the packed manager's name */
  74816. name: string;
  74817. /**
  74818. * Creates a new sprite manager from a packed sprite sheet
  74819. * @param name defines the manager's name
  74820. * @param imgUrl defines the sprite sheet url
  74821. * @param capacity defines the maximum allowed number of sprites
  74822. * @param scene defines the hosting scene
  74823. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74824. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74825. * @param samplingMode defines the smapling mode to use with spritesheet
  74826. * @param fromPacked set to true; do not alter
  74827. */
  74828. constructor(
  74829. /** defines the packed manager's name */
  74830. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74831. }
  74832. }
  74833. declare module "babylonjs/Sprites/index" {
  74834. export * from "babylonjs/Sprites/sprite";
  74835. export * from "babylonjs/Sprites/ISprites";
  74836. export * from "babylonjs/Sprites/spriteManager";
  74837. export * from "babylonjs/Sprites/spriteMap";
  74838. export * from "babylonjs/Sprites/spritePackedManager";
  74839. export * from "babylonjs/Sprites/spriteSceneComponent";
  74840. }
  74841. declare module "babylonjs/States/index" {
  74842. export * from "babylonjs/States/alphaCullingState";
  74843. export * from "babylonjs/States/depthCullingState";
  74844. export * from "babylonjs/States/stencilState";
  74845. }
  74846. declare module "babylonjs/Misc/assetsManager" {
  74847. import { Scene } from "babylonjs/scene";
  74848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74849. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74850. import { Skeleton } from "babylonjs/Bones/skeleton";
  74851. import { Observable } from "babylonjs/Misc/observable";
  74852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74853. import { Texture } from "babylonjs/Materials/Textures/texture";
  74854. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74855. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74856. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74857. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74858. /**
  74859. * Defines the list of states available for a task inside a AssetsManager
  74860. */
  74861. export enum AssetTaskState {
  74862. /**
  74863. * Initialization
  74864. */
  74865. INIT = 0,
  74866. /**
  74867. * Running
  74868. */
  74869. RUNNING = 1,
  74870. /**
  74871. * Done
  74872. */
  74873. DONE = 2,
  74874. /**
  74875. * Error
  74876. */
  74877. ERROR = 3
  74878. }
  74879. /**
  74880. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74881. */
  74882. export abstract class AbstractAssetTask {
  74883. /**
  74884. * Task name
  74885. */ name: string;
  74886. /**
  74887. * Callback called when the task is successful
  74888. */
  74889. onSuccess: (task: any) => void;
  74890. /**
  74891. * Callback called when the task is not successful
  74892. */
  74893. onError: (task: any, message?: string, exception?: any) => void;
  74894. /**
  74895. * Creates a new AssetsManager
  74896. * @param name defines the name of the task
  74897. */
  74898. constructor(
  74899. /**
  74900. * Task name
  74901. */ name: string);
  74902. private _isCompleted;
  74903. private _taskState;
  74904. private _errorObject;
  74905. /**
  74906. * Get if the task is completed
  74907. */
  74908. get isCompleted(): boolean;
  74909. /**
  74910. * Gets the current state of the task
  74911. */
  74912. get taskState(): AssetTaskState;
  74913. /**
  74914. * Gets the current error object (if task is in error)
  74915. */
  74916. get errorObject(): {
  74917. message?: string;
  74918. exception?: any;
  74919. };
  74920. /**
  74921. * Internal only
  74922. * @hidden
  74923. */
  74924. _setErrorObject(message?: string, exception?: any): void;
  74925. /**
  74926. * Execute the current task
  74927. * @param scene defines the scene where you want your assets to be loaded
  74928. * @param onSuccess is a callback called when the task is successfully executed
  74929. * @param onError is a callback called if an error occurs
  74930. */
  74931. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74932. /**
  74933. * Execute the current task
  74934. * @param scene defines the scene where you want your assets to be loaded
  74935. * @param onSuccess is a callback called when the task is successfully executed
  74936. * @param onError is a callback called if an error occurs
  74937. */
  74938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74939. /**
  74940. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74941. * This can be used with failed tasks that have the reason for failure fixed.
  74942. */
  74943. reset(): void;
  74944. private onErrorCallback;
  74945. private onDoneCallback;
  74946. }
  74947. /**
  74948. * Define the interface used by progress events raised during assets loading
  74949. */
  74950. export interface IAssetsProgressEvent {
  74951. /**
  74952. * Defines the number of remaining tasks to process
  74953. */
  74954. remainingCount: number;
  74955. /**
  74956. * Defines the total number of tasks
  74957. */
  74958. totalCount: number;
  74959. /**
  74960. * Defines the task that was just processed
  74961. */
  74962. task: AbstractAssetTask;
  74963. }
  74964. /**
  74965. * Class used to share progress information about assets loading
  74966. */
  74967. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74968. /**
  74969. * Defines the number of remaining tasks to process
  74970. */
  74971. remainingCount: number;
  74972. /**
  74973. * Defines the total number of tasks
  74974. */
  74975. totalCount: number;
  74976. /**
  74977. * Defines the task that was just processed
  74978. */
  74979. task: AbstractAssetTask;
  74980. /**
  74981. * Creates a AssetsProgressEvent
  74982. * @param remainingCount defines the number of remaining tasks to process
  74983. * @param totalCount defines the total number of tasks
  74984. * @param task defines the task that was just processed
  74985. */
  74986. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74987. }
  74988. /**
  74989. * Define a task used by AssetsManager to load meshes
  74990. */
  74991. export class MeshAssetTask extends AbstractAssetTask {
  74992. /**
  74993. * Defines the name of the task
  74994. */
  74995. name: string;
  74996. /**
  74997. * Defines the list of mesh's names you want to load
  74998. */
  74999. meshesNames: any;
  75000. /**
  75001. * Defines the root url to use as a base to load your meshes and associated resources
  75002. */
  75003. rootUrl: string;
  75004. /**
  75005. * Defines the filename or File of the scene to load from
  75006. */
  75007. sceneFilename: string | File;
  75008. /**
  75009. * Gets the list of loaded meshes
  75010. */
  75011. loadedMeshes: Array<AbstractMesh>;
  75012. /**
  75013. * Gets the list of loaded particle systems
  75014. */
  75015. loadedParticleSystems: Array<IParticleSystem>;
  75016. /**
  75017. * Gets the list of loaded skeletons
  75018. */
  75019. loadedSkeletons: Array<Skeleton>;
  75020. /**
  75021. * Gets the list of loaded animation groups
  75022. */
  75023. loadedAnimationGroups: Array<AnimationGroup>;
  75024. /**
  75025. * Callback called when the task is successful
  75026. */
  75027. onSuccess: (task: MeshAssetTask) => void;
  75028. /**
  75029. * Callback called when the task is successful
  75030. */
  75031. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75032. /**
  75033. * Creates a new MeshAssetTask
  75034. * @param name defines the name of the task
  75035. * @param meshesNames defines the list of mesh's names you want to load
  75036. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75037. * @param sceneFilename defines the filename or File of the scene to load from
  75038. */
  75039. constructor(
  75040. /**
  75041. * Defines the name of the task
  75042. */
  75043. name: string,
  75044. /**
  75045. * Defines the list of mesh's names you want to load
  75046. */
  75047. meshesNames: any,
  75048. /**
  75049. * Defines the root url to use as a base to load your meshes and associated resources
  75050. */
  75051. rootUrl: string,
  75052. /**
  75053. * Defines the filename or File of the scene to load from
  75054. */
  75055. sceneFilename: string | File);
  75056. /**
  75057. * Execute the current task
  75058. * @param scene defines the scene where you want your assets to be loaded
  75059. * @param onSuccess is a callback called when the task is successfully executed
  75060. * @param onError is a callback called if an error occurs
  75061. */
  75062. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75063. }
  75064. /**
  75065. * Define a task used by AssetsManager to load text content
  75066. */
  75067. export class TextFileAssetTask extends AbstractAssetTask {
  75068. /**
  75069. * Defines the name of the task
  75070. */
  75071. name: string;
  75072. /**
  75073. * Defines the location of the file to load
  75074. */
  75075. url: string;
  75076. /**
  75077. * Gets the loaded text string
  75078. */
  75079. text: string;
  75080. /**
  75081. * Callback called when the task is successful
  75082. */
  75083. onSuccess: (task: TextFileAssetTask) => void;
  75084. /**
  75085. * Callback called when the task is successful
  75086. */
  75087. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75088. /**
  75089. * Creates a new TextFileAssetTask object
  75090. * @param name defines the name of the task
  75091. * @param url defines the location of the file to load
  75092. */
  75093. constructor(
  75094. /**
  75095. * Defines the name of the task
  75096. */
  75097. name: string,
  75098. /**
  75099. * Defines the location of the file to load
  75100. */
  75101. url: string);
  75102. /**
  75103. * Execute the current task
  75104. * @param scene defines the scene where you want your assets to be loaded
  75105. * @param onSuccess is a callback called when the task is successfully executed
  75106. * @param onError is a callback called if an error occurs
  75107. */
  75108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75109. }
  75110. /**
  75111. * Define a task used by AssetsManager to load binary data
  75112. */
  75113. export class BinaryFileAssetTask extends AbstractAssetTask {
  75114. /**
  75115. * Defines the name of the task
  75116. */
  75117. name: string;
  75118. /**
  75119. * Defines the location of the file to load
  75120. */
  75121. url: string;
  75122. /**
  75123. * Gets the lodaded data (as an array buffer)
  75124. */
  75125. data: ArrayBuffer;
  75126. /**
  75127. * Callback called when the task is successful
  75128. */
  75129. onSuccess: (task: BinaryFileAssetTask) => void;
  75130. /**
  75131. * Callback called when the task is successful
  75132. */
  75133. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75134. /**
  75135. * Creates a new BinaryFileAssetTask object
  75136. * @param name defines the name of the new task
  75137. * @param url defines the location of the file to load
  75138. */
  75139. constructor(
  75140. /**
  75141. * Defines the name of the task
  75142. */
  75143. name: string,
  75144. /**
  75145. * Defines the location of the file to load
  75146. */
  75147. url: string);
  75148. /**
  75149. * Execute the current task
  75150. * @param scene defines the scene where you want your assets to be loaded
  75151. * @param onSuccess is a callback called when the task is successfully executed
  75152. * @param onError is a callback called if an error occurs
  75153. */
  75154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75155. }
  75156. /**
  75157. * Define a task used by AssetsManager to load images
  75158. */
  75159. export class ImageAssetTask extends AbstractAssetTask {
  75160. /**
  75161. * Defines the name of the task
  75162. */
  75163. name: string;
  75164. /**
  75165. * Defines the location of the image to load
  75166. */
  75167. url: string;
  75168. /**
  75169. * Gets the loaded images
  75170. */
  75171. image: HTMLImageElement;
  75172. /**
  75173. * Callback called when the task is successful
  75174. */
  75175. onSuccess: (task: ImageAssetTask) => void;
  75176. /**
  75177. * Callback called when the task is successful
  75178. */
  75179. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75180. /**
  75181. * Creates a new ImageAssetTask
  75182. * @param name defines the name of the task
  75183. * @param url defines the location of the image to load
  75184. */
  75185. constructor(
  75186. /**
  75187. * Defines the name of the task
  75188. */
  75189. name: string,
  75190. /**
  75191. * Defines the location of the image to load
  75192. */
  75193. url: string);
  75194. /**
  75195. * Execute the current task
  75196. * @param scene defines the scene where you want your assets to be loaded
  75197. * @param onSuccess is a callback called when the task is successfully executed
  75198. * @param onError is a callback called if an error occurs
  75199. */
  75200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75201. }
  75202. /**
  75203. * Defines the interface used by texture loading tasks
  75204. */
  75205. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75206. /**
  75207. * Gets the loaded texture
  75208. */
  75209. texture: TEX;
  75210. }
  75211. /**
  75212. * Define a task used by AssetsManager to load 2D textures
  75213. */
  75214. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75215. /**
  75216. * Defines the name of the task
  75217. */
  75218. name: string;
  75219. /**
  75220. * Defines the location of the file to load
  75221. */
  75222. url: string;
  75223. /**
  75224. * Defines if mipmap should not be generated (default is false)
  75225. */
  75226. noMipmap?: boolean | undefined;
  75227. /**
  75228. * Defines if texture must be inverted on Y axis (default is true)
  75229. */
  75230. invertY: boolean;
  75231. /**
  75232. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75233. */
  75234. samplingMode: number;
  75235. /**
  75236. * Gets the loaded texture
  75237. */
  75238. texture: Texture;
  75239. /**
  75240. * Callback called when the task is successful
  75241. */
  75242. onSuccess: (task: TextureAssetTask) => void;
  75243. /**
  75244. * Callback called when the task is successful
  75245. */
  75246. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75247. /**
  75248. * Creates a new TextureAssetTask object
  75249. * @param name defines the name of the task
  75250. * @param url defines the location of the file to load
  75251. * @param noMipmap defines if mipmap should not be generated (default is false)
  75252. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75253. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75254. */
  75255. constructor(
  75256. /**
  75257. * Defines the name of the task
  75258. */
  75259. name: string,
  75260. /**
  75261. * Defines the location of the file to load
  75262. */
  75263. url: string,
  75264. /**
  75265. * Defines if mipmap should not be generated (default is false)
  75266. */
  75267. noMipmap?: boolean | undefined,
  75268. /**
  75269. * Defines if texture must be inverted on Y axis (default is true)
  75270. */
  75271. invertY?: boolean,
  75272. /**
  75273. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75274. */
  75275. samplingMode?: number);
  75276. /**
  75277. * Execute the current task
  75278. * @param scene defines the scene where you want your assets to be loaded
  75279. * @param onSuccess is a callback called when the task is successfully executed
  75280. * @param onError is a callback called if an error occurs
  75281. */
  75282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75283. }
  75284. /**
  75285. * Define a task used by AssetsManager to load cube textures
  75286. */
  75287. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75288. /**
  75289. * Defines the name of the task
  75290. */
  75291. name: string;
  75292. /**
  75293. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75294. */
  75295. url: string;
  75296. /**
  75297. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75298. */
  75299. extensions?: string[] | undefined;
  75300. /**
  75301. * Defines if mipmaps should not be generated (default is false)
  75302. */
  75303. noMipmap?: boolean | undefined;
  75304. /**
  75305. * Defines the explicit list of files (undefined by default)
  75306. */
  75307. files?: string[] | undefined;
  75308. /**
  75309. * Gets the loaded texture
  75310. */
  75311. texture: CubeTexture;
  75312. /**
  75313. * Callback called when the task is successful
  75314. */
  75315. onSuccess: (task: CubeTextureAssetTask) => void;
  75316. /**
  75317. * Callback called when the task is successful
  75318. */
  75319. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75320. /**
  75321. * Creates a new CubeTextureAssetTask
  75322. * @param name defines the name of the task
  75323. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75324. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75325. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75326. * @param files defines the explicit list of files (undefined by default)
  75327. */
  75328. constructor(
  75329. /**
  75330. * Defines the name of the task
  75331. */
  75332. name: string,
  75333. /**
  75334. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75335. */
  75336. url: string,
  75337. /**
  75338. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75339. */
  75340. extensions?: string[] | undefined,
  75341. /**
  75342. * Defines if mipmaps should not be generated (default is false)
  75343. */
  75344. noMipmap?: boolean | undefined,
  75345. /**
  75346. * Defines the explicit list of files (undefined by default)
  75347. */
  75348. files?: string[] | undefined);
  75349. /**
  75350. * Execute the current task
  75351. * @param scene defines the scene where you want your assets to be loaded
  75352. * @param onSuccess is a callback called when the task is successfully executed
  75353. * @param onError is a callback called if an error occurs
  75354. */
  75355. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75356. }
  75357. /**
  75358. * Define a task used by AssetsManager to load HDR cube textures
  75359. */
  75360. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75361. /**
  75362. * Defines the name of the task
  75363. */
  75364. name: string;
  75365. /**
  75366. * Defines the location of the file to load
  75367. */
  75368. url: string;
  75369. /**
  75370. * Defines the desired size (the more it increases the longer the generation will be)
  75371. */
  75372. size: number;
  75373. /**
  75374. * Defines if mipmaps should not be generated (default is false)
  75375. */
  75376. noMipmap: boolean;
  75377. /**
  75378. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75379. */
  75380. generateHarmonics: boolean;
  75381. /**
  75382. * 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)
  75383. */
  75384. gammaSpace: boolean;
  75385. /**
  75386. * Internal Use Only
  75387. */
  75388. reserved: boolean;
  75389. /**
  75390. * Gets the loaded texture
  75391. */
  75392. texture: HDRCubeTexture;
  75393. /**
  75394. * Callback called when the task is successful
  75395. */
  75396. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75397. /**
  75398. * Callback called when the task is successful
  75399. */
  75400. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75401. /**
  75402. * Creates a new HDRCubeTextureAssetTask object
  75403. * @param name defines the name of the task
  75404. * @param url defines the location of the file to load
  75405. * @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.
  75406. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75407. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75408. * @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)
  75409. * @param reserved Internal use only
  75410. */
  75411. constructor(
  75412. /**
  75413. * Defines the name of the task
  75414. */
  75415. name: string,
  75416. /**
  75417. * Defines the location of the file to load
  75418. */
  75419. url: string,
  75420. /**
  75421. * Defines the desired size (the more it increases the longer the generation will be)
  75422. */
  75423. size: number,
  75424. /**
  75425. * Defines if mipmaps should not be generated (default is false)
  75426. */
  75427. noMipmap?: boolean,
  75428. /**
  75429. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75430. */
  75431. generateHarmonics?: boolean,
  75432. /**
  75433. * 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)
  75434. */
  75435. gammaSpace?: boolean,
  75436. /**
  75437. * Internal Use Only
  75438. */
  75439. reserved?: boolean);
  75440. /**
  75441. * Execute the current task
  75442. * @param scene defines the scene where you want your assets to be loaded
  75443. * @param onSuccess is a callback called when the task is successfully executed
  75444. * @param onError is a callback called if an error occurs
  75445. */
  75446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75447. }
  75448. /**
  75449. * Define a task used by AssetsManager to load Equirectangular cube textures
  75450. */
  75451. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75452. /**
  75453. * Defines the name of the task
  75454. */
  75455. name: string;
  75456. /**
  75457. * Defines the location of the file to load
  75458. */
  75459. url: string;
  75460. /**
  75461. * Defines the desired size (the more it increases the longer the generation will be)
  75462. */
  75463. size: number;
  75464. /**
  75465. * Defines if mipmaps should not be generated (default is false)
  75466. */
  75467. noMipmap: boolean;
  75468. /**
  75469. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75470. * but the standard material would require them in Gamma space) (default is true)
  75471. */
  75472. gammaSpace: boolean;
  75473. /**
  75474. * Gets the loaded texture
  75475. */
  75476. texture: EquiRectangularCubeTexture;
  75477. /**
  75478. * Callback called when the task is successful
  75479. */
  75480. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75481. /**
  75482. * Callback called when the task is successful
  75483. */
  75484. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75485. /**
  75486. * Creates a new EquiRectangularCubeTextureAssetTask object
  75487. * @param name defines the name of the task
  75488. * @param url defines the location of the file to load
  75489. * @param size defines the desired size (the more it increases the longer the generation will be)
  75490. * If the size is omitted this implies you are using a preprocessed cubemap.
  75491. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75492. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75493. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75494. * (default is true)
  75495. */
  75496. constructor(
  75497. /**
  75498. * Defines the name of the task
  75499. */
  75500. name: string,
  75501. /**
  75502. * Defines the location of the file to load
  75503. */
  75504. url: string,
  75505. /**
  75506. * Defines the desired size (the more it increases the longer the generation will be)
  75507. */
  75508. size: number,
  75509. /**
  75510. * Defines if mipmaps should not be generated (default is false)
  75511. */
  75512. noMipmap?: boolean,
  75513. /**
  75514. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75515. * but the standard material would require them in Gamma space) (default is true)
  75516. */
  75517. gammaSpace?: boolean);
  75518. /**
  75519. * Execute the current task
  75520. * @param scene defines the scene where you want your assets to be loaded
  75521. * @param onSuccess is a callback called when the task is successfully executed
  75522. * @param onError is a callback called if an error occurs
  75523. */
  75524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75525. }
  75526. /**
  75527. * This class can be used to easily import assets into a scene
  75528. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75529. */
  75530. export class AssetsManager {
  75531. private _scene;
  75532. private _isLoading;
  75533. protected _tasks: AbstractAssetTask[];
  75534. protected _waitingTasksCount: number;
  75535. protected _totalTasksCount: number;
  75536. /**
  75537. * Callback called when all tasks are processed
  75538. */
  75539. onFinish: (tasks: AbstractAssetTask[]) => void;
  75540. /**
  75541. * Callback called when a task is successful
  75542. */
  75543. onTaskSuccess: (task: AbstractAssetTask) => void;
  75544. /**
  75545. * Callback called when a task had an error
  75546. */
  75547. onTaskError: (task: AbstractAssetTask) => void;
  75548. /**
  75549. * Callback called when a task is done (whatever the result is)
  75550. */
  75551. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75552. /**
  75553. * Observable called when all tasks are processed
  75554. */
  75555. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75556. /**
  75557. * Observable called when a task had an error
  75558. */
  75559. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75560. /**
  75561. * Observable called when all tasks were executed
  75562. */
  75563. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75564. /**
  75565. * Observable called when a task is done (whatever the result is)
  75566. */
  75567. onProgressObservable: Observable<IAssetsProgressEvent>;
  75568. /**
  75569. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75571. */
  75572. useDefaultLoadingScreen: boolean;
  75573. /**
  75574. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75575. * when all assets have been downloaded.
  75576. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75577. */
  75578. autoHideLoadingUI: boolean;
  75579. /**
  75580. * Creates a new AssetsManager
  75581. * @param scene defines the scene to work on
  75582. */
  75583. constructor(scene: Scene);
  75584. /**
  75585. * Add a MeshAssetTask to the list of active tasks
  75586. * @param taskName defines the name of the new task
  75587. * @param meshesNames defines the name of meshes to load
  75588. * @param rootUrl defines the root url to use to locate files
  75589. * @param sceneFilename defines the filename of the scene file
  75590. * @returns a new MeshAssetTask object
  75591. */
  75592. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75593. /**
  75594. * Add a TextFileAssetTask to the list of active tasks
  75595. * @param taskName defines the name of the new task
  75596. * @param url defines the url of the file to load
  75597. * @returns a new TextFileAssetTask object
  75598. */
  75599. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75600. /**
  75601. * Add a BinaryFileAssetTask to the list of active tasks
  75602. * @param taskName defines the name of the new task
  75603. * @param url defines the url of the file to load
  75604. * @returns a new BinaryFileAssetTask object
  75605. */
  75606. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75607. /**
  75608. * Add a ImageAssetTask to the list of active tasks
  75609. * @param taskName defines the name of the new task
  75610. * @param url defines the url of the file to load
  75611. * @returns a new ImageAssetTask object
  75612. */
  75613. addImageTask(taskName: string, url: string): ImageAssetTask;
  75614. /**
  75615. * Add a TextureAssetTask to the list of active tasks
  75616. * @param taskName defines the name of the new task
  75617. * @param url defines the url of the file to load
  75618. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75619. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75620. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75621. * @returns a new TextureAssetTask object
  75622. */
  75623. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75624. /**
  75625. * Add a CubeTextureAssetTask to the list of active tasks
  75626. * @param taskName defines the name of the new task
  75627. * @param url defines the url of the file to load
  75628. * @param extensions defines the extension to use to load the cube map (can be null)
  75629. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75630. * @param files defines the list of files to load (can be null)
  75631. * @returns a new CubeTextureAssetTask object
  75632. */
  75633. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75634. /**
  75635. *
  75636. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75637. * @param taskName defines the name of the new task
  75638. * @param url defines the url of the file to load
  75639. * @param size defines the size you want for the cubemap (can be null)
  75640. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75641. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75642. * @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)
  75643. * @param reserved Internal use only
  75644. * @returns a new HDRCubeTextureAssetTask object
  75645. */
  75646. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75647. /**
  75648. *
  75649. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75650. * @param taskName defines the name of the new task
  75651. * @param url defines the url of the file to load
  75652. * @param size defines the size you want for the cubemap (can be null)
  75653. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75654. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75655. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75656. * @returns a new EquiRectangularCubeTextureAssetTask object
  75657. */
  75658. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75659. /**
  75660. * Remove a task from the assets manager.
  75661. * @param task the task to remove
  75662. */
  75663. removeTask(task: AbstractAssetTask): void;
  75664. private _decreaseWaitingTasksCount;
  75665. private _runTask;
  75666. /**
  75667. * Reset the AssetsManager and remove all tasks
  75668. * @return the current instance of the AssetsManager
  75669. */
  75670. reset(): AssetsManager;
  75671. /**
  75672. * Start the loading process
  75673. * @return the current instance of the AssetsManager
  75674. */
  75675. load(): AssetsManager;
  75676. /**
  75677. * Start the loading process as an async operation
  75678. * @return a promise returning the list of failed tasks
  75679. */
  75680. loadAsync(): Promise<void>;
  75681. }
  75682. }
  75683. declare module "babylonjs/Misc/deferred" {
  75684. /**
  75685. * Wrapper class for promise with external resolve and reject.
  75686. */
  75687. export class Deferred<T> {
  75688. /**
  75689. * The promise associated with this deferred object.
  75690. */
  75691. readonly promise: Promise<T>;
  75692. private _resolve;
  75693. private _reject;
  75694. /**
  75695. * The resolve method of the promise associated with this deferred object.
  75696. */
  75697. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75698. /**
  75699. * The reject method of the promise associated with this deferred object.
  75700. */
  75701. get reject(): (reason?: any) => void;
  75702. /**
  75703. * Constructor for this deferred object.
  75704. */
  75705. constructor();
  75706. }
  75707. }
  75708. declare module "babylonjs/Misc/meshExploder" {
  75709. import { Mesh } from "babylonjs/Meshes/mesh";
  75710. /**
  75711. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75712. */
  75713. export class MeshExploder {
  75714. private _centerMesh;
  75715. private _meshes;
  75716. private _meshesOrigins;
  75717. private _toCenterVectors;
  75718. private _scaledDirection;
  75719. private _newPosition;
  75720. private _centerPosition;
  75721. /**
  75722. * Explodes meshes from a center mesh.
  75723. * @param meshes The meshes to explode.
  75724. * @param centerMesh The mesh to be center of explosion.
  75725. */
  75726. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75727. private _setCenterMesh;
  75728. /**
  75729. * Get class name
  75730. * @returns "MeshExploder"
  75731. */
  75732. getClassName(): string;
  75733. /**
  75734. * "Exploded meshes"
  75735. * @returns Array of meshes with the centerMesh at index 0.
  75736. */
  75737. getMeshes(): Array<Mesh>;
  75738. /**
  75739. * Explodes meshes giving a specific direction
  75740. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75741. */
  75742. explode(direction?: number): void;
  75743. }
  75744. }
  75745. declare module "babylonjs/Misc/filesInput" {
  75746. import { Engine } from "babylonjs/Engines/engine";
  75747. import { Scene } from "babylonjs/scene";
  75748. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75749. /**
  75750. * Class used to help managing file picking and drag'n'drop
  75751. */
  75752. export class FilesInput {
  75753. /**
  75754. * List of files ready to be loaded
  75755. */
  75756. static get FilesToLoad(): {
  75757. [key: string]: File;
  75758. };
  75759. /**
  75760. * Callback called when a file is processed
  75761. */
  75762. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75763. private _engine;
  75764. private _currentScene;
  75765. private _sceneLoadedCallback;
  75766. private _progressCallback;
  75767. private _additionalRenderLoopLogicCallback;
  75768. private _textureLoadingCallback;
  75769. private _startingProcessingFilesCallback;
  75770. private _onReloadCallback;
  75771. private _errorCallback;
  75772. private _elementToMonitor;
  75773. private _sceneFileToLoad;
  75774. private _filesToLoad;
  75775. /**
  75776. * Creates a new FilesInput
  75777. * @param engine defines the rendering engine
  75778. * @param scene defines the hosting scene
  75779. * @param sceneLoadedCallback callback called when scene is loaded
  75780. * @param progressCallback callback called to track progress
  75781. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75782. * @param textureLoadingCallback callback called when a texture is loading
  75783. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75784. * @param onReloadCallback callback called when a reload is requested
  75785. * @param errorCallback callback call if an error occurs
  75786. */
  75787. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  75788. private _dragEnterHandler;
  75789. private _dragOverHandler;
  75790. private _dropHandler;
  75791. /**
  75792. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75793. * @param elementToMonitor defines the DOM element to track
  75794. */
  75795. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75796. /**
  75797. * Release all associated resources
  75798. */
  75799. dispose(): void;
  75800. private renderFunction;
  75801. private drag;
  75802. private drop;
  75803. private _traverseFolder;
  75804. private _processFiles;
  75805. /**
  75806. * Load files from a drop event
  75807. * @param event defines the drop event to use as source
  75808. */
  75809. loadFiles(event: any): void;
  75810. private _processReload;
  75811. /**
  75812. * Reload the current scene from the loaded files
  75813. */
  75814. reload(): void;
  75815. }
  75816. }
  75817. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75818. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75819. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75820. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75821. }
  75822. declare module "babylonjs/Misc/sceneOptimizer" {
  75823. import { Scene, IDisposable } from "babylonjs/scene";
  75824. import { Observable } from "babylonjs/Misc/observable";
  75825. /**
  75826. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75828. */
  75829. export class SceneOptimization {
  75830. /**
  75831. * Defines the priority of this optimization (0 by default which means first in the list)
  75832. */
  75833. priority: number;
  75834. /**
  75835. * Gets a string describing the action executed by the current optimization
  75836. * @returns description string
  75837. */
  75838. getDescription(): string;
  75839. /**
  75840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75841. * @param scene defines the current scene where to apply this optimization
  75842. * @param optimizer defines the current optimizer
  75843. * @returns true if everything that can be done was applied
  75844. */
  75845. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75846. /**
  75847. * Creates the SceneOptimization object
  75848. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75849. * @param desc defines the description associated with the optimization
  75850. */
  75851. constructor(
  75852. /**
  75853. * Defines the priority of this optimization (0 by default which means first in the list)
  75854. */
  75855. priority?: number);
  75856. }
  75857. /**
  75858. * Defines an optimization used to reduce the size of render target textures
  75859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75860. */
  75861. export class TextureOptimization extends SceneOptimization {
  75862. /**
  75863. * Defines the priority of this optimization (0 by default which means first in the list)
  75864. */
  75865. priority: number;
  75866. /**
  75867. * 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
  75868. */
  75869. maximumSize: number;
  75870. /**
  75871. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75872. */
  75873. step: number;
  75874. /**
  75875. * Gets a string describing the action executed by the current optimization
  75876. * @returns description string
  75877. */
  75878. getDescription(): string;
  75879. /**
  75880. * Creates the TextureOptimization object
  75881. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75882. * @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
  75883. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75884. */
  75885. constructor(
  75886. /**
  75887. * Defines the priority of this optimization (0 by default which means first in the list)
  75888. */
  75889. priority?: number,
  75890. /**
  75891. * 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
  75892. */
  75893. maximumSize?: number,
  75894. /**
  75895. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75896. */
  75897. step?: number);
  75898. /**
  75899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75900. * @param scene defines the current scene where to apply this optimization
  75901. * @param optimizer defines the current optimizer
  75902. * @returns true if everything that can be done was applied
  75903. */
  75904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75905. }
  75906. /**
  75907. * Defines an optimization used to increase or decrease the rendering resolution
  75908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75909. */
  75910. export class HardwareScalingOptimization extends SceneOptimization {
  75911. /**
  75912. * Defines the priority of this optimization (0 by default which means first in the list)
  75913. */
  75914. priority: number;
  75915. /**
  75916. * Defines the maximum scale to use (2 by default)
  75917. */
  75918. maximumScale: number;
  75919. /**
  75920. * Defines the step to use between two passes (0.5 by default)
  75921. */
  75922. step: number;
  75923. private _currentScale;
  75924. private _directionOffset;
  75925. /**
  75926. * Gets a string describing the action executed by the current optimization
  75927. * @return description string
  75928. */
  75929. getDescription(): string;
  75930. /**
  75931. * Creates the HardwareScalingOptimization object
  75932. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75933. * @param maximumScale defines the maximum scale to use (2 by default)
  75934. * @param step defines the step to use between two passes (0.5 by default)
  75935. */
  75936. constructor(
  75937. /**
  75938. * Defines the priority of this optimization (0 by default which means first in the list)
  75939. */
  75940. priority?: number,
  75941. /**
  75942. * Defines the maximum scale to use (2 by default)
  75943. */
  75944. maximumScale?: number,
  75945. /**
  75946. * Defines the step to use between two passes (0.5 by default)
  75947. */
  75948. step?: number);
  75949. /**
  75950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75951. * @param scene defines the current scene where to apply this optimization
  75952. * @param optimizer defines the current optimizer
  75953. * @returns true if everything that can be done was applied
  75954. */
  75955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75956. }
  75957. /**
  75958. * Defines an optimization used to remove shadows
  75959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75960. */
  75961. export class ShadowsOptimization extends SceneOptimization {
  75962. /**
  75963. * Gets a string describing the action executed by the current optimization
  75964. * @return description string
  75965. */
  75966. getDescription(): string;
  75967. /**
  75968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75969. * @param scene defines the current scene where to apply this optimization
  75970. * @param optimizer defines the current optimizer
  75971. * @returns true if everything that can be done was applied
  75972. */
  75973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75974. }
  75975. /**
  75976. * Defines an optimization used to turn post-processes off
  75977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75978. */
  75979. export class PostProcessesOptimization extends SceneOptimization {
  75980. /**
  75981. * Gets a string describing the action executed by the current optimization
  75982. * @return description string
  75983. */
  75984. getDescription(): string;
  75985. /**
  75986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75987. * @param scene defines the current scene where to apply this optimization
  75988. * @param optimizer defines the current optimizer
  75989. * @returns true if everything that can be done was applied
  75990. */
  75991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75992. }
  75993. /**
  75994. * Defines an optimization used to turn lens flares off
  75995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75996. */
  75997. export class LensFlaresOptimization extends SceneOptimization {
  75998. /**
  75999. * Gets a string describing the action executed by the current optimization
  76000. * @return description string
  76001. */
  76002. getDescription(): string;
  76003. /**
  76004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76005. * @param scene defines the current scene where to apply this optimization
  76006. * @param optimizer defines the current optimizer
  76007. * @returns true if everything that can be done was applied
  76008. */
  76009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76010. }
  76011. /**
  76012. * Defines an optimization based on user defined callback.
  76013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76014. */
  76015. export class CustomOptimization extends SceneOptimization {
  76016. /**
  76017. * Callback called to apply the custom optimization.
  76018. */
  76019. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76020. /**
  76021. * Callback called to get custom description
  76022. */
  76023. onGetDescription: () => string;
  76024. /**
  76025. * Gets a string describing the action executed by the current optimization
  76026. * @returns description string
  76027. */
  76028. getDescription(): string;
  76029. /**
  76030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76031. * @param scene defines the current scene where to apply this optimization
  76032. * @param optimizer defines the current optimizer
  76033. * @returns true if everything that can be done was applied
  76034. */
  76035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76036. }
  76037. /**
  76038. * Defines an optimization used to turn particles off
  76039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76040. */
  76041. export class ParticlesOptimization extends SceneOptimization {
  76042. /**
  76043. * Gets a string describing the action executed by the current optimization
  76044. * @return description string
  76045. */
  76046. getDescription(): string;
  76047. /**
  76048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76049. * @param scene defines the current scene where to apply this optimization
  76050. * @param optimizer defines the current optimizer
  76051. * @returns true if everything that can be done was applied
  76052. */
  76053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76054. }
  76055. /**
  76056. * Defines an optimization used to turn render targets off
  76057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76058. */
  76059. export class RenderTargetsOptimization extends SceneOptimization {
  76060. /**
  76061. * Gets a string describing the action executed by the current optimization
  76062. * @return description string
  76063. */
  76064. getDescription(): string;
  76065. /**
  76066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76067. * @param scene defines the current scene where to apply this optimization
  76068. * @param optimizer defines the current optimizer
  76069. * @returns true if everything that can be done was applied
  76070. */
  76071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76072. }
  76073. /**
  76074. * Defines an optimization used to merge meshes with compatible materials
  76075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76076. */
  76077. export class MergeMeshesOptimization extends SceneOptimization {
  76078. private static _UpdateSelectionTree;
  76079. /**
  76080. * Gets or sets a boolean which defines if optimization octree has to be updated
  76081. */
  76082. static get UpdateSelectionTree(): boolean;
  76083. /**
  76084. * Gets or sets a boolean which defines if optimization octree has to be updated
  76085. */
  76086. static set UpdateSelectionTree(value: boolean);
  76087. /**
  76088. * Gets a string describing the action executed by the current optimization
  76089. * @return description string
  76090. */
  76091. getDescription(): string;
  76092. private _canBeMerged;
  76093. /**
  76094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76095. * @param scene defines the current scene where to apply this optimization
  76096. * @param optimizer defines the current optimizer
  76097. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76098. * @returns true if everything that can be done was applied
  76099. */
  76100. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76101. }
  76102. /**
  76103. * Defines a list of options used by SceneOptimizer
  76104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76105. */
  76106. export class SceneOptimizerOptions {
  76107. /**
  76108. * Defines the target frame rate to reach (60 by default)
  76109. */
  76110. targetFrameRate: number;
  76111. /**
  76112. * Defines the interval between two checkes (2000ms by default)
  76113. */
  76114. trackerDuration: number;
  76115. /**
  76116. * Gets the list of optimizations to apply
  76117. */
  76118. optimizations: SceneOptimization[];
  76119. /**
  76120. * Creates a new list of options used by SceneOptimizer
  76121. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76122. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76123. */
  76124. constructor(
  76125. /**
  76126. * Defines the target frame rate to reach (60 by default)
  76127. */
  76128. targetFrameRate?: number,
  76129. /**
  76130. * Defines the interval between two checkes (2000ms by default)
  76131. */
  76132. trackerDuration?: number);
  76133. /**
  76134. * Add a new optimization
  76135. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76136. * @returns the current SceneOptimizerOptions
  76137. */
  76138. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76139. /**
  76140. * Add a new custom optimization
  76141. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76142. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76143. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76144. * @returns the current SceneOptimizerOptions
  76145. */
  76146. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76147. /**
  76148. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76149. * @param targetFrameRate defines the target frame rate (60 by default)
  76150. * @returns a SceneOptimizerOptions object
  76151. */
  76152. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76153. /**
  76154. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76155. * @param targetFrameRate defines the target frame rate (60 by default)
  76156. * @returns a SceneOptimizerOptions object
  76157. */
  76158. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76159. /**
  76160. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76161. * @param targetFrameRate defines the target frame rate (60 by default)
  76162. * @returns a SceneOptimizerOptions object
  76163. */
  76164. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76165. }
  76166. /**
  76167. * Class used to run optimizations in order to reach a target frame rate
  76168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76169. */
  76170. export class SceneOptimizer implements IDisposable {
  76171. private _isRunning;
  76172. private _options;
  76173. private _scene;
  76174. private _currentPriorityLevel;
  76175. private _targetFrameRate;
  76176. private _trackerDuration;
  76177. private _currentFrameRate;
  76178. private _sceneDisposeObserver;
  76179. private _improvementMode;
  76180. /**
  76181. * Defines an observable called when the optimizer reaches the target frame rate
  76182. */
  76183. onSuccessObservable: Observable<SceneOptimizer>;
  76184. /**
  76185. * Defines an observable called when the optimizer enables an optimization
  76186. */
  76187. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76188. /**
  76189. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76190. */
  76191. onFailureObservable: Observable<SceneOptimizer>;
  76192. /**
  76193. * Gets a boolean indicating if the optimizer is in improvement mode
  76194. */
  76195. get isInImprovementMode(): boolean;
  76196. /**
  76197. * Gets the current priority level (0 at start)
  76198. */
  76199. get currentPriorityLevel(): number;
  76200. /**
  76201. * Gets the current frame rate checked by the SceneOptimizer
  76202. */
  76203. get currentFrameRate(): number;
  76204. /**
  76205. * Gets or sets the current target frame rate (60 by default)
  76206. */
  76207. get targetFrameRate(): number;
  76208. /**
  76209. * Gets or sets the current target frame rate (60 by default)
  76210. */
  76211. set targetFrameRate(value: number);
  76212. /**
  76213. * Gets or sets the current interval between two checks (every 2000ms by default)
  76214. */
  76215. get trackerDuration(): number;
  76216. /**
  76217. * Gets or sets the current interval between two checks (every 2000ms by default)
  76218. */
  76219. set trackerDuration(value: number);
  76220. /**
  76221. * Gets the list of active optimizations
  76222. */
  76223. get optimizations(): SceneOptimization[];
  76224. /**
  76225. * Creates a new SceneOptimizer
  76226. * @param scene defines the scene to work on
  76227. * @param options defines the options to use with the SceneOptimizer
  76228. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76229. * @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)
  76230. */
  76231. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76232. /**
  76233. * Stops the current optimizer
  76234. */
  76235. stop(): void;
  76236. /**
  76237. * Reset the optimizer to initial step (current priority level = 0)
  76238. */
  76239. reset(): void;
  76240. /**
  76241. * Start the optimizer. By default it will try to reach a specific framerate
  76242. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76243. */
  76244. start(): void;
  76245. private _checkCurrentState;
  76246. /**
  76247. * Release all resources
  76248. */
  76249. dispose(): void;
  76250. /**
  76251. * Helper function to create a SceneOptimizer with one single line of code
  76252. * @param scene defines the scene to work on
  76253. * @param options defines the options to use with the SceneOptimizer
  76254. * @param onSuccess defines a callback to call on success
  76255. * @param onFailure defines a callback to call on failure
  76256. * @returns the new SceneOptimizer object
  76257. */
  76258. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76259. }
  76260. }
  76261. declare module "babylonjs/Misc/sceneSerializer" {
  76262. import { Scene } from "babylonjs/scene";
  76263. /**
  76264. * Class used to serialize a scene into a string
  76265. */
  76266. export class SceneSerializer {
  76267. /**
  76268. * Clear cache used by a previous serialization
  76269. */
  76270. static ClearCache(): void;
  76271. /**
  76272. * Serialize a scene into a JSON compatible object
  76273. * @param scene defines the scene to serialize
  76274. * @returns a JSON compatible object
  76275. */
  76276. static Serialize(scene: Scene): any;
  76277. /**
  76278. * Serialize a mesh into a JSON compatible object
  76279. * @param toSerialize defines the mesh to serialize
  76280. * @param withParents defines if parents must be serialized as well
  76281. * @param withChildren defines if children must be serialized as well
  76282. * @returns a JSON compatible object
  76283. */
  76284. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76285. }
  76286. }
  76287. declare module "babylonjs/Misc/textureTools" {
  76288. import { Texture } from "babylonjs/Materials/Textures/texture";
  76289. /**
  76290. * Class used to host texture specific utilities
  76291. */
  76292. export class TextureTools {
  76293. /**
  76294. * Uses the GPU to create a copy texture rescaled at a given size
  76295. * @param texture Texture to copy from
  76296. * @param width defines the desired width
  76297. * @param height defines the desired height
  76298. * @param useBilinearMode defines if bilinear mode has to be used
  76299. * @return the generated texture
  76300. */
  76301. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76302. }
  76303. }
  76304. declare module "babylonjs/Misc/videoRecorder" {
  76305. import { Nullable } from "babylonjs/types";
  76306. import { Engine } from "babylonjs/Engines/engine";
  76307. /**
  76308. * This represents the different options available for the video capture.
  76309. */
  76310. export interface VideoRecorderOptions {
  76311. /** Defines the mime type of the video. */
  76312. mimeType: string;
  76313. /** Defines the FPS the video should be recorded at. */
  76314. fps: number;
  76315. /** Defines the chunk size for the recording data. */
  76316. recordChunckSize: number;
  76317. /** The audio tracks to attach to the recording. */
  76318. audioTracks?: MediaStreamTrack[];
  76319. }
  76320. /**
  76321. * This can help with recording videos from BabylonJS.
  76322. * This is based on the available WebRTC functionalities of the browser.
  76323. *
  76324. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76325. */
  76326. export class VideoRecorder {
  76327. private static readonly _defaultOptions;
  76328. /**
  76329. * Returns whether or not the VideoRecorder is available in your browser.
  76330. * @param engine Defines the Babylon Engine.
  76331. * @returns true if supported otherwise false.
  76332. */
  76333. static IsSupported(engine: Engine): boolean;
  76334. private readonly _options;
  76335. private _canvas;
  76336. private _mediaRecorder;
  76337. private _recordedChunks;
  76338. private _fileName;
  76339. private _resolve;
  76340. private _reject;
  76341. /**
  76342. * True when a recording is already in progress.
  76343. */
  76344. get isRecording(): boolean;
  76345. /**
  76346. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76347. * @param engine Defines the BabylonJS Engine you wish to record.
  76348. * @param options Defines options that can be used to customize the capture.
  76349. */
  76350. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76351. /**
  76352. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76353. */
  76354. stopRecording(): void;
  76355. /**
  76356. * Starts recording the canvas for a max duration specified in parameters.
  76357. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76358. * If null no automatic download will start and you can rely on the promise to get the data back.
  76359. * @param maxDuration Defines the maximum recording time in seconds.
  76360. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76361. * @return A promise callback at the end of the recording with the video data in Blob.
  76362. */
  76363. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76364. /**
  76365. * Releases internal resources used during the recording.
  76366. */
  76367. dispose(): void;
  76368. private _handleDataAvailable;
  76369. private _handleError;
  76370. private _handleStop;
  76371. }
  76372. }
  76373. declare module "babylonjs/Misc/screenshotTools" {
  76374. import { Camera } from "babylonjs/Cameras/camera";
  76375. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76376. import { Engine } from "babylonjs/Engines/engine";
  76377. /**
  76378. * Class containing a set of static utilities functions for screenshots
  76379. */
  76380. export class ScreenshotTools {
  76381. /**
  76382. * Captures a screenshot of the current rendering
  76383. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76384. * @param engine defines the rendering engine
  76385. * @param camera defines the source camera
  76386. * @param size This parameter can be set to a single number or to an object with the
  76387. * following (optional) properties: precision, width, height. If a single number is passed,
  76388. * it will be used for both width and height. If an object is passed, the screenshot size
  76389. * will be derived from the parameters. The precision property is a multiplier allowing
  76390. * rendering at a higher or lower resolution
  76391. * @param successCallback defines the callback receives a single parameter which contains the
  76392. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76393. * src parameter of an <img> to display it
  76394. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76395. * Check your browser for supported MIME types
  76396. */
  76397. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76398. /**
  76399. * Captures a screenshot of the current rendering
  76400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76401. * @param engine defines the rendering engine
  76402. * @param camera defines the source camera
  76403. * @param size This parameter can be set to a single number or to an object with the
  76404. * following (optional) properties: precision, width, height. If a single number is passed,
  76405. * it will be used for both width and height. If an object is passed, the screenshot size
  76406. * will be derived from the parameters. The precision property is a multiplier allowing
  76407. * rendering at a higher or lower resolution
  76408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76409. * Check your browser for supported MIME types
  76410. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76411. * to the src parameter of an <img> to display it
  76412. */
  76413. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76414. /**
  76415. * Generates an image screenshot from the specified camera.
  76416. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76417. * @param engine The engine to use for rendering
  76418. * @param camera The camera to use for rendering
  76419. * @param size This parameter can be set to a single number or to an object with the
  76420. * following (optional) properties: precision, width, height. If a single number is passed,
  76421. * it will be used for both width and height. If an object is passed, the screenshot size
  76422. * will be derived from the parameters. The precision property is a multiplier allowing
  76423. * rendering at a higher or lower resolution
  76424. * @param successCallback The callback receives a single parameter which contains the
  76425. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76426. * src parameter of an <img> to display it
  76427. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76428. * Check your browser for supported MIME types
  76429. * @param samples Texture samples (default: 1)
  76430. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76431. * @param fileName A name for for the downloaded file.
  76432. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76433. */
  76434. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76435. /**
  76436. * Generates an image screenshot from the specified camera.
  76437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76438. * @param engine The engine to use for rendering
  76439. * @param camera The camera to use for rendering
  76440. * @param size This parameter can be set to a single number or to an object with the
  76441. * following (optional) properties: precision, width, height. If a single number is passed,
  76442. * it will be used for both width and height. If an object is passed, the screenshot size
  76443. * will be derived from the parameters. The precision property is a multiplier allowing
  76444. * rendering at a higher or lower resolution
  76445. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76446. * Check your browser for supported MIME types
  76447. * @param samples Texture samples (default: 1)
  76448. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76449. * @param fileName A name for for the downloaded file.
  76450. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76451. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76452. * to the src parameter of an <img> to display it
  76453. */
  76454. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76455. /**
  76456. * Gets height and width for screenshot size
  76457. * @private
  76458. */
  76459. private static _getScreenshotSize;
  76460. }
  76461. }
  76462. declare module "babylonjs/Misc/dataReader" {
  76463. /**
  76464. * Interface for a data buffer
  76465. */
  76466. export interface IDataBuffer {
  76467. /**
  76468. * Reads bytes from the data buffer.
  76469. * @param byteOffset The byte offset to read
  76470. * @param byteLength The byte length to read
  76471. * @returns A promise that resolves when the bytes are read
  76472. */
  76473. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76474. /**
  76475. * The byte length of the buffer.
  76476. */
  76477. readonly byteLength: number;
  76478. }
  76479. /**
  76480. * Utility class for reading from a data buffer
  76481. */
  76482. export class DataReader {
  76483. /**
  76484. * The data buffer associated with this data reader.
  76485. */
  76486. readonly buffer: IDataBuffer;
  76487. /**
  76488. * The current byte offset from the beginning of the data buffer.
  76489. */
  76490. byteOffset: number;
  76491. private _dataView;
  76492. private _dataByteOffset;
  76493. /**
  76494. * Constructor
  76495. * @param buffer The buffer to read
  76496. */
  76497. constructor(buffer: IDataBuffer);
  76498. /**
  76499. * Loads the given byte length.
  76500. * @param byteLength The byte length to load
  76501. * @returns A promise that resolves when the load is complete
  76502. */
  76503. loadAsync(byteLength: number): Promise<void>;
  76504. /**
  76505. * Read a unsigned 32-bit integer from the currently loaded data range.
  76506. * @returns The 32-bit integer read
  76507. */
  76508. readUint32(): number;
  76509. /**
  76510. * Read a byte array from the currently loaded data range.
  76511. * @param byteLength The byte length to read
  76512. * @returns The byte array read
  76513. */
  76514. readUint8Array(byteLength: number): Uint8Array;
  76515. /**
  76516. * Read a string from the currently loaded data range.
  76517. * @param byteLength The byte length to read
  76518. * @returns The string read
  76519. */
  76520. readString(byteLength: number): string;
  76521. /**
  76522. * Skips the given byte length the currently loaded data range.
  76523. * @param byteLength The byte length to skip
  76524. */
  76525. skipBytes(byteLength: number): void;
  76526. }
  76527. }
  76528. declare module "babylonjs/Misc/dataStorage" {
  76529. /**
  76530. * Class for storing data to local storage if available or in-memory storage otherwise
  76531. */
  76532. export class DataStorage {
  76533. private static _Storage;
  76534. private static _GetStorage;
  76535. /**
  76536. * Reads a string from the data storage
  76537. * @param key The key to read
  76538. * @param defaultValue The value if the key doesn't exist
  76539. * @returns The string value
  76540. */
  76541. static ReadString(key: string, defaultValue: string): string;
  76542. /**
  76543. * Writes a string to the data storage
  76544. * @param key The key to write
  76545. * @param value The value to write
  76546. */
  76547. static WriteString(key: string, value: string): void;
  76548. /**
  76549. * Reads a boolean from the data storage
  76550. * @param key The key to read
  76551. * @param defaultValue The value if the key doesn't exist
  76552. * @returns The boolean value
  76553. */
  76554. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76555. /**
  76556. * Writes a boolean to the data storage
  76557. * @param key The key to write
  76558. * @param value The value to write
  76559. */
  76560. static WriteBoolean(key: string, value: boolean): void;
  76561. /**
  76562. * Reads a number from the data storage
  76563. * @param key The key to read
  76564. * @param defaultValue The value if the key doesn't exist
  76565. * @returns The number value
  76566. */
  76567. static ReadNumber(key: string, defaultValue: number): number;
  76568. /**
  76569. * Writes a number to the data storage
  76570. * @param key The key to write
  76571. * @param value The value to write
  76572. */
  76573. static WriteNumber(key: string, value: number): void;
  76574. }
  76575. }
  76576. declare module "babylonjs/Misc/index" {
  76577. export * from "babylonjs/Misc/andOrNotEvaluator";
  76578. export * from "babylonjs/Misc/assetsManager";
  76579. export * from "babylonjs/Misc/basis";
  76580. export * from "babylonjs/Misc/dds";
  76581. export * from "babylonjs/Misc/decorators";
  76582. export * from "babylonjs/Misc/deferred";
  76583. export * from "babylonjs/Misc/environmentTextureTools";
  76584. export * from "babylonjs/Misc/meshExploder";
  76585. export * from "babylonjs/Misc/filesInput";
  76586. export * from "babylonjs/Misc/HighDynamicRange/index";
  76587. export * from "babylonjs/Misc/khronosTextureContainer";
  76588. export * from "babylonjs/Misc/observable";
  76589. export * from "babylonjs/Misc/performanceMonitor";
  76590. export * from "babylonjs/Misc/promise";
  76591. export * from "babylonjs/Misc/sceneOptimizer";
  76592. export * from "babylonjs/Misc/sceneSerializer";
  76593. export * from "babylonjs/Misc/smartArray";
  76594. export * from "babylonjs/Misc/stringDictionary";
  76595. export * from "babylonjs/Misc/tags";
  76596. export * from "babylonjs/Misc/textureTools";
  76597. export * from "babylonjs/Misc/tga";
  76598. export * from "babylonjs/Misc/tools";
  76599. export * from "babylonjs/Misc/videoRecorder";
  76600. export * from "babylonjs/Misc/virtualJoystick";
  76601. export * from "babylonjs/Misc/workerPool";
  76602. export * from "babylonjs/Misc/logger";
  76603. export * from "babylonjs/Misc/typeStore";
  76604. export * from "babylonjs/Misc/filesInputStore";
  76605. export * from "babylonjs/Misc/deepCopier";
  76606. export * from "babylonjs/Misc/pivotTools";
  76607. export * from "babylonjs/Misc/precisionDate";
  76608. export * from "babylonjs/Misc/screenshotTools";
  76609. export * from "babylonjs/Misc/typeStore";
  76610. export * from "babylonjs/Misc/webRequest";
  76611. export * from "babylonjs/Misc/iInspectable";
  76612. export * from "babylonjs/Misc/brdfTextureTools";
  76613. export * from "babylonjs/Misc/rgbdTextureTools";
  76614. export * from "babylonjs/Misc/gradients";
  76615. export * from "babylonjs/Misc/perfCounter";
  76616. export * from "babylonjs/Misc/fileRequest";
  76617. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76618. export * from "babylonjs/Misc/retryStrategy";
  76619. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76620. export * from "babylonjs/Misc/canvasGenerator";
  76621. export * from "babylonjs/Misc/fileTools";
  76622. export * from "babylonjs/Misc/stringTools";
  76623. export * from "babylonjs/Misc/dataReader";
  76624. export * from "babylonjs/Misc/minMaxReducer";
  76625. export * from "babylonjs/Misc/depthReducer";
  76626. export * from "babylonjs/Misc/dataStorage";
  76627. }
  76628. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76629. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76630. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76631. import { Observable } from "babylonjs/Misc/observable";
  76632. import { Matrix } from "babylonjs/Maths/math.vector";
  76633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76634. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76635. /**
  76636. * An interface for all Hit test features
  76637. */
  76638. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76639. /**
  76640. * Triggered when new babylon (transformed) hit test results are available
  76641. */
  76642. onHitTestResultObservable: Observable<T[]>;
  76643. }
  76644. /**
  76645. * Options used for hit testing
  76646. */
  76647. export interface IWebXRLegacyHitTestOptions {
  76648. /**
  76649. * Only test when user interacted with the scene. Default - hit test every frame
  76650. */
  76651. testOnPointerDownOnly?: boolean;
  76652. /**
  76653. * The node to use to transform the local results to world coordinates
  76654. */
  76655. worldParentNode?: TransformNode;
  76656. }
  76657. /**
  76658. * Interface defining the babylon result of raycasting/hit-test
  76659. */
  76660. export interface IWebXRLegacyHitResult {
  76661. /**
  76662. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76663. */
  76664. transformationMatrix: Matrix;
  76665. /**
  76666. * The native hit test result
  76667. */
  76668. xrHitResult: XRHitResult | XRHitTestResult;
  76669. }
  76670. /**
  76671. * The currently-working hit-test module.
  76672. * Hit test (or Ray-casting) is used to interact with the real world.
  76673. * For further information read here - https://github.com/immersive-web/hit-test
  76674. */
  76675. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76676. /**
  76677. * options to use when constructing this feature
  76678. */
  76679. readonly options: IWebXRLegacyHitTestOptions;
  76680. private _direction;
  76681. private _mat;
  76682. private _onSelectEnabled;
  76683. private _origin;
  76684. /**
  76685. * The module's name
  76686. */
  76687. static readonly Name: string;
  76688. /**
  76689. * The (Babylon) version of this module.
  76690. * This is an integer representing the implementation version.
  76691. * This number does not correspond to the WebXR specs version
  76692. */
  76693. static readonly Version: number;
  76694. /**
  76695. * Populated with the last native XR Hit Results
  76696. */
  76697. lastNativeXRHitResults: XRHitResult[];
  76698. /**
  76699. * Triggered when new babylon (transformed) hit test results are available
  76700. */
  76701. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76702. /**
  76703. * Creates a new instance of the (legacy version) hit test feature
  76704. * @param _xrSessionManager an instance of WebXRSessionManager
  76705. * @param options options to use when constructing this feature
  76706. */
  76707. constructor(_xrSessionManager: WebXRSessionManager,
  76708. /**
  76709. * options to use when constructing this feature
  76710. */
  76711. options?: IWebXRLegacyHitTestOptions);
  76712. /**
  76713. * execute a hit test with an XR Ray
  76714. *
  76715. * @param xrSession a native xrSession that will execute this hit test
  76716. * @param xrRay the ray (position and direction) to use for ray-casting
  76717. * @param referenceSpace native XR reference space to use for the hit-test
  76718. * @param filter filter function that will filter the results
  76719. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76720. */
  76721. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76722. /**
  76723. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76724. * @param event the (select) event to use to select with
  76725. * @param referenceSpace the reference space to use for this hit test
  76726. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76727. */
  76728. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76729. /**
  76730. * attach this feature
  76731. * Will usually be called by the features manager
  76732. *
  76733. * @returns true if successful.
  76734. */
  76735. attach(): boolean;
  76736. /**
  76737. * detach this feature.
  76738. * Will usually be called by the features manager
  76739. *
  76740. * @returns true if successful.
  76741. */
  76742. detach(): boolean;
  76743. /**
  76744. * Dispose this feature and all of the resources attached
  76745. */
  76746. dispose(): void;
  76747. protected _onXRFrame(frame: XRFrame): void;
  76748. private _onHitTestResults;
  76749. private _onSelect;
  76750. }
  76751. }
  76752. declare module "babylonjs/XR/features/WebXRHitTest" {
  76753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76754. import { Observable } from "babylonjs/Misc/observable";
  76755. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76756. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76757. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76758. /**
  76759. * Options used for hit testing (version 2)
  76760. */
  76761. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76762. /**
  76763. * Do not create a permanent hit test. Will usually be used when only
  76764. * transient inputs are needed.
  76765. */
  76766. disablePermanentHitTest?: boolean;
  76767. /**
  76768. * Enable transient (for example touch-based) hit test inspections
  76769. */
  76770. enableTransientHitTest?: boolean;
  76771. /**
  76772. * Offset ray for the permanent hit test
  76773. */
  76774. offsetRay?: Vector3;
  76775. /**
  76776. * Offset ray for the transient hit test
  76777. */
  76778. transientOffsetRay?: Vector3;
  76779. /**
  76780. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76781. */
  76782. useReferenceSpace?: boolean;
  76783. }
  76784. /**
  76785. * Interface defining the babylon result of hit-test
  76786. */
  76787. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76788. /**
  76789. * The input source that generated this hit test (if transient)
  76790. */
  76791. inputSource?: XRInputSource;
  76792. /**
  76793. * Is this a transient hit test
  76794. */
  76795. isTransient?: boolean;
  76796. /**
  76797. * Position of the hit test result
  76798. */
  76799. position: Vector3;
  76800. /**
  76801. * Rotation of the hit test result
  76802. */
  76803. rotationQuaternion: Quaternion;
  76804. /**
  76805. * The native hit test result
  76806. */
  76807. xrHitResult: XRHitTestResult;
  76808. }
  76809. /**
  76810. * The currently-working hit-test module.
  76811. * Hit test (or Ray-casting) is used to interact with the real world.
  76812. * For further information read here - https://github.com/immersive-web/hit-test
  76813. *
  76814. * Tested on chrome (mobile) 80.
  76815. */
  76816. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76817. /**
  76818. * options to use when constructing this feature
  76819. */
  76820. readonly options: IWebXRHitTestOptions;
  76821. private _tmpMat;
  76822. private _tmpPos;
  76823. private _tmpQuat;
  76824. private _transientXrHitTestSource;
  76825. private _xrHitTestSource;
  76826. private initHitTestSource;
  76827. /**
  76828. * The module's name
  76829. */
  76830. static readonly Name: string;
  76831. /**
  76832. * The (Babylon) version of this module.
  76833. * This is an integer representing the implementation version.
  76834. * This number does not correspond to the WebXR specs version
  76835. */
  76836. static readonly Version: number;
  76837. /**
  76838. * When set to true, each hit test will have its own position/rotation objects
  76839. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76840. * the developers will clone them or copy them as they see fit.
  76841. */
  76842. autoCloneTransformation: boolean;
  76843. /**
  76844. * Triggered when new babylon (transformed) hit test results are available
  76845. */
  76846. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76847. /**
  76848. * Use this to temporarily pause hit test checks.
  76849. */
  76850. paused: boolean;
  76851. /**
  76852. * Creates a new instance of the hit test feature
  76853. * @param _xrSessionManager an instance of WebXRSessionManager
  76854. * @param options options to use when constructing this feature
  76855. */
  76856. constructor(_xrSessionManager: WebXRSessionManager,
  76857. /**
  76858. * options to use when constructing this feature
  76859. */
  76860. options?: IWebXRHitTestOptions);
  76861. /**
  76862. * attach this feature
  76863. * Will usually be called by the features manager
  76864. *
  76865. * @returns true if successful.
  76866. */
  76867. attach(): boolean;
  76868. /**
  76869. * detach this feature.
  76870. * Will usually be called by the features manager
  76871. *
  76872. * @returns true if successful.
  76873. */
  76874. detach(): boolean;
  76875. /**
  76876. * Dispose this feature and all of the resources attached
  76877. */
  76878. dispose(): void;
  76879. protected _onXRFrame(frame: XRFrame): void;
  76880. private _processWebXRHitTestResult;
  76881. }
  76882. }
  76883. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76884. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76885. import { Observable } from "babylonjs/Misc/observable";
  76886. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76888. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76889. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76890. /**
  76891. * Configuration options of the anchor system
  76892. */
  76893. export interface IWebXRAnchorSystemOptions {
  76894. /**
  76895. * a node that will be used to convert local to world coordinates
  76896. */
  76897. worldParentNode?: TransformNode;
  76898. /**
  76899. * If set to true a reference of the created anchors will be kept until the next session starts
  76900. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76901. */
  76902. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76903. }
  76904. /**
  76905. * A babylon container for an XR Anchor
  76906. */
  76907. export interface IWebXRAnchor {
  76908. /**
  76909. * A babylon-assigned ID for this anchor
  76910. */
  76911. id: number;
  76912. /**
  76913. * Transformation matrix to apply to an object attached to this anchor
  76914. */
  76915. transformationMatrix: Matrix;
  76916. /**
  76917. * The native anchor object
  76918. */
  76919. xrAnchor: XRAnchor;
  76920. /**
  76921. * if defined, this object will be constantly updated by the anchor's position and rotation
  76922. */
  76923. attachedNode?: TransformNode;
  76924. }
  76925. /**
  76926. * An implementation of the anchor system for WebXR.
  76927. * For further information see https://github.com/immersive-web/anchors/
  76928. */
  76929. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76930. private _options;
  76931. private _lastFrameDetected;
  76932. private _trackedAnchors;
  76933. private _referenceSpaceForFrameAnchors;
  76934. private _futureAnchors;
  76935. /**
  76936. * The module's name
  76937. */
  76938. static readonly Name: string;
  76939. /**
  76940. * The (Babylon) version of this module.
  76941. * This is an integer representing the implementation version.
  76942. * This number does not correspond to the WebXR specs version
  76943. */
  76944. static readonly Version: number;
  76945. /**
  76946. * Observers registered here will be executed when a new anchor was added to the session
  76947. */
  76948. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76949. /**
  76950. * Observers registered here will be executed when an anchor was removed from the session
  76951. */
  76952. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76953. /**
  76954. * Observers registered here will be executed when an existing anchor updates
  76955. * This can execute N times every frame
  76956. */
  76957. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76958. /**
  76959. * Set the reference space to use for anchor creation, when not using a hit test.
  76960. * Will default to the session's reference space if not defined
  76961. */
  76962. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76963. /**
  76964. * constructs a new anchor system
  76965. * @param _xrSessionManager an instance of WebXRSessionManager
  76966. * @param _options configuration object for this feature
  76967. */
  76968. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76969. private _tmpVector;
  76970. private _tmpQuaternion;
  76971. private _populateTmpTransformation;
  76972. /**
  76973. * Create a new anchor point using a hit test result at a specific point in the scene
  76974. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76975. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76976. *
  76977. * @param hitTestResult The hit test result to use for this anchor creation
  76978. * @param position an optional position offset for this anchor
  76979. * @param rotationQuaternion an optional rotation offset for this anchor
  76980. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76981. */
  76982. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76983. /**
  76984. * Add a new anchor at a specific position and rotation
  76985. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76986. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76987. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76988. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76989. *
  76990. * @param position the position in which to add an anchor
  76991. * @param rotationQuaternion an optional rotation for the anchor transformation
  76992. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76993. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76994. */
  76995. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76996. /**
  76997. * detach this feature.
  76998. * Will usually be called by the features manager
  76999. *
  77000. * @returns true if successful.
  77001. */
  77002. detach(): boolean;
  77003. /**
  77004. * Dispose this feature and all of the resources attached
  77005. */
  77006. dispose(): void;
  77007. protected _onXRFrame(frame: XRFrame): void;
  77008. /**
  77009. * avoiding using Array.find for global support.
  77010. * @param xrAnchor the plane to find in the array
  77011. */
  77012. private _findIndexInAnchorArray;
  77013. private _updateAnchorWithXRFrame;
  77014. private _createAnchorAtTransformation;
  77015. }
  77016. }
  77017. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77019. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77020. import { Observable } from "babylonjs/Misc/observable";
  77021. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77022. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77023. /**
  77024. * Options used in the plane detector module
  77025. */
  77026. export interface IWebXRPlaneDetectorOptions {
  77027. /**
  77028. * The node to use to transform the local results to world coordinates
  77029. */
  77030. worldParentNode?: TransformNode;
  77031. /**
  77032. * If set to true a reference of the created planes will be kept until the next session starts
  77033. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77034. */
  77035. doNotRemovePlanesOnSessionEnded?: boolean;
  77036. }
  77037. /**
  77038. * A babylon interface for a WebXR plane.
  77039. * A Plane is actually a polygon, built from N points in space
  77040. *
  77041. * Supported in chrome 79, not supported in canary 81 ATM
  77042. */
  77043. export interface IWebXRPlane {
  77044. /**
  77045. * a babylon-assigned ID for this polygon
  77046. */
  77047. id: number;
  77048. /**
  77049. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77050. */
  77051. polygonDefinition: Array<Vector3>;
  77052. /**
  77053. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77054. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77055. */
  77056. transformationMatrix: Matrix;
  77057. /**
  77058. * the native xr-plane object
  77059. */
  77060. xrPlane: XRPlane;
  77061. }
  77062. /**
  77063. * The plane detector is used to detect planes in the real world when in AR
  77064. * For more information see https://github.com/immersive-web/real-world-geometry/
  77065. */
  77066. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77067. private _options;
  77068. private _detectedPlanes;
  77069. private _enabled;
  77070. private _lastFrameDetected;
  77071. /**
  77072. * The module's name
  77073. */
  77074. static readonly Name: string;
  77075. /**
  77076. * The (Babylon) version of this module.
  77077. * This is an integer representing the implementation version.
  77078. * This number does not correspond to the WebXR specs version
  77079. */
  77080. static readonly Version: number;
  77081. /**
  77082. * Observers registered here will be executed when a new plane was added to the session
  77083. */
  77084. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77085. /**
  77086. * Observers registered here will be executed when a plane is no longer detected in the session
  77087. */
  77088. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77089. /**
  77090. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77091. * This can execute N times every frame
  77092. */
  77093. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77094. /**
  77095. * construct a new Plane Detector
  77096. * @param _xrSessionManager an instance of xr Session manager
  77097. * @param _options configuration to use when constructing this feature
  77098. */
  77099. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77100. /**
  77101. * detach this feature.
  77102. * Will usually be called by the features manager
  77103. *
  77104. * @returns true if successful.
  77105. */
  77106. detach(): boolean;
  77107. /**
  77108. * Dispose this feature and all of the resources attached
  77109. */
  77110. dispose(): void;
  77111. protected _onXRFrame(frame: XRFrame): void;
  77112. private _init;
  77113. private _updatePlaneWithXRPlane;
  77114. /**
  77115. * avoiding using Array.find for global support.
  77116. * @param xrPlane the plane to find in the array
  77117. */
  77118. private findIndexInPlaneArray;
  77119. }
  77120. }
  77121. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77122. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77124. import { Observable } from "babylonjs/Misc/observable";
  77125. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77126. /**
  77127. * Options interface for the background remover plugin
  77128. */
  77129. export interface IWebXRBackgroundRemoverOptions {
  77130. /**
  77131. * Further background meshes to disable when entering AR
  77132. */
  77133. backgroundMeshes?: AbstractMesh[];
  77134. /**
  77135. * flags to configure the removal of the environment helper.
  77136. * If not set, the entire background will be removed. If set, flags should be set as well.
  77137. */
  77138. environmentHelperRemovalFlags?: {
  77139. /**
  77140. * Should the skybox be removed (default false)
  77141. */
  77142. skyBox?: boolean;
  77143. /**
  77144. * Should the ground be removed (default false)
  77145. */
  77146. ground?: boolean;
  77147. };
  77148. /**
  77149. * don't disable the environment helper
  77150. */
  77151. ignoreEnvironmentHelper?: boolean;
  77152. }
  77153. /**
  77154. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77155. */
  77156. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77157. /**
  77158. * read-only options to be used in this module
  77159. */
  77160. readonly options: IWebXRBackgroundRemoverOptions;
  77161. /**
  77162. * The module's name
  77163. */
  77164. static readonly Name: string;
  77165. /**
  77166. * The (Babylon) version of this module.
  77167. * This is an integer representing the implementation version.
  77168. * This number does not correspond to the WebXR specs version
  77169. */
  77170. static readonly Version: number;
  77171. /**
  77172. * registered observers will be triggered when the background state changes
  77173. */
  77174. onBackgroundStateChangedObservable: Observable<boolean>;
  77175. /**
  77176. * constructs a new background remover module
  77177. * @param _xrSessionManager the session manager for this module
  77178. * @param options read-only options to be used in this module
  77179. */
  77180. constructor(_xrSessionManager: WebXRSessionManager,
  77181. /**
  77182. * read-only options to be used in this module
  77183. */
  77184. options?: IWebXRBackgroundRemoverOptions);
  77185. /**
  77186. * attach this feature
  77187. * Will usually be called by the features manager
  77188. *
  77189. * @returns true if successful.
  77190. */
  77191. attach(): boolean;
  77192. /**
  77193. * detach this feature.
  77194. * Will usually be called by the features manager
  77195. *
  77196. * @returns true if successful.
  77197. */
  77198. detach(): boolean;
  77199. /**
  77200. * Dispose this feature and all of the resources attached
  77201. */
  77202. dispose(): void;
  77203. protected _onXRFrame(_xrFrame: XRFrame): void;
  77204. private _setBackgroundState;
  77205. }
  77206. }
  77207. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77208. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77209. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77210. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77211. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77212. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77213. import { Nullable } from "babylonjs/types";
  77214. /**
  77215. * Options for the controller physics feature
  77216. */
  77217. export class IWebXRControllerPhysicsOptions {
  77218. /**
  77219. * Should the headset get its own impostor
  77220. */
  77221. enableHeadsetImpostor?: boolean;
  77222. /**
  77223. * Optional parameters for the headset impostor
  77224. */
  77225. headsetImpostorParams?: {
  77226. /**
  77227. * The type of impostor to create. Default is sphere
  77228. */
  77229. impostorType: number;
  77230. /**
  77231. * the size of the impostor. Defaults to 10cm
  77232. */
  77233. impostorSize?: number | {
  77234. width: number;
  77235. height: number;
  77236. depth: number;
  77237. };
  77238. /**
  77239. * Friction definitions
  77240. */
  77241. friction?: number;
  77242. /**
  77243. * Restitution
  77244. */
  77245. restitution?: number;
  77246. };
  77247. /**
  77248. * The physics properties of the future impostors
  77249. */
  77250. physicsProperties?: {
  77251. /**
  77252. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77253. * Note that this requires a physics engine that supports mesh impostors!
  77254. */
  77255. useControllerMesh?: boolean;
  77256. /**
  77257. * The type of impostor to create. Default is sphere
  77258. */
  77259. impostorType?: number;
  77260. /**
  77261. * the size of the impostor. Defaults to 10cm
  77262. */
  77263. impostorSize?: number | {
  77264. width: number;
  77265. height: number;
  77266. depth: number;
  77267. };
  77268. /**
  77269. * Friction definitions
  77270. */
  77271. friction?: number;
  77272. /**
  77273. * Restitution
  77274. */
  77275. restitution?: number;
  77276. };
  77277. /**
  77278. * the xr input to use with this pointer selection
  77279. */
  77280. xrInput: WebXRInput;
  77281. }
  77282. /**
  77283. * Add physics impostor to your webxr controllers,
  77284. * including naive calculation of their linear and angular velocity
  77285. */
  77286. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77287. private readonly _options;
  77288. private _attachController;
  77289. private _controllers;
  77290. private _debugMode;
  77291. private _delta;
  77292. private _headsetImpostor?;
  77293. private _headsetMesh?;
  77294. private _lastTimestamp;
  77295. private _tmpQuaternion;
  77296. private _tmpVector;
  77297. /**
  77298. * The module's name
  77299. */
  77300. static readonly Name: string;
  77301. /**
  77302. * The (Babylon) version of this module.
  77303. * This is an integer representing the implementation version.
  77304. * This number does not correspond to the webxr specs version
  77305. */
  77306. static readonly Version: number;
  77307. /**
  77308. * Construct a new Controller Physics Feature
  77309. * @param _xrSessionManager the corresponding xr session manager
  77310. * @param _options options to create this feature with
  77311. */
  77312. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77313. /**
  77314. * @hidden
  77315. * enable debugging - will show console outputs and the impostor mesh
  77316. */
  77317. _enablePhysicsDebug(): void;
  77318. /**
  77319. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77320. * @param xrController the controller to add
  77321. */
  77322. addController(xrController: WebXRInputSource): void;
  77323. /**
  77324. * attach this feature
  77325. * Will usually be called by the features manager
  77326. *
  77327. * @returns true if successful.
  77328. */
  77329. attach(): boolean;
  77330. /**
  77331. * detach this feature.
  77332. * Will usually be called by the features manager
  77333. *
  77334. * @returns true if successful.
  77335. */
  77336. detach(): boolean;
  77337. /**
  77338. * Get the headset impostor, if enabled
  77339. * @returns the impostor
  77340. */
  77341. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77342. /**
  77343. * Get the physics impostor of a specific controller.
  77344. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77345. * @param controller the controller or the controller id of which to get the impostor
  77346. * @returns the impostor or null
  77347. */
  77348. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77349. /**
  77350. * Update the physics properties provided in the constructor
  77351. * @param newProperties the new properties object
  77352. */
  77353. setPhysicsProperties(newProperties: {
  77354. impostorType?: number;
  77355. impostorSize?: number | {
  77356. width: number;
  77357. height: number;
  77358. depth: number;
  77359. };
  77360. friction?: number;
  77361. restitution?: number;
  77362. }): void;
  77363. protected _onXRFrame(_xrFrame: any): void;
  77364. private _detachController;
  77365. }
  77366. }
  77367. declare module "babylonjs/XR/features/index" {
  77368. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77369. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77370. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77371. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77372. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77373. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77374. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77375. export * from "babylonjs/XR/features/WebXRHitTest";
  77376. }
  77377. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77378. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77380. import { Scene } from "babylonjs/scene";
  77381. /**
  77382. * The motion controller class for all microsoft mixed reality controllers
  77383. */
  77384. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77385. protected readonly _mapping: {
  77386. defaultButton: {
  77387. valueNodeName: string;
  77388. unpressedNodeName: string;
  77389. pressedNodeName: string;
  77390. };
  77391. defaultAxis: {
  77392. valueNodeName: string;
  77393. minNodeName: string;
  77394. maxNodeName: string;
  77395. };
  77396. buttons: {
  77397. "xr-standard-trigger": {
  77398. rootNodeName: string;
  77399. componentProperty: string;
  77400. states: string[];
  77401. };
  77402. "xr-standard-squeeze": {
  77403. rootNodeName: string;
  77404. componentProperty: string;
  77405. states: string[];
  77406. };
  77407. "xr-standard-touchpad": {
  77408. rootNodeName: string;
  77409. labelAnchorNodeName: string;
  77410. touchPointNodeName: string;
  77411. };
  77412. "xr-standard-thumbstick": {
  77413. rootNodeName: string;
  77414. componentProperty: string;
  77415. states: string[];
  77416. };
  77417. };
  77418. axes: {
  77419. "xr-standard-touchpad": {
  77420. "x-axis": {
  77421. rootNodeName: string;
  77422. };
  77423. "y-axis": {
  77424. rootNodeName: string;
  77425. };
  77426. };
  77427. "xr-standard-thumbstick": {
  77428. "x-axis": {
  77429. rootNodeName: string;
  77430. };
  77431. "y-axis": {
  77432. rootNodeName: string;
  77433. };
  77434. };
  77435. };
  77436. };
  77437. /**
  77438. * The base url used to load the left and right controller models
  77439. */
  77440. static MODEL_BASE_URL: string;
  77441. /**
  77442. * The name of the left controller model file
  77443. */
  77444. static MODEL_LEFT_FILENAME: string;
  77445. /**
  77446. * The name of the right controller model file
  77447. */
  77448. static MODEL_RIGHT_FILENAME: string;
  77449. profileId: string;
  77450. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77451. protected _getFilenameAndPath(): {
  77452. filename: string;
  77453. path: string;
  77454. };
  77455. protected _getModelLoadingConstraints(): boolean;
  77456. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77457. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77458. protected _updateModel(): void;
  77459. }
  77460. }
  77461. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77462. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77464. import { Scene } from "babylonjs/scene";
  77465. /**
  77466. * The motion controller class for oculus touch (quest, rift).
  77467. * This class supports legacy mapping as well the standard xr mapping
  77468. */
  77469. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77470. private _forceLegacyControllers;
  77471. private _modelRootNode;
  77472. /**
  77473. * The base url used to load the left and right controller models
  77474. */
  77475. static MODEL_BASE_URL: string;
  77476. /**
  77477. * The name of the left controller model file
  77478. */
  77479. static MODEL_LEFT_FILENAME: string;
  77480. /**
  77481. * The name of the right controller model file
  77482. */
  77483. static MODEL_RIGHT_FILENAME: string;
  77484. /**
  77485. * Base Url for the Quest controller model.
  77486. */
  77487. static QUEST_MODEL_BASE_URL: string;
  77488. profileId: string;
  77489. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77490. protected _getFilenameAndPath(): {
  77491. filename: string;
  77492. path: string;
  77493. };
  77494. protected _getModelLoadingConstraints(): boolean;
  77495. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77496. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77497. protected _updateModel(): void;
  77498. /**
  77499. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77500. * between the touch and touch 2.
  77501. */
  77502. private _isQuest;
  77503. }
  77504. }
  77505. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77506. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77507. import { Scene } from "babylonjs/scene";
  77508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77509. /**
  77510. * The motion controller class for the standard HTC-Vive controllers
  77511. */
  77512. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77513. private _modelRootNode;
  77514. /**
  77515. * The base url used to load the left and right controller models
  77516. */
  77517. static MODEL_BASE_URL: string;
  77518. /**
  77519. * File name for the controller model.
  77520. */
  77521. static MODEL_FILENAME: string;
  77522. profileId: string;
  77523. /**
  77524. * Create a new Vive motion controller object
  77525. * @param scene the scene to use to create this controller
  77526. * @param gamepadObject the corresponding gamepad object
  77527. * @param handedness the handedness of the controller
  77528. */
  77529. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77530. protected _getFilenameAndPath(): {
  77531. filename: string;
  77532. path: string;
  77533. };
  77534. protected _getModelLoadingConstraints(): boolean;
  77535. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77536. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77537. protected _updateModel(): void;
  77538. }
  77539. }
  77540. declare module "babylonjs/XR/motionController/index" {
  77541. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77542. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77543. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77544. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77545. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77546. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77547. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77548. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77549. }
  77550. declare module "babylonjs/XR/index" {
  77551. export * from "babylonjs/XR/webXRCamera";
  77552. export * from "babylonjs/XR/webXREnterExitUI";
  77553. export * from "babylonjs/XR/webXRExperienceHelper";
  77554. export * from "babylonjs/XR/webXRInput";
  77555. export * from "babylonjs/XR/webXRInputSource";
  77556. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77557. export * from "babylonjs/XR/webXRTypes";
  77558. export * from "babylonjs/XR/webXRSessionManager";
  77559. export * from "babylonjs/XR/webXRDefaultExperience";
  77560. export * from "babylonjs/XR/webXRFeaturesManager";
  77561. export * from "babylonjs/XR/features/index";
  77562. export * from "babylonjs/XR/motionController/index";
  77563. }
  77564. declare module "babylonjs/index" {
  77565. export * from "babylonjs/abstractScene";
  77566. export * from "babylonjs/Actions/index";
  77567. export * from "babylonjs/Animations/index";
  77568. export * from "babylonjs/assetContainer";
  77569. export * from "babylonjs/Audio/index";
  77570. export * from "babylonjs/Behaviors/index";
  77571. export * from "babylonjs/Bones/index";
  77572. export * from "babylonjs/Cameras/index";
  77573. export * from "babylonjs/Collisions/index";
  77574. export * from "babylonjs/Culling/index";
  77575. export * from "babylonjs/Debug/index";
  77576. export * from "babylonjs/DeviceInput/index";
  77577. export * from "babylonjs/Engines/index";
  77578. export * from "babylonjs/Events/index";
  77579. export * from "babylonjs/Gamepads/index";
  77580. export * from "babylonjs/Gizmos/index";
  77581. export * from "babylonjs/Helpers/index";
  77582. export * from "babylonjs/Instrumentation/index";
  77583. export * from "babylonjs/Layers/index";
  77584. export * from "babylonjs/LensFlares/index";
  77585. export * from "babylonjs/Lights/index";
  77586. export * from "babylonjs/Loading/index";
  77587. export * from "babylonjs/Materials/index";
  77588. export * from "babylonjs/Maths/index";
  77589. export * from "babylonjs/Meshes/index";
  77590. export * from "babylonjs/Morph/index";
  77591. export * from "babylonjs/Navigation/index";
  77592. export * from "babylonjs/node";
  77593. export * from "babylonjs/Offline/index";
  77594. export * from "babylonjs/Particles/index";
  77595. export * from "babylonjs/Physics/index";
  77596. export * from "babylonjs/PostProcesses/index";
  77597. export * from "babylonjs/Probes/index";
  77598. export * from "babylonjs/Rendering/index";
  77599. export * from "babylonjs/scene";
  77600. export * from "babylonjs/sceneComponent";
  77601. export * from "babylonjs/Sprites/index";
  77602. export * from "babylonjs/States/index";
  77603. export * from "babylonjs/Misc/index";
  77604. export * from "babylonjs/XR/index";
  77605. export * from "babylonjs/types";
  77606. }
  77607. declare module "babylonjs/Animations/pathCursor" {
  77608. import { Vector3 } from "babylonjs/Maths/math.vector";
  77609. import { Path2 } from "babylonjs/Maths/math.path";
  77610. /**
  77611. * A cursor which tracks a point on a path
  77612. */
  77613. export class PathCursor {
  77614. private path;
  77615. /**
  77616. * Stores path cursor callbacks for when an onchange event is triggered
  77617. */
  77618. private _onchange;
  77619. /**
  77620. * The value of the path cursor
  77621. */
  77622. value: number;
  77623. /**
  77624. * The animation array of the path cursor
  77625. */
  77626. animations: Animation[];
  77627. /**
  77628. * Initializes the path cursor
  77629. * @param path The path to track
  77630. */
  77631. constructor(path: Path2);
  77632. /**
  77633. * Gets the cursor point on the path
  77634. * @returns A point on the path cursor at the cursor location
  77635. */
  77636. getPoint(): Vector3;
  77637. /**
  77638. * Moves the cursor ahead by the step amount
  77639. * @param step The amount to move the cursor forward
  77640. * @returns This path cursor
  77641. */
  77642. moveAhead(step?: number): PathCursor;
  77643. /**
  77644. * Moves the cursor behind by the step amount
  77645. * @param step The amount to move the cursor back
  77646. * @returns This path cursor
  77647. */
  77648. moveBack(step?: number): PathCursor;
  77649. /**
  77650. * Moves the cursor by the step amount
  77651. * If the step amount is greater than one, an exception is thrown
  77652. * @param step The amount to move the cursor
  77653. * @returns This path cursor
  77654. */
  77655. move(step: number): PathCursor;
  77656. /**
  77657. * Ensures that the value is limited between zero and one
  77658. * @returns This path cursor
  77659. */
  77660. private ensureLimits;
  77661. /**
  77662. * Runs onchange callbacks on change (used by the animation engine)
  77663. * @returns This path cursor
  77664. */
  77665. private raiseOnChange;
  77666. /**
  77667. * Executes a function on change
  77668. * @param f A path cursor onchange callback
  77669. * @returns This path cursor
  77670. */
  77671. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77672. }
  77673. }
  77674. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77675. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77676. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77677. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77678. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77679. }
  77680. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77681. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77682. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77683. }
  77684. declare module "babylonjs/Engines/Processors/index" {
  77685. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77686. export * from "babylonjs/Engines/Processors/Expressions/index";
  77687. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77688. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77689. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77690. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77691. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77692. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77693. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77694. }
  77695. declare module "babylonjs/Legacy/legacy" {
  77696. import * as Babylon from "babylonjs/index";
  77697. export * from "babylonjs/index";
  77698. }
  77699. declare module "babylonjs/Shaders/blur.fragment" {
  77700. /** @hidden */
  77701. export var blurPixelShader: {
  77702. name: string;
  77703. shader: string;
  77704. };
  77705. }
  77706. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77707. /** @hidden */
  77708. export var pointCloudVertexDeclaration: {
  77709. name: string;
  77710. shader: string;
  77711. };
  77712. }
  77713. declare module "babylonjs" {
  77714. export * from "babylonjs/Legacy/legacy";
  77715. }
  77716. declare module BABYLON {
  77717. /** Alias type for value that can be null */
  77718. export type Nullable<T> = T | null;
  77719. /**
  77720. * Alias type for number that are floats
  77721. * @ignorenaming
  77722. */
  77723. export type float = number;
  77724. /**
  77725. * Alias type for number that are doubles.
  77726. * @ignorenaming
  77727. */
  77728. export type double = number;
  77729. /**
  77730. * Alias type for number that are integer
  77731. * @ignorenaming
  77732. */
  77733. export type int = number;
  77734. /** Alias type for number array or Float32Array */
  77735. export type FloatArray = number[] | Float32Array;
  77736. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77737. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77738. /**
  77739. * Alias for types that can be used by a Buffer or VertexBuffer.
  77740. */
  77741. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77742. /**
  77743. * Alias type for primitive types
  77744. * @ignorenaming
  77745. */
  77746. type Primitive = undefined | null | boolean | string | number | Function;
  77747. /**
  77748. * Type modifier to make all the properties of an object Readonly
  77749. */
  77750. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77751. /**
  77752. * Type modifier to make all the properties of an object Readonly recursively
  77753. */
  77754. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77755. /**
  77756. * Type modifier to make object properties readonly.
  77757. */
  77758. export type DeepImmutableObject<T> = {
  77759. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77760. };
  77761. /** @hidden */
  77762. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77763. }
  77764. }
  77765. declare module BABYLON {
  77766. /**
  77767. * A class serves as a medium between the observable and its observers
  77768. */
  77769. export class EventState {
  77770. /**
  77771. * Create a new EventState
  77772. * @param mask defines the mask associated with this state
  77773. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77774. * @param target defines the original target of the state
  77775. * @param currentTarget defines the current target of the state
  77776. */
  77777. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77778. /**
  77779. * Initialize the current event state
  77780. * @param mask defines the mask associated with this state
  77781. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77782. * @param target defines the original target of the state
  77783. * @param currentTarget defines the current target of the state
  77784. * @returns the current event state
  77785. */
  77786. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77787. /**
  77788. * An Observer can set this property to true to prevent subsequent observers of being notified
  77789. */
  77790. skipNextObservers: boolean;
  77791. /**
  77792. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77793. */
  77794. mask: number;
  77795. /**
  77796. * The object that originally notified the event
  77797. */
  77798. target?: any;
  77799. /**
  77800. * The current object in the bubbling phase
  77801. */
  77802. currentTarget?: any;
  77803. /**
  77804. * This will be populated with the return value of the last function that was executed.
  77805. * If it is the first function in the callback chain it will be the event data.
  77806. */
  77807. lastReturnValue?: any;
  77808. }
  77809. /**
  77810. * Represent an Observer registered to a given Observable object.
  77811. */
  77812. export class Observer<T> {
  77813. /**
  77814. * Defines the callback to call when the observer is notified
  77815. */
  77816. callback: (eventData: T, eventState: EventState) => void;
  77817. /**
  77818. * Defines the mask of the observer (used to filter notifications)
  77819. */
  77820. mask: number;
  77821. /**
  77822. * Defines the current scope used to restore the JS context
  77823. */
  77824. scope: any;
  77825. /** @hidden */
  77826. _willBeUnregistered: boolean;
  77827. /**
  77828. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77829. */
  77830. unregisterOnNextCall: boolean;
  77831. /**
  77832. * Creates a new observer
  77833. * @param callback defines the callback to call when the observer is notified
  77834. * @param mask defines the mask of the observer (used to filter notifications)
  77835. * @param scope defines the current scope used to restore the JS context
  77836. */
  77837. constructor(
  77838. /**
  77839. * Defines the callback to call when the observer is notified
  77840. */
  77841. callback: (eventData: T, eventState: EventState) => void,
  77842. /**
  77843. * Defines the mask of the observer (used to filter notifications)
  77844. */
  77845. mask: number,
  77846. /**
  77847. * Defines the current scope used to restore the JS context
  77848. */
  77849. scope?: any);
  77850. }
  77851. /**
  77852. * Represent a list of observers registered to multiple Observables object.
  77853. */
  77854. export class MultiObserver<T> {
  77855. private _observers;
  77856. private _observables;
  77857. /**
  77858. * Release associated resources
  77859. */
  77860. dispose(): void;
  77861. /**
  77862. * Raise a callback when one of the observable will notify
  77863. * @param observables defines a list of observables to watch
  77864. * @param callback defines the callback to call on notification
  77865. * @param mask defines the mask used to filter notifications
  77866. * @param scope defines the current scope used to restore the JS context
  77867. * @returns the new MultiObserver
  77868. */
  77869. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77870. }
  77871. /**
  77872. * The Observable class is a simple implementation of the Observable pattern.
  77873. *
  77874. * 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.
  77875. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77876. * 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).
  77877. * 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.
  77878. */
  77879. export class Observable<T> {
  77880. private _observers;
  77881. private _eventState;
  77882. private _onObserverAdded;
  77883. /**
  77884. * Gets the list of observers
  77885. */
  77886. get observers(): Array<Observer<T>>;
  77887. /**
  77888. * Creates a new observable
  77889. * @param onObserverAdded defines a callback to call when a new observer is added
  77890. */
  77891. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77892. /**
  77893. * Create a new Observer with the specified callback
  77894. * @param callback the callback that will be executed for that Observer
  77895. * @param mask the mask used to filter observers
  77896. * @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.
  77897. * @param scope optional scope for the callback to be called from
  77898. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77899. * @returns the new observer created for the callback
  77900. */
  77901. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77902. /**
  77903. * Create a new Observer with the specified callback and unregisters after the next notification
  77904. * @param callback the callback that will be executed for that Observer
  77905. * @returns the new observer created for the callback
  77906. */
  77907. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77908. /**
  77909. * Remove an Observer from the Observable object
  77910. * @param observer the instance of the Observer to remove
  77911. * @returns false if it doesn't belong to this Observable
  77912. */
  77913. remove(observer: Nullable<Observer<T>>): boolean;
  77914. /**
  77915. * Remove a callback from the Observable object
  77916. * @param callback the callback to remove
  77917. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77918. * @returns false if it doesn't belong to this Observable
  77919. */
  77920. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77921. private _deferUnregister;
  77922. private _remove;
  77923. /**
  77924. * Moves the observable to the top of the observer list making it get called first when notified
  77925. * @param observer the observer to move
  77926. */
  77927. makeObserverTopPriority(observer: Observer<T>): void;
  77928. /**
  77929. * Moves the observable to the bottom of the observer list making it get called last when notified
  77930. * @param observer the observer to move
  77931. */
  77932. makeObserverBottomPriority(observer: Observer<T>): void;
  77933. /**
  77934. * Notify all Observers by calling their respective callback with the given data
  77935. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77936. * @param eventData defines the data to send to all observers
  77937. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77938. * @param target defines the original target of the state
  77939. * @param currentTarget defines the current target of the state
  77940. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77941. */
  77942. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77943. /**
  77944. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77945. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77946. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77947. * and it is crucial that all callbacks will be executed.
  77948. * The order of the callbacks is kept, callbacks are not executed parallel.
  77949. *
  77950. * @param eventData The data to be sent to each callback
  77951. * @param mask is used to filter observers defaults to -1
  77952. * @param target defines the callback target (see EventState)
  77953. * @param currentTarget defines he current object in the bubbling phase
  77954. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77955. */
  77956. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77957. /**
  77958. * Notify a specific observer
  77959. * @param observer defines the observer to notify
  77960. * @param eventData defines the data to be sent to each callback
  77961. * @param mask is used to filter observers defaults to -1
  77962. */
  77963. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77964. /**
  77965. * Gets a boolean indicating if the observable has at least one observer
  77966. * @returns true is the Observable has at least one Observer registered
  77967. */
  77968. hasObservers(): boolean;
  77969. /**
  77970. * Clear the list of observers
  77971. */
  77972. clear(): void;
  77973. /**
  77974. * Clone the current observable
  77975. * @returns a new observable
  77976. */
  77977. clone(): Observable<T>;
  77978. /**
  77979. * Does this observable handles observer registered with a given mask
  77980. * @param mask defines the mask to be tested
  77981. * @return whether or not one observer registered with the given mask is handeled
  77982. **/
  77983. hasSpecificMask(mask?: number): boolean;
  77984. }
  77985. }
  77986. declare module BABYLON {
  77987. /**
  77988. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77989. * Babylon.js
  77990. */
  77991. export class DomManagement {
  77992. /**
  77993. * Checks if the window object exists
  77994. * @returns true if the window object exists
  77995. */
  77996. static IsWindowObjectExist(): boolean;
  77997. /**
  77998. * Checks if the navigator object exists
  77999. * @returns true if the navigator object exists
  78000. */
  78001. static IsNavigatorAvailable(): boolean;
  78002. /**
  78003. * Check if the document object exists
  78004. * @returns true if the document object exists
  78005. */
  78006. static IsDocumentAvailable(): boolean;
  78007. /**
  78008. * Extracts text content from a DOM element hierarchy
  78009. * @param element defines the root element
  78010. * @returns a string
  78011. */
  78012. static GetDOMTextContent(element: HTMLElement): string;
  78013. }
  78014. }
  78015. declare module BABYLON {
  78016. /**
  78017. * Logger used througouht the application to allow configuration of
  78018. * the log level required for the messages.
  78019. */
  78020. export class Logger {
  78021. /**
  78022. * No log
  78023. */
  78024. static readonly NoneLogLevel: number;
  78025. /**
  78026. * Only message logs
  78027. */
  78028. static readonly MessageLogLevel: number;
  78029. /**
  78030. * Only warning logs
  78031. */
  78032. static readonly WarningLogLevel: number;
  78033. /**
  78034. * Only error logs
  78035. */
  78036. static readonly ErrorLogLevel: number;
  78037. /**
  78038. * All logs
  78039. */
  78040. static readonly AllLogLevel: number;
  78041. private static _LogCache;
  78042. /**
  78043. * Gets a value indicating the number of loading errors
  78044. * @ignorenaming
  78045. */
  78046. static errorsCount: number;
  78047. /**
  78048. * Callback called when a new log is added
  78049. */
  78050. static OnNewCacheEntry: (entry: string) => void;
  78051. private static _AddLogEntry;
  78052. private static _FormatMessage;
  78053. private static _LogDisabled;
  78054. private static _LogEnabled;
  78055. private static _WarnDisabled;
  78056. private static _WarnEnabled;
  78057. private static _ErrorDisabled;
  78058. private static _ErrorEnabled;
  78059. /**
  78060. * Log a message to the console
  78061. */
  78062. static Log: (message: string) => void;
  78063. /**
  78064. * Write a warning message to the console
  78065. */
  78066. static Warn: (message: string) => void;
  78067. /**
  78068. * Write an error message to the console
  78069. */
  78070. static Error: (message: string) => void;
  78071. /**
  78072. * Gets current log cache (list of logs)
  78073. */
  78074. static get LogCache(): string;
  78075. /**
  78076. * Clears the log cache
  78077. */
  78078. static ClearLogCache(): void;
  78079. /**
  78080. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78081. */
  78082. static set LogLevels(level: number);
  78083. }
  78084. }
  78085. declare module BABYLON {
  78086. /** @hidden */
  78087. export class _TypeStore {
  78088. /** @hidden */
  78089. static RegisteredTypes: {
  78090. [key: string]: Object;
  78091. };
  78092. /** @hidden */
  78093. static GetClass(fqdn: string): any;
  78094. }
  78095. }
  78096. declare module BABYLON {
  78097. /**
  78098. * Helper to manipulate strings
  78099. */
  78100. export class StringTools {
  78101. /**
  78102. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78103. * @param str Source string
  78104. * @param suffix Suffix to search for in the source string
  78105. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78106. */
  78107. static EndsWith(str: string, suffix: string): boolean;
  78108. /**
  78109. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78110. * @param str Source string
  78111. * @param suffix Suffix to search for in the source string
  78112. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78113. */
  78114. static StartsWith(str: string, suffix: string): boolean;
  78115. /**
  78116. * Decodes a buffer into a string
  78117. * @param buffer The buffer to decode
  78118. * @returns The decoded string
  78119. */
  78120. static Decode(buffer: Uint8Array | Uint16Array): string;
  78121. /**
  78122. * Encode a buffer to a base64 string
  78123. * @param buffer defines the buffer to encode
  78124. * @returns the encoded string
  78125. */
  78126. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78127. /**
  78128. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78129. * @param num the number to convert and pad
  78130. * @param length the expected length of the string
  78131. * @returns the padded string
  78132. */
  78133. static PadNumber(num: number, length: number): string;
  78134. }
  78135. }
  78136. declare module BABYLON {
  78137. /**
  78138. * Class containing a set of static utilities functions for deep copy.
  78139. */
  78140. export class DeepCopier {
  78141. /**
  78142. * Tries to copy an object by duplicating every property
  78143. * @param source defines the source object
  78144. * @param destination defines the target object
  78145. * @param doNotCopyList defines a list of properties to avoid
  78146. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78147. */
  78148. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78149. }
  78150. }
  78151. declare module BABYLON {
  78152. /**
  78153. * Class containing a set of static utilities functions for precision date
  78154. */
  78155. export class PrecisionDate {
  78156. /**
  78157. * Gets either window.performance.now() if supported or Date.now() else
  78158. */
  78159. static get Now(): number;
  78160. }
  78161. }
  78162. declare module BABYLON {
  78163. /** @hidden */
  78164. export class _DevTools {
  78165. static WarnImport(name: string): string;
  78166. }
  78167. }
  78168. declare module BABYLON {
  78169. /**
  78170. * Interface used to define the mechanism to get data from the network
  78171. */
  78172. export interface IWebRequest {
  78173. /**
  78174. * Returns client's response url
  78175. */
  78176. responseURL: string;
  78177. /**
  78178. * Returns client's status
  78179. */
  78180. status: number;
  78181. /**
  78182. * Returns client's status as a text
  78183. */
  78184. statusText: string;
  78185. }
  78186. }
  78187. declare module BABYLON {
  78188. /**
  78189. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78190. */
  78191. export class WebRequest implements IWebRequest {
  78192. private _xhr;
  78193. /**
  78194. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78195. * i.e. when loading files, where the server/service expects an Authorization header
  78196. */
  78197. static CustomRequestHeaders: {
  78198. [key: string]: string;
  78199. };
  78200. /**
  78201. * Add callback functions in this array to update all the requests before they get sent to the network
  78202. */
  78203. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78204. private _injectCustomRequestHeaders;
  78205. /**
  78206. * Gets or sets a function to be called when loading progress changes
  78207. */
  78208. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78209. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78210. /**
  78211. * Returns client's state
  78212. */
  78213. get readyState(): number;
  78214. /**
  78215. * Returns client's status
  78216. */
  78217. get status(): number;
  78218. /**
  78219. * Returns client's status as a text
  78220. */
  78221. get statusText(): string;
  78222. /**
  78223. * Returns client's response
  78224. */
  78225. get response(): any;
  78226. /**
  78227. * Returns client's response url
  78228. */
  78229. get responseURL(): string;
  78230. /**
  78231. * Returns client's response as text
  78232. */
  78233. get responseText(): string;
  78234. /**
  78235. * Gets or sets the expected response type
  78236. */
  78237. get responseType(): XMLHttpRequestResponseType;
  78238. set responseType(value: XMLHttpRequestResponseType);
  78239. /** @hidden */
  78240. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78241. /** @hidden */
  78242. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78243. /**
  78244. * Cancels any network activity
  78245. */
  78246. abort(): void;
  78247. /**
  78248. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78249. * @param body defines an optional request body
  78250. */
  78251. send(body?: Document | BodyInit | null): void;
  78252. /**
  78253. * Sets the request method, request URL
  78254. * @param method defines the method to use (GET, POST, etc..)
  78255. * @param url defines the url to connect with
  78256. */
  78257. open(method: string, url: string): void;
  78258. /**
  78259. * Sets the value of a request header.
  78260. * @param name The name of the header whose value is to be set
  78261. * @param value The value to set as the body of the header
  78262. */
  78263. setRequestHeader(name: string, value: string): void;
  78264. /**
  78265. * Get the string containing the text of a particular header's value.
  78266. * @param name The name of the header
  78267. * @returns The string containing the text of the given header name
  78268. */
  78269. getResponseHeader(name: string): Nullable<string>;
  78270. }
  78271. }
  78272. declare module BABYLON {
  78273. /**
  78274. * File request interface
  78275. */
  78276. export interface IFileRequest {
  78277. /**
  78278. * Raised when the request is complete (success or error).
  78279. */
  78280. onCompleteObservable: Observable<IFileRequest>;
  78281. /**
  78282. * Aborts the request for a file.
  78283. */
  78284. abort: () => void;
  78285. }
  78286. }
  78287. declare module BABYLON {
  78288. /**
  78289. * Define options used to create a render target texture
  78290. */
  78291. export class RenderTargetCreationOptions {
  78292. /**
  78293. * Specifies is mipmaps must be generated
  78294. */
  78295. generateMipMaps?: boolean;
  78296. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78297. generateDepthBuffer?: boolean;
  78298. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78299. generateStencilBuffer?: boolean;
  78300. /** Defines texture type (int by default) */
  78301. type?: number;
  78302. /** Defines sampling mode (trilinear by default) */
  78303. samplingMode?: number;
  78304. /** Defines format (RGBA by default) */
  78305. format?: number;
  78306. }
  78307. }
  78308. declare module BABYLON {
  78309. /** Defines the cross module used constants to avoid circular dependncies */
  78310. export class Constants {
  78311. /** Defines that alpha blending is disabled */
  78312. static readonly ALPHA_DISABLE: number;
  78313. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78314. static readonly ALPHA_ADD: number;
  78315. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78316. static readonly ALPHA_COMBINE: number;
  78317. /** Defines that alpha blending is DEST - SRC * DEST */
  78318. static readonly ALPHA_SUBTRACT: number;
  78319. /** Defines that alpha blending is SRC * DEST */
  78320. static readonly ALPHA_MULTIPLY: number;
  78321. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78322. static readonly ALPHA_MAXIMIZED: number;
  78323. /** Defines that alpha blending is SRC + DEST */
  78324. static readonly ALPHA_ONEONE: number;
  78325. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78326. static readonly ALPHA_PREMULTIPLIED: number;
  78327. /**
  78328. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78329. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78330. */
  78331. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78332. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78333. static readonly ALPHA_INTERPOLATE: number;
  78334. /**
  78335. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78336. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78337. */
  78338. static readonly ALPHA_SCREENMODE: number;
  78339. /**
  78340. * Defines that alpha blending is SRC + DST
  78341. * Alpha will be set to SRC ALPHA + DST ALPHA
  78342. */
  78343. static readonly ALPHA_ONEONE_ONEONE: number;
  78344. /**
  78345. * Defines that alpha blending is SRC * DST ALPHA + DST
  78346. * Alpha will be set to 0
  78347. */
  78348. static readonly ALPHA_ALPHATOCOLOR: number;
  78349. /**
  78350. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78351. */
  78352. static readonly ALPHA_REVERSEONEMINUS: number;
  78353. /**
  78354. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78355. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78356. */
  78357. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78358. /**
  78359. * Defines that alpha blending is SRC + DST
  78360. * Alpha will be set to SRC ALPHA
  78361. */
  78362. static readonly ALPHA_ONEONE_ONEZERO: number;
  78363. /**
  78364. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78365. * Alpha will be set to DST ALPHA
  78366. */
  78367. static readonly ALPHA_EXCLUSION: number;
  78368. /** Defines that alpha blending equation a SUM */
  78369. static readonly ALPHA_EQUATION_ADD: number;
  78370. /** Defines that alpha blending equation a SUBSTRACTION */
  78371. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78372. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78373. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78374. /** Defines that alpha blending equation a MAX operation */
  78375. static readonly ALPHA_EQUATION_MAX: number;
  78376. /** Defines that alpha blending equation a MIN operation */
  78377. static readonly ALPHA_EQUATION_MIN: number;
  78378. /**
  78379. * Defines that alpha blending equation a DARKEN operation:
  78380. * It takes the min of the src and sums the alpha channels.
  78381. */
  78382. static readonly ALPHA_EQUATION_DARKEN: number;
  78383. /** Defines that the ressource is not delayed*/
  78384. static readonly DELAYLOADSTATE_NONE: number;
  78385. /** Defines that the ressource was successfully delay loaded */
  78386. static readonly DELAYLOADSTATE_LOADED: number;
  78387. /** Defines that the ressource is currently delay loading */
  78388. static readonly DELAYLOADSTATE_LOADING: number;
  78389. /** Defines that the ressource is delayed and has not started loading */
  78390. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78392. static readonly NEVER: number;
  78393. /** 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 */
  78394. static readonly ALWAYS: number;
  78395. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78396. static readonly LESS: number;
  78397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78398. static readonly EQUAL: number;
  78399. /** 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 */
  78400. static readonly LEQUAL: number;
  78401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78402. static readonly GREATER: number;
  78403. /** 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 */
  78404. static readonly GEQUAL: number;
  78405. /** 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 */
  78406. static readonly NOTEQUAL: number;
  78407. /** Passed to stencilOperation to specify that stencil value must be kept */
  78408. static readonly KEEP: number;
  78409. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78410. static readonly REPLACE: number;
  78411. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78412. static readonly INCR: number;
  78413. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78414. static readonly DECR: number;
  78415. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78416. static readonly INVERT: number;
  78417. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78418. static readonly INCR_WRAP: number;
  78419. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78420. static readonly DECR_WRAP: number;
  78421. /** Texture is not repeating outside of 0..1 UVs */
  78422. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78423. /** Texture is repeating outside of 0..1 UVs */
  78424. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78425. /** Texture is repeating and mirrored */
  78426. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78427. /** ALPHA */
  78428. static readonly TEXTUREFORMAT_ALPHA: number;
  78429. /** LUMINANCE */
  78430. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78431. /** LUMINANCE_ALPHA */
  78432. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78433. /** RGB */
  78434. static readonly TEXTUREFORMAT_RGB: number;
  78435. /** RGBA */
  78436. static readonly TEXTUREFORMAT_RGBA: number;
  78437. /** RED */
  78438. static readonly TEXTUREFORMAT_RED: number;
  78439. /** RED (2nd reference) */
  78440. static readonly TEXTUREFORMAT_R: number;
  78441. /** RG */
  78442. static readonly TEXTUREFORMAT_RG: number;
  78443. /** RED_INTEGER */
  78444. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78445. /** RED_INTEGER (2nd reference) */
  78446. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78447. /** RG_INTEGER */
  78448. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78449. /** RGB_INTEGER */
  78450. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78451. /** RGBA_INTEGER */
  78452. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78453. /** UNSIGNED_BYTE */
  78454. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78455. /** UNSIGNED_BYTE (2nd reference) */
  78456. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78457. /** FLOAT */
  78458. static readonly TEXTURETYPE_FLOAT: number;
  78459. /** HALF_FLOAT */
  78460. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78461. /** BYTE */
  78462. static readonly TEXTURETYPE_BYTE: number;
  78463. /** SHORT */
  78464. static readonly TEXTURETYPE_SHORT: number;
  78465. /** UNSIGNED_SHORT */
  78466. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78467. /** INT */
  78468. static readonly TEXTURETYPE_INT: number;
  78469. /** UNSIGNED_INT */
  78470. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78471. /** UNSIGNED_SHORT_4_4_4_4 */
  78472. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78473. /** UNSIGNED_SHORT_5_5_5_1 */
  78474. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78475. /** UNSIGNED_SHORT_5_6_5 */
  78476. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78477. /** UNSIGNED_INT_2_10_10_10_REV */
  78478. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78479. /** UNSIGNED_INT_24_8 */
  78480. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78481. /** UNSIGNED_INT_10F_11F_11F_REV */
  78482. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78483. /** UNSIGNED_INT_5_9_9_9_REV */
  78484. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78485. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78486. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78487. /** nearest is mag = nearest and min = nearest and no mip */
  78488. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78489. /** mag = nearest and min = nearest and mip = none */
  78490. static readonly TEXTURE_NEAREST_NEAREST: number;
  78491. /** Bilinear is mag = linear and min = linear and no mip */
  78492. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78493. /** mag = linear and min = linear and mip = none */
  78494. static readonly TEXTURE_LINEAR_LINEAR: number;
  78495. /** Trilinear is mag = linear and min = linear and mip = linear */
  78496. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78497. /** Trilinear is mag = linear and min = linear and mip = linear */
  78498. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78499. /** mag = nearest and min = nearest and mip = nearest */
  78500. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78501. /** mag = nearest and min = linear and mip = nearest */
  78502. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78503. /** mag = nearest and min = linear and mip = linear */
  78504. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78505. /** mag = nearest and min = linear and mip = none */
  78506. static readonly TEXTURE_NEAREST_LINEAR: number;
  78507. /** nearest is mag = nearest and min = nearest and mip = linear */
  78508. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78509. /** mag = linear and min = nearest and mip = nearest */
  78510. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78511. /** mag = linear and min = nearest and mip = linear */
  78512. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78514. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78515. /** mag = linear and min = nearest and mip = none */
  78516. static readonly TEXTURE_LINEAR_NEAREST: number;
  78517. /** Explicit coordinates mode */
  78518. static readonly TEXTURE_EXPLICIT_MODE: number;
  78519. /** Spherical coordinates mode */
  78520. static readonly TEXTURE_SPHERICAL_MODE: number;
  78521. /** Planar coordinates mode */
  78522. static readonly TEXTURE_PLANAR_MODE: number;
  78523. /** Cubic coordinates mode */
  78524. static readonly TEXTURE_CUBIC_MODE: number;
  78525. /** Projection coordinates mode */
  78526. static readonly TEXTURE_PROJECTION_MODE: number;
  78527. /** Skybox coordinates mode */
  78528. static readonly TEXTURE_SKYBOX_MODE: number;
  78529. /** Inverse Cubic coordinates mode */
  78530. static readonly TEXTURE_INVCUBIC_MODE: number;
  78531. /** Equirectangular coordinates mode */
  78532. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78533. /** Equirectangular Fixed coordinates mode */
  78534. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78535. /** Equirectangular Fixed Mirrored coordinates mode */
  78536. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78537. /** Offline (baking) quality for texture filtering */
  78538. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78539. /** High quality for texture filtering */
  78540. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78541. /** Medium quality for texture filtering */
  78542. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78543. /** Low quality for texture filtering */
  78544. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78545. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78546. static readonly SCALEMODE_FLOOR: number;
  78547. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78548. static readonly SCALEMODE_NEAREST: number;
  78549. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78550. static readonly SCALEMODE_CEILING: number;
  78551. /**
  78552. * The dirty texture flag value
  78553. */
  78554. static readonly MATERIAL_TextureDirtyFlag: number;
  78555. /**
  78556. * The dirty light flag value
  78557. */
  78558. static readonly MATERIAL_LightDirtyFlag: number;
  78559. /**
  78560. * The dirty fresnel flag value
  78561. */
  78562. static readonly MATERIAL_FresnelDirtyFlag: number;
  78563. /**
  78564. * The dirty attribute flag value
  78565. */
  78566. static readonly MATERIAL_AttributesDirtyFlag: number;
  78567. /**
  78568. * The dirty misc flag value
  78569. */
  78570. static readonly MATERIAL_MiscDirtyFlag: number;
  78571. /**
  78572. * The all dirty flag value
  78573. */
  78574. static readonly MATERIAL_AllDirtyFlag: number;
  78575. /**
  78576. * Returns the triangle fill mode
  78577. */
  78578. static readonly MATERIAL_TriangleFillMode: number;
  78579. /**
  78580. * Returns the wireframe mode
  78581. */
  78582. static readonly MATERIAL_WireFrameFillMode: number;
  78583. /**
  78584. * Returns the point fill mode
  78585. */
  78586. static readonly MATERIAL_PointFillMode: number;
  78587. /**
  78588. * Returns the point list draw mode
  78589. */
  78590. static readonly MATERIAL_PointListDrawMode: number;
  78591. /**
  78592. * Returns the line list draw mode
  78593. */
  78594. static readonly MATERIAL_LineListDrawMode: number;
  78595. /**
  78596. * Returns the line loop draw mode
  78597. */
  78598. static readonly MATERIAL_LineLoopDrawMode: number;
  78599. /**
  78600. * Returns the line strip draw mode
  78601. */
  78602. static readonly MATERIAL_LineStripDrawMode: number;
  78603. /**
  78604. * Returns the triangle strip draw mode
  78605. */
  78606. static readonly MATERIAL_TriangleStripDrawMode: number;
  78607. /**
  78608. * Returns the triangle fan draw mode
  78609. */
  78610. static readonly MATERIAL_TriangleFanDrawMode: number;
  78611. /**
  78612. * Stores the clock-wise side orientation
  78613. */
  78614. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78615. /**
  78616. * Stores the counter clock-wise side orientation
  78617. */
  78618. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78619. /**
  78620. * Nothing
  78621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78622. */
  78623. static readonly ACTION_NothingTrigger: number;
  78624. /**
  78625. * On pick
  78626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78627. */
  78628. static readonly ACTION_OnPickTrigger: number;
  78629. /**
  78630. * On left pick
  78631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78632. */
  78633. static readonly ACTION_OnLeftPickTrigger: number;
  78634. /**
  78635. * On right pick
  78636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78637. */
  78638. static readonly ACTION_OnRightPickTrigger: number;
  78639. /**
  78640. * On center pick
  78641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78642. */
  78643. static readonly ACTION_OnCenterPickTrigger: number;
  78644. /**
  78645. * On pick down
  78646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78647. */
  78648. static readonly ACTION_OnPickDownTrigger: number;
  78649. /**
  78650. * On double pick
  78651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78652. */
  78653. static readonly ACTION_OnDoublePickTrigger: number;
  78654. /**
  78655. * On pick up
  78656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78657. */
  78658. static readonly ACTION_OnPickUpTrigger: number;
  78659. /**
  78660. * On pick out.
  78661. * This trigger will only be raised if you also declared a OnPickDown
  78662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78663. */
  78664. static readonly ACTION_OnPickOutTrigger: number;
  78665. /**
  78666. * On long press
  78667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78668. */
  78669. static readonly ACTION_OnLongPressTrigger: number;
  78670. /**
  78671. * On pointer over
  78672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78673. */
  78674. static readonly ACTION_OnPointerOverTrigger: number;
  78675. /**
  78676. * On pointer out
  78677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78678. */
  78679. static readonly ACTION_OnPointerOutTrigger: number;
  78680. /**
  78681. * On every frame
  78682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78683. */
  78684. static readonly ACTION_OnEveryFrameTrigger: number;
  78685. /**
  78686. * On intersection enter
  78687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78688. */
  78689. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78690. /**
  78691. * On intersection exit
  78692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78693. */
  78694. static readonly ACTION_OnIntersectionExitTrigger: number;
  78695. /**
  78696. * On key down
  78697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78698. */
  78699. static readonly ACTION_OnKeyDownTrigger: number;
  78700. /**
  78701. * On key up
  78702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78703. */
  78704. static readonly ACTION_OnKeyUpTrigger: number;
  78705. /**
  78706. * Billboard mode will only apply to Y axis
  78707. */
  78708. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78709. /**
  78710. * Billboard mode will apply to all axes
  78711. */
  78712. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78713. /**
  78714. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78715. */
  78716. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78717. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78718. * Test order :
  78719. * Is the bounding sphere outside the frustum ?
  78720. * If not, are the bounding box vertices outside the frustum ?
  78721. * It not, then the cullable object is in the frustum.
  78722. */
  78723. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78724. /** Culling strategy : Bounding Sphere Only.
  78725. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78726. * It's also less accurate than the standard because some not visible objects can still be selected.
  78727. * Test : is the bounding sphere outside the frustum ?
  78728. * If not, then the cullable object is in the frustum.
  78729. */
  78730. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78731. /** Culling strategy : Optimistic Inclusion.
  78732. * This in an inclusion test first, then the standard exclusion test.
  78733. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78734. * 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.
  78735. * Anyway, it's as accurate as the standard strategy.
  78736. * Test :
  78737. * Is the cullable object bounding sphere center in the frustum ?
  78738. * If not, apply the default culling strategy.
  78739. */
  78740. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78741. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78742. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78743. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78744. * 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.
  78745. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78746. * Test :
  78747. * Is the cullable object bounding sphere center in the frustum ?
  78748. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78749. */
  78750. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78751. /**
  78752. * No logging while loading
  78753. */
  78754. static readonly SCENELOADER_NO_LOGGING: number;
  78755. /**
  78756. * Minimal logging while loading
  78757. */
  78758. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78759. /**
  78760. * Summary logging while loading
  78761. */
  78762. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78763. /**
  78764. * Detailled logging while loading
  78765. */
  78766. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78767. }
  78768. }
  78769. declare module BABYLON {
  78770. /**
  78771. * This represents the required contract to create a new type of texture loader.
  78772. */
  78773. export interface IInternalTextureLoader {
  78774. /**
  78775. * Defines wether the loader supports cascade loading the different faces.
  78776. */
  78777. supportCascades: boolean;
  78778. /**
  78779. * This returns if the loader support the current file information.
  78780. * @param extension defines the file extension of the file being loaded
  78781. * @returns true if the loader can load the specified file
  78782. */
  78783. canLoad(extension: string): boolean;
  78784. /**
  78785. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78786. * @param data contains the texture data
  78787. * @param texture defines the BabylonJS internal texture
  78788. * @param createPolynomials will be true if polynomials have been requested
  78789. * @param onLoad defines the callback to trigger once the texture is ready
  78790. * @param onError defines the callback to trigger in case of error
  78791. */
  78792. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78793. /**
  78794. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78795. * @param data contains the texture data
  78796. * @param texture defines the BabylonJS internal texture
  78797. * @param callback defines the method to call once ready to upload
  78798. */
  78799. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78800. }
  78801. }
  78802. declare module BABYLON {
  78803. /**
  78804. * Class used to store and describe the pipeline context associated with an effect
  78805. */
  78806. export interface IPipelineContext {
  78807. /**
  78808. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78809. */
  78810. isAsync: boolean;
  78811. /**
  78812. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78813. */
  78814. isReady: boolean;
  78815. /** @hidden */
  78816. _getVertexShaderCode(): string | null;
  78817. /** @hidden */
  78818. _getFragmentShaderCode(): string | null;
  78819. /** @hidden */
  78820. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78821. }
  78822. }
  78823. declare module BABYLON {
  78824. /**
  78825. * Class used to store gfx data (like WebGLBuffer)
  78826. */
  78827. export class DataBuffer {
  78828. /**
  78829. * Gets or sets the number of objects referencing this buffer
  78830. */
  78831. references: number;
  78832. /** Gets or sets the size of the underlying buffer */
  78833. capacity: number;
  78834. /**
  78835. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78836. */
  78837. is32Bits: boolean;
  78838. /**
  78839. * Gets the underlying buffer
  78840. */
  78841. get underlyingResource(): any;
  78842. }
  78843. }
  78844. declare module BABYLON {
  78845. /** @hidden */
  78846. export interface IShaderProcessor {
  78847. attributeProcessor?: (attribute: string) => string;
  78848. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78849. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78850. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78851. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78852. lineProcessor?: (line: string, isFragment: boolean) => string;
  78853. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78854. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78855. }
  78856. }
  78857. declare module BABYLON {
  78858. /** @hidden */
  78859. export interface ProcessingOptions {
  78860. defines: string[];
  78861. indexParameters: any;
  78862. isFragment: boolean;
  78863. shouldUseHighPrecisionShader: boolean;
  78864. supportsUniformBuffers: boolean;
  78865. shadersRepository: string;
  78866. includesShadersStore: {
  78867. [key: string]: string;
  78868. };
  78869. processor?: IShaderProcessor;
  78870. version: string;
  78871. platformName: string;
  78872. lookForClosingBracketForUniformBuffer?: boolean;
  78873. }
  78874. }
  78875. declare module BABYLON {
  78876. /** @hidden */
  78877. export class ShaderCodeNode {
  78878. line: string;
  78879. children: ShaderCodeNode[];
  78880. additionalDefineKey?: string;
  78881. additionalDefineValue?: string;
  78882. isValid(preprocessors: {
  78883. [key: string]: string;
  78884. }): boolean;
  78885. process(preprocessors: {
  78886. [key: string]: string;
  78887. }, options: ProcessingOptions): string;
  78888. }
  78889. }
  78890. declare module BABYLON {
  78891. /** @hidden */
  78892. export class ShaderCodeCursor {
  78893. private _lines;
  78894. lineIndex: number;
  78895. get currentLine(): string;
  78896. get canRead(): boolean;
  78897. set lines(value: string[]);
  78898. }
  78899. }
  78900. declare module BABYLON {
  78901. /** @hidden */
  78902. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78903. process(preprocessors: {
  78904. [key: string]: string;
  78905. }, options: ProcessingOptions): string;
  78906. }
  78907. }
  78908. declare module BABYLON {
  78909. /** @hidden */
  78910. export class ShaderDefineExpression {
  78911. isTrue(preprocessors: {
  78912. [key: string]: string;
  78913. }): boolean;
  78914. private static _OperatorPriority;
  78915. private static _Stack;
  78916. static postfixToInfix(postfix: string[]): string;
  78917. static infixToPostfix(infix: string): string[];
  78918. }
  78919. }
  78920. declare module BABYLON {
  78921. /** @hidden */
  78922. export class ShaderCodeTestNode extends ShaderCodeNode {
  78923. testExpression: ShaderDefineExpression;
  78924. isValid(preprocessors: {
  78925. [key: string]: string;
  78926. }): boolean;
  78927. }
  78928. }
  78929. declare module BABYLON {
  78930. /** @hidden */
  78931. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78932. define: string;
  78933. not: boolean;
  78934. constructor(define: string, not?: boolean);
  78935. isTrue(preprocessors: {
  78936. [key: string]: string;
  78937. }): boolean;
  78938. }
  78939. }
  78940. declare module BABYLON {
  78941. /** @hidden */
  78942. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78943. leftOperand: ShaderDefineExpression;
  78944. rightOperand: ShaderDefineExpression;
  78945. isTrue(preprocessors: {
  78946. [key: string]: string;
  78947. }): boolean;
  78948. }
  78949. }
  78950. declare module BABYLON {
  78951. /** @hidden */
  78952. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78953. leftOperand: ShaderDefineExpression;
  78954. rightOperand: ShaderDefineExpression;
  78955. isTrue(preprocessors: {
  78956. [key: string]: string;
  78957. }): boolean;
  78958. }
  78959. }
  78960. declare module BABYLON {
  78961. /** @hidden */
  78962. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78963. define: string;
  78964. operand: string;
  78965. testValue: string;
  78966. constructor(define: string, operand: string, testValue: string);
  78967. isTrue(preprocessors: {
  78968. [key: string]: string;
  78969. }): boolean;
  78970. }
  78971. }
  78972. declare module BABYLON {
  78973. /**
  78974. * Class used to enable access to offline support
  78975. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78976. */
  78977. export interface IOfflineProvider {
  78978. /**
  78979. * Gets a boolean indicating if scene must be saved in the database
  78980. */
  78981. enableSceneOffline: boolean;
  78982. /**
  78983. * Gets a boolean indicating if textures must be saved in the database
  78984. */
  78985. enableTexturesOffline: boolean;
  78986. /**
  78987. * Open the offline support and make it available
  78988. * @param successCallback defines the callback to call on success
  78989. * @param errorCallback defines the callback to call on error
  78990. */
  78991. open(successCallback: () => void, errorCallback: () => void): void;
  78992. /**
  78993. * Loads an image from the offline support
  78994. * @param url defines the url to load from
  78995. * @param image defines the target DOM image
  78996. */
  78997. loadImage(url: string, image: HTMLImageElement): void;
  78998. /**
  78999. * Loads a file from offline support
  79000. * @param url defines the URL to load from
  79001. * @param sceneLoaded defines a callback to call on success
  79002. * @param progressCallBack defines a callback to call when progress changed
  79003. * @param errorCallback defines a callback to call on error
  79004. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79005. */
  79006. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79007. }
  79008. }
  79009. declare module BABYLON {
  79010. /**
  79011. * Class used to help managing file picking and drag'n'drop
  79012. * File Storage
  79013. */
  79014. export class FilesInputStore {
  79015. /**
  79016. * List of files ready to be loaded
  79017. */
  79018. static FilesToLoad: {
  79019. [key: string]: File;
  79020. };
  79021. }
  79022. }
  79023. declare module BABYLON {
  79024. /**
  79025. * Class used to define a retry strategy when error happens while loading assets
  79026. */
  79027. export class RetryStrategy {
  79028. /**
  79029. * Function used to defines an exponential back off strategy
  79030. * @param maxRetries defines the maximum number of retries (3 by default)
  79031. * @param baseInterval defines the interval between retries
  79032. * @returns the strategy function to use
  79033. */
  79034. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79035. }
  79036. }
  79037. declare module BABYLON {
  79038. /**
  79039. * @ignore
  79040. * Application error to support additional information when loading a file
  79041. */
  79042. export abstract class BaseError extends Error {
  79043. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79044. }
  79045. }
  79046. declare module BABYLON {
  79047. /** @ignore */
  79048. export class LoadFileError extends BaseError {
  79049. request?: WebRequest;
  79050. file?: File;
  79051. /**
  79052. * Creates a new LoadFileError
  79053. * @param message defines the message of the error
  79054. * @param request defines the optional web request
  79055. * @param file defines the optional file
  79056. */
  79057. constructor(message: string, object?: WebRequest | File);
  79058. }
  79059. /** @ignore */
  79060. export class RequestFileError extends BaseError {
  79061. request: WebRequest;
  79062. /**
  79063. * Creates a new LoadFileError
  79064. * @param message defines the message of the error
  79065. * @param request defines the optional web request
  79066. */
  79067. constructor(message: string, request: WebRequest);
  79068. }
  79069. /** @ignore */
  79070. export class ReadFileError extends BaseError {
  79071. file: File;
  79072. /**
  79073. * Creates a new ReadFileError
  79074. * @param message defines the message of the error
  79075. * @param file defines the optional file
  79076. */
  79077. constructor(message: string, file: File);
  79078. }
  79079. /**
  79080. * @hidden
  79081. */
  79082. export class FileTools {
  79083. /**
  79084. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79085. */
  79086. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79087. /**
  79088. * Gets or sets the base URL to use to load assets
  79089. */
  79090. static BaseUrl: string;
  79091. /**
  79092. * Default behaviour for cors in the application.
  79093. * It can be a string if the expected behavior is identical in the entire app.
  79094. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79095. */
  79096. static CorsBehavior: string | ((url: string | string[]) => string);
  79097. /**
  79098. * Gets or sets a function used to pre-process url before using them to load assets
  79099. */
  79100. static PreprocessUrl: (url: string) => string;
  79101. /**
  79102. * Removes unwanted characters from an url
  79103. * @param url defines the url to clean
  79104. * @returns the cleaned url
  79105. */
  79106. private static _CleanUrl;
  79107. /**
  79108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79109. * @param url define the url we are trying
  79110. * @param element define the dom element where to configure the cors policy
  79111. */
  79112. static SetCorsBehavior(url: string | string[], element: {
  79113. crossOrigin: string | null;
  79114. }): void;
  79115. /**
  79116. * Loads an image as an HTMLImageElement.
  79117. * @param input url string, ArrayBuffer, or Blob to load
  79118. * @param onLoad callback called when the image successfully loads
  79119. * @param onError callback called when the image fails to load
  79120. * @param offlineProvider offline provider for caching
  79121. * @param mimeType optional mime type
  79122. * @returns the HTMLImageElement of the loaded image
  79123. */
  79124. 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>;
  79125. /**
  79126. * Reads a file from a File object
  79127. * @param file defines the file to load
  79128. * @param onSuccess defines the callback to call when data is loaded
  79129. * @param onProgress defines the callback to call during loading process
  79130. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79131. * @param onError defines the callback to call when an error occurs
  79132. * @returns a file request object
  79133. */
  79134. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79135. /**
  79136. * Loads a file from a url
  79137. * @param url url to load
  79138. * @param onSuccess callback called when the file successfully loads
  79139. * @param onProgress callback called while file is loading (if the server supports this mode)
  79140. * @param offlineProvider defines the offline provider for caching
  79141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79142. * @param onError callback called when the file fails to load
  79143. * @returns a file request object
  79144. */
  79145. 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;
  79146. /**
  79147. * Loads a file
  79148. * @param url url to load
  79149. * @param onSuccess callback called when the file successfully loads
  79150. * @param onProgress callback called while file is loading (if the server supports this mode)
  79151. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79152. * @param onError callback called when the file fails to load
  79153. * @param onOpened callback called when the web request is opened
  79154. * @returns a file request object
  79155. */
  79156. 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;
  79157. /**
  79158. * Checks if the loaded document was accessed via `file:`-Protocol.
  79159. * @returns boolean
  79160. */
  79161. static IsFileURL(): boolean;
  79162. }
  79163. }
  79164. declare module BABYLON {
  79165. /** @hidden */
  79166. export class ShaderProcessor {
  79167. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79168. private static _ProcessPrecision;
  79169. private static _ExtractOperation;
  79170. private static _BuildSubExpression;
  79171. private static _BuildExpression;
  79172. private static _MoveCursorWithinIf;
  79173. private static _MoveCursor;
  79174. private static _EvaluatePreProcessors;
  79175. private static _PreparePreProcessors;
  79176. private static _ProcessShaderConversion;
  79177. private static _ProcessIncludes;
  79178. /**
  79179. * Loads a file from a url
  79180. * @param url url to load
  79181. * @param onSuccess callback called when the file successfully loads
  79182. * @param onProgress callback called while file is loading (if the server supports this mode)
  79183. * @param offlineProvider defines the offline provider for caching
  79184. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79185. * @param onError callback called when the file fails to load
  79186. * @returns a file request object
  79187. * @hidden
  79188. */
  79189. 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;
  79190. }
  79191. }
  79192. declare module BABYLON {
  79193. /**
  79194. * @hidden
  79195. */
  79196. export interface IColor4Like {
  79197. r: float;
  79198. g: float;
  79199. b: float;
  79200. a: float;
  79201. }
  79202. /**
  79203. * @hidden
  79204. */
  79205. export interface IColor3Like {
  79206. r: float;
  79207. g: float;
  79208. b: float;
  79209. }
  79210. /**
  79211. * @hidden
  79212. */
  79213. export interface IVector4Like {
  79214. x: float;
  79215. y: float;
  79216. z: float;
  79217. w: float;
  79218. }
  79219. /**
  79220. * @hidden
  79221. */
  79222. export interface IVector3Like {
  79223. x: float;
  79224. y: float;
  79225. z: float;
  79226. }
  79227. /**
  79228. * @hidden
  79229. */
  79230. export interface IVector2Like {
  79231. x: float;
  79232. y: float;
  79233. }
  79234. /**
  79235. * @hidden
  79236. */
  79237. export interface IMatrixLike {
  79238. toArray(): DeepImmutable<Float32Array>;
  79239. updateFlag: int;
  79240. }
  79241. /**
  79242. * @hidden
  79243. */
  79244. export interface IViewportLike {
  79245. x: float;
  79246. y: float;
  79247. width: float;
  79248. height: float;
  79249. }
  79250. /**
  79251. * @hidden
  79252. */
  79253. export interface IPlaneLike {
  79254. normal: IVector3Like;
  79255. d: float;
  79256. normalize(): void;
  79257. }
  79258. }
  79259. declare module BABYLON {
  79260. /**
  79261. * Interface used to define common properties for effect fallbacks
  79262. */
  79263. export interface IEffectFallbacks {
  79264. /**
  79265. * Removes the defines that should be removed when falling back.
  79266. * @param currentDefines defines the current define statements for the shader.
  79267. * @param effect defines the current effect we try to compile
  79268. * @returns The resulting defines with defines of the current rank removed.
  79269. */
  79270. reduce(currentDefines: string, effect: Effect): string;
  79271. /**
  79272. * Removes the fallback from the bound mesh.
  79273. */
  79274. unBindMesh(): void;
  79275. /**
  79276. * Checks to see if more fallbacks are still availible.
  79277. */
  79278. hasMoreFallbacks: boolean;
  79279. }
  79280. }
  79281. declare module BABYLON {
  79282. /**
  79283. * Class used to evalaute queries containing `and` and `or` operators
  79284. */
  79285. export class AndOrNotEvaluator {
  79286. /**
  79287. * Evaluate a query
  79288. * @param query defines the query to evaluate
  79289. * @param evaluateCallback defines the callback used to filter result
  79290. * @returns true if the query matches
  79291. */
  79292. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79293. private static _HandleParenthesisContent;
  79294. private static _SimplifyNegation;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * Class used to store custom tags
  79300. */
  79301. export class Tags {
  79302. /**
  79303. * Adds support for tags on the given object
  79304. * @param obj defines the object to use
  79305. */
  79306. static EnableFor(obj: any): void;
  79307. /**
  79308. * Removes tags support
  79309. * @param obj defines the object to use
  79310. */
  79311. static DisableFor(obj: any): void;
  79312. /**
  79313. * Gets a boolean indicating if the given object has tags
  79314. * @param obj defines the object to use
  79315. * @returns a boolean
  79316. */
  79317. static HasTags(obj: any): boolean;
  79318. /**
  79319. * Gets the tags available on a given object
  79320. * @param obj defines the object to use
  79321. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79322. * @returns the tags
  79323. */
  79324. static GetTags(obj: any, asString?: boolean): any;
  79325. /**
  79326. * Adds tags to an object
  79327. * @param obj defines the object to use
  79328. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79329. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79330. */
  79331. static AddTagsTo(obj: any, tagsString: string): void;
  79332. /**
  79333. * @hidden
  79334. */
  79335. static _AddTagTo(obj: any, tag: string): void;
  79336. /**
  79337. * Removes specific tags from a specific object
  79338. * @param obj defines the object to use
  79339. * @param tagsString defines the tags to remove
  79340. */
  79341. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79342. /**
  79343. * @hidden
  79344. */
  79345. static _RemoveTagFrom(obj: any, tag: string): void;
  79346. /**
  79347. * Defines if tags hosted on an object match a given query
  79348. * @param obj defines the object to use
  79349. * @param tagsQuery defines the tag query
  79350. * @returns a boolean
  79351. */
  79352. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79353. }
  79354. }
  79355. declare module BABYLON {
  79356. /**
  79357. * Scalar computation library
  79358. */
  79359. export class Scalar {
  79360. /**
  79361. * Two pi constants convenient for computation.
  79362. */
  79363. static TwoPi: number;
  79364. /**
  79365. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79366. * @param a number
  79367. * @param b number
  79368. * @param epsilon (default = 1.401298E-45)
  79369. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79370. */
  79371. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79372. /**
  79373. * Returns a string : the upper case translation of the number i to hexadecimal.
  79374. * @param i number
  79375. * @returns the upper case translation of the number i to hexadecimal.
  79376. */
  79377. static ToHex(i: number): string;
  79378. /**
  79379. * Returns -1 if value is negative and +1 is value is positive.
  79380. * @param value the value
  79381. * @returns the value itself if it's equal to zero.
  79382. */
  79383. static Sign(value: number): number;
  79384. /**
  79385. * Returns the value itself if it's between min and max.
  79386. * Returns min if the value is lower than min.
  79387. * Returns max if the value is greater than max.
  79388. * @param value the value to clmap
  79389. * @param min the min value to clamp to (default: 0)
  79390. * @param max the max value to clamp to (default: 1)
  79391. * @returns the clamped value
  79392. */
  79393. static Clamp(value: number, min?: number, max?: number): number;
  79394. /**
  79395. * the log2 of value.
  79396. * @param value the value to compute log2 of
  79397. * @returns the log2 of value.
  79398. */
  79399. static Log2(value: number): number;
  79400. /**
  79401. * Loops the value, so that it is never larger than length and never smaller than 0.
  79402. *
  79403. * This is similar to the modulo operator but it works with floating point numbers.
  79404. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79405. * With t = 5 and length = 2.5, the result would be 0.0.
  79406. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79407. * @param value the value
  79408. * @param length the length
  79409. * @returns the looped value
  79410. */
  79411. static Repeat(value: number, length: number): number;
  79412. /**
  79413. * Normalize the value between 0.0 and 1.0 using min and max values
  79414. * @param value value to normalize
  79415. * @param min max to normalize between
  79416. * @param max min to normalize between
  79417. * @returns the normalized value
  79418. */
  79419. static Normalize(value: number, min: number, max: number): number;
  79420. /**
  79421. * Denormalize the value from 0.0 and 1.0 using min and max values
  79422. * @param normalized value to denormalize
  79423. * @param min max to denormalize between
  79424. * @param max min to denormalize between
  79425. * @returns the denormalized value
  79426. */
  79427. static Denormalize(normalized: number, min: number, max: number): number;
  79428. /**
  79429. * Calculates the shortest difference between two given angles given in degrees.
  79430. * @param current current angle in degrees
  79431. * @param target target angle in degrees
  79432. * @returns the delta
  79433. */
  79434. static DeltaAngle(current: number, target: number): number;
  79435. /**
  79436. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79437. * @param tx value
  79438. * @param length length
  79439. * @returns The returned value will move back and forth between 0 and length
  79440. */
  79441. static PingPong(tx: number, length: number): number;
  79442. /**
  79443. * Interpolates between min and max with smoothing at the limits.
  79444. *
  79445. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79446. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79447. * @param from from
  79448. * @param to to
  79449. * @param tx value
  79450. * @returns the smooth stepped value
  79451. */
  79452. static SmoothStep(from: number, to: number, tx: number): number;
  79453. /**
  79454. * Moves a value current towards target.
  79455. *
  79456. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79457. * Negative values of maxDelta pushes the value away from target.
  79458. * @param current current value
  79459. * @param target target value
  79460. * @param maxDelta max distance to move
  79461. * @returns resulting value
  79462. */
  79463. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79464. /**
  79465. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79466. *
  79467. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79468. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79469. * @param current current value
  79470. * @param target target value
  79471. * @param maxDelta max distance to move
  79472. * @returns resulting angle
  79473. */
  79474. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79475. /**
  79476. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79477. * @param start start value
  79478. * @param end target value
  79479. * @param amount amount to lerp between
  79480. * @returns the lerped value
  79481. */
  79482. static Lerp(start: number, end: number, amount: number): number;
  79483. /**
  79484. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79485. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79486. * @param start start value
  79487. * @param end target value
  79488. * @param amount amount to lerp between
  79489. * @returns the lerped value
  79490. */
  79491. static LerpAngle(start: number, end: number, amount: number): number;
  79492. /**
  79493. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79494. * @param a start value
  79495. * @param b target value
  79496. * @param value value between a and b
  79497. * @returns the inverseLerp value
  79498. */
  79499. static InverseLerp(a: number, b: number, value: number): number;
  79500. /**
  79501. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79502. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79503. * @param value1 spline value
  79504. * @param tangent1 spline value
  79505. * @param value2 spline value
  79506. * @param tangent2 spline value
  79507. * @param amount input value
  79508. * @returns hermite result
  79509. */
  79510. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79511. /**
  79512. * Returns a random float number between and min and max values
  79513. * @param min min value of random
  79514. * @param max max value of random
  79515. * @returns random value
  79516. */
  79517. static RandomRange(min: number, max: number): number;
  79518. /**
  79519. * This function returns percentage of a number in a given range.
  79520. *
  79521. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79522. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79523. * @param number to convert to percentage
  79524. * @param min min range
  79525. * @param max max range
  79526. * @returns the percentage
  79527. */
  79528. static RangeToPercent(number: number, min: number, max: number): number;
  79529. /**
  79530. * This function returns number that corresponds to the percentage in a given range.
  79531. *
  79532. * PercentToRange(0.34,0,100) will return 34.
  79533. * @param percent to convert to number
  79534. * @param min min range
  79535. * @param max max range
  79536. * @returns the number
  79537. */
  79538. static PercentToRange(percent: number, min: number, max: number): number;
  79539. /**
  79540. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79541. * @param angle The angle to normalize in radian.
  79542. * @return The converted angle.
  79543. */
  79544. static NormalizeRadians(angle: number): number;
  79545. }
  79546. }
  79547. declare module BABYLON {
  79548. /**
  79549. * Constant used to convert a value to gamma space
  79550. * @ignorenaming
  79551. */
  79552. export const ToGammaSpace: number;
  79553. /**
  79554. * Constant used to convert a value to linear space
  79555. * @ignorenaming
  79556. */
  79557. export const ToLinearSpace = 2.2;
  79558. /**
  79559. * Constant used to define the minimal number value in Babylon.js
  79560. * @ignorenaming
  79561. */
  79562. let Epsilon: number;
  79563. }
  79564. declare module BABYLON {
  79565. /**
  79566. * Class used to represent a viewport on screen
  79567. */
  79568. export class Viewport {
  79569. /** viewport left coordinate */
  79570. x: number;
  79571. /** viewport top coordinate */
  79572. y: number;
  79573. /**viewport width */
  79574. width: number;
  79575. /** viewport height */
  79576. height: number;
  79577. /**
  79578. * Creates a Viewport object located at (x, y) and sized (width, height)
  79579. * @param x defines viewport left coordinate
  79580. * @param y defines viewport top coordinate
  79581. * @param width defines the viewport width
  79582. * @param height defines the viewport height
  79583. */
  79584. constructor(
  79585. /** viewport left coordinate */
  79586. x: number,
  79587. /** viewport top coordinate */
  79588. y: number,
  79589. /**viewport width */
  79590. width: number,
  79591. /** viewport height */
  79592. height: number);
  79593. /**
  79594. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79595. * @param renderWidth defines the rendering width
  79596. * @param renderHeight defines the rendering height
  79597. * @returns a new Viewport
  79598. */
  79599. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79600. /**
  79601. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79602. * @param renderWidth defines the rendering width
  79603. * @param renderHeight defines the rendering height
  79604. * @param ref defines the target viewport
  79605. * @returns the current viewport
  79606. */
  79607. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79608. /**
  79609. * Returns a new Viewport copied from the current one
  79610. * @returns a new Viewport
  79611. */
  79612. clone(): Viewport;
  79613. }
  79614. }
  79615. declare module BABYLON {
  79616. /**
  79617. * Class containing a set of static utilities functions for arrays.
  79618. */
  79619. export class ArrayTools {
  79620. /**
  79621. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79622. * @param size the number of element to construct and put in the array
  79623. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79624. * @returns a new array filled with new objects
  79625. */
  79626. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79627. }
  79628. }
  79629. declare module BABYLON {
  79630. /**
  79631. * Represents a plane by the equation ax + by + cz + d = 0
  79632. */
  79633. export class Plane {
  79634. private static _TmpMatrix;
  79635. /**
  79636. * Normal of the plane (a,b,c)
  79637. */
  79638. normal: Vector3;
  79639. /**
  79640. * d component of the plane
  79641. */
  79642. d: number;
  79643. /**
  79644. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79645. * @param a a component of the plane
  79646. * @param b b component of the plane
  79647. * @param c c component of the plane
  79648. * @param d d component of the plane
  79649. */
  79650. constructor(a: number, b: number, c: number, d: number);
  79651. /**
  79652. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79653. */
  79654. asArray(): number[];
  79655. /**
  79656. * @returns a new plane copied from the current Plane.
  79657. */
  79658. clone(): Plane;
  79659. /**
  79660. * @returns the string "Plane".
  79661. */
  79662. getClassName(): string;
  79663. /**
  79664. * @returns the Plane hash code.
  79665. */
  79666. getHashCode(): number;
  79667. /**
  79668. * Normalize the current Plane in place.
  79669. * @returns the updated Plane.
  79670. */
  79671. normalize(): Plane;
  79672. /**
  79673. * Applies a transformation the plane and returns the result
  79674. * @param transformation the transformation matrix to be applied to the plane
  79675. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79676. */
  79677. transform(transformation: DeepImmutable<Matrix>): Plane;
  79678. /**
  79679. * Compute the dot product between the point and the plane normal
  79680. * @param point point to calculate the dot product with
  79681. * @returns the dot product (float) of the point coordinates and the plane normal.
  79682. */
  79683. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79684. /**
  79685. * Updates the current Plane from the plane defined by the three given points.
  79686. * @param point1 one of the points used to contruct the plane
  79687. * @param point2 one of the points used to contruct the plane
  79688. * @param point3 one of the points used to contruct the plane
  79689. * @returns the updated Plane.
  79690. */
  79691. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79692. /**
  79693. * Checks if the plane is facing a given direction
  79694. * @param direction the direction to check if the plane is facing
  79695. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79696. * @returns True is the vector "direction" is the same side than the plane normal.
  79697. */
  79698. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79699. /**
  79700. * Calculates the distance to a point
  79701. * @param point point to calculate distance to
  79702. * @returns the signed distance (float) from the given point to the Plane.
  79703. */
  79704. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79705. /**
  79706. * Creates a plane from an array
  79707. * @param array the array to create a plane from
  79708. * @returns a new Plane from the given array.
  79709. */
  79710. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79711. /**
  79712. * Creates a plane from three points
  79713. * @param point1 point used to create the plane
  79714. * @param point2 point used to create the plane
  79715. * @param point3 point used to create the plane
  79716. * @returns a new Plane defined by the three given points.
  79717. */
  79718. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79719. /**
  79720. * Creates a plane from an origin point and a normal
  79721. * @param origin origin of the plane to be constructed
  79722. * @param normal normal of the plane to be constructed
  79723. * @returns a new Plane the normal vector to this plane at the given origin point.
  79724. * Note : the vector "normal" is updated because normalized.
  79725. */
  79726. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79727. /**
  79728. * Calculates the distance from a plane and a point
  79729. * @param origin origin of the plane to be constructed
  79730. * @param normal normal of the plane to be constructed
  79731. * @param point point to calculate distance to
  79732. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79733. */
  79734. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79735. }
  79736. }
  79737. declare module BABYLON {
  79738. /**
  79739. * Class representing a vector containing 2 coordinates
  79740. */
  79741. export class Vector2 {
  79742. /** defines the first coordinate */
  79743. x: number;
  79744. /** defines the second coordinate */
  79745. y: number;
  79746. /**
  79747. * Creates a new Vector2 from the given x and y coordinates
  79748. * @param x defines the first coordinate
  79749. * @param y defines the second coordinate
  79750. */
  79751. constructor(
  79752. /** defines the first coordinate */
  79753. x?: number,
  79754. /** defines the second coordinate */
  79755. y?: number);
  79756. /**
  79757. * Gets a string with the Vector2 coordinates
  79758. * @returns a string with the Vector2 coordinates
  79759. */
  79760. toString(): string;
  79761. /**
  79762. * Gets class name
  79763. * @returns the string "Vector2"
  79764. */
  79765. getClassName(): string;
  79766. /**
  79767. * Gets current vector hash code
  79768. * @returns the Vector2 hash code as a number
  79769. */
  79770. getHashCode(): number;
  79771. /**
  79772. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79773. * @param array defines the source array
  79774. * @param index defines the offset in source array
  79775. * @returns the current Vector2
  79776. */
  79777. toArray(array: FloatArray, index?: number): Vector2;
  79778. /**
  79779. * Copy the current vector to an array
  79780. * @returns a new array with 2 elements: the Vector2 coordinates.
  79781. */
  79782. asArray(): number[];
  79783. /**
  79784. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79785. * @param source defines the source Vector2
  79786. * @returns the current updated Vector2
  79787. */
  79788. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79789. /**
  79790. * Sets the Vector2 coordinates with the given floats
  79791. * @param x defines the first coordinate
  79792. * @param y defines the second coordinate
  79793. * @returns the current updated Vector2
  79794. */
  79795. copyFromFloats(x: number, y: number): Vector2;
  79796. /**
  79797. * Sets the Vector2 coordinates with the given floats
  79798. * @param x defines the first coordinate
  79799. * @param y defines the second coordinate
  79800. * @returns the current updated Vector2
  79801. */
  79802. set(x: number, y: number): Vector2;
  79803. /**
  79804. * Add another vector with the current one
  79805. * @param otherVector defines the other vector
  79806. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79807. */
  79808. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79809. /**
  79810. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79811. * @param otherVector defines the other vector
  79812. * @param result defines the target vector
  79813. * @returns the unmodified current Vector2
  79814. */
  79815. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79816. /**
  79817. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79818. * @param otherVector defines the other vector
  79819. * @returns the current updated Vector2
  79820. */
  79821. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79822. /**
  79823. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79824. * @param otherVector defines the other vector
  79825. * @returns a new Vector2
  79826. */
  79827. addVector3(otherVector: Vector3): Vector2;
  79828. /**
  79829. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79830. * @param otherVector defines the other vector
  79831. * @returns a new Vector2
  79832. */
  79833. subtract(otherVector: Vector2): Vector2;
  79834. /**
  79835. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79836. * @param otherVector defines the other vector
  79837. * @param result defines the target vector
  79838. * @returns the unmodified current Vector2
  79839. */
  79840. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79841. /**
  79842. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79843. * @param otherVector defines the other vector
  79844. * @returns the current updated Vector2
  79845. */
  79846. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79847. /**
  79848. * Multiplies in place the current Vector2 coordinates by the given ones
  79849. * @param otherVector defines the other vector
  79850. * @returns the current updated Vector2
  79851. */
  79852. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79853. /**
  79854. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79855. * @param otherVector defines the other vector
  79856. * @returns a new Vector2
  79857. */
  79858. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79859. /**
  79860. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79861. * @param otherVector defines the other vector
  79862. * @param result defines the target vector
  79863. * @returns the unmodified current Vector2
  79864. */
  79865. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79866. /**
  79867. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79868. * @param x defines the first coordinate
  79869. * @param y defines the second coordinate
  79870. * @returns a new Vector2
  79871. */
  79872. multiplyByFloats(x: number, y: number): Vector2;
  79873. /**
  79874. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79875. * @param otherVector defines the other vector
  79876. * @returns a new Vector2
  79877. */
  79878. divide(otherVector: Vector2): Vector2;
  79879. /**
  79880. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79881. * @param otherVector defines the other vector
  79882. * @param result defines the target vector
  79883. * @returns the unmodified current Vector2
  79884. */
  79885. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79886. /**
  79887. * Divides the current Vector2 coordinates by the given ones
  79888. * @param otherVector defines the other vector
  79889. * @returns the current updated Vector2
  79890. */
  79891. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79892. /**
  79893. * Gets a new Vector2 with current Vector2 negated coordinates
  79894. * @returns a new Vector2
  79895. */
  79896. negate(): Vector2;
  79897. /**
  79898. * Negate this vector in place
  79899. * @returns this
  79900. */
  79901. negateInPlace(): Vector2;
  79902. /**
  79903. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79904. * @param result defines the Vector3 object where to store the result
  79905. * @returns the current Vector2
  79906. */
  79907. negateToRef(result: Vector2): Vector2;
  79908. /**
  79909. * Multiply the Vector2 coordinates by scale
  79910. * @param scale defines the scaling factor
  79911. * @returns the current updated Vector2
  79912. */
  79913. scaleInPlace(scale: number): Vector2;
  79914. /**
  79915. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79916. * @param scale defines the scaling factor
  79917. * @returns a new Vector2
  79918. */
  79919. scale(scale: number): Vector2;
  79920. /**
  79921. * Scale the current Vector2 values by a factor to a given Vector2
  79922. * @param scale defines the scale factor
  79923. * @param result defines the Vector2 object where to store the result
  79924. * @returns the unmodified current Vector2
  79925. */
  79926. scaleToRef(scale: number, result: Vector2): Vector2;
  79927. /**
  79928. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79929. * @param scale defines the scale factor
  79930. * @param result defines the Vector2 object where to store the result
  79931. * @returns the unmodified current Vector2
  79932. */
  79933. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79934. /**
  79935. * Gets a boolean if two vectors are equals
  79936. * @param otherVector defines the other vector
  79937. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79938. */
  79939. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79940. /**
  79941. * Gets a boolean if two vectors are equals (using an epsilon value)
  79942. * @param otherVector defines the other vector
  79943. * @param epsilon defines the minimal distance to consider equality
  79944. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79945. */
  79946. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79947. /**
  79948. * Gets a new Vector2 from current Vector2 floored values
  79949. * @returns a new Vector2
  79950. */
  79951. floor(): Vector2;
  79952. /**
  79953. * Gets a new Vector2 from current Vector2 floored values
  79954. * @returns a new Vector2
  79955. */
  79956. fract(): Vector2;
  79957. /**
  79958. * Gets the length of the vector
  79959. * @returns the vector length (float)
  79960. */
  79961. length(): number;
  79962. /**
  79963. * Gets the vector squared length
  79964. * @returns the vector squared length (float)
  79965. */
  79966. lengthSquared(): number;
  79967. /**
  79968. * Normalize the vector
  79969. * @returns the current updated Vector2
  79970. */
  79971. normalize(): Vector2;
  79972. /**
  79973. * Gets a new Vector2 copied from the Vector2
  79974. * @returns a new Vector2
  79975. */
  79976. clone(): Vector2;
  79977. /**
  79978. * Gets a new Vector2(0, 0)
  79979. * @returns a new Vector2
  79980. */
  79981. static Zero(): Vector2;
  79982. /**
  79983. * Gets a new Vector2(1, 1)
  79984. * @returns a new Vector2
  79985. */
  79986. static One(): Vector2;
  79987. /**
  79988. * Gets a new Vector2 set from the given index element of the given array
  79989. * @param array defines the data source
  79990. * @param offset defines the offset in the data source
  79991. * @returns a new Vector2
  79992. */
  79993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79994. /**
  79995. * Sets "result" from the given index element of the given array
  79996. * @param array defines the data source
  79997. * @param offset defines the offset in the data source
  79998. * @param result defines the target vector
  79999. */
  80000. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80001. /**
  80002. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80003. * @param value1 defines 1st point of control
  80004. * @param value2 defines 2nd point of control
  80005. * @param value3 defines 3rd point of control
  80006. * @param value4 defines 4th point of control
  80007. * @param amount defines the interpolation factor
  80008. * @returns a new Vector2
  80009. */
  80010. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80011. /**
  80012. * 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".
  80013. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80014. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80015. * @param value defines the value to clamp
  80016. * @param min defines the lower limit
  80017. * @param max defines the upper limit
  80018. * @returns a new Vector2
  80019. */
  80020. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80021. /**
  80022. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80023. * @param value1 defines the 1st control point
  80024. * @param tangent1 defines the outgoing tangent
  80025. * @param value2 defines the 2nd control point
  80026. * @param tangent2 defines the incoming tangent
  80027. * @param amount defines the interpolation factor
  80028. * @returns a new Vector2
  80029. */
  80030. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80031. /**
  80032. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80033. * @param start defines the start vector
  80034. * @param end defines the end vector
  80035. * @param amount defines the interpolation factor
  80036. * @returns a new Vector2
  80037. */
  80038. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80039. /**
  80040. * Gets the dot product of the vector "left" and the vector "right"
  80041. * @param left defines first vector
  80042. * @param right defines second vector
  80043. * @returns the dot product (float)
  80044. */
  80045. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80046. /**
  80047. * Returns a new Vector2 equal to the normalized given vector
  80048. * @param vector defines the vector to normalize
  80049. * @returns a new Vector2
  80050. */
  80051. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80052. /**
  80053. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80054. * @param left defines 1st vector
  80055. * @param right defines 2nd vector
  80056. * @returns a new Vector2
  80057. */
  80058. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80059. /**
  80060. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80061. * @param left defines 1st vector
  80062. * @param right defines 2nd vector
  80063. * @returns a new Vector2
  80064. */
  80065. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80066. /**
  80067. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80068. * @param vector defines the vector to transform
  80069. * @param transformation defines the matrix to apply
  80070. * @returns a new Vector2
  80071. */
  80072. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80073. /**
  80074. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80075. * @param vector defines the vector to transform
  80076. * @param transformation defines the matrix to apply
  80077. * @param result defines the target vector
  80078. */
  80079. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80080. /**
  80081. * Determines if a given vector is included in a triangle
  80082. * @param p defines the vector to test
  80083. * @param p0 defines 1st triangle point
  80084. * @param p1 defines 2nd triangle point
  80085. * @param p2 defines 3rd triangle point
  80086. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80087. */
  80088. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80089. /**
  80090. * Gets the distance between the vectors "value1" and "value2"
  80091. * @param value1 defines first vector
  80092. * @param value2 defines second vector
  80093. * @returns the distance between vectors
  80094. */
  80095. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80096. /**
  80097. * Returns the squared distance between the vectors "value1" and "value2"
  80098. * @param value1 defines first vector
  80099. * @param value2 defines second vector
  80100. * @returns the squared distance between vectors
  80101. */
  80102. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80103. /**
  80104. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80105. * @param value1 defines first vector
  80106. * @param value2 defines second vector
  80107. * @returns a new Vector2
  80108. */
  80109. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80110. /**
  80111. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80112. * @param p defines the middle point
  80113. * @param segA defines one point of the segment
  80114. * @param segB defines the other point of the segment
  80115. * @returns the shortest distance
  80116. */
  80117. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80118. }
  80119. /**
  80120. * Class used to store (x,y,z) vector representation
  80121. * A Vector3 is the main object used in 3D geometry
  80122. * It can represent etiher the coordinates of a point the space, either a direction
  80123. * Reminder: js uses a left handed forward facing system
  80124. */
  80125. export class Vector3 {
  80126. /**
  80127. * Defines the first coordinates (on X axis)
  80128. */
  80129. x: number;
  80130. /**
  80131. * Defines the second coordinates (on Y axis)
  80132. */
  80133. y: number;
  80134. /**
  80135. * Defines the third coordinates (on Z axis)
  80136. */
  80137. z: number;
  80138. private static _UpReadOnly;
  80139. private static _ZeroReadOnly;
  80140. /**
  80141. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80142. * @param x defines the first coordinates (on X axis)
  80143. * @param y defines the second coordinates (on Y axis)
  80144. * @param z defines the third coordinates (on Z axis)
  80145. */
  80146. constructor(
  80147. /**
  80148. * Defines the first coordinates (on X axis)
  80149. */
  80150. x?: number,
  80151. /**
  80152. * Defines the second coordinates (on Y axis)
  80153. */
  80154. y?: number,
  80155. /**
  80156. * Defines the third coordinates (on Z axis)
  80157. */
  80158. z?: number);
  80159. /**
  80160. * Creates a string representation of the Vector3
  80161. * @returns a string with the Vector3 coordinates.
  80162. */
  80163. toString(): string;
  80164. /**
  80165. * Gets the class name
  80166. * @returns the string "Vector3"
  80167. */
  80168. getClassName(): string;
  80169. /**
  80170. * Creates the Vector3 hash code
  80171. * @returns a number which tends to be unique between Vector3 instances
  80172. */
  80173. getHashCode(): number;
  80174. /**
  80175. * Creates an array containing three elements : the coordinates of the Vector3
  80176. * @returns a new array of numbers
  80177. */
  80178. asArray(): number[];
  80179. /**
  80180. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80181. * @param array defines the destination array
  80182. * @param index defines the offset in the destination array
  80183. * @returns the current Vector3
  80184. */
  80185. toArray(array: FloatArray, index?: number): Vector3;
  80186. /**
  80187. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80188. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80189. */
  80190. toQuaternion(): Quaternion;
  80191. /**
  80192. * Adds the given vector to the current Vector3
  80193. * @param otherVector defines the second operand
  80194. * @returns the current updated Vector3
  80195. */
  80196. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80197. /**
  80198. * Adds the given coordinates to the current Vector3
  80199. * @param x defines the x coordinate of the operand
  80200. * @param y defines the y coordinate of the operand
  80201. * @param z defines the z coordinate of the operand
  80202. * @returns the current updated Vector3
  80203. */
  80204. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80205. /**
  80206. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80207. * @param otherVector defines the second operand
  80208. * @returns the resulting Vector3
  80209. */
  80210. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80211. /**
  80212. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80213. * @param otherVector defines the second operand
  80214. * @param result defines the Vector3 object where to store the result
  80215. * @returns the current Vector3
  80216. */
  80217. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80218. /**
  80219. * Subtract the given vector from the current Vector3
  80220. * @param otherVector defines the second operand
  80221. * @returns the current updated Vector3
  80222. */
  80223. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80224. /**
  80225. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80226. * @param otherVector defines the second operand
  80227. * @returns the resulting Vector3
  80228. */
  80229. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80230. /**
  80231. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80232. * @param otherVector defines the second operand
  80233. * @param result defines the Vector3 object where to store the result
  80234. * @returns the current Vector3
  80235. */
  80236. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80237. /**
  80238. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80239. * @param x defines the x coordinate of the operand
  80240. * @param y defines the y coordinate of the operand
  80241. * @param z defines the z coordinate of the operand
  80242. * @returns the resulting Vector3
  80243. */
  80244. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80245. /**
  80246. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80247. * @param x defines the x coordinate of the operand
  80248. * @param y defines the y coordinate of the operand
  80249. * @param z defines the z coordinate of the operand
  80250. * @param result defines the Vector3 object where to store the result
  80251. * @returns the current Vector3
  80252. */
  80253. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80254. /**
  80255. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80256. * @returns a new Vector3
  80257. */
  80258. negate(): Vector3;
  80259. /**
  80260. * Negate this vector in place
  80261. * @returns this
  80262. */
  80263. negateInPlace(): Vector3;
  80264. /**
  80265. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80266. * @param result defines the Vector3 object where to store the result
  80267. * @returns the current Vector3
  80268. */
  80269. negateToRef(result: Vector3): Vector3;
  80270. /**
  80271. * Multiplies the Vector3 coordinates by the float "scale"
  80272. * @param scale defines the multiplier factor
  80273. * @returns the current updated Vector3
  80274. */
  80275. scaleInPlace(scale: number): Vector3;
  80276. /**
  80277. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80278. * @param scale defines the multiplier factor
  80279. * @returns a new Vector3
  80280. */
  80281. scale(scale: number): Vector3;
  80282. /**
  80283. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80284. * @param scale defines the multiplier factor
  80285. * @param result defines the Vector3 object where to store the result
  80286. * @returns the current Vector3
  80287. */
  80288. scaleToRef(scale: number, result: Vector3): Vector3;
  80289. /**
  80290. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80291. * @param scale defines the scale factor
  80292. * @param result defines the Vector3 object where to store the result
  80293. * @returns the unmodified current Vector3
  80294. */
  80295. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80296. /**
  80297. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80298. * @param origin defines the origin of the projection ray
  80299. * @param plane defines the plane to project to
  80300. * @returns the projected vector3
  80301. */
  80302. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80303. /**
  80304. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80305. * @param origin defines the origin of the projection ray
  80306. * @param plane defines the plane to project to
  80307. * @param result defines the Vector3 where to store the result
  80308. */
  80309. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80310. /**
  80311. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80312. * @param otherVector defines the second operand
  80313. * @returns true if both vectors are equals
  80314. */
  80315. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80316. /**
  80317. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80318. * @param otherVector defines the second operand
  80319. * @param epsilon defines the minimal distance to define values as equals
  80320. * @returns true if both vectors are distant less than epsilon
  80321. */
  80322. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80323. /**
  80324. * Returns true if the current Vector3 coordinates equals the given floats
  80325. * @param x defines the x coordinate of the operand
  80326. * @param y defines the y coordinate of the operand
  80327. * @param z defines the z coordinate of the operand
  80328. * @returns true if both vectors are equals
  80329. */
  80330. equalsToFloats(x: number, y: number, z: number): boolean;
  80331. /**
  80332. * Multiplies the current Vector3 coordinates by the given ones
  80333. * @param otherVector defines the second operand
  80334. * @returns the current updated Vector3
  80335. */
  80336. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80337. /**
  80338. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80339. * @param otherVector defines the second operand
  80340. * @returns the new Vector3
  80341. */
  80342. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80343. /**
  80344. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80345. * @param otherVector defines the second operand
  80346. * @param result defines the Vector3 object where to store the result
  80347. * @returns the current Vector3
  80348. */
  80349. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80350. /**
  80351. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80352. * @param x defines the x coordinate of the operand
  80353. * @param y defines the y coordinate of the operand
  80354. * @param z defines the z coordinate of the operand
  80355. * @returns the new Vector3
  80356. */
  80357. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80358. /**
  80359. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80360. * @param otherVector defines the second operand
  80361. * @returns the new Vector3
  80362. */
  80363. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80364. /**
  80365. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80366. * @param otherVector defines the second operand
  80367. * @param result defines the Vector3 object where to store the result
  80368. * @returns the current Vector3
  80369. */
  80370. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80371. /**
  80372. * Divides the current Vector3 coordinates by the given ones.
  80373. * @param otherVector defines the second operand
  80374. * @returns the current updated Vector3
  80375. */
  80376. divideInPlace(otherVector: Vector3): Vector3;
  80377. /**
  80378. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80379. * @param other defines the second operand
  80380. * @returns the current updated Vector3
  80381. */
  80382. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80383. /**
  80384. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80385. * @param other defines the second operand
  80386. * @returns the current updated Vector3
  80387. */
  80388. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80389. /**
  80390. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80391. * @param x defines the x coordinate of the operand
  80392. * @param y defines the y coordinate of the operand
  80393. * @param z defines the z coordinate of the operand
  80394. * @returns the current updated Vector3
  80395. */
  80396. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80397. /**
  80398. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80399. * @param x defines the x coordinate of the operand
  80400. * @param y defines the y coordinate of the operand
  80401. * @param z defines the z coordinate of the operand
  80402. * @returns the current updated Vector3
  80403. */
  80404. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80405. /**
  80406. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80407. * Check if is non uniform within a certain amount of decimal places to account for this
  80408. * @param epsilon the amount the values can differ
  80409. * @returns if the the vector is non uniform to a certain number of decimal places
  80410. */
  80411. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80412. /**
  80413. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80414. */
  80415. get isNonUniform(): boolean;
  80416. /**
  80417. * Gets a new Vector3 from current Vector3 floored values
  80418. * @returns a new Vector3
  80419. */
  80420. floor(): Vector3;
  80421. /**
  80422. * Gets a new Vector3 from current Vector3 floored values
  80423. * @returns a new Vector3
  80424. */
  80425. fract(): Vector3;
  80426. /**
  80427. * Gets the length of the Vector3
  80428. * @returns the length of the Vector3
  80429. */
  80430. length(): number;
  80431. /**
  80432. * Gets the squared length of the Vector3
  80433. * @returns squared length of the Vector3
  80434. */
  80435. lengthSquared(): number;
  80436. /**
  80437. * Normalize the current Vector3.
  80438. * Please note that this is an in place operation.
  80439. * @returns the current updated Vector3
  80440. */
  80441. normalize(): Vector3;
  80442. /**
  80443. * Reorders the x y z properties of the vector in place
  80444. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80445. * @returns the current updated vector
  80446. */
  80447. reorderInPlace(order: string): this;
  80448. /**
  80449. * Rotates the vector around 0,0,0 by a quaternion
  80450. * @param quaternion the rotation quaternion
  80451. * @param result vector to store the result
  80452. * @returns the resulting vector
  80453. */
  80454. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80455. /**
  80456. * Rotates a vector around a given point
  80457. * @param quaternion the rotation quaternion
  80458. * @param point the point to rotate around
  80459. * @param result vector to store the result
  80460. * @returns the resulting vector
  80461. */
  80462. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80463. /**
  80464. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80465. * The cross product is then orthogonal to both current and "other"
  80466. * @param other defines the right operand
  80467. * @returns the cross product
  80468. */
  80469. cross(other: Vector3): Vector3;
  80470. /**
  80471. * Normalize the current Vector3 with the given input length.
  80472. * Please note that this is an in place operation.
  80473. * @param len the length of the vector
  80474. * @returns the current updated Vector3
  80475. */
  80476. normalizeFromLength(len: number): Vector3;
  80477. /**
  80478. * Normalize the current Vector3 to a new vector
  80479. * @returns the new Vector3
  80480. */
  80481. normalizeToNew(): Vector3;
  80482. /**
  80483. * Normalize the current Vector3 to the reference
  80484. * @param reference define the Vector3 to update
  80485. * @returns the updated Vector3
  80486. */
  80487. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  80488. /**
  80489. * Creates a new Vector3 copied from the current Vector3
  80490. * @returns the new Vector3
  80491. */
  80492. clone(): Vector3;
  80493. /**
  80494. * Copies the given vector coordinates to the current Vector3 ones
  80495. * @param source defines the source Vector3
  80496. * @returns the current updated Vector3
  80497. */
  80498. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80499. /**
  80500. * Copies the given floats to the current Vector3 coordinates
  80501. * @param x defines the x coordinate of the operand
  80502. * @param y defines the y coordinate of the operand
  80503. * @param z defines the z coordinate of the operand
  80504. * @returns the current updated Vector3
  80505. */
  80506. copyFromFloats(x: number, y: number, z: number): Vector3;
  80507. /**
  80508. * Copies the given floats to the current Vector3 coordinates
  80509. * @param x defines the x coordinate of the operand
  80510. * @param y defines the y coordinate of the operand
  80511. * @param z defines the z coordinate of the operand
  80512. * @returns the current updated Vector3
  80513. */
  80514. set(x: number, y: number, z: number): Vector3;
  80515. /**
  80516. * Copies the given float to the current Vector3 coordinates
  80517. * @param v defines the x, y and z coordinates of the operand
  80518. * @returns the current updated Vector3
  80519. */
  80520. setAll(v: number): Vector3;
  80521. /**
  80522. * Get the clip factor between two vectors
  80523. * @param vector0 defines the first operand
  80524. * @param vector1 defines the second operand
  80525. * @param axis defines the axis to use
  80526. * @param size defines the size along the axis
  80527. * @returns the clip factor
  80528. */
  80529. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80530. /**
  80531. * Get angle between two vectors
  80532. * @param vector0 angle between vector0 and vector1
  80533. * @param vector1 angle between vector0 and vector1
  80534. * @param normal direction of the normal
  80535. * @return the angle between vector0 and vector1
  80536. */
  80537. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80538. /**
  80539. * Returns a new Vector3 set from the index "offset" of the given array
  80540. * @param array defines the source array
  80541. * @param offset defines the offset in the source array
  80542. * @returns the new Vector3
  80543. */
  80544. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80545. /**
  80546. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80547. * @param array defines the source array
  80548. * @param offset defines the offset in the source array
  80549. * @returns the new Vector3
  80550. * @deprecated Please use FromArray instead.
  80551. */
  80552. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80553. /**
  80554. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80555. * @param array defines the source array
  80556. * @param offset defines the offset in the source array
  80557. * @param result defines the Vector3 where to store the result
  80558. */
  80559. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80560. /**
  80561. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80562. * @param array defines the source array
  80563. * @param offset defines the offset in the source array
  80564. * @param result defines the Vector3 where to store the result
  80565. * @deprecated Please use FromArrayToRef instead.
  80566. */
  80567. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80568. /**
  80569. * Sets the given vector "result" with the given floats.
  80570. * @param x defines the x coordinate of the source
  80571. * @param y defines the y coordinate of the source
  80572. * @param z defines the z coordinate of the source
  80573. * @param result defines the Vector3 where to store the result
  80574. */
  80575. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80576. /**
  80577. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80578. * @returns a new empty Vector3
  80579. */
  80580. static Zero(): Vector3;
  80581. /**
  80582. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80583. * @returns a new unit Vector3
  80584. */
  80585. static One(): Vector3;
  80586. /**
  80587. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80588. * @returns a new up Vector3
  80589. */
  80590. static Up(): Vector3;
  80591. /**
  80592. * Gets a up Vector3 that must not be updated
  80593. */
  80594. static get UpReadOnly(): DeepImmutable<Vector3>;
  80595. /**
  80596. * Gets a zero Vector3 that must not be updated
  80597. */
  80598. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80599. /**
  80600. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80601. * @returns a new down Vector3
  80602. */
  80603. static Down(): Vector3;
  80604. /**
  80605. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80606. * @param rightHandedSystem is the scene right-handed (negative z)
  80607. * @returns a new forward Vector3
  80608. */
  80609. static Forward(rightHandedSystem?: boolean): Vector3;
  80610. /**
  80611. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80612. * @param rightHandedSystem is the scene right-handed (negative-z)
  80613. * @returns a new forward Vector3
  80614. */
  80615. static Backward(rightHandedSystem?: boolean): Vector3;
  80616. /**
  80617. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80618. * @returns a new right Vector3
  80619. */
  80620. static Right(): Vector3;
  80621. /**
  80622. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80623. * @returns a new left Vector3
  80624. */
  80625. static Left(): Vector3;
  80626. /**
  80627. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80628. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80629. * @param vector defines the Vector3 to transform
  80630. * @param transformation defines the transformation matrix
  80631. * @returns the transformed Vector3
  80632. */
  80633. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80634. /**
  80635. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80636. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80637. * @param vector defines the Vector3 to transform
  80638. * @param transformation defines the transformation matrix
  80639. * @param result defines the Vector3 where to store the result
  80640. */
  80641. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80642. /**
  80643. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80644. * This method computes tranformed coordinates only, not transformed direction vectors
  80645. * @param x define the x coordinate of the source vector
  80646. * @param y define the y coordinate of the source vector
  80647. * @param z define the z coordinate of the source vector
  80648. * @param transformation defines the transformation matrix
  80649. * @param result defines the Vector3 where to store the result
  80650. */
  80651. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80652. /**
  80653. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80654. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80655. * @param vector defines the Vector3 to transform
  80656. * @param transformation defines the transformation matrix
  80657. * @returns the new Vector3
  80658. */
  80659. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80660. /**
  80661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80662. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80663. * @param vector defines the Vector3 to transform
  80664. * @param transformation defines the transformation matrix
  80665. * @param result defines the Vector3 where to store the result
  80666. */
  80667. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80668. /**
  80669. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80670. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80671. * @param x define the x coordinate of the source vector
  80672. * @param y define the y coordinate of the source vector
  80673. * @param z define the z coordinate of the source vector
  80674. * @param transformation defines the transformation matrix
  80675. * @param result defines the Vector3 where to store the result
  80676. */
  80677. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80678. /**
  80679. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80680. * @param value1 defines the first control point
  80681. * @param value2 defines the second control point
  80682. * @param value3 defines the third control point
  80683. * @param value4 defines the fourth control point
  80684. * @param amount defines the amount on the spline to use
  80685. * @returns the new Vector3
  80686. */
  80687. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80688. /**
  80689. * 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"
  80690. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80691. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80692. * @param value defines the current value
  80693. * @param min defines the lower range value
  80694. * @param max defines the upper range value
  80695. * @returns the new Vector3
  80696. */
  80697. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80698. /**
  80699. * 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"
  80700. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80701. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80702. * @param value defines the current value
  80703. * @param min defines the lower range value
  80704. * @param max defines the upper range value
  80705. * @param result defines the Vector3 where to store the result
  80706. */
  80707. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80708. /**
  80709. * Checks if a given vector is inside a specific range
  80710. * @param v defines the vector to test
  80711. * @param min defines the minimum range
  80712. * @param max defines the maximum range
  80713. */
  80714. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80715. /**
  80716. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80717. * @param value1 defines the first control point
  80718. * @param tangent1 defines the first tangent vector
  80719. * @param value2 defines the second control point
  80720. * @param tangent2 defines the second tangent vector
  80721. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80722. * @returns the new Vector3
  80723. */
  80724. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80725. /**
  80726. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80727. * @param start defines the start value
  80728. * @param end defines the end value
  80729. * @param amount max defines amount between both (between 0 and 1)
  80730. * @returns the new Vector3
  80731. */
  80732. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80733. /**
  80734. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80735. * @param start defines the start value
  80736. * @param end defines the end value
  80737. * @param amount max defines amount between both (between 0 and 1)
  80738. * @param result defines the Vector3 where to store the result
  80739. */
  80740. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80741. /**
  80742. * Returns the dot product (float) between the vectors "left" and "right"
  80743. * @param left defines the left operand
  80744. * @param right defines the right operand
  80745. * @returns the dot product
  80746. */
  80747. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80748. /**
  80749. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80750. * The cross product is then orthogonal to both "left" and "right"
  80751. * @param left defines the left operand
  80752. * @param right defines the right operand
  80753. * @returns the cross product
  80754. */
  80755. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80756. /**
  80757. * Sets the given vector "result" with the cross product of "left" and "right"
  80758. * The cross product is then orthogonal to both "left" and "right"
  80759. * @param left defines the left operand
  80760. * @param right defines the right operand
  80761. * @param result defines the Vector3 where to store the result
  80762. */
  80763. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80764. /**
  80765. * Returns a new Vector3 as the normalization of the given vector
  80766. * @param vector defines the Vector3 to normalize
  80767. * @returns the new Vector3
  80768. */
  80769. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80770. /**
  80771. * Sets the given vector "result" with the normalization of the given first vector
  80772. * @param vector defines the Vector3 to normalize
  80773. * @param result defines the Vector3 where to store the result
  80774. */
  80775. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80776. /**
  80777. * Project a Vector3 onto screen space
  80778. * @param vector defines the Vector3 to project
  80779. * @param world defines the world matrix to use
  80780. * @param transform defines the transform (view x projection) matrix to use
  80781. * @param viewport defines the screen viewport to use
  80782. * @returns the new Vector3
  80783. */
  80784. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80785. /** @hidden */
  80786. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80787. /**
  80788. * Unproject from screen space to object space
  80789. * @param source defines the screen space Vector3 to use
  80790. * @param viewportWidth defines the current width of the viewport
  80791. * @param viewportHeight defines the current height of the viewport
  80792. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80793. * @param transform defines the transform (view x projection) matrix to use
  80794. * @returns the new Vector3
  80795. */
  80796. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80797. /**
  80798. * Unproject from screen space to object space
  80799. * @param source defines the screen space Vector3 to use
  80800. * @param viewportWidth defines the current width of the viewport
  80801. * @param viewportHeight defines the current height of the viewport
  80802. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80803. * @param view defines the view matrix to use
  80804. * @param projection defines the projection matrix to use
  80805. * @returns the new Vector3
  80806. */
  80807. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80808. /**
  80809. * Unproject from screen space to object space
  80810. * @param source defines the screen space Vector3 to use
  80811. * @param viewportWidth defines the current width of the viewport
  80812. * @param viewportHeight defines the current height of the viewport
  80813. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80814. * @param view defines the view matrix to use
  80815. * @param projection defines the projection matrix to use
  80816. * @param result defines the Vector3 where to store the result
  80817. */
  80818. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80819. /**
  80820. * Unproject from screen space to object space
  80821. * @param sourceX defines the screen space x coordinate to use
  80822. * @param sourceY defines the screen space y coordinate to use
  80823. * @param sourceZ defines the screen space z coordinate to use
  80824. * @param viewportWidth defines the current width of the viewport
  80825. * @param viewportHeight defines the current height of the viewport
  80826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80827. * @param view defines the view matrix to use
  80828. * @param projection defines the projection matrix to use
  80829. * @param result defines the Vector3 where to store the result
  80830. */
  80831. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80832. /**
  80833. * Gets the minimal coordinate values between two Vector3
  80834. * @param left defines the first operand
  80835. * @param right defines the second operand
  80836. * @returns the new Vector3
  80837. */
  80838. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80839. /**
  80840. * Gets the maximal coordinate values between two Vector3
  80841. * @param left defines the first operand
  80842. * @param right defines the second operand
  80843. * @returns the new Vector3
  80844. */
  80845. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80846. /**
  80847. * Returns the distance between the vectors "value1" and "value2"
  80848. * @param value1 defines the first operand
  80849. * @param value2 defines the second operand
  80850. * @returns the distance
  80851. */
  80852. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80853. /**
  80854. * Returns the squared distance between the vectors "value1" and "value2"
  80855. * @param value1 defines the first operand
  80856. * @param value2 defines the second operand
  80857. * @returns the squared distance
  80858. */
  80859. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80860. /**
  80861. * Returns a new Vector3 located at the center between "value1" and "value2"
  80862. * @param value1 defines the first operand
  80863. * @param value2 defines the second operand
  80864. * @returns the new Vector3
  80865. */
  80866. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80867. /**
  80868. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80869. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80870. * to something in order to rotate it from its local system to the given target system
  80871. * Note: axis1, axis2 and axis3 are normalized during this operation
  80872. * @param axis1 defines the first axis
  80873. * @param axis2 defines the second axis
  80874. * @param axis3 defines the third axis
  80875. * @returns a new Vector3
  80876. */
  80877. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80878. /**
  80879. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80880. * @param axis1 defines the first axis
  80881. * @param axis2 defines the second axis
  80882. * @param axis3 defines the third axis
  80883. * @param ref defines the Vector3 where to store the result
  80884. */
  80885. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80886. }
  80887. /**
  80888. * Vector4 class created for EulerAngle class conversion to Quaternion
  80889. */
  80890. export class Vector4 {
  80891. /** x value of the vector */
  80892. x: number;
  80893. /** y value of the vector */
  80894. y: number;
  80895. /** z value of the vector */
  80896. z: number;
  80897. /** w value of the vector */
  80898. w: number;
  80899. /**
  80900. * Creates a Vector4 object from the given floats.
  80901. * @param x x value of the vector
  80902. * @param y y value of the vector
  80903. * @param z z value of the vector
  80904. * @param w w value of the vector
  80905. */
  80906. constructor(
  80907. /** x value of the vector */
  80908. x: number,
  80909. /** y value of the vector */
  80910. y: number,
  80911. /** z value of the vector */
  80912. z: number,
  80913. /** w value of the vector */
  80914. w: number);
  80915. /**
  80916. * Returns the string with the Vector4 coordinates.
  80917. * @returns a string containing all the vector values
  80918. */
  80919. toString(): string;
  80920. /**
  80921. * Returns the string "Vector4".
  80922. * @returns "Vector4"
  80923. */
  80924. getClassName(): string;
  80925. /**
  80926. * Returns the Vector4 hash code.
  80927. * @returns a unique hash code
  80928. */
  80929. getHashCode(): number;
  80930. /**
  80931. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80932. * @returns the resulting array
  80933. */
  80934. asArray(): number[];
  80935. /**
  80936. * Populates the given array from the given index with the Vector4 coordinates.
  80937. * @param array array to populate
  80938. * @param index index of the array to start at (default: 0)
  80939. * @returns the Vector4.
  80940. */
  80941. toArray(array: FloatArray, index?: number): Vector4;
  80942. /**
  80943. * Adds the given vector to the current Vector4.
  80944. * @param otherVector the vector to add
  80945. * @returns the updated Vector4.
  80946. */
  80947. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80948. /**
  80949. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80950. * @param otherVector the vector to add
  80951. * @returns the resulting vector
  80952. */
  80953. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80954. /**
  80955. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80956. * @param otherVector the vector to add
  80957. * @param result the vector to store the result
  80958. * @returns the current Vector4.
  80959. */
  80960. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80961. /**
  80962. * Subtract in place the given vector from the current Vector4.
  80963. * @param otherVector the vector to subtract
  80964. * @returns the updated Vector4.
  80965. */
  80966. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80967. /**
  80968. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80969. * @param otherVector the vector to add
  80970. * @returns the new vector with the result
  80971. */
  80972. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80973. /**
  80974. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80975. * @param otherVector the vector to subtract
  80976. * @param result the vector to store the result
  80977. * @returns the current Vector4.
  80978. */
  80979. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80980. /**
  80981. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80982. */
  80983. /**
  80984. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80985. * @param x value to subtract
  80986. * @param y value to subtract
  80987. * @param z value to subtract
  80988. * @param w value to subtract
  80989. * @returns new vector containing the result
  80990. */
  80991. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80992. /**
  80993. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80994. * @param x value to subtract
  80995. * @param y value to subtract
  80996. * @param z value to subtract
  80997. * @param w value to subtract
  80998. * @param result the vector to store the result in
  80999. * @returns the current Vector4.
  81000. */
  81001. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81002. /**
  81003. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81004. * @returns a new vector with the negated values
  81005. */
  81006. negate(): Vector4;
  81007. /**
  81008. * Negate this vector in place
  81009. * @returns this
  81010. */
  81011. negateInPlace(): Vector4;
  81012. /**
  81013. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81014. * @param result defines the Vector3 object where to store the result
  81015. * @returns the current Vector4
  81016. */
  81017. negateToRef(result: Vector4): Vector4;
  81018. /**
  81019. * Multiplies the current Vector4 coordinates by scale (float).
  81020. * @param scale the number to scale with
  81021. * @returns the updated Vector4.
  81022. */
  81023. scaleInPlace(scale: number): Vector4;
  81024. /**
  81025. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81026. * @param scale the number to scale with
  81027. * @returns a new vector with the result
  81028. */
  81029. scale(scale: number): Vector4;
  81030. /**
  81031. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81032. * @param scale the number to scale with
  81033. * @param result a vector to store the result in
  81034. * @returns the current Vector4.
  81035. */
  81036. scaleToRef(scale: number, result: Vector4): Vector4;
  81037. /**
  81038. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81039. * @param scale defines the scale factor
  81040. * @param result defines the Vector4 object where to store the result
  81041. * @returns the unmodified current Vector4
  81042. */
  81043. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81044. /**
  81045. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81046. * @param otherVector the vector to compare against
  81047. * @returns true if they are equal
  81048. */
  81049. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81050. /**
  81051. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81052. * @param otherVector vector to compare against
  81053. * @param epsilon (Default: very small number)
  81054. * @returns true if they are equal
  81055. */
  81056. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81057. /**
  81058. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81059. * @param x x value to compare against
  81060. * @param y y value to compare against
  81061. * @param z z value to compare against
  81062. * @param w w value to compare against
  81063. * @returns true if equal
  81064. */
  81065. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81066. /**
  81067. * Multiplies in place the current Vector4 by the given one.
  81068. * @param otherVector vector to multiple with
  81069. * @returns the updated Vector4.
  81070. */
  81071. multiplyInPlace(otherVector: Vector4): Vector4;
  81072. /**
  81073. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81074. * @param otherVector vector to multiple with
  81075. * @returns resulting new vector
  81076. */
  81077. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81078. /**
  81079. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81080. * @param otherVector vector to multiple with
  81081. * @param result vector to store the result
  81082. * @returns the current Vector4.
  81083. */
  81084. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81085. /**
  81086. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81087. * @param x x value multiply with
  81088. * @param y y value multiply with
  81089. * @param z z value multiply with
  81090. * @param w w value multiply with
  81091. * @returns resulting new vector
  81092. */
  81093. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81094. /**
  81095. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81096. * @param otherVector vector to devide with
  81097. * @returns resulting new vector
  81098. */
  81099. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81100. /**
  81101. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81102. * @param otherVector vector to devide with
  81103. * @param result vector to store the result
  81104. * @returns the current Vector4.
  81105. */
  81106. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81107. /**
  81108. * Divides the current Vector3 coordinates by the given ones.
  81109. * @param otherVector vector to devide with
  81110. * @returns the updated Vector3.
  81111. */
  81112. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81113. /**
  81114. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81115. * @param other defines the second operand
  81116. * @returns the current updated Vector4
  81117. */
  81118. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81119. /**
  81120. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81121. * @param other defines the second operand
  81122. * @returns the current updated Vector4
  81123. */
  81124. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81125. /**
  81126. * Gets a new Vector4 from current Vector4 floored values
  81127. * @returns a new Vector4
  81128. */
  81129. floor(): Vector4;
  81130. /**
  81131. * Gets a new Vector4 from current Vector3 floored values
  81132. * @returns a new Vector4
  81133. */
  81134. fract(): Vector4;
  81135. /**
  81136. * Returns the Vector4 length (float).
  81137. * @returns the length
  81138. */
  81139. length(): number;
  81140. /**
  81141. * Returns the Vector4 squared length (float).
  81142. * @returns the length squared
  81143. */
  81144. lengthSquared(): number;
  81145. /**
  81146. * Normalizes in place the Vector4.
  81147. * @returns the updated Vector4.
  81148. */
  81149. normalize(): Vector4;
  81150. /**
  81151. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81152. * @returns this converted to a new vector3
  81153. */
  81154. toVector3(): Vector3;
  81155. /**
  81156. * Returns a new Vector4 copied from the current one.
  81157. * @returns the new cloned vector
  81158. */
  81159. clone(): Vector4;
  81160. /**
  81161. * Updates the current Vector4 with the given one coordinates.
  81162. * @param source the source vector to copy from
  81163. * @returns the updated Vector4.
  81164. */
  81165. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81166. /**
  81167. * Updates the current Vector4 coordinates with the given floats.
  81168. * @param x float to copy from
  81169. * @param y float to copy from
  81170. * @param z float to copy from
  81171. * @param w float to copy from
  81172. * @returns the updated Vector4.
  81173. */
  81174. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81175. /**
  81176. * Updates the current Vector4 coordinates with the given floats.
  81177. * @param x float to set from
  81178. * @param y float to set from
  81179. * @param z float to set from
  81180. * @param w float to set from
  81181. * @returns the updated Vector4.
  81182. */
  81183. set(x: number, y: number, z: number, w: number): Vector4;
  81184. /**
  81185. * Copies the given float to the current Vector3 coordinates
  81186. * @param v defines the x, y, z and w coordinates of the operand
  81187. * @returns the current updated Vector3
  81188. */
  81189. setAll(v: number): Vector4;
  81190. /**
  81191. * Returns a new Vector4 set from the starting index of the given array.
  81192. * @param array the array to pull values from
  81193. * @param offset the offset into the array to start at
  81194. * @returns the new vector
  81195. */
  81196. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81197. /**
  81198. * Updates the given vector "result" from the starting index of the given array.
  81199. * @param array the array to pull values from
  81200. * @param offset the offset into the array to start at
  81201. * @param result the vector to store the result in
  81202. */
  81203. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81204. /**
  81205. * Updates the given vector "result" from the starting index of the given Float32Array.
  81206. * @param array the array to pull values from
  81207. * @param offset the offset into the array to start at
  81208. * @param result the vector to store the result in
  81209. */
  81210. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81211. /**
  81212. * Updates the given vector "result" coordinates from the given floats.
  81213. * @param x float to set from
  81214. * @param y float to set from
  81215. * @param z float to set from
  81216. * @param w float to set from
  81217. * @param result the vector to the floats in
  81218. */
  81219. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81220. /**
  81221. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81222. * @returns the new vector
  81223. */
  81224. static Zero(): Vector4;
  81225. /**
  81226. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81227. * @returns the new vector
  81228. */
  81229. static One(): Vector4;
  81230. /**
  81231. * Returns a new normalized Vector4 from the given one.
  81232. * @param vector the vector to normalize
  81233. * @returns the vector
  81234. */
  81235. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81236. /**
  81237. * Updates the given vector "result" from the normalization of the given one.
  81238. * @param vector the vector to normalize
  81239. * @param result the vector to store the result in
  81240. */
  81241. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81242. /**
  81243. * Returns a vector with the minimum values from the left and right vectors
  81244. * @param left left vector to minimize
  81245. * @param right right vector to minimize
  81246. * @returns a new vector with the minimum of the left and right vector values
  81247. */
  81248. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81249. /**
  81250. * Returns a vector with the maximum values from the left and right vectors
  81251. * @param left left vector to maximize
  81252. * @param right right vector to maximize
  81253. * @returns a new vector with the maximum of the left and right vector values
  81254. */
  81255. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81256. /**
  81257. * Returns the distance (float) between the vectors "value1" and "value2".
  81258. * @param value1 value to calulate the distance between
  81259. * @param value2 value to calulate the distance between
  81260. * @return the distance between the two vectors
  81261. */
  81262. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81263. /**
  81264. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81265. * @param value1 value to calulate the distance between
  81266. * @param value2 value to calulate the distance between
  81267. * @return the distance between the two vectors squared
  81268. */
  81269. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81270. /**
  81271. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81272. * @param value1 value to calulate the center between
  81273. * @param value2 value to calulate the center between
  81274. * @return the center between the two vectors
  81275. */
  81276. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81277. /**
  81278. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81279. * This methods computes transformed normalized direction vectors only.
  81280. * @param vector the vector to transform
  81281. * @param transformation the transformation matrix to apply
  81282. * @returns the new vector
  81283. */
  81284. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81285. /**
  81286. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81287. * This methods computes transformed normalized direction vectors only.
  81288. * @param vector the vector to transform
  81289. * @param transformation the transformation matrix to apply
  81290. * @param result the vector to store the result in
  81291. */
  81292. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81293. /**
  81294. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81295. * This methods computes transformed normalized direction vectors only.
  81296. * @param x value to transform
  81297. * @param y value to transform
  81298. * @param z value to transform
  81299. * @param w value to transform
  81300. * @param transformation the transformation matrix to apply
  81301. * @param result the vector to store the results in
  81302. */
  81303. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81304. /**
  81305. * Creates a new Vector4 from a Vector3
  81306. * @param source defines the source data
  81307. * @param w defines the 4th component (default is 0)
  81308. * @returns a new Vector4
  81309. */
  81310. static FromVector3(source: Vector3, w?: number): Vector4;
  81311. }
  81312. /**
  81313. * Class used to store quaternion data
  81314. * @see https://en.wikipedia.org/wiki/Quaternion
  81315. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81316. */
  81317. export class Quaternion {
  81318. /** defines the first component (0 by default) */
  81319. x: number;
  81320. /** defines the second component (0 by default) */
  81321. y: number;
  81322. /** defines the third component (0 by default) */
  81323. z: number;
  81324. /** defines the fourth component (1.0 by default) */
  81325. w: number;
  81326. /**
  81327. * Creates a new Quaternion from the given floats
  81328. * @param x defines the first component (0 by default)
  81329. * @param y defines the second component (0 by default)
  81330. * @param z defines the third component (0 by default)
  81331. * @param w defines the fourth component (1.0 by default)
  81332. */
  81333. constructor(
  81334. /** defines the first component (0 by default) */
  81335. x?: number,
  81336. /** defines the second component (0 by default) */
  81337. y?: number,
  81338. /** defines the third component (0 by default) */
  81339. z?: number,
  81340. /** defines the fourth component (1.0 by default) */
  81341. w?: number);
  81342. /**
  81343. * Gets a string representation for the current quaternion
  81344. * @returns a string with the Quaternion coordinates
  81345. */
  81346. toString(): string;
  81347. /**
  81348. * Gets the class name of the quaternion
  81349. * @returns the string "Quaternion"
  81350. */
  81351. getClassName(): string;
  81352. /**
  81353. * Gets a hash code for this quaternion
  81354. * @returns the quaternion hash code
  81355. */
  81356. getHashCode(): number;
  81357. /**
  81358. * Copy the quaternion to an array
  81359. * @returns a new array populated with 4 elements from the quaternion coordinates
  81360. */
  81361. asArray(): number[];
  81362. /**
  81363. * Check if two quaternions are equals
  81364. * @param otherQuaternion defines the second operand
  81365. * @return true if the current quaternion and the given one coordinates are strictly equals
  81366. */
  81367. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81368. /**
  81369. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81370. * @param otherQuaternion defines the other quaternion
  81371. * @param epsilon defines the minimal distance to consider equality
  81372. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81373. */
  81374. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81375. /**
  81376. * Clone the current quaternion
  81377. * @returns a new quaternion copied from the current one
  81378. */
  81379. clone(): Quaternion;
  81380. /**
  81381. * Copy a quaternion to the current one
  81382. * @param other defines the other quaternion
  81383. * @returns the updated current quaternion
  81384. */
  81385. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81386. /**
  81387. * Updates the current quaternion with the given float coordinates
  81388. * @param x defines the x coordinate
  81389. * @param y defines the y coordinate
  81390. * @param z defines the z coordinate
  81391. * @param w defines the w coordinate
  81392. * @returns the updated current quaternion
  81393. */
  81394. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81395. /**
  81396. * Updates the current quaternion from the given float coordinates
  81397. * @param x defines the x coordinate
  81398. * @param y defines the y coordinate
  81399. * @param z defines the z coordinate
  81400. * @param w defines the w coordinate
  81401. * @returns the updated current quaternion
  81402. */
  81403. set(x: number, y: number, z: number, w: number): Quaternion;
  81404. /**
  81405. * Adds two quaternions
  81406. * @param other defines the second operand
  81407. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81408. */
  81409. add(other: DeepImmutable<Quaternion>): Quaternion;
  81410. /**
  81411. * Add a quaternion to the current one
  81412. * @param other defines the quaternion to add
  81413. * @returns the current quaternion
  81414. */
  81415. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81416. /**
  81417. * Subtract two quaternions
  81418. * @param other defines the second operand
  81419. * @returns a new quaternion as the subtraction result of the given one from the current one
  81420. */
  81421. subtract(other: Quaternion): Quaternion;
  81422. /**
  81423. * Multiplies the current quaternion by a scale factor
  81424. * @param value defines the scale factor
  81425. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81426. */
  81427. scale(value: number): Quaternion;
  81428. /**
  81429. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81430. * @param scale defines the scale factor
  81431. * @param result defines the Quaternion object where to store the result
  81432. * @returns the unmodified current quaternion
  81433. */
  81434. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81435. /**
  81436. * Multiplies in place the current quaternion by a scale factor
  81437. * @param value defines the scale factor
  81438. * @returns the current modified quaternion
  81439. */
  81440. scaleInPlace(value: number): Quaternion;
  81441. /**
  81442. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81443. * @param scale defines the scale factor
  81444. * @param result defines the Quaternion object where to store the result
  81445. * @returns the unmodified current quaternion
  81446. */
  81447. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81448. /**
  81449. * Multiplies two quaternions
  81450. * @param q1 defines the second operand
  81451. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81452. */
  81453. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81454. /**
  81455. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81456. * @param q1 defines the second operand
  81457. * @param result defines the target quaternion
  81458. * @returns the current quaternion
  81459. */
  81460. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81461. /**
  81462. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81463. * @param q1 defines the second operand
  81464. * @returns the currentupdated quaternion
  81465. */
  81466. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81467. /**
  81468. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81469. * @param ref defines the target quaternion
  81470. * @returns the current quaternion
  81471. */
  81472. conjugateToRef(ref: Quaternion): Quaternion;
  81473. /**
  81474. * Conjugates in place (1-q) the current quaternion
  81475. * @returns the current updated quaternion
  81476. */
  81477. conjugateInPlace(): Quaternion;
  81478. /**
  81479. * Conjugates in place (1-q) the current quaternion
  81480. * @returns a new quaternion
  81481. */
  81482. conjugate(): Quaternion;
  81483. /**
  81484. * Gets length of current quaternion
  81485. * @returns the quaternion length (float)
  81486. */
  81487. length(): number;
  81488. /**
  81489. * Normalize in place the current quaternion
  81490. * @returns the current updated quaternion
  81491. */
  81492. normalize(): Quaternion;
  81493. /**
  81494. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81495. * @param order is a reserved parameter and is ignore for now
  81496. * @returns a new Vector3 containing the Euler angles
  81497. */
  81498. toEulerAngles(order?: string): Vector3;
  81499. /**
  81500. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81501. * @param result defines the vector which will be filled with the Euler angles
  81502. * @param order is a reserved parameter and is ignore for now
  81503. * @returns the current unchanged quaternion
  81504. */
  81505. toEulerAnglesToRef(result: Vector3): Quaternion;
  81506. /**
  81507. * Updates the given rotation matrix with the current quaternion values
  81508. * @param result defines the target matrix
  81509. * @returns the current unchanged quaternion
  81510. */
  81511. toRotationMatrix(result: Matrix): Quaternion;
  81512. /**
  81513. * Updates the current quaternion from the given rotation matrix values
  81514. * @param matrix defines the source matrix
  81515. * @returns the current updated quaternion
  81516. */
  81517. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81518. /**
  81519. * Creates a new quaternion from a rotation matrix
  81520. * @param matrix defines the source matrix
  81521. * @returns a new quaternion created from the given rotation matrix values
  81522. */
  81523. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81524. /**
  81525. * Updates the given quaternion with the given rotation matrix values
  81526. * @param matrix defines the source matrix
  81527. * @param result defines the target quaternion
  81528. */
  81529. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81530. /**
  81531. * Returns the dot product (float) between the quaternions "left" and "right"
  81532. * @param left defines the left operand
  81533. * @param right defines the right operand
  81534. * @returns the dot product
  81535. */
  81536. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81537. /**
  81538. * Checks if the two quaternions are close to each other
  81539. * @param quat0 defines the first quaternion to check
  81540. * @param quat1 defines the second quaternion to check
  81541. * @returns true if the two quaternions are close to each other
  81542. */
  81543. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81544. /**
  81545. * Creates an empty quaternion
  81546. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81547. */
  81548. static Zero(): Quaternion;
  81549. /**
  81550. * Inverse a given quaternion
  81551. * @param q defines the source quaternion
  81552. * @returns a new quaternion as the inverted current quaternion
  81553. */
  81554. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81555. /**
  81556. * Inverse a given quaternion
  81557. * @param q defines the source quaternion
  81558. * @param result the quaternion the result will be stored in
  81559. * @returns the result quaternion
  81560. */
  81561. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81562. /**
  81563. * Creates an identity quaternion
  81564. * @returns the identity quaternion
  81565. */
  81566. static Identity(): Quaternion;
  81567. /**
  81568. * Gets a boolean indicating if the given quaternion is identity
  81569. * @param quaternion defines the quaternion to check
  81570. * @returns true if the quaternion is identity
  81571. */
  81572. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81573. /**
  81574. * Creates a quaternion from a rotation around an axis
  81575. * @param axis defines the axis to use
  81576. * @param angle defines the angle to use
  81577. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81578. */
  81579. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81580. /**
  81581. * Creates a rotation around an axis and stores it into the given quaternion
  81582. * @param axis defines the axis to use
  81583. * @param angle defines the angle to use
  81584. * @param result defines the target quaternion
  81585. * @returns the target quaternion
  81586. */
  81587. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81588. /**
  81589. * Creates a new quaternion from data stored into an array
  81590. * @param array defines the data source
  81591. * @param offset defines the offset in the source array where the data starts
  81592. * @returns a new quaternion
  81593. */
  81594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81595. /**
  81596. * Updates the given quaternion "result" from the starting index of the given array.
  81597. * @param array the array to pull values from
  81598. * @param offset the offset into the array to start at
  81599. * @param result the quaternion to store the result in
  81600. */
  81601. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81602. /**
  81603. * Create a quaternion from Euler rotation angles
  81604. * @param x Pitch
  81605. * @param y Yaw
  81606. * @param z Roll
  81607. * @returns the new Quaternion
  81608. */
  81609. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81610. /**
  81611. * Updates a quaternion from Euler rotation angles
  81612. * @param x Pitch
  81613. * @param y Yaw
  81614. * @param z Roll
  81615. * @param result the quaternion to store the result
  81616. * @returns the updated quaternion
  81617. */
  81618. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81619. /**
  81620. * Create a quaternion from Euler rotation vector
  81621. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81622. * @returns the new Quaternion
  81623. */
  81624. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81625. /**
  81626. * Updates a quaternion from Euler rotation vector
  81627. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81628. * @param result the quaternion to store the result
  81629. * @returns the updated quaternion
  81630. */
  81631. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81632. /**
  81633. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81634. * @param yaw defines the rotation around Y axis
  81635. * @param pitch defines the rotation around X axis
  81636. * @param roll defines the rotation around Z axis
  81637. * @returns the new quaternion
  81638. */
  81639. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81640. /**
  81641. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81642. * @param yaw defines the rotation around Y axis
  81643. * @param pitch defines the rotation around X axis
  81644. * @param roll defines the rotation around Z axis
  81645. * @param result defines the target quaternion
  81646. */
  81647. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81648. /**
  81649. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81650. * @param alpha defines the rotation around first axis
  81651. * @param beta defines the rotation around second axis
  81652. * @param gamma defines the rotation around third axis
  81653. * @returns the new quaternion
  81654. */
  81655. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81656. /**
  81657. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81658. * @param alpha defines the rotation around first axis
  81659. * @param beta defines the rotation around second axis
  81660. * @param gamma defines the rotation around third axis
  81661. * @param result defines the target quaternion
  81662. */
  81663. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81664. /**
  81665. * 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)
  81666. * @param axis1 defines the first axis
  81667. * @param axis2 defines the second axis
  81668. * @param axis3 defines the third axis
  81669. * @returns the new quaternion
  81670. */
  81671. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81672. /**
  81673. * 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
  81674. * @param axis1 defines the first axis
  81675. * @param axis2 defines the second axis
  81676. * @param axis3 defines the third axis
  81677. * @param ref defines the target quaternion
  81678. */
  81679. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81680. /**
  81681. * Interpolates between two quaternions
  81682. * @param left defines first quaternion
  81683. * @param right defines second quaternion
  81684. * @param amount defines the gradient to use
  81685. * @returns the new interpolated quaternion
  81686. */
  81687. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81688. /**
  81689. * Interpolates between two quaternions and stores it into a target quaternion
  81690. * @param left defines first quaternion
  81691. * @param right defines second quaternion
  81692. * @param amount defines the gradient to use
  81693. * @param result defines the target quaternion
  81694. */
  81695. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81696. /**
  81697. * Interpolate between two quaternions using Hermite interpolation
  81698. * @param value1 defines first quaternion
  81699. * @param tangent1 defines the incoming tangent
  81700. * @param value2 defines second quaternion
  81701. * @param tangent2 defines the outgoing tangent
  81702. * @param amount defines the target quaternion
  81703. * @returns the new interpolated quaternion
  81704. */
  81705. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81706. }
  81707. /**
  81708. * Class used to store matrix data (4x4)
  81709. */
  81710. export class Matrix {
  81711. private static _updateFlagSeed;
  81712. private static _identityReadOnly;
  81713. private _isIdentity;
  81714. private _isIdentityDirty;
  81715. private _isIdentity3x2;
  81716. private _isIdentity3x2Dirty;
  81717. /**
  81718. * Gets the update flag of the matrix which is an unique number for the matrix.
  81719. * It will be incremented every time the matrix data change.
  81720. * You can use it to speed the comparison between two versions of the same matrix.
  81721. */
  81722. updateFlag: number;
  81723. private readonly _m;
  81724. /**
  81725. * Gets the internal data of the matrix
  81726. */
  81727. get m(): DeepImmutable<Float32Array>;
  81728. /** @hidden */
  81729. _markAsUpdated(): void;
  81730. /** @hidden */
  81731. private _updateIdentityStatus;
  81732. /**
  81733. * Creates an empty matrix (filled with zeros)
  81734. */
  81735. constructor();
  81736. /**
  81737. * Check if the current matrix is identity
  81738. * @returns true is the matrix is the identity matrix
  81739. */
  81740. isIdentity(): boolean;
  81741. /**
  81742. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81743. * @returns true is the matrix is the identity matrix
  81744. */
  81745. isIdentityAs3x2(): boolean;
  81746. /**
  81747. * Gets the determinant of the matrix
  81748. * @returns the matrix determinant
  81749. */
  81750. determinant(): number;
  81751. /**
  81752. * Returns the matrix as a Float32Array
  81753. * @returns the matrix underlying array
  81754. */
  81755. toArray(): DeepImmutable<Float32Array>;
  81756. /**
  81757. * Returns the matrix as a Float32Array
  81758. * @returns the matrix underlying array.
  81759. */
  81760. asArray(): DeepImmutable<Float32Array>;
  81761. /**
  81762. * Inverts the current matrix in place
  81763. * @returns the current inverted matrix
  81764. */
  81765. invert(): Matrix;
  81766. /**
  81767. * Sets all the matrix elements to zero
  81768. * @returns the current matrix
  81769. */
  81770. reset(): Matrix;
  81771. /**
  81772. * Adds the current matrix with a second one
  81773. * @param other defines the matrix to add
  81774. * @returns a new matrix as the addition of the current matrix and the given one
  81775. */
  81776. add(other: DeepImmutable<Matrix>): Matrix;
  81777. /**
  81778. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81779. * @param other defines the matrix to add
  81780. * @param result defines the target matrix
  81781. * @returns the current matrix
  81782. */
  81783. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81784. /**
  81785. * Adds in place the given matrix to the current matrix
  81786. * @param other defines the second operand
  81787. * @returns the current updated matrix
  81788. */
  81789. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81790. /**
  81791. * Sets the given matrix to the current inverted Matrix
  81792. * @param other defines the target matrix
  81793. * @returns the unmodified current matrix
  81794. */
  81795. invertToRef(other: Matrix): Matrix;
  81796. /**
  81797. * add a value at the specified position in the current Matrix
  81798. * @param index the index of the value within the matrix. between 0 and 15.
  81799. * @param value the value to be added
  81800. * @returns the current updated matrix
  81801. */
  81802. addAtIndex(index: number, value: number): Matrix;
  81803. /**
  81804. * mutiply the specified position in the current Matrix by a value
  81805. * @param index the index of the value within the matrix. between 0 and 15.
  81806. * @param value the value to be added
  81807. * @returns the current updated matrix
  81808. */
  81809. multiplyAtIndex(index: number, value: number): Matrix;
  81810. /**
  81811. * Inserts the translation vector (using 3 floats) in the current matrix
  81812. * @param x defines the 1st component of the translation
  81813. * @param y defines the 2nd component of the translation
  81814. * @param z defines the 3rd component of the translation
  81815. * @returns the current updated matrix
  81816. */
  81817. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81818. /**
  81819. * Adds the translation vector (using 3 floats) in the current matrix
  81820. * @param x defines the 1st component of the translation
  81821. * @param y defines the 2nd component of the translation
  81822. * @param z defines the 3rd component of the translation
  81823. * @returns the current updated matrix
  81824. */
  81825. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81826. /**
  81827. * Inserts the translation vector in the current matrix
  81828. * @param vector3 defines the translation to insert
  81829. * @returns the current updated matrix
  81830. */
  81831. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81832. /**
  81833. * Gets the translation value of the current matrix
  81834. * @returns a new Vector3 as the extracted translation from the matrix
  81835. */
  81836. getTranslation(): Vector3;
  81837. /**
  81838. * Fill a Vector3 with the extracted translation from the matrix
  81839. * @param result defines the Vector3 where to store the translation
  81840. * @returns the current matrix
  81841. */
  81842. getTranslationToRef(result: Vector3): Matrix;
  81843. /**
  81844. * Remove rotation and scaling part from the matrix
  81845. * @returns the updated matrix
  81846. */
  81847. removeRotationAndScaling(): Matrix;
  81848. /**
  81849. * Multiply two matrices
  81850. * @param other defines the second operand
  81851. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81852. */
  81853. multiply(other: DeepImmutable<Matrix>): Matrix;
  81854. /**
  81855. * Copy the current matrix from the given one
  81856. * @param other defines the source matrix
  81857. * @returns the current updated matrix
  81858. */
  81859. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81860. /**
  81861. * Populates the given array from the starting index with the current matrix values
  81862. * @param array defines the target array
  81863. * @param offset defines the offset in the target array where to start storing values
  81864. * @returns the current matrix
  81865. */
  81866. copyToArray(array: Float32Array, offset?: number): Matrix;
  81867. /**
  81868. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81869. * @param other defines the second operand
  81870. * @param result defines the matrix where to store the multiplication
  81871. * @returns the current matrix
  81872. */
  81873. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81874. /**
  81875. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81876. * @param other defines the second operand
  81877. * @param result defines the array where to store the multiplication
  81878. * @param offset defines the offset in the target array where to start storing values
  81879. * @returns the current matrix
  81880. */
  81881. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81882. /**
  81883. * Check equality between this matrix and a second one
  81884. * @param value defines the second matrix to compare
  81885. * @returns true is the current matrix and the given one values are strictly equal
  81886. */
  81887. equals(value: DeepImmutable<Matrix>): boolean;
  81888. /**
  81889. * Clone the current matrix
  81890. * @returns a new matrix from the current matrix
  81891. */
  81892. clone(): Matrix;
  81893. /**
  81894. * Returns the name of the current matrix class
  81895. * @returns the string "Matrix"
  81896. */
  81897. getClassName(): string;
  81898. /**
  81899. * Gets the hash code of the current matrix
  81900. * @returns the hash code
  81901. */
  81902. getHashCode(): number;
  81903. /**
  81904. * Decomposes the current Matrix into a translation, rotation and scaling components
  81905. * @param scale defines the scale vector3 given as a reference to update
  81906. * @param rotation defines the rotation quaternion given as a reference to update
  81907. * @param translation defines the translation vector3 given as a reference to update
  81908. * @returns true if operation was successful
  81909. */
  81910. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81911. /**
  81912. * Gets specific row of the matrix
  81913. * @param index defines the number of the row to get
  81914. * @returns the index-th row of the current matrix as a new Vector4
  81915. */
  81916. getRow(index: number): Nullable<Vector4>;
  81917. /**
  81918. * Sets the index-th row of the current matrix to the vector4 values
  81919. * @param index defines the number of the row to set
  81920. * @param row defines the target vector4
  81921. * @returns the updated current matrix
  81922. */
  81923. setRow(index: number, row: Vector4): Matrix;
  81924. /**
  81925. * Compute the transpose of the matrix
  81926. * @returns the new transposed matrix
  81927. */
  81928. transpose(): Matrix;
  81929. /**
  81930. * Compute the transpose of the matrix and store it in a given matrix
  81931. * @param result defines the target matrix
  81932. * @returns the current matrix
  81933. */
  81934. transposeToRef(result: Matrix): Matrix;
  81935. /**
  81936. * Sets the index-th row of the current matrix with the given 4 x float values
  81937. * @param index defines the row index
  81938. * @param x defines the x component to set
  81939. * @param y defines the y component to set
  81940. * @param z defines the z component to set
  81941. * @param w defines the w component to set
  81942. * @returns the updated current matrix
  81943. */
  81944. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81945. /**
  81946. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81947. * @param scale defines the scale factor
  81948. * @returns a new matrix
  81949. */
  81950. scale(scale: number): Matrix;
  81951. /**
  81952. * Scale the current matrix values by a factor to a given result matrix
  81953. * @param scale defines the scale factor
  81954. * @param result defines the matrix to store the result
  81955. * @returns the current matrix
  81956. */
  81957. scaleToRef(scale: number, result: Matrix): Matrix;
  81958. /**
  81959. * Scale the current matrix values by a factor and add the result to a given matrix
  81960. * @param scale defines the scale factor
  81961. * @param result defines the Matrix to store the result
  81962. * @returns the current matrix
  81963. */
  81964. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81965. /**
  81966. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81967. * @param ref matrix to store the result
  81968. */
  81969. toNormalMatrix(ref: Matrix): void;
  81970. /**
  81971. * Gets only rotation part of the current matrix
  81972. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81973. */
  81974. getRotationMatrix(): Matrix;
  81975. /**
  81976. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81977. * @param result defines the target matrix to store data to
  81978. * @returns the current matrix
  81979. */
  81980. getRotationMatrixToRef(result: Matrix): Matrix;
  81981. /**
  81982. * Toggles model matrix from being right handed to left handed in place and vice versa
  81983. */
  81984. toggleModelMatrixHandInPlace(): void;
  81985. /**
  81986. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81987. */
  81988. toggleProjectionMatrixHandInPlace(): void;
  81989. /**
  81990. * Creates a matrix from an array
  81991. * @param array defines the source array
  81992. * @param offset defines an offset in the source array
  81993. * @returns a new Matrix set from the starting index of the given array
  81994. */
  81995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81996. /**
  81997. * Copy the content of an array into a given matrix
  81998. * @param array defines the source array
  81999. * @param offset defines an offset in the source array
  82000. * @param result defines the target matrix
  82001. */
  82002. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82003. /**
  82004. * Stores an array into a matrix after having multiplied each component by a given factor
  82005. * @param array defines the source array
  82006. * @param offset defines the offset in the source array
  82007. * @param scale defines the scaling factor
  82008. * @param result defines the target matrix
  82009. */
  82010. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82011. /**
  82012. * Gets an identity matrix that must not be updated
  82013. */
  82014. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82015. /**
  82016. * Stores a list of values (16) inside a given matrix
  82017. * @param initialM11 defines 1st value of 1st row
  82018. * @param initialM12 defines 2nd value of 1st row
  82019. * @param initialM13 defines 3rd value of 1st row
  82020. * @param initialM14 defines 4th value of 1st row
  82021. * @param initialM21 defines 1st value of 2nd row
  82022. * @param initialM22 defines 2nd value of 2nd row
  82023. * @param initialM23 defines 3rd value of 2nd row
  82024. * @param initialM24 defines 4th value of 2nd row
  82025. * @param initialM31 defines 1st value of 3rd row
  82026. * @param initialM32 defines 2nd value of 3rd row
  82027. * @param initialM33 defines 3rd value of 3rd row
  82028. * @param initialM34 defines 4th value of 3rd row
  82029. * @param initialM41 defines 1st value of 4th row
  82030. * @param initialM42 defines 2nd value of 4th row
  82031. * @param initialM43 defines 3rd value of 4th row
  82032. * @param initialM44 defines 4th value of 4th row
  82033. * @param result defines the target matrix
  82034. */
  82035. 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;
  82036. /**
  82037. * Creates new matrix from a list of values (16)
  82038. * @param initialM11 defines 1st value of 1st row
  82039. * @param initialM12 defines 2nd value of 1st row
  82040. * @param initialM13 defines 3rd value of 1st row
  82041. * @param initialM14 defines 4th value of 1st row
  82042. * @param initialM21 defines 1st value of 2nd row
  82043. * @param initialM22 defines 2nd value of 2nd row
  82044. * @param initialM23 defines 3rd value of 2nd row
  82045. * @param initialM24 defines 4th value of 2nd row
  82046. * @param initialM31 defines 1st value of 3rd row
  82047. * @param initialM32 defines 2nd value of 3rd row
  82048. * @param initialM33 defines 3rd value of 3rd row
  82049. * @param initialM34 defines 4th value of 3rd row
  82050. * @param initialM41 defines 1st value of 4th row
  82051. * @param initialM42 defines 2nd value of 4th row
  82052. * @param initialM43 defines 3rd value of 4th row
  82053. * @param initialM44 defines 4th value of 4th row
  82054. * @returns the new matrix
  82055. */
  82056. 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;
  82057. /**
  82058. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82059. * @param scale defines the scale vector3
  82060. * @param rotation defines the rotation quaternion
  82061. * @param translation defines the translation vector3
  82062. * @returns a new matrix
  82063. */
  82064. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82065. /**
  82066. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82067. * @param scale defines the scale vector3
  82068. * @param rotation defines the rotation quaternion
  82069. * @param translation defines the translation vector3
  82070. * @param result defines the target matrix
  82071. */
  82072. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82073. /**
  82074. * Creates a new identity matrix
  82075. * @returns a new identity matrix
  82076. */
  82077. static Identity(): Matrix;
  82078. /**
  82079. * Creates a new identity matrix and stores the result in a given matrix
  82080. * @param result defines the target matrix
  82081. */
  82082. static IdentityToRef(result: Matrix): void;
  82083. /**
  82084. * Creates a new zero matrix
  82085. * @returns a new zero matrix
  82086. */
  82087. static Zero(): Matrix;
  82088. /**
  82089. * Creates a new rotation matrix for "angle" radians around the X axis
  82090. * @param angle defines the angle (in radians) to use
  82091. * @return the new matrix
  82092. */
  82093. static RotationX(angle: number): Matrix;
  82094. /**
  82095. * Creates a new matrix as the invert of a given matrix
  82096. * @param source defines the source matrix
  82097. * @returns the new matrix
  82098. */
  82099. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82100. /**
  82101. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82102. * @param angle defines the angle (in radians) to use
  82103. * @param result defines the target matrix
  82104. */
  82105. static RotationXToRef(angle: number, result: Matrix): void;
  82106. /**
  82107. * Creates a new rotation matrix for "angle" radians around the Y axis
  82108. * @param angle defines the angle (in radians) to use
  82109. * @return the new matrix
  82110. */
  82111. static RotationY(angle: number): Matrix;
  82112. /**
  82113. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82114. * @param angle defines the angle (in radians) to use
  82115. * @param result defines the target matrix
  82116. */
  82117. static RotationYToRef(angle: number, result: Matrix): void;
  82118. /**
  82119. * Creates a new rotation matrix for "angle" radians around the Z axis
  82120. * @param angle defines the angle (in radians) to use
  82121. * @return the new matrix
  82122. */
  82123. static RotationZ(angle: number): Matrix;
  82124. /**
  82125. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82126. * @param angle defines the angle (in radians) to use
  82127. * @param result defines the target matrix
  82128. */
  82129. static RotationZToRef(angle: number, result: Matrix): void;
  82130. /**
  82131. * Creates a new rotation matrix for "angle" radians around the given axis
  82132. * @param axis defines the axis to use
  82133. * @param angle defines the angle (in radians) to use
  82134. * @return the new matrix
  82135. */
  82136. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82137. /**
  82138. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82139. * @param axis defines the axis to use
  82140. * @param angle defines the angle (in radians) to use
  82141. * @param result defines the target matrix
  82142. */
  82143. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82144. /**
  82145. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82146. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82147. * @param from defines the vector to align
  82148. * @param to defines the vector to align to
  82149. * @param result defines the target matrix
  82150. */
  82151. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82152. /**
  82153. * Creates a rotation matrix
  82154. * @param yaw defines the yaw angle in radians (Y axis)
  82155. * @param pitch defines the pitch angle in radians (X axis)
  82156. * @param roll defines the roll angle in radians (X axis)
  82157. * @returns the new rotation matrix
  82158. */
  82159. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82160. /**
  82161. * Creates a rotation matrix and stores it in a given matrix
  82162. * @param yaw defines the yaw angle in radians (Y axis)
  82163. * @param pitch defines the pitch angle in radians (X axis)
  82164. * @param roll defines the roll angle in radians (X axis)
  82165. * @param result defines the target matrix
  82166. */
  82167. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82168. /**
  82169. * Creates a scaling matrix
  82170. * @param x defines the scale factor on X axis
  82171. * @param y defines the scale factor on Y axis
  82172. * @param z defines the scale factor on Z axis
  82173. * @returns the new matrix
  82174. */
  82175. static Scaling(x: number, y: number, z: number): Matrix;
  82176. /**
  82177. * Creates a scaling matrix and stores it in a given matrix
  82178. * @param x defines the scale factor on X axis
  82179. * @param y defines the scale factor on Y axis
  82180. * @param z defines the scale factor on Z axis
  82181. * @param result defines the target matrix
  82182. */
  82183. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82184. /**
  82185. * Creates a translation matrix
  82186. * @param x defines the translation on X axis
  82187. * @param y defines the translation on Y axis
  82188. * @param z defines the translationon Z axis
  82189. * @returns the new matrix
  82190. */
  82191. static Translation(x: number, y: number, z: number): Matrix;
  82192. /**
  82193. * Creates a translation matrix and stores it in a given matrix
  82194. * @param x defines the translation on X axis
  82195. * @param y defines the translation on Y axis
  82196. * @param z defines the translationon Z axis
  82197. * @param result defines the target matrix
  82198. */
  82199. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82200. /**
  82201. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82202. * @param startValue defines the start value
  82203. * @param endValue defines the end value
  82204. * @param gradient defines the gradient factor
  82205. * @returns the new matrix
  82206. */
  82207. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82208. /**
  82209. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82210. * @param startValue defines the start value
  82211. * @param endValue defines the end value
  82212. * @param gradient defines the gradient factor
  82213. * @param result defines the Matrix object where to store data
  82214. */
  82215. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82216. /**
  82217. * Builds a new matrix whose values are computed by:
  82218. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82219. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82220. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82221. * @param startValue defines the first matrix
  82222. * @param endValue defines the second matrix
  82223. * @param gradient defines the gradient between the two matrices
  82224. * @returns the new matrix
  82225. */
  82226. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82227. /**
  82228. * Update a matrix to values which are computed by:
  82229. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82230. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82231. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82232. * @param startValue defines the first matrix
  82233. * @param endValue defines the second matrix
  82234. * @param gradient defines the gradient between the two matrices
  82235. * @param result defines the target matrix
  82236. */
  82237. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82238. /**
  82239. * 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"
  82240. * This function works in left handed mode
  82241. * @param eye defines the final position of the entity
  82242. * @param target defines where the entity should look at
  82243. * @param up defines the up vector for the entity
  82244. * @returns the new matrix
  82245. */
  82246. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82247. /**
  82248. * 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".
  82249. * This function works in left handed mode
  82250. * @param eye defines the final position of the entity
  82251. * @param target defines where the entity should look at
  82252. * @param up defines the up vector for the entity
  82253. * @param result defines the target matrix
  82254. */
  82255. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82256. /**
  82257. * 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"
  82258. * This function works in right handed mode
  82259. * @param eye defines the final position of the entity
  82260. * @param target defines where the entity should look at
  82261. * @param up defines the up vector for the entity
  82262. * @returns the new matrix
  82263. */
  82264. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82265. /**
  82266. * 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".
  82267. * This function works in right handed mode
  82268. * @param eye defines the final position of the entity
  82269. * @param target defines where the entity should look at
  82270. * @param up defines the up vector for the entity
  82271. * @param result defines the target matrix
  82272. */
  82273. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82274. /**
  82275. * Create a left-handed orthographic projection matrix
  82276. * @param width defines the viewport width
  82277. * @param height defines the viewport height
  82278. * @param znear defines the near clip plane
  82279. * @param zfar defines the far clip plane
  82280. * @returns a new matrix as a left-handed orthographic projection matrix
  82281. */
  82282. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82283. /**
  82284. * Store a left-handed orthographic projection to a given matrix
  82285. * @param width defines the viewport width
  82286. * @param height defines the viewport height
  82287. * @param znear defines the near clip plane
  82288. * @param zfar defines the far clip plane
  82289. * @param result defines the target matrix
  82290. */
  82291. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82292. /**
  82293. * Create a left-handed orthographic projection matrix
  82294. * @param left defines the viewport left coordinate
  82295. * @param right defines the viewport right coordinate
  82296. * @param bottom defines the viewport bottom coordinate
  82297. * @param top defines the viewport top coordinate
  82298. * @param znear defines the near clip plane
  82299. * @param zfar defines the far clip plane
  82300. * @returns a new matrix as a left-handed orthographic projection matrix
  82301. */
  82302. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82303. /**
  82304. * Stores a left-handed orthographic projection into a given matrix
  82305. * @param left defines the viewport left coordinate
  82306. * @param right defines the viewport right coordinate
  82307. * @param bottom defines the viewport bottom coordinate
  82308. * @param top defines the viewport top coordinate
  82309. * @param znear defines the near clip plane
  82310. * @param zfar defines the far clip plane
  82311. * @param result defines the target matrix
  82312. */
  82313. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82314. /**
  82315. * Creates a right-handed orthographic projection matrix
  82316. * @param left defines the viewport left coordinate
  82317. * @param right defines the viewport right coordinate
  82318. * @param bottom defines the viewport bottom coordinate
  82319. * @param top defines the viewport top coordinate
  82320. * @param znear defines the near clip plane
  82321. * @param zfar defines the far clip plane
  82322. * @returns a new matrix as a right-handed orthographic projection matrix
  82323. */
  82324. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82325. /**
  82326. * Stores a right-handed orthographic projection into a given matrix
  82327. * @param left defines the viewport left coordinate
  82328. * @param right defines the viewport right coordinate
  82329. * @param bottom defines the viewport bottom coordinate
  82330. * @param top defines the viewport top coordinate
  82331. * @param znear defines the near clip plane
  82332. * @param zfar defines the far clip plane
  82333. * @param result defines the target matrix
  82334. */
  82335. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82336. /**
  82337. * Creates a left-handed perspective projection matrix
  82338. * @param width defines the viewport width
  82339. * @param height defines the viewport height
  82340. * @param znear defines the near clip plane
  82341. * @param zfar defines the far clip plane
  82342. * @returns a new matrix as a left-handed perspective projection matrix
  82343. */
  82344. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82345. /**
  82346. * Creates a left-handed perspective projection matrix
  82347. * @param fov defines the horizontal field of view
  82348. * @param aspect defines the aspect ratio
  82349. * @param znear defines the near clip plane
  82350. * @param zfar defines the far clip plane
  82351. * @returns a new matrix as a left-handed perspective projection matrix
  82352. */
  82353. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82354. /**
  82355. * Stores a left-handed perspective projection into a given matrix
  82356. * @param fov defines the horizontal field of view
  82357. * @param aspect defines the aspect ratio
  82358. * @param znear defines the near clip plane
  82359. * @param zfar defines the far clip plane
  82360. * @param result defines the target matrix
  82361. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82362. */
  82363. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82364. /**
  82365. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82366. * @param fov defines the horizontal field of view
  82367. * @param aspect defines the aspect ratio
  82368. * @param znear defines the near clip plane
  82369. * @param zfar not used as infinity is used as far clip
  82370. * @param result defines the target matrix
  82371. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82372. */
  82373. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82374. /**
  82375. * Creates a right-handed perspective projection matrix
  82376. * @param fov defines the horizontal field of view
  82377. * @param aspect defines the aspect ratio
  82378. * @param znear defines the near clip plane
  82379. * @param zfar defines the far clip plane
  82380. * @returns a new matrix as a right-handed perspective projection matrix
  82381. */
  82382. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82383. /**
  82384. * Stores a right-handed perspective projection into a given matrix
  82385. * @param fov defines the horizontal field of view
  82386. * @param aspect defines the aspect ratio
  82387. * @param znear defines the near clip plane
  82388. * @param zfar defines the far clip plane
  82389. * @param result defines the target matrix
  82390. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82391. */
  82392. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82393. /**
  82394. * Stores a right-handed perspective projection into a given matrix
  82395. * @param fov defines the horizontal field of view
  82396. * @param aspect defines the aspect ratio
  82397. * @param znear defines the near clip plane
  82398. * @param zfar not used as infinity is used as far clip
  82399. * @param result defines the target matrix
  82400. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82401. */
  82402. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82403. /**
  82404. * Stores a perspective projection for WebVR info a given matrix
  82405. * @param fov defines the field of view
  82406. * @param znear defines the near clip plane
  82407. * @param zfar defines the far clip plane
  82408. * @param result defines the target matrix
  82409. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82410. */
  82411. static PerspectiveFovWebVRToRef(fov: {
  82412. upDegrees: number;
  82413. downDegrees: number;
  82414. leftDegrees: number;
  82415. rightDegrees: number;
  82416. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82417. /**
  82418. * Computes a complete transformation matrix
  82419. * @param viewport defines the viewport to use
  82420. * @param world defines the world matrix
  82421. * @param view defines the view matrix
  82422. * @param projection defines the projection matrix
  82423. * @param zmin defines the near clip plane
  82424. * @param zmax defines the far clip plane
  82425. * @returns the transformation matrix
  82426. */
  82427. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82428. /**
  82429. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82430. * @param matrix defines the matrix to use
  82431. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82432. */
  82433. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82434. /**
  82435. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82436. * @param matrix defines the matrix to use
  82437. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82438. */
  82439. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82440. /**
  82441. * Compute the transpose of a given matrix
  82442. * @param matrix defines the matrix to transpose
  82443. * @returns the new matrix
  82444. */
  82445. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82446. /**
  82447. * Compute the transpose of a matrix and store it in a target matrix
  82448. * @param matrix defines the matrix to transpose
  82449. * @param result defines the target matrix
  82450. */
  82451. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82452. /**
  82453. * Computes a reflection matrix from a plane
  82454. * @param plane defines the reflection plane
  82455. * @returns a new matrix
  82456. */
  82457. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82458. /**
  82459. * Computes a reflection matrix from a plane
  82460. * @param plane defines the reflection plane
  82461. * @param result defines the target matrix
  82462. */
  82463. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82464. /**
  82465. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82466. * @param xaxis defines the value of the 1st axis
  82467. * @param yaxis defines the value of the 2nd axis
  82468. * @param zaxis defines the value of the 3rd axis
  82469. * @param result defines the target matrix
  82470. */
  82471. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82472. /**
  82473. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82474. * @param quat defines the quaternion to use
  82475. * @param result defines the target matrix
  82476. */
  82477. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82478. }
  82479. /**
  82480. * @hidden
  82481. */
  82482. export class TmpVectors {
  82483. static Vector2: Vector2[];
  82484. static Vector3: Vector3[];
  82485. static Vector4: Vector4[];
  82486. static Quaternion: Quaternion[];
  82487. static Matrix: Matrix[];
  82488. }
  82489. }
  82490. declare module BABYLON {
  82491. /**
  82492. * Defines potential orientation for back face culling
  82493. */
  82494. export enum Orientation {
  82495. /**
  82496. * Clockwise
  82497. */
  82498. CW = 0,
  82499. /** Counter clockwise */
  82500. CCW = 1
  82501. }
  82502. /** Class used to represent a Bezier curve */
  82503. export class BezierCurve {
  82504. /**
  82505. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82506. * @param t defines the time
  82507. * @param x1 defines the left coordinate on X axis
  82508. * @param y1 defines the left coordinate on Y axis
  82509. * @param x2 defines the right coordinate on X axis
  82510. * @param y2 defines the right coordinate on Y axis
  82511. * @returns the interpolated value
  82512. */
  82513. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82514. }
  82515. /**
  82516. * Defines angle representation
  82517. */
  82518. export class Angle {
  82519. private _radians;
  82520. /**
  82521. * Creates an Angle object of "radians" radians (float).
  82522. * @param radians the angle in radians
  82523. */
  82524. constructor(radians: number);
  82525. /**
  82526. * Get value in degrees
  82527. * @returns the Angle value in degrees (float)
  82528. */
  82529. degrees(): number;
  82530. /**
  82531. * Get value in radians
  82532. * @returns the Angle value in radians (float)
  82533. */
  82534. radians(): number;
  82535. /**
  82536. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82537. * @param a defines first vector
  82538. * @param b defines second vector
  82539. * @returns a new Angle
  82540. */
  82541. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82542. /**
  82543. * Gets a new Angle object from the given float in radians
  82544. * @param radians defines the angle value in radians
  82545. * @returns a new Angle
  82546. */
  82547. static FromRadians(radians: number): Angle;
  82548. /**
  82549. * Gets a new Angle object from the given float in degrees
  82550. * @param degrees defines the angle value in degrees
  82551. * @returns a new Angle
  82552. */
  82553. static FromDegrees(degrees: number): Angle;
  82554. }
  82555. /**
  82556. * This represents an arc in a 2d space.
  82557. */
  82558. export class Arc2 {
  82559. /** Defines the start point of the arc */
  82560. startPoint: Vector2;
  82561. /** Defines the mid point of the arc */
  82562. midPoint: Vector2;
  82563. /** Defines the end point of the arc */
  82564. endPoint: Vector2;
  82565. /**
  82566. * Defines the center point of the arc.
  82567. */
  82568. centerPoint: Vector2;
  82569. /**
  82570. * Defines the radius of the arc.
  82571. */
  82572. radius: number;
  82573. /**
  82574. * Defines the angle of the arc (from mid point to end point).
  82575. */
  82576. angle: Angle;
  82577. /**
  82578. * Defines the start angle of the arc (from start point to middle point).
  82579. */
  82580. startAngle: Angle;
  82581. /**
  82582. * Defines the orientation of the arc (clock wise/counter clock wise).
  82583. */
  82584. orientation: Orientation;
  82585. /**
  82586. * Creates an Arc object from the three given points : start, middle and end.
  82587. * @param startPoint Defines the start point of the arc
  82588. * @param midPoint Defines the midlle point of the arc
  82589. * @param endPoint Defines the end point of the arc
  82590. */
  82591. constructor(
  82592. /** Defines the start point of the arc */
  82593. startPoint: Vector2,
  82594. /** Defines the mid point of the arc */
  82595. midPoint: Vector2,
  82596. /** Defines the end point of the arc */
  82597. endPoint: Vector2);
  82598. }
  82599. /**
  82600. * Represents a 2D path made up of multiple 2D points
  82601. */
  82602. export class Path2 {
  82603. private _points;
  82604. private _length;
  82605. /**
  82606. * If the path start and end point are the same
  82607. */
  82608. closed: boolean;
  82609. /**
  82610. * Creates a Path2 object from the starting 2D coordinates x and y.
  82611. * @param x the starting points x value
  82612. * @param y the starting points y value
  82613. */
  82614. constructor(x: number, y: number);
  82615. /**
  82616. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82617. * @param x the added points x value
  82618. * @param y the added points y value
  82619. * @returns the updated Path2.
  82620. */
  82621. addLineTo(x: number, y: number): Path2;
  82622. /**
  82623. * 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.
  82624. * @param midX middle point x value
  82625. * @param midY middle point y value
  82626. * @param endX end point x value
  82627. * @param endY end point y value
  82628. * @param numberOfSegments (default: 36)
  82629. * @returns the updated Path2.
  82630. */
  82631. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82632. /**
  82633. * Closes the Path2.
  82634. * @returns the Path2.
  82635. */
  82636. close(): Path2;
  82637. /**
  82638. * Gets the sum of the distance between each sequential point in the path
  82639. * @returns the Path2 total length (float).
  82640. */
  82641. length(): number;
  82642. /**
  82643. * Gets the points which construct the path
  82644. * @returns the Path2 internal array of points.
  82645. */
  82646. getPoints(): Vector2[];
  82647. /**
  82648. * Retreives the point at the distance aways from the starting point
  82649. * @param normalizedLengthPosition the length along the path to retreive the point from
  82650. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82651. */
  82652. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82653. /**
  82654. * Creates a new path starting from an x and y position
  82655. * @param x starting x value
  82656. * @param y starting y value
  82657. * @returns a new Path2 starting at the coordinates (x, y).
  82658. */
  82659. static StartingAt(x: number, y: number): Path2;
  82660. }
  82661. /**
  82662. * Represents a 3D path made up of multiple 3D points
  82663. */
  82664. export class Path3D {
  82665. /**
  82666. * an array of Vector3, the curve axis of the Path3D
  82667. */
  82668. path: Vector3[];
  82669. private _curve;
  82670. private _distances;
  82671. private _tangents;
  82672. private _normals;
  82673. private _binormals;
  82674. private _raw;
  82675. private _alignTangentsWithPath;
  82676. private readonly _pointAtData;
  82677. /**
  82678. * new Path3D(path, normal, raw)
  82679. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82680. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82681. * @param path an array of Vector3, the curve axis of the Path3D
  82682. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82683. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82684. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82685. */
  82686. constructor(
  82687. /**
  82688. * an array of Vector3, the curve axis of the Path3D
  82689. */
  82690. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82691. /**
  82692. * Returns the Path3D array of successive Vector3 designing its curve.
  82693. * @returns the Path3D array of successive Vector3 designing its curve.
  82694. */
  82695. getCurve(): Vector3[];
  82696. /**
  82697. * Returns the Path3D array of successive Vector3 designing its curve.
  82698. * @returns the Path3D array of successive Vector3 designing its curve.
  82699. */
  82700. getPoints(): Vector3[];
  82701. /**
  82702. * @returns the computed length (float) of the path.
  82703. */
  82704. length(): number;
  82705. /**
  82706. * Returns an array populated with tangent vectors on each Path3D curve point.
  82707. * @returns an array populated with tangent vectors on each Path3D curve point.
  82708. */
  82709. getTangents(): Vector3[];
  82710. /**
  82711. * Returns an array populated with normal vectors on each Path3D curve point.
  82712. * @returns an array populated with normal vectors on each Path3D curve point.
  82713. */
  82714. getNormals(): Vector3[];
  82715. /**
  82716. * Returns an array populated with binormal vectors on each Path3D curve point.
  82717. * @returns an array populated with binormal vectors on each Path3D curve point.
  82718. */
  82719. getBinormals(): Vector3[];
  82720. /**
  82721. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82722. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82723. */
  82724. getDistances(): number[];
  82725. /**
  82726. * Returns an interpolated point along this path
  82727. * @param position the position of the point along this path, from 0.0 to 1.0
  82728. * @returns a new Vector3 as the point
  82729. */
  82730. getPointAt(position: number): Vector3;
  82731. /**
  82732. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82733. * @param position the position of the point along this path, from 0.0 to 1.0
  82734. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82735. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82736. */
  82737. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82738. /**
  82739. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82740. * @param position the position of the point along this path, from 0.0 to 1.0
  82741. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82742. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82743. */
  82744. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82745. /**
  82746. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82747. * @param position the position of the point along this path, from 0.0 to 1.0
  82748. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82749. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82750. */
  82751. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82752. /**
  82753. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82754. * @param position the position of the point along this path, from 0.0 to 1.0
  82755. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82756. */
  82757. getDistanceAt(position: number): number;
  82758. /**
  82759. * Returns the array index of the previous point of an interpolated point along this path
  82760. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82761. * @returns the array index
  82762. */
  82763. getPreviousPointIndexAt(position: number): number;
  82764. /**
  82765. * 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)
  82766. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82767. * @returns the sub position
  82768. */
  82769. getSubPositionAt(position: number): number;
  82770. /**
  82771. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82772. * @param target the vector of which to get the closest position to
  82773. * @returns the position of the closest virtual point on this path to the target vector
  82774. */
  82775. getClosestPositionTo(target: Vector3): number;
  82776. /**
  82777. * Returns a sub path (slice) of this path
  82778. * @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
  82779. * @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
  82780. * @returns a sub path (slice) of this path
  82781. */
  82782. slice(start?: number, end?: number): Path3D;
  82783. /**
  82784. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82785. * @param path path which all values are copied into the curves points
  82786. * @param firstNormal which should be projected onto the curve
  82787. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82788. * @returns the same object updated.
  82789. */
  82790. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82791. private _compute;
  82792. private _getFirstNonNullVector;
  82793. private _getLastNonNullVector;
  82794. private _normalVector;
  82795. /**
  82796. * Updates the point at data for an interpolated point along this curve
  82797. * @param position the position of the point along this curve, from 0.0 to 1.0
  82798. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82799. * @returns the (updated) point at data
  82800. */
  82801. private _updatePointAtData;
  82802. /**
  82803. * Updates the point at data from the specified parameters
  82804. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82805. * @param point the interpolated point
  82806. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82807. */
  82808. private _setPointAtData;
  82809. /**
  82810. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82811. */
  82812. private _updateInterpolationMatrix;
  82813. }
  82814. /**
  82815. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82816. * A Curve3 is designed from a series of successive Vector3.
  82817. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82818. */
  82819. export class Curve3 {
  82820. private _points;
  82821. private _length;
  82822. /**
  82823. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82824. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82825. * @param v1 (Vector3) the control point
  82826. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82827. * @param nbPoints (integer) the wanted number of points in the curve
  82828. * @returns the created Curve3
  82829. */
  82830. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82831. /**
  82832. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82833. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82834. * @param v1 (Vector3) the first control point
  82835. * @param v2 (Vector3) the second control point
  82836. * @param v3 (Vector3) the end point of the Cubic Bezier
  82837. * @param nbPoints (integer) the wanted number of points in the curve
  82838. * @returns the created Curve3
  82839. */
  82840. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82841. /**
  82842. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82843. * @param p1 (Vector3) the origin point of the Hermite Spline
  82844. * @param t1 (Vector3) the tangent vector at the origin point
  82845. * @param p2 (Vector3) the end point of the Hermite Spline
  82846. * @param t2 (Vector3) the tangent vector at the end point
  82847. * @param nbPoints (integer) the wanted number of points in the curve
  82848. * @returns the created Curve3
  82849. */
  82850. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82851. /**
  82852. * Returns a Curve3 object along a CatmullRom Spline curve :
  82853. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82854. * @param nbPoints (integer) the wanted number of points between each curve control points
  82855. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82856. * @returns the created Curve3
  82857. */
  82858. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82859. /**
  82860. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82861. * A Curve3 is designed from a series of successive Vector3.
  82862. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82863. * @param points points which make up the curve
  82864. */
  82865. constructor(points: Vector3[]);
  82866. /**
  82867. * @returns the Curve3 stored array of successive Vector3
  82868. */
  82869. getPoints(): Vector3[];
  82870. /**
  82871. * @returns the computed length (float) of the curve.
  82872. */
  82873. length(): number;
  82874. /**
  82875. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82876. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82877. * curveA and curveB keep unchanged.
  82878. * @param curve the curve to continue from this curve
  82879. * @returns the newly constructed curve
  82880. */
  82881. continue(curve: DeepImmutable<Curve3>): Curve3;
  82882. private _computeLength;
  82883. }
  82884. }
  82885. declare module BABYLON {
  82886. /**
  82887. * This represents the main contract an easing function should follow.
  82888. * Easing functions are used throughout the animation system.
  82889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82890. */
  82891. export interface IEasingFunction {
  82892. /**
  82893. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82894. * of the easing function.
  82895. * The link below provides some of the most common examples of easing functions.
  82896. * @see https://easings.net/
  82897. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82898. * @returns the corresponding value on the curve defined by the easing function
  82899. */
  82900. ease(gradient: number): number;
  82901. }
  82902. /**
  82903. * Base class used for every default easing function.
  82904. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82905. */
  82906. export class EasingFunction implements IEasingFunction {
  82907. /**
  82908. * Interpolation follows the mathematical formula associated with the easing function.
  82909. */
  82910. static readonly EASINGMODE_EASEIN: number;
  82911. /**
  82912. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82913. */
  82914. static readonly EASINGMODE_EASEOUT: number;
  82915. /**
  82916. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82917. */
  82918. static readonly EASINGMODE_EASEINOUT: number;
  82919. private _easingMode;
  82920. /**
  82921. * Sets the easing mode of the current function.
  82922. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82923. */
  82924. setEasingMode(easingMode: number): void;
  82925. /**
  82926. * Gets the current easing mode.
  82927. * @returns the easing mode
  82928. */
  82929. getEasingMode(): number;
  82930. /**
  82931. * @hidden
  82932. */
  82933. easeInCore(gradient: number): number;
  82934. /**
  82935. * Given an input gradient between 0 and 1, this returns the corresponding value
  82936. * of the easing function.
  82937. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82938. * @returns the corresponding value on the curve defined by the easing function
  82939. */
  82940. ease(gradient: number): number;
  82941. }
  82942. /**
  82943. * Easing function with a circle shape (see link below).
  82944. * @see https://easings.net/#easeInCirc
  82945. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82946. */
  82947. export class CircleEase extends EasingFunction implements IEasingFunction {
  82948. /** @hidden */
  82949. easeInCore(gradient: number): number;
  82950. }
  82951. /**
  82952. * Easing function with a ease back shape (see link below).
  82953. * @see https://easings.net/#easeInBack
  82954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82955. */
  82956. export class BackEase extends EasingFunction implements IEasingFunction {
  82957. /** Defines the amplitude of the function */
  82958. amplitude: number;
  82959. /**
  82960. * Instantiates a back ease easing
  82961. * @see https://easings.net/#easeInBack
  82962. * @param amplitude Defines the amplitude of the function
  82963. */
  82964. constructor(
  82965. /** Defines the amplitude of the function */
  82966. amplitude?: number);
  82967. /** @hidden */
  82968. easeInCore(gradient: number): number;
  82969. }
  82970. /**
  82971. * Easing function with a bouncing shape (see link below).
  82972. * @see https://easings.net/#easeInBounce
  82973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82974. */
  82975. export class BounceEase extends EasingFunction implements IEasingFunction {
  82976. /** Defines the number of bounces */
  82977. bounces: number;
  82978. /** Defines the amplitude of the bounce */
  82979. bounciness: number;
  82980. /**
  82981. * Instantiates a bounce easing
  82982. * @see https://easings.net/#easeInBounce
  82983. * @param bounces Defines the number of bounces
  82984. * @param bounciness Defines the amplitude of the bounce
  82985. */
  82986. constructor(
  82987. /** Defines the number of bounces */
  82988. bounces?: number,
  82989. /** Defines the amplitude of the bounce */
  82990. bounciness?: number);
  82991. /** @hidden */
  82992. easeInCore(gradient: number): number;
  82993. }
  82994. /**
  82995. * Easing function with a power of 3 shape (see link below).
  82996. * @see https://easings.net/#easeInCubic
  82997. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82998. */
  82999. export class CubicEase extends EasingFunction implements IEasingFunction {
  83000. /** @hidden */
  83001. easeInCore(gradient: number): number;
  83002. }
  83003. /**
  83004. * Easing function with an elastic shape (see link below).
  83005. * @see https://easings.net/#easeInElastic
  83006. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83007. */
  83008. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83009. /** Defines the number of oscillations*/
  83010. oscillations: number;
  83011. /** Defines the amplitude of the oscillations*/
  83012. springiness: number;
  83013. /**
  83014. * Instantiates an elastic easing function
  83015. * @see https://easings.net/#easeInElastic
  83016. * @param oscillations Defines the number of oscillations
  83017. * @param springiness Defines the amplitude of the oscillations
  83018. */
  83019. constructor(
  83020. /** Defines the number of oscillations*/
  83021. oscillations?: number,
  83022. /** Defines the amplitude of the oscillations*/
  83023. springiness?: number);
  83024. /** @hidden */
  83025. easeInCore(gradient: number): number;
  83026. }
  83027. /**
  83028. * Easing function with an exponential shape (see link below).
  83029. * @see https://easings.net/#easeInExpo
  83030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83031. */
  83032. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83033. /** Defines the exponent of the function */
  83034. exponent: number;
  83035. /**
  83036. * Instantiates an exponential easing function
  83037. * @see https://easings.net/#easeInExpo
  83038. * @param exponent Defines the exponent of the function
  83039. */
  83040. constructor(
  83041. /** Defines the exponent of the function */
  83042. exponent?: number);
  83043. /** @hidden */
  83044. easeInCore(gradient: number): number;
  83045. }
  83046. /**
  83047. * Easing function with a power shape (see link below).
  83048. * @see https://easings.net/#easeInQuad
  83049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83050. */
  83051. export class PowerEase extends EasingFunction implements IEasingFunction {
  83052. /** Defines the power of the function */
  83053. power: number;
  83054. /**
  83055. * Instantiates an power base easing function
  83056. * @see https://easings.net/#easeInQuad
  83057. * @param power Defines the power of the function
  83058. */
  83059. constructor(
  83060. /** Defines the power of the function */
  83061. power?: number);
  83062. /** @hidden */
  83063. easeInCore(gradient: number): number;
  83064. }
  83065. /**
  83066. * Easing function with a power of 2 shape (see link below).
  83067. * @see https://easings.net/#easeInQuad
  83068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83069. */
  83070. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83071. /** @hidden */
  83072. easeInCore(gradient: number): number;
  83073. }
  83074. /**
  83075. * Easing function with a power of 4 shape (see link below).
  83076. * @see https://easings.net/#easeInQuart
  83077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83078. */
  83079. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83080. /** @hidden */
  83081. easeInCore(gradient: number): number;
  83082. }
  83083. /**
  83084. * Easing function with a power of 5 shape (see link below).
  83085. * @see https://easings.net/#easeInQuint
  83086. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83087. */
  83088. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83089. /** @hidden */
  83090. easeInCore(gradient: number): number;
  83091. }
  83092. /**
  83093. * Easing function with a sin shape (see link below).
  83094. * @see https://easings.net/#easeInSine
  83095. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83096. */
  83097. export class SineEase extends EasingFunction implements IEasingFunction {
  83098. /** @hidden */
  83099. easeInCore(gradient: number): number;
  83100. }
  83101. /**
  83102. * Easing function with a bezier shape (see link below).
  83103. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83105. */
  83106. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83107. /** Defines the x component of the start tangent in the bezier curve */
  83108. x1: number;
  83109. /** Defines the y component of the start tangent in the bezier curve */
  83110. y1: number;
  83111. /** Defines the x component of the end tangent in the bezier curve */
  83112. x2: number;
  83113. /** Defines the y component of the end tangent in the bezier curve */
  83114. y2: number;
  83115. /**
  83116. * Instantiates a bezier function
  83117. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83118. * @param x1 Defines the x component of the start tangent in the bezier curve
  83119. * @param y1 Defines the y component of the start tangent in the bezier curve
  83120. * @param x2 Defines the x component of the end tangent in the bezier curve
  83121. * @param y2 Defines the y component of the end tangent in the bezier curve
  83122. */
  83123. constructor(
  83124. /** Defines the x component of the start tangent in the bezier curve */
  83125. x1?: number,
  83126. /** Defines the y component of the start tangent in the bezier curve */
  83127. y1?: number,
  83128. /** Defines the x component of the end tangent in the bezier curve */
  83129. x2?: number,
  83130. /** Defines the y component of the end tangent in the bezier curve */
  83131. y2?: number);
  83132. /** @hidden */
  83133. easeInCore(gradient: number): number;
  83134. }
  83135. }
  83136. declare module BABYLON {
  83137. /**
  83138. * Class used to hold a RBG color
  83139. */
  83140. export class Color3 {
  83141. /**
  83142. * Defines the red component (between 0 and 1, default is 0)
  83143. */
  83144. r: number;
  83145. /**
  83146. * Defines the green component (between 0 and 1, default is 0)
  83147. */
  83148. g: number;
  83149. /**
  83150. * Defines the blue component (between 0 and 1, default is 0)
  83151. */
  83152. b: number;
  83153. /**
  83154. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83155. * @param r defines the red component (between 0 and 1, default is 0)
  83156. * @param g defines the green component (between 0 and 1, default is 0)
  83157. * @param b defines the blue component (between 0 and 1, default is 0)
  83158. */
  83159. constructor(
  83160. /**
  83161. * Defines the red component (between 0 and 1, default is 0)
  83162. */
  83163. r?: number,
  83164. /**
  83165. * Defines the green component (between 0 and 1, default is 0)
  83166. */
  83167. g?: number,
  83168. /**
  83169. * Defines the blue component (between 0 and 1, default is 0)
  83170. */
  83171. b?: number);
  83172. /**
  83173. * Creates a string with the Color3 current values
  83174. * @returns the string representation of the Color3 object
  83175. */
  83176. toString(): string;
  83177. /**
  83178. * Returns the string "Color3"
  83179. * @returns "Color3"
  83180. */
  83181. getClassName(): string;
  83182. /**
  83183. * Compute the Color3 hash code
  83184. * @returns an unique number that can be used to hash Color3 objects
  83185. */
  83186. getHashCode(): number;
  83187. /**
  83188. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83189. * @param array defines the array where to store the r,g,b components
  83190. * @param index defines an optional index in the target array to define where to start storing values
  83191. * @returns the current Color3 object
  83192. */
  83193. toArray(array: FloatArray, index?: number): Color3;
  83194. /**
  83195. * Returns a new Color4 object from the current Color3 and the given alpha
  83196. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83197. * @returns a new Color4 object
  83198. */
  83199. toColor4(alpha?: number): Color4;
  83200. /**
  83201. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83202. * @returns the new array
  83203. */
  83204. asArray(): number[];
  83205. /**
  83206. * Returns the luminance value
  83207. * @returns a float value
  83208. */
  83209. toLuminance(): number;
  83210. /**
  83211. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83212. * @param otherColor defines the second operand
  83213. * @returns the new Color3 object
  83214. */
  83215. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83216. /**
  83217. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83218. * @param otherColor defines the second operand
  83219. * @param result defines the Color3 object where to store the result
  83220. * @returns the current Color3
  83221. */
  83222. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83223. /**
  83224. * Determines equality between Color3 objects
  83225. * @param otherColor defines the second operand
  83226. * @returns true if the rgb values are equal to the given ones
  83227. */
  83228. equals(otherColor: DeepImmutable<Color3>): boolean;
  83229. /**
  83230. * Determines equality between the current Color3 object and a set of r,b,g values
  83231. * @param r defines the red component to check
  83232. * @param g defines the green component to check
  83233. * @param b defines the blue component to check
  83234. * @returns true if the rgb values are equal to the given ones
  83235. */
  83236. equalsFloats(r: number, g: number, b: number): boolean;
  83237. /**
  83238. * Multiplies in place each rgb value by scale
  83239. * @param scale defines the scaling factor
  83240. * @returns the updated Color3
  83241. */
  83242. scale(scale: number): Color3;
  83243. /**
  83244. * Multiplies the rgb values by scale and stores the result into "result"
  83245. * @param scale defines the scaling factor
  83246. * @param result defines the Color3 object where to store the result
  83247. * @returns the unmodified current Color3
  83248. */
  83249. scaleToRef(scale: number, result: Color3): Color3;
  83250. /**
  83251. * Scale the current Color3 values by a factor and add the result to a given Color3
  83252. * @param scale defines the scale factor
  83253. * @param result defines color to store the result into
  83254. * @returns the unmodified current Color3
  83255. */
  83256. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83257. /**
  83258. * Clamps the rgb values by the min and max values and stores the result into "result"
  83259. * @param min defines minimum clamping value (default is 0)
  83260. * @param max defines maximum clamping value (default is 1)
  83261. * @param result defines color to store the result into
  83262. * @returns the original Color3
  83263. */
  83264. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83265. /**
  83266. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83267. * @param otherColor defines the second operand
  83268. * @returns the new Color3
  83269. */
  83270. add(otherColor: DeepImmutable<Color3>): Color3;
  83271. /**
  83272. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83273. * @param otherColor defines the second operand
  83274. * @param result defines Color3 object to store the result into
  83275. * @returns the unmodified current Color3
  83276. */
  83277. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83278. /**
  83279. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83280. * @param otherColor defines the second operand
  83281. * @returns the new Color3
  83282. */
  83283. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83284. /**
  83285. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83286. * @param otherColor defines the second operand
  83287. * @param result defines Color3 object to store the result into
  83288. * @returns the unmodified current Color3
  83289. */
  83290. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83291. /**
  83292. * Copy the current object
  83293. * @returns a new Color3 copied the current one
  83294. */
  83295. clone(): Color3;
  83296. /**
  83297. * Copies the rgb values from the source in the current Color3
  83298. * @param source defines the source Color3 object
  83299. * @returns the updated Color3 object
  83300. */
  83301. copyFrom(source: DeepImmutable<Color3>): Color3;
  83302. /**
  83303. * Updates the Color3 rgb values from the given floats
  83304. * @param r defines the red component to read from
  83305. * @param g defines the green component to read from
  83306. * @param b defines the blue component to read from
  83307. * @returns the current Color3 object
  83308. */
  83309. copyFromFloats(r: number, g: number, b: number): Color3;
  83310. /**
  83311. * Updates the Color3 rgb values from the given floats
  83312. * @param r defines the red component to read from
  83313. * @param g defines the green component to read from
  83314. * @param b defines the blue component to read from
  83315. * @returns the current Color3 object
  83316. */
  83317. set(r: number, g: number, b: number): Color3;
  83318. /**
  83319. * Compute the Color3 hexadecimal code as a string
  83320. * @returns a string containing the hexadecimal representation of the Color3 object
  83321. */
  83322. toHexString(): string;
  83323. /**
  83324. * Computes a new Color3 converted from the current one to linear space
  83325. * @returns a new Color3 object
  83326. */
  83327. toLinearSpace(): Color3;
  83328. /**
  83329. * Converts current color in rgb space to HSV values
  83330. * @returns a new color3 representing the HSV values
  83331. */
  83332. toHSV(): Color3;
  83333. /**
  83334. * Converts current color in rgb space to HSV values
  83335. * @param result defines the Color3 where to store the HSV values
  83336. */
  83337. toHSVToRef(result: Color3): void;
  83338. /**
  83339. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83340. * @param convertedColor defines the Color3 object where to store the linear space version
  83341. * @returns the unmodified Color3
  83342. */
  83343. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83344. /**
  83345. * Computes a new Color3 converted from the current one to gamma space
  83346. * @returns a new Color3 object
  83347. */
  83348. toGammaSpace(): Color3;
  83349. /**
  83350. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83351. * @param convertedColor defines the Color3 object where to store the gamma space version
  83352. * @returns the unmodified Color3
  83353. */
  83354. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83355. private static _BlackReadOnly;
  83356. /**
  83357. * Convert Hue, saturation and value to a Color3 (RGB)
  83358. * @param hue defines the hue
  83359. * @param saturation defines the saturation
  83360. * @param value defines the value
  83361. * @param result defines the Color3 where to store the RGB values
  83362. */
  83363. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83364. /**
  83365. * Creates a new Color3 from the string containing valid hexadecimal values
  83366. * @param hex defines a string containing valid hexadecimal values
  83367. * @returns a new Color3 object
  83368. */
  83369. static FromHexString(hex: string): Color3;
  83370. /**
  83371. * Creates a new Color3 from the starting index of the given array
  83372. * @param array defines the source array
  83373. * @param offset defines an offset in the source array
  83374. * @returns a new Color3 object
  83375. */
  83376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83377. /**
  83378. * Creates a new Color3 from integer values (< 256)
  83379. * @param r defines the red component to read from (value between 0 and 255)
  83380. * @param g defines the green component to read from (value between 0 and 255)
  83381. * @param b defines the blue component to read from (value between 0 and 255)
  83382. * @returns a new Color3 object
  83383. */
  83384. static FromInts(r: number, g: number, b: number): Color3;
  83385. /**
  83386. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83387. * @param start defines the start Color3 value
  83388. * @param end defines the end Color3 value
  83389. * @param amount defines the gradient value between start and end
  83390. * @returns a new Color3 object
  83391. */
  83392. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83393. /**
  83394. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83395. * @param left defines the start value
  83396. * @param right defines the end value
  83397. * @param amount defines the gradient factor
  83398. * @param result defines the Color3 object where to store the result
  83399. */
  83400. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83401. /**
  83402. * Returns a Color3 value containing a red color
  83403. * @returns a new Color3 object
  83404. */
  83405. static Red(): Color3;
  83406. /**
  83407. * Returns a Color3 value containing a green color
  83408. * @returns a new Color3 object
  83409. */
  83410. static Green(): Color3;
  83411. /**
  83412. * Returns a Color3 value containing a blue color
  83413. * @returns a new Color3 object
  83414. */
  83415. static Blue(): Color3;
  83416. /**
  83417. * Returns a Color3 value containing a black color
  83418. * @returns a new Color3 object
  83419. */
  83420. static Black(): Color3;
  83421. /**
  83422. * Gets a Color3 value containing a black color that must not be updated
  83423. */
  83424. static get BlackReadOnly(): DeepImmutable<Color3>;
  83425. /**
  83426. * Returns a Color3 value containing a white color
  83427. * @returns a new Color3 object
  83428. */
  83429. static White(): Color3;
  83430. /**
  83431. * Returns a Color3 value containing a purple color
  83432. * @returns a new Color3 object
  83433. */
  83434. static Purple(): Color3;
  83435. /**
  83436. * Returns a Color3 value containing a magenta color
  83437. * @returns a new Color3 object
  83438. */
  83439. static Magenta(): Color3;
  83440. /**
  83441. * Returns a Color3 value containing a yellow color
  83442. * @returns a new Color3 object
  83443. */
  83444. static Yellow(): Color3;
  83445. /**
  83446. * Returns a Color3 value containing a gray color
  83447. * @returns a new Color3 object
  83448. */
  83449. static Gray(): Color3;
  83450. /**
  83451. * Returns a Color3 value containing a teal color
  83452. * @returns a new Color3 object
  83453. */
  83454. static Teal(): Color3;
  83455. /**
  83456. * Returns a Color3 value containing a random color
  83457. * @returns a new Color3 object
  83458. */
  83459. static Random(): Color3;
  83460. }
  83461. /**
  83462. * Class used to hold a RBGA color
  83463. */
  83464. export class Color4 {
  83465. /**
  83466. * Defines the red component (between 0 and 1, default is 0)
  83467. */
  83468. r: number;
  83469. /**
  83470. * Defines the green component (between 0 and 1, default is 0)
  83471. */
  83472. g: number;
  83473. /**
  83474. * Defines the blue component (between 0 and 1, default is 0)
  83475. */
  83476. b: number;
  83477. /**
  83478. * Defines the alpha component (between 0 and 1, default is 1)
  83479. */
  83480. a: number;
  83481. /**
  83482. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83483. * @param r defines the red component (between 0 and 1, default is 0)
  83484. * @param g defines the green component (between 0 and 1, default is 0)
  83485. * @param b defines the blue component (between 0 and 1, default is 0)
  83486. * @param a defines the alpha component (between 0 and 1, default is 1)
  83487. */
  83488. constructor(
  83489. /**
  83490. * Defines the red component (between 0 and 1, default is 0)
  83491. */
  83492. r?: number,
  83493. /**
  83494. * Defines the green component (between 0 and 1, default is 0)
  83495. */
  83496. g?: number,
  83497. /**
  83498. * Defines the blue component (between 0 and 1, default is 0)
  83499. */
  83500. b?: number,
  83501. /**
  83502. * Defines the alpha component (between 0 and 1, default is 1)
  83503. */
  83504. a?: number);
  83505. /**
  83506. * Adds in place the given Color4 values to the current Color4 object
  83507. * @param right defines the second operand
  83508. * @returns the current updated Color4 object
  83509. */
  83510. addInPlace(right: DeepImmutable<Color4>): Color4;
  83511. /**
  83512. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83513. * @returns the new array
  83514. */
  83515. asArray(): number[];
  83516. /**
  83517. * Stores from the starting index in the given array the Color4 successive values
  83518. * @param array defines the array where to store the r,g,b components
  83519. * @param index defines an optional index in the target array to define where to start storing values
  83520. * @returns the current Color4 object
  83521. */
  83522. toArray(array: number[], index?: number): Color4;
  83523. /**
  83524. * Determines equality between Color4 objects
  83525. * @param otherColor defines the second operand
  83526. * @returns true if the rgba values are equal to the given ones
  83527. */
  83528. equals(otherColor: DeepImmutable<Color4>): boolean;
  83529. /**
  83530. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83531. * @param right defines the second operand
  83532. * @returns a new Color4 object
  83533. */
  83534. add(right: DeepImmutable<Color4>): Color4;
  83535. /**
  83536. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83537. * @param right defines the second operand
  83538. * @returns a new Color4 object
  83539. */
  83540. subtract(right: DeepImmutable<Color4>): Color4;
  83541. /**
  83542. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83543. * @param right defines the second operand
  83544. * @param result defines the Color4 object where to store the result
  83545. * @returns the current Color4 object
  83546. */
  83547. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83548. /**
  83549. * Creates a new Color4 with the current Color4 values multiplied by scale
  83550. * @param scale defines the scaling factor to apply
  83551. * @returns a new Color4 object
  83552. */
  83553. scale(scale: number): Color4;
  83554. /**
  83555. * Multiplies the current Color4 values by scale and stores the result in "result"
  83556. * @param scale defines the scaling factor to apply
  83557. * @param result defines the Color4 object where to store the result
  83558. * @returns the current unmodified Color4
  83559. */
  83560. scaleToRef(scale: number, result: Color4): Color4;
  83561. /**
  83562. * Scale the current Color4 values by a factor and add the result to a given Color4
  83563. * @param scale defines the scale factor
  83564. * @param result defines the Color4 object where to store the result
  83565. * @returns the unmodified current Color4
  83566. */
  83567. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83568. /**
  83569. * Clamps the rgb values by the min and max values and stores the result into "result"
  83570. * @param min defines minimum clamping value (default is 0)
  83571. * @param max defines maximum clamping value (default is 1)
  83572. * @param result defines color to store the result into.
  83573. * @returns the cuurent Color4
  83574. */
  83575. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83576. /**
  83577. * Multipy an Color4 value by another and return a new Color4 object
  83578. * @param color defines the Color4 value to multiply by
  83579. * @returns a new Color4 object
  83580. */
  83581. multiply(color: Color4): Color4;
  83582. /**
  83583. * Multipy a Color4 value by another and push the result in a reference value
  83584. * @param color defines the Color4 value to multiply by
  83585. * @param result defines the Color4 to fill the result in
  83586. * @returns the result Color4
  83587. */
  83588. multiplyToRef(color: Color4, result: Color4): Color4;
  83589. /**
  83590. * Creates a string with the Color4 current values
  83591. * @returns the string representation of the Color4 object
  83592. */
  83593. toString(): string;
  83594. /**
  83595. * Returns the string "Color4"
  83596. * @returns "Color4"
  83597. */
  83598. getClassName(): string;
  83599. /**
  83600. * Compute the Color4 hash code
  83601. * @returns an unique number that can be used to hash Color4 objects
  83602. */
  83603. getHashCode(): number;
  83604. /**
  83605. * Creates a new Color4 copied from the current one
  83606. * @returns a new Color4 object
  83607. */
  83608. clone(): Color4;
  83609. /**
  83610. * Copies the given Color4 values into the current one
  83611. * @param source defines the source Color4 object
  83612. * @returns the current updated Color4 object
  83613. */
  83614. copyFrom(source: Color4): Color4;
  83615. /**
  83616. * Copies the given float values into the current one
  83617. * @param r defines the red component to read from
  83618. * @param g defines the green component to read from
  83619. * @param b defines the blue component to read from
  83620. * @param a defines the alpha component to read from
  83621. * @returns the current updated Color4 object
  83622. */
  83623. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83624. /**
  83625. * Copies the given float values into the current one
  83626. * @param r defines the red component to read from
  83627. * @param g defines the green component to read from
  83628. * @param b defines the blue component to read from
  83629. * @param a defines the alpha component to read from
  83630. * @returns the current updated Color4 object
  83631. */
  83632. set(r: number, g: number, b: number, a: number): Color4;
  83633. /**
  83634. * Compute the Color4 hexadecimal code as a string
  83635. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83636. * @returns a string containing the hexadecimal representation of the Color4 object
  83637. */
  83638. toHexString(returnAsColor3?: boolean): string;
  83639. /**
  83640. * Computes a new Color4 converted from the current one to linear space
  83641. * @returns a new Color4 object
  83642. */
  83643. toLinearSpace(): Color4;
  83644. /**
  83645. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83646. * @param convertedColor defines the Color4 object where to store the linear space version
  83647. * @returns the unmodified Color4
  83648. */
  83649. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83650. /**
  83651. * Computes a new Color4 converted from the current one to gamma space
  83652. * @returns a new Color4 object
  83653. */
  83654. toGammaSpace(): Color4;
  83655. /**
  83656. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83657. * @param convertedColor defines the Color4 object where to store the gamma space version
  83658. * @returns the unmodified Color4
  83659. */
  83660. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83661. /**
  83662. * Creates a new Color4 from the string containing valid hexadecimal values
  83663. * @param hex defines a string containing valid hexadecimal values
  83664. * @returns a new Color4 object
  83665. */
  83666. static FromHexString(hex: string): Color4;
  83667. /**
  83668. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83669. * @param left defines the start value
  83670. * @param right defines the end value
  83671. * @param amount defines the gradient factor
  83672. * @returns a new Color4 object
  83673. */
  83674. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83675. /**
  83676. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83677. * @param left defines the start value
  83678. * @param right defines the end value
  83679. * @param amount defines the gradient factor
  83680. * @param result defines the Color4 object where to store data
  83681. */
  83682. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83683. /**
  83684. * Creates a new Color4 from a Color3 and an alpha value
  83685. * @param color3 defines the source Color3 to read from
  83686. * @param alpha defines the alpha component (1.0 by default)
  83687. * @returns a new Color4 object
  83688. */
  83689. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83690. /**
  83691. * Creates a new Color4 from the starting index element of the given array
  83692. * @param array defines the source array to read from
  83693. * @param offset defines the offset in the source array
  83694. * @returns a new Color4 object
  83695. */
  83696. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83697. /**
  83698. * Creates a new Color3 from integer values (< 256)
  83699. * @param r defines the red component to read from (value between 0 and 255)
  83700. * @param g defines the green component to read from (value between 0 and 255)
  83701. * @param b defines the blue component to read from (value between 0 and 255)
  83702. * @param a defines the alpha component to read from (value between 0 and 255)
  83703. * @returns a new Color3 object
  83704. */
  83705. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83706. /**
  83707. * Check the content of a given array and convert it to an array containing RGBA data
  83708. * If the original array was already containing count * 4 values then it is returned directly
  83709. * @param colors defines the array to check
  83710. * @param count defines the number of RGBA data to expect
  83711. * @returns an array containing count * 4 values (RGBA)
  83712. */
  83713. static CheckColors4(colors: number[], count: number): number[];
  83714. }
  83715. /**
  83716. * @hidden
  83717. */
  83718. export class TmpColors {
  83719. static Color3: Color3[];
  83720. static Color4: Color4[];
  83721. }
  83722. }
  83723. declare module BABYLON {
  83724. /**
  83725. * Defines an interface which represents an animation key frame
  83726. */
  83727. export interface IAnimationKey {
  83728. /**
  83729. * Frame of the key frame
  83730. */
  83731. frame: number;
  83732. /**
  83733. * Value at the specifies key frame
  83734. */
  83735. value: any;
  83736. /**
  83737. * The input tangent for the cubic hermite spline
  83738. */
  83739. inTangent?: any;
  83740. /**
  83741. * The output tangent for the cubic hermite spline
  83742. */
  83743. outTangent?: any;
  83744. /**
  83745. * The animation interpolation type
  83746. */
  83747. interpolation?: AnimationKeyInterpolation;
  83748. }
  83749. /**
  83750. * Enum for the animation key frame interpolation type
  83751. */
  83752. export enum AnimationKeyInterpolation {
  83753. /**
  83754. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83755. */
  83756. STEP = 1
  83757. }
  83758. }
  83759. declare module BABYLON {
  83760. /**
  83761. * Represents the range of an animation
  83762. */
  83763. export class AnimationRange {
  83764. /**The name of the animation range**/
  83765. name: string;
  83766. /**The starting frame of the animation */
  83767. from: number;
  83768. /**The ending frame of the animation*/
  83769. to: number;
  83770. /**
  83771. * Initializes the range of an animation
  83772. * @param name The name of the animation range
  83773. * @param from The starting frame of the animation
  83774. * @param to The ending frame of the animation
  83775. */
  83776. constructor(
  83777. /**The name of the animation range**/
  83778. name: string,
  83779. /**The starting frame of the animation */
  83780. from: number,
  83781. /**The ending frame of the animation*/
  83782. to: number);
  83783. /**
  83784. * Makes a copy of the animation range
  83785. * @returns A copy of the animation range
  83786. */
  83787. clone(): AnimationRange;
  83788. }
  83789. }
  83790. declare module BABYLON {
  83791. /**
  83792. * Composed of a frame, and an action function
  83793. */
  83794. export class AnimationEvent {
  83795. /** The frame for which the event is triggered **/
  83796. frame: number;
  83797. /** The event to perform when triggered **/
  83798. action: (currentFrame: number) => void;
  83799. /** Specifies if the event should be triggered only once**/
  83800. onlyOnce?: boolean | undefined;
  83801. /**
  83802. * Specifies if the animation event is done
  83803. */
  83804. isDone: boolean;
  83805. /**
  83806. * Initializes the animation event
  83807. * @param frame The frame for which the event is triggered
  83808. * @param action The event to perform when triggered
  83809. * @param onlyOnce Specifies if the event should be triggered only once
  83810. */
  83811. constructor(
  83812. /** The frame for which the event is triggered **/
  83813. frame: number,
  83814. /** The event to perform when triggered **/
  83815. action: (currentFrame: number) => void,
  83816. /** Specifies if the event should be triggered only once**/
  83817. onlyOnce?: boolean | undefined);
  83818. /** @hidden */
  83819. _clone(): AnimationEvent;
  83820. }
  83821. }
  83822. declare module BABYLON {
  83823. /**
  83824. * Interface used to define a behavior
  83825. */
  83826. export interface Behavior<T> {
  83827. /** gets or sets behavior's name */
  83828. name: string;
  83829. /**
  83830. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83831. */
  83832. init(): void;
  83833. /**
  83834. * Called when the behavior is attached to a target
  83835. * @param target defines the target where the behavior is attached to
  83836. */
  83837. attach(target: T): void;
  83838. /**
  83839. * Called when the behavior is detached from its target
  83840. */
  83841. detach(): void;
  83842. }
  83843. /**
  83844. * Interface implemented by classes supporting behaviors
  83845. */
  83846. export interface IBehaviorAware<T> {
  83847. /**
  83848. * Attach a behavior
  83849. * @param behavior defines the behavior to attach
  83850. * @returns the current host
  83851. */
  83852. addBehavior(behavior: Behavior<T>): T;
  83853. /**
  83854. * Remove a behavior from the current object
  83855. * @param behavior defines the behavior to detach
  83856. * @returns the current host
  83857. */
  83858. removeBehavior(behavior: Behavior<T>): T;
  83859. /**
  83860. * Gets a behavior using its name to search
  83861. * @param name defines the name to search
  83862. * @returns the behavior or null if not found
  83863. */
  83864. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83865. }
  83866. }
  83867. declare module BABYLON {
  83868. /**
  83869. * Defines an array and its length.
  83870. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83871. */
  83872. export interface ISmartArrayLike<T> {
  83873. /**
  83874. * The data of the array.
  83875. */
  83876. data: Array<T>;
  83877. /**
  83878. * The active length of the array.
  83879. */
  83880. length: number;
  83881. }
  83882. /**
  83883. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83884. */
  83885. export class SmartArray<T> implements ISmartArrayLike<T> {
  83886. /**
  83887. * The full set of data from the array.
  83888. */
  83889. data: Array<T>;
  83890. /**
  83891. * The active length of the array.
  83892. */
  83893. length: number;
  83894. protected _id: number;
  83895. /**
  83896. * Instantiates a Smart Array.
  83897. * @param capacity defines the default capacity of the array.
  83898. */
  83899. constructor(capacity: number);
  83900. /**
  83901. * Pushes a value at the end of the active data.
  83902. * @param value defines the object to push in the array.
  83903. */
  83904. push(value: T): void;
  83905. /**
  83906. * Iterates over the active data and apply the lambda to them.
  83907. * @param func defines the action to apply on each value.
  83908. */
  83909. forEach(func: (content: T) => void): void;
  83910. /**
  83911. * Sorts the full sets of data.
  83912. * @param compareFn defines the comparison function to apply.
  83913. */
  83914. sort(compareFn: (a: T, b: T) => number): void;
  83915. /**
  83916. * Resets the active data to an empty array.
  83917. */
  83918. reset(): void;
  83919. /**
  83920. * Releases all the data from the array as well as the array.
  83921. */
  83922. dispose(): void;
  83923. /**
  83924. * Concats the active data with a given array.
  83925. * @param array defines the data to concatenate with.
  83926. */
  83927. concat(array: any): void;
  83928. /**
  83929. * Returns the position of a value in the active data.
  83930. * @param value defines the value to find the index for
  83931. * @returns the index if found in the active data otherwise -1
  83932. */
  83933. indexOf(value: T): number;
  83934. /**
  83935. * Returns whether an element is part of the active data.
  83936. * @param value defines the value to look for
  83937. * @returns true if found in the active data otherwise false
  83938. */
  83939. contains(value: T): boolean;
  83940. private static _GlobalId;
  83941. }
  83942. /**
  83943. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83944. * The data in this array can only be present once
  83945. */
  83946. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83947. private _duplicateId;
  83948. /**
  83949. * Pushes a value at the end of the active data.
  83950. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83951. * @param value defines the object to push in the array.
  83952. */
  83953. push(value: T): void;
  83954. /**
  83955. * Pushes a value at the end of the active data.
  83956. * If the data is already present, it won t be added again
  83957. * @param value defines the object to push in the array.
  83958. * @returns true if added false if it was already present
  83959. */
  83960. pushNoDuplicate(value: T): boolean;
  83961. /**
  83962. * Resets the active data to an empty array.
  83963. */
  83964. reset(): void;
  83965. /**
  83966. * Concats the active data with a given array.
  83967. * This ensures no dupplicate will be present in the result.
  83968. * @param array defines the data to concatenate with.
  83969. */
  83970. concatWithNoDuplicate(array: any): void;
  83971. }
  83972. }
  83973. declare module BABYLON {
  83974. /**
  83975. * @ignore
  83976. * This is a list of all the different input types that are available in the application.
  83977. * Fo instance: ArcRotateCameraGamepadInput...
  83978. */
  83979. export var CameraInputTypes: {};
  83980. /**
  83981. * This is the contract to implement in order to create a new input class.
  83982. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83983. */
  83984. export interface ICameraInput<TCamera extends Camera> {
  83985. /**
  83986. * Defines the camera the input is attached to.
  83987. */
  83988. camera: Nullable<TCamera>;
  83989. /**
  83990. * Gets the class name of the current intput.
  83991. * @returns the class name
  83992. */
  83993. getClassName(): string;
  83994. /**
  83995. * Get the friendly name associated with the input class.
  83996. * @returns the input friendly name
  83997. */
  83998. getSimpleName(): string;
  83999. /**
  84000. * Attach the input controls to a specific dom element to get the input from.
  84001. * @param element Defines the element the controls should be listened from
  84002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84003. */
  84004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84005. /**
  84006. * Detach the current controls from the specified dom element.
  84007. * @param element Defines the element to stop listening the inputs from
  84008. */
  84009. detachControl(element: Nullable<HTMLElement>): void;
  84010. /**
  84011. * Update the current camera state depending on the inputs that have been used this frame.
  84012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84013. */
  84014. checkInputs?: () => void;
  84015. }
  84016. /**
  84017. * Represents a map of input types to input instance or input index to input instance.
  84018. */
  84019. export interface CameraInputsMap<TCamera extends Camera> {
  84020. /**
  84021. * Accessor to the input by input type.
  84022. */
  84023. [name: string]: ICameraInput<TCamera>;
  84024. /**
  84025. * Accessor to the input by input index.
  84026. */
  84027. [idx: number]: ICameraInput<TCamera>;
  84028. }
  84029. /**
  84030. * This represents the input manager used within a camera.
  84031. * It helps dealing with all the different kind of input attached to a camera.
  84032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84033. */
  84034. export class CameraInputsManager<TCamera extends Camera> {
  84035. /**
  84036. * Defines the list of inputs attahed to the camera.
  84037. */
  84038. attached: CameraInputsMap<TCamera>;
  84039. /**
  84040. * Defines the dom element the camera is collecting inputs from.
  84041. * This is null if the controls have not been attached.
  84042. */
  84043. attachedElement: Nullable<HTMLElement>;
  84044. /**
  84045. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84046. */
  84047. noPreventDefault: boolean;
  84048. /**
  84049. * Defined the camera the input manager belongs to.
  84050. */
  84051. camera: TCamera;
  84052. /**
  84053. * Update the current camera state depending on the inputs that have been used this frame.
  84054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84055. */
  84056. checkInputs: () => void;
  84057. /**
  84058. * Instantiate a new Camera Input Manager.
  84059. * @param camera Defines the camera the input manager blongs to
  84060. */
  84061. constructor(camera: TCamera);
  84062. /**
  84063. * Add an input method to a camera
  84064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84065. * @param input camera input method
  84066. */
  84067. add(input: ICameraInput<TCamera>): void;
  84068. /**
  84069. * Remove a specific input method from a camera
  84070. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84071. * @param inputToRemove camera input method
  84072. */
  84073. remove(inputToRemove: ICameraInput<TCamera>): void;
  84074. /**
  84075. * Remove a specific input type from a camera
  84076. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84077. * @param inputType the type of the input to remove
  84078. */
  84079. removeByType(inputType: string): void;
  84080. private _addCheckInputs;
  84081. /**
  84082. * Attach the input controls to the currently attached dom element to listen the events from.
  84083. * @param input Defines the input to attach
  84084. */
  84085. attachInput(input: ICameraInput<TCamera>): void;
  84086. /**
  84087. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84088. * @param element Defines the dom element to collect the events from
  84089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84090. */
  84091. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84092. /**
  84093. * Detach the current manager inputs controls from a specific dom element.
  84094. * @param element Defines the dom element to collect the events from
  84095. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84096. */
  84097. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84098. /**
  84099. * Rebuild the dynamic inputCheck function from the current list of
  84100. * defined inputs in the manager.
  84101. */
  84102. rebuildInputCheck(): void;
  84103. /**
  84104. * Remove all attached input methods from a camera
  84105. */
  84106. clear(): void;
  84107. /**
  84108. * Serialize the current input manager attached to a camera.
  84109. * This ensures than once parsed,
  84110. * the input associated to the camera will be identical to the current ones
  84111. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84112. */
  84113. serialize(serializedCamera: any): void;
  84114. /**
  84115. * Parses an input manager serialized JSON to restore the previous list of inputs
  84116. * and states associated to a camera.
  84117. * @param parsedCamera Defines the JSON to parse
  84118. */
  84119. parse(parsedCamera: any): void;
  84120. }
  84121. }
  84122. declare module BABYLON {
  84123. /**
  84124. * Class used to store data that will be store in GPU memory
  84125. */
  84126. export class Buffer {
  84127. private _engine;
  84128. private _buffer;
  84129. /** @hidden */
  84130. _data: Nullable<DataArray>;
  84131. private _updatable;
  84132. private _instanced;
  84133. private _divisor;
  84134. /**
  84135. * Gets the byte stride.
  84136. */
  84137. readonly byteStride: number;
  84138. /**
  84139. * Constructor
  84140. * @param engine the engine
  84141. * @param data the data to use for this buffer
  84142. * @param updatable whether the data is updatable
  84143. * @param stride the stride (optional)
  84144. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84145. * @param instanced whether the buffer is instanced (optional)
  84146. * @param useBytes set to true if the stride in in bytes (optional)
  84147. * @param divisor sets an optional divisor for instances (1 by default)
  84148. */
  84149. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84150. /**
  84151. * Create a new VertexBuffer based on the current buffer
  84152. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84153. * @param offset defines offset in the buffer (0 by default)
  84154. * @param size defines the size in floats of attributes (position is 3 for instance)
  84155. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84156. * @param instanced defines if the vertex buffer contains indexed data
  84157. * @param useBytes defines if the offset and stride are in bytes *
  84158. * @param divisor sets an optional divisor for instances (1 by default)
  84159. * @returns the new vertex buffer
  84160. */
  84161. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84162. /**
  84163. * Gets a boolean indicating if the Buffer is updatable?
  84164. * @returns true if the buffer is updatable
  84165. */
  84166. isUpdatable(): boolean;
  84167. /**
  84168. * Gets current buffer's data
  84169. * @returns a DataArray or null
  84170. */
  84171. getData(): Nullable<DataArray>;
  84172. /**
  84173. * Gets underlying native buffer
  84174. * @returns underlying native buffer
  84175. */
  84176. getBuffer(): Nullable<DataBuffer>;
  84177. /**
  84178. * Gets the stride in float32 units (i.e. byte stride / 4).
  84179. * May not be an integer if the byte stride is not divisible by 4.
  84180. * @returns the stride in float32 units
  84181. * @deprecated Please use byteStride instead.
  84182. */
  84183. getStrideSize(): number;
  84184. /**
  84185. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84186. * @param data defines the data to store
  84187. */
  84188. create(data?: Nullable<DataArray>): void;
  84189. /** @hidden */
  84190. _rebuild(): void;
  84191. /**
  84192. * Update current buffer data
  84193. * @param data defines the data to store
  84194. */
  84195. update(data: DataArray): void;
  84196. /**
  84197. * Updates the data directly.
  84198. * @param data the new data
  84199. * @param offset the new offset
  84200. * @param vertexCount the vertex count (optional)
  84201. * @param useBytes set to true if the offset is in bytes
  84202. */
  84203. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84204. /**
  84205. * Release all resources
  84206. */
  84207. dispose(): void;
  84208. }
  84209. /**
  84210. * Specialized buffer used to store vertex data
  84211. */
  84212. export class VertexBuffer {
  84213. /** @hidden */
  84214. _buffer: Buffer;
  84215. private _kind;
  84216. private _size;
  84217. private _ownsBuffer;
  84218. private _instanced;
  84219. private _instanceDivisor;
  84220. /**
  84221. * The byte type.
  84222. */
  84223. static readonly BYTE: number;
  84224. /**
  84225. * The unsigned byte type.
  84226. */
  84227. static readonly UNSIGNED_BYTE: number;
  84228. /**
  84229. * The short type.
  84230. */
  84231. static readonly SHORT: number;
  84232. /**
  84233. * The unsigned short type.
  84234. */
  84235. static readonly UNSIGNED_SHORT: number;
  84236. /**
  84237. * The integer type.
  84238. */
  84239. static readonly INT: number;
  84240. /**
  84241. * The unsigned integer type.
  84242. */
  84243. static readonly UNSIGNED_INT: number;
  84244. /**
  84245. * The float type.
  84246. */
  84247. static readonly FLOAT: number;
  84248. /**
  84249. * Gets or sets the instance divisor when in instanced mode
  84250. */
  84251. get instanceDivisor(): number;
  84252. set instanceDivisor(value: number);
  84253. /**
  84254. * Gets the byte stride.
  84255. */
  84256. readonly byteStride: number;
  84257. /**
  84258. * Gets the byte offset.
  84259. */
  84260. readonly byteOffset: number;
  84261. /**
  84262. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84263. */
  84264. readonly normalized: boolean;
  84265. /**
  84266. * Gets the data type of each component in the array.
  84267. */
  84268. readonly type: number;
  84269. /**
  84270. * Constructor
  84271. * @param engine the engine
  84272. * @param data the data to use for this vertex buffer
  84273. * @param kind the vertex buffer kind
  84274. * @param updatable whether the data is updatable
  84275. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84276. * @param stride the stride (optional)
  84277. * @param instanced whether the buffer is instanced (optional)
  84278. * @param offset the offset of the data (optional)
  84279. * @param size the number of components (optional)
  84280. * @param type the type of the component (optional)
  84281. * @param normalized whether the data contains normalized data (optional)
  84282. * @param useBytes set to true if stride and offset are in bytes (optional)
  84283. * @param divisor defines the instance divisor to use (1 by default)
  84284. */
  84285. 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);
  84286. /** @hidden */
  84287. _rebuild(): void;
  84288. /**
  84289. * Returns the kind of the VertexBuffer (string)
  84290. * @returns a string
  84291. */
  84292. getKind(): string;
  84293. /**
  84294. * Gets a boolean indicating if the VertexBuffer is updatable?
  84295. * @returns true if the buffer is updatable
  84296. */
  84297. isUpdatable(): boolean;
  84298. /**
  84299. * Gets current buffer's data
  84300. * @returns a DataArray or null
  84301. */
  84302. getData(): Nullable<DataArray>;
  84303. /**
  84304. * Gets underlying native buffer
  84305. * @returns underlying native buffer
  84306. */
  84307. getBuffer(): Nullable<DataBuffer>;
  84308. /**
  84309. * Gets the stride in float32 units (i.e. byte stride / 4).
  84310. * May not be an integer if the byte stride is not divisible by 4.
  84311. * @returns the stride in float32 units
  84312. * @deprecated Please use byteStride instead.
  84313. */
  84314. getStrideSize(): number;
  84315. /**
  84316. * Returns the offset as a multiple of the type byte length.
  84317. * @returns the offset in bytes
  84318. * @deprecated Please use byteOffset instead.
  84319. */
  84320. getOffset(): number;
  84321. /**
  84322. * Returns the number of components per vertex attribute (integer)
  84323. * @returns the size in float
  84324. */
  84325. getSize(): number;
  84326. /**
  84327. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84328. * @returns true if this buffer is instanced
  84329. */
  84330. getIsInstanced(): boolean;
  84331. /**
  84332. * Returns the instancing divisor, zero for non-instanced (integer).
  84333. * @returns a number
  84334. */
  84335. getInstanceDivisor(): number;
  84336. /**
  84337. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84338. * @param data defines the data to store
  84339. */
  84340. create(data?: DataArray): void;
  84341. /**
  84342. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84343. * This function will create a new buffer if the current one is not updatable
  84344. * @param data defines the data to store
  84345. */
  84346. update(data: DataArray): void;
  84347. /**
  84348. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84349. * Returns the directly updated WebGLBuffer.
  84350. * @param data the new data
  84351. * @param offset the new offset
  84352. * @param useBytes set to true if the offset is in bytes
  84353. */
  84354. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84355. /**
  84356. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84357. */
  84358. dispose(): void;
  84359. /**
  84360. * Enumerates each value of this vertex buffer as numbers.
  84361. * @param count the number of values to enumerate
  84362. * @param callback the callback function called for each value
  84363. */
  84364. forEach(count: number, callback: (value: number, index: number) => void): void;
  84365. /**
  84366. * Positions
  84367. */
  84368. static readonly PositionKind: string;
  84369. /**
  84370. * Normals
  84371. */
  84372. static readonly NormalKind: string;
  84373. /**
  84374. * Tangents
  84375. */
  84376. static readonly TangentKind: string;
  84377. /**
  84378. * Texture coordinates
  84379. */
  84380. static readonly UVKind: string;
  84381. /**
  84382. * Texture coordinates 2
  84383. */
  84384. static readonly UV2Kind: string;
  84385. /**
  84386. * Texture coordinates 3
  84387. */
  84388. static readonly UV3Kind: string;
  84389. /**
  84390. * Texture coordinates 4
  84391. */
  84392. static readonly UV4Kind: string;
  84393. /**
  84394. * Texture coordinates 5
  84395. */
  84396. static readonly UV5Kind: string;
  84397. /**
  84398. * Texture coordinates 6
  84399. */
  84400. static readonly UV6Kind: string;
  84401. /**
  84402. * Colors
  84403. */
  84404. static readonly ColorKind: string;
  84405. /**
  84406. * Matrix indices (for bones)
  84407. */
  84408. static readonly MatricesIndicesKind: string;
  84409. /**
  84410. * Matrix weights (for bones)
  84411. */
  84412. static readonly MatricesWeightsKind: string;
  84413. /**
  84414. * Additional matrix indices (for bones)
  84415. */
  84416. static readonly MatricesIndicesExtraKind: string;
  84417. /**
  84418. * Additional matrix weights (for bones)
  84419. */
  84420. static readonly MatricesWeightsExtraKind: string;
  84421. /**
  84422. * Deduces the stride given a kind.
  84423. * @param kind The kind string to deduce
  84424. * @returns The deduced stride
  84425. */
  84426. static DeduceStride(kind: string): number;
  84427. /**
  84428. * Gets the byte length of the given type.
  84429. * @param type the type
  84430. * @returns the number of bytes
  84431. */
  84432. static GetTypeByteLength(type: number): number;
  84433. /**
  84434. * Enumerates each value of the given parameters as numbers.
  84435. * @param data the data to enumerate
  84436. * @param byteOffset the byte offset of the data
  84437. * @param byteStride the byte stride of the data
  84438. * @param componentCount the number of components per element
  84439. * @param componentType the type of the component
  84440. * @param count the number of values to enumerate
  84441. * @param normalized whether the data is normalized
  84442. * @param callback the callback function called for each value
  84443. */
  84444. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84445. private static _GetFloatValue;
  84446. }
  84447. }
  84448. declare module BABYLON {
  84449. /**
  84450. * @hidden
  84451. */
  84452. export class IntersectionInfo {
  84453. bu: Nullable<number>;
  84454. bv: Nullable<number>;
  84455. distance: number;
  84456. faceId: number;
  84457. subMeshId: number;
  84458. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84459. }
  84460. }
  84461. declare module BABYLON {
  84462. /**
  84463. * Class used to store bounding sphere information
  84464. */
  84465. export class BoundingSphere {
  84466. /**
  84467. * Gets the center of the bounding sphere in local space
  84468. */
  84469. readonly center: Vector3;
  84470. /**
  84471. * Radius of the bounding sphere in local space
  84472. */
  84473. radius: number;
  84474. /**
  84475. * Gets the center of the bounding sphere in world space
  84476. */
  84477. readonly centerWorld: Vector3;
  84478. /**
  84479. * Radius of the bounding sphere in world space
  84480. */
  84481. radiusWorld: number;
  84482. /**
  84483. * Gets the minimum vector in local space
  84484. */
  84485. readonly minimum: Vector3;
  84486. /**
  84487. * Gets the maximum vector in local space
  84488. */
  84489. readonly maximum: Vector3;
  84490. private _worldMatrix;
  84491. private static readonly TmpVector3;
  84492. /**
  84493. * Creates a new bounding sphere
  84494. * @param min defines the minimum vector (in local space)
  84495. * @param max defines the maximum vector (in local space)
  84496. * @param worldMatrix defines the new world matrix
  84497. */
  84498. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84499. /**
  84500. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84501. * @param min defines the new minimum vector (in local space)
  84502. * @param max defines the new maximum vector (in local space)
  84503. * @param worldMatrix defines the new world matrix
  84504. */
  84505. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84506. /**
  84507. * Scale the current bounding sphere by applying a scale factor
  84508. * @param factor defines the scale factor to apply
  84509. * @returns the current bounding box
  84510. */
  84511. scale(factor: number): BoundingSphere;
  84512. /**
  84513. * Gets the world matrix of the bounding box
  84514. * @returns a matrix
  84515. */
  84516. getWorldMatrix(): DeepImmutable<Matrix>;
  84517. /** @hidden */
  84518. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84519. /**
  84520. * Tests if the bounding sphere is intersecting the frustum planes
  84521. * @param frustumPlanes defines the frustum planes to test
  84522. * @returns true if there is an intersection
  84523. */
  84524. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84525. /**
  84526. * Tests if the bounding sphere center is in between the frustum planes.
  84527. * Used for optimistic fast inclusion.
  84528. * @param frustumPlanes defines the frustum planes to test
  84529. * @returns true if the sphere center is in between the frustum planes
  84530. */
  84531. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84532. /**
  84533. * Tests if a point is inside the bounding sphere
  84534. * @param point defines the point to test
  84535. * @returns true if the point is inside the bounding sphere
  84536. */
  84537. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84538. /**
  84539. * Checks if two sphere intersct
  84540. * @param sphere0 sphere 0
  84541. * @param sphere1 sphere 1
  84542. * @returns true if the speres intersect
  84543. */
  84544. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /**
  84549. * Class used to store bounding box information
  84550. */
  84551. export class BoundingBox implements ICullable {
  84552. /**
  84553. * Gets the 8 vectors representing the bounding box in local space
  84554. */
  84555. readonly vectors: Vector3[];
  84556. /**
  84557. * Gets the center of the bounding box in local space
  84558. */
  84559. readonly center: Vector3;
  84560. /**
  84561. * Gets the center of the bounding box in world space
  84562. */
  84563. readonly centerWorld: Vector3;
  84564. /**
  84565. * Gets the extend size in local space
  84566. */
  84567. readonly extendSize: Vector3;
  84568. /**
  84569. * Gets the extend size in world space
  84570. */
  84571. readonly extendSizeWorld: Vector3;
  84572. /**
  84573. * Gets the OBB (object bounding box) directions
  84574. */
  84575. readonly directions: Vector3[];
  84576. /**
  84577. * Gets the 8 vectors representing the bounding box in world space
  84578. */
  84579. readonly vectorsWorld: Vector3[];
  84580. /**
  84581. * Gets the minimum vector in world space
  84582. */
  84583. readonly minimumWorld: Vector3;
  84584. /**
  84585. * Gets the maximum vector in world space
  84586. */
  84587. readonly maximumWorld: Vector3;
  84588. /**
  84589. * Gets the minimum vector in local space
  84590. */
  84591. readonly minimum: Vector3;
  84592. /**
  84593. * Gets the maximum vector in local space
  84594. */
  84595. readonly maximum: Vector3;
  84596. private _worldMatrix;
  84597. private static readonly TmpVector3;
  84598. /**
  84599. * @hidden
  84600. */
  84601. _tag: number;
  84602. /**
  84603. * Creates a new bounding box
  84604. * @param min defines the minimum vector (in local space)
  84605. * @param max defines the maximum vector (in local space)
  84606. * @param worldMatrix defines the new world matrix
  84607. */
  84608. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84609. /**
  84610. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84611. * @param min defines the new minimum vector (in local space)
  84612. * @param max defines the new maximum vector (in local space)
  84613. * @param worldMatrix defines the new world matrix
  84614. */
  84615. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84616. /**
  84617. * Scale the current bounding box by applying a scale factor
  84618. * @param factor defines the scale factor to apply
  84619. * @returns the current bounding box
  84620. */
  84621. scale(factor: number): BoundingBox;
  84622. /**
  84623. * Gets the world matrix of the bounding box
  84624. * @returns a matrix
  84625. */
  84626. getWorldMatrix(): DeepImmutable<Matrix>;
  84627. /** @hidden */
  84628. _update(world: DeepImmutable<Matrix>): void;
  84629. /**
  84630. * Tests if the bounding box is intersecting the frustum planes
  84631. * @param frustumPlanes defines the frustum planes to test
  84632. * @returns true if there is an intersection
  84633. */
  84634. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84635. /**
  84636. * Tests if the bounding box is entirely inside the frustum planes
  84637. * @param frustumPlanes defines the frustum planes to test
  84638. * @returns true if there is an inclusion
  84639. */
  84640. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84641. /**
  84642. * Tests if a point is inside the bounding box
  84643. * @param point defines the point to test
  84644. * @returns true if the point is inside the bounding box
  84645. */
  84646. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84647. /**
  84648. * Tests if the bounding box intersects with a bounding sphere
  84649. * @param sphere defines the sphere to test
  84650. * @returns true if there is an intersection
  84651. */
  84652. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84653. /**
  84654. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84655. * @param min defines the min vector to use
  84656. * @param max defines the max vector to use
  84657. * @returns true if there is an intersection
  84658. */
  84659. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84660. /**
  84661. * Tests if two bounding boxes are intersections
  84662. * @param box0 defines the first box to test
  84663. * @param box1 defines the second box to test
  84664. * @returns true if there is an intersection
  84665. */
  84666. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84667. /**
  84668. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84669. * @param minPoint defines the minimum vector of the bounding box
  84670. * @param maxPoint defines the maximum vector of the bounding box
  84671. * @param sphereCenter defines the sphere center
  84672. * @param sphereRadius defines the sphere radius
  84673. * @returns true if there is an intersection
  84674. */
  84675. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84676. /**
  84677. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84678. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84679. * @param frustumPlanes defines the frustum planes to test
  84680. * @return true if there is an inclusion
  84681. */
  84682. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84683. /**
  84684. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84685. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84686. * @param frustumPlanes defines the frustum planes to test
  84687. * @return true if there is an intersection
  84688. */
  84689. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84690. }
  84691. }
  84692. declare module BABYLON {
  84693. /** @hidden */
  84694. export class Collider {
  84695. /** Define if a collision was found */
  84696. collisionFound: boolean;
  84697. /**
  84698. * Define last intersection point in local space
  84699. */
  84700. intersectionPoint: Vector3;
  84701. /**
  84702. * Define last collided mesh
  84703. */
  84704. collidedMesh: Nullable<AbstractMesh>;
  84705. private _collisionPoint;
  84706. private _planeIntersectionPoint;
  84707. private _tempVector;
  84708. private _tempVector2;
  84709. private _tempVector3;
  84710. private _tempVector4;
  84711. private _edge;
  84712. private _baseToVertex;
  84713. private _destinationPoint;
  84714. private _slidePlaneNormal;
  84715. private _displacementVector;
  84716. /** @hidden */
  84717. _radius: Vector3;
  84718. /** @hidden */
  84719. _retry: number;
  84720. private _velocity;
  84721. private _basePoint;
  84722. private _epsilon;
  84723. /** @hidden */
  84724. _velocityWorldLength: number;
  84725. /** @hidden */
  84726. _basePointWorld: Vector3;
  84727. private _velocityWorld;
  84728. private _normalizedVelocity;
  84729. /** @hidden */
  84730. _initialVelocity: Vector3;
  84731. /** @hidden */
  84732. _initialPosition: Vector3;
  84733. private _nearestDistance;
  84734. private _collisionMask;
  84735. get collisionMask(): number;
  84736. set collisionMask(mask: number);
  84737. /**
  84738. * Gets the plane normal used to compute the sliding response (in local space)
  84739. */
  84740. get slidePlaneNormal(): Vector3;
  84741. /** @hidden */
  84742. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84743. /** @hidden */
  84744. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84745. /** @hidden */
  84746. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84747. /** @hidden */
  84748. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84749. /** @hidden */
  84750. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84751. /** @hidden */
  84752. _getResponse(pos: Vector3, vel: Vector3): void;
  84753. }
  84754. }
  84755. declare module BABYLON {
  84756. /**
  84757. * Interface for cullable objects
  84758. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84759. */
  84760. export interface ICullable {
  84761. /**
  84762. * Checks if the object or part of the object is in the frustum
  84763. * @param frustumPlanes Camera near/planes
  84764. * @returns true if the object is in frustum otherwise false
  84765. */
  84766. isInFrustum(frustumPlanes: Plane[]): boolean;
  84767. /**
  84768. * Checks if a cullable object (mesh...) is in the camera frustum
  84769. * Unlike isInFrustum this cheks the full bounding box
  84770. * @param frustumPlanes Camera near/planes
  84771. * @returns true if the object is in frustum otherwise false
  84772. */
  84773. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84774. }
  84775. /**
  84776. * Info for a bounding data of a mesh
  84777. */
  84778. export class BoundingInfo implements ICullable {
  84779. /**
  84780. * Bounding box for the mesh
  84781. */
  84782. readonly boundingBox: BoundingBox;
  84783. /**
  84784. * Bounding sphere for the mesh
  84785. */
  84786. readonly boundingSphere: BoundingSphere;
  84787. private _isLocked;
  84788. private static readonly TmpVector3;
  84789. /**
  84790. * Constructs bounding info
  84791. * @param minimum min vector of the bounding box/sphere
  84792. * @param maximum max vector of the bounding box/sphere
  84793. * @param worldMatrix defines the new world matrix
  84794. */
  84795. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84796. /**
  84797. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84798. * @param min defines the new minimum vector (in local space)
  84799. * @param max defines the new maximum vector (in local space)
  84800. * @param worldMatrix defines the new world matrix
  84801. */
  84802. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84803. /**
  84804. * min vector of the bounding box/sphere
  84805. */
  84806. get minimum(): Vector3;
  84807. /**
  84808. * max vector of the bounding box/sphere
  84809. */
  84810. get maximum(): Vector3;
  84811. /**
  84812. * If the info is locked and won't be updated to avoid perf overhead
  84813. */
  84814. get isLocked(): boolean;
  84815. set isLocked(value: boolean);
  84816. /**
  84817. * Updates the bounding sphere and box
  84818. * @param world world matrix to be used to update
  84819. */
  84820. update(world: DeepImmutable<Matrix>): void;
  84821. /**
  84822. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84823. * @param center New center of the bounding info
  84824. * @param extend New extend of the bounding info
  84825. * @returns the current bounding info
  84826. */
  84827. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84828. /**
  84829. * Scale the current bounding info by applying a scale factor
  84830. * @param factor defines the scale factor to apply
  84831. * @returns the current bounding info
  84832. */
  84833. scale(factor: number): BoundingInfo;
  84834. /**
  84835. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84836. * @param frustumPlanes defines the frustum to test
  84837. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84838. * @returns true if the bounding info is in the frustum planes
  84839. */
  84840. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84841. /**
  84842. * Gets the world distance between the min and max points of the bounding box
  84843. */
  84844. get diagonalLength(): number;
  84845. /**
  84846. * Checks if a cullable object (mesh...) is in the camera frustum
  84847. * Unlike isInFrustum this cheks the full bounding box
  84848. * @param frustumPlanes Camera near/planes
  84849. * @returns true if the object is in frustum otherwise false
  84850. */
  84851. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84852. /** @hidden */
  84853. _checkCollision(collider: Collider): boolean;
  84854. /**
  84855. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84856. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84857. * @param point the point to check intersection with
  84858. * @returns if the point intersects
  84859. */
  84860. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84861. /**
  84862. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84863. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84864. * @param boundingInfo the bounding info to check intersection with
  84865. * @param precise if the intersection should be done using OBB
  84866. * @returns if the bounding info intersects
  84867. */
  84868. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84869. }
  84870. }
  84871. declare module BABYLON {
  84872. /**
  84873. * Extracts minimum and maximum values from a list of indexed positions
  84874. * @param positions defines the positions to use
  84875. * @param indices defines the indices to the positions
  84876. * @param indexStart defines the start index
  84877. * @param indexCount defines the end index
  84878. * @param bias defines bias value to add to the result
  84879. * @return minimum and maximum values
  84880. */
  84881. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84882. minimum: Vector3;
  84883. maximum: Vector3;
  84884. };
  84885. /**
  84886. * Extracts minimum and maximum values from a list of positions
  84887. * @param positions defines the positions to use
  84888. * @param start defines the start index in the positions array
  84889. * @param count defines the number of positions to handle
  84890. * @param bias defines bias value to add to the result
  84891. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84892. * @return minimum and maximum values
  84893. */
  84894. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84895. minimum: Vector3;
  84896. maximum: Vector3;
  84897. };
  84898. }
  84899. declare module BABYLON {
  84900. /** @hidden */
  84901. export class WebGLDataBuffer extends DataBuffer {
  84902. private _buffer;
  84903. constructor(resource: WebGLBuffer);
  84904. get underlyingResource(): any;
  84905. }
  84906. }
  84907. declare module BABYLON {
  84908. /** @hidden */
  84909. export class WebGLPipelineContext implements IPipelineContext {
  84910. engine: ThinEngine;
  84911. program: Nullable<WebGLProgram>;
  84912. context?: WebGLRenderingContext;
  84913. vertexShader?: WebGLShader;
  84914. fragmentShader?: WebGLShader;
  84915. isParallelCompiled: boolean;
  84916. onCompiled?: () => void;
  84917. transformFeedback?: WebGLTransformFeedback | null;
  84918. vertexCompilationError: Nullable<string>;
  84919. fragmentCompilationError: Nullable<string>;
  84920. programLinkError: Nullable<string>;
  84921. programValidationError: Nullable<string>;
  84922. get isAsync(): boolean;
  84923. get isReady(): boolean;
  84924. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84925. _getVertexShaderCode(): string | null;
  84926. _getFragmentShaderCode(): string | null;
  84927. }
  84928. }
  84929. declare module BABYLON {
  84930. interface ThinEngine {
  84931. /**
  84932. * Create an uniform buffer
  84933. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84934. * @param elements defines the content of the uniform buffer
  84935. * @returns the webGL uniform buffer
  84936. */
  84937. createUniformBuffer(elements: FloatArray): DataBuffer;
  84938. /**
  84939. * Create a dynamic uniform buffer
  84940. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84941. * @param elements defines the content of the uniform buffer
  84942. * @returns the webGL uniform buffer
  84943. */
  84944. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84945. /**
  84946. * Update an existing uniform buffer
  84947. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84948. * @param uniformBuffer defines the target uniform buffer
  84949. * @param elements defines the content to update
  84950. * @param offset defines the offset in the uniform buffer where update should start
  84951. * @param count defines the size of the data to update
  84952. */
  84953. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84954. /**
  84955. * Bind an uniform buffer to the current webGL context
  84956. * @param buffer defines the buffer to bind
  84957. */
  84958. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84959. /**
  84960. * Bind a buffer to the current webGL context at a given location
  84961. * @param buffer defines the buffer to bind
  84962. * @param location defines the index where to bind the buffer
  84963. */
  84964. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84965. /**
  84966. * Bind a specific block at a given index in a specific shader program
  84967. * @param pipelineContext defines the pipeline context to use
  84968. * @param blockName defines the block name
  84969. * @param index defines the index where to bind the block
  84970. */
  84971. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84972. }
  84973. }
  84974. declare module BABYLON {
  84975. /**
  84976. * Uniform buffer objects.
  84977. *
  84978. * Handles blocks of uniform on the GPU.
  84979. *
  84980. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84981. *
  84982. * For more information, please refer to :
  84983. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84984. */
  84985. export class UniformBuffer {
  84986. private _engine;
  84987. private _buffer;
  84988. private _data;
  84989. private _bufferData;
  84990. private _dynamic?;
  84991. private _uniformLocations;
  84992. private _uniformSizes;
  84993. private _uniformLocationPointer;
  84994. private _needSync;
  84995. private _noUBO;
  84996. private _currentEffect;
  84997. /** @hidden */
  84998. _alreadyBound: boolean;
  84999. private static _MAX_UNIFORM_SIZE;
  85000. private static _tempBuffer;
  85001. /**
  85002. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85003. * This is dynamic to allow compat with webgl 1 and 2.
  85004. * You will need to pass the name of the uniform as well as the value.
  85005. */
  85006. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85007. /**
  85008. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85009. * This is dynamic to allow compat with webgl 1 and 2.
  85010. * You will need to pass the name of the uniform as well as the value.
  85011. */
  85012. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85013. /**
  85014. * Lambda to Update a single float in a uniform buffer.
  85015. * This is dynamic to allow compat with webgl 1 and 2.
  85016. * You will need to pass the name of the uniform as well as the value.
  85017. */
  85018. updateFloat: (name: string, x: number) => void;
  85019. /**
  85020. * Lambda to Update a vec2 of float in a uniform buffer.
  85021. * This is dynamic to allow compat with webgl 1 and 2.
  85022. * You will need to pass the name of the uniform as well as the value.
  85023. */
  85024. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85025. /**
  85026. * Lambda to Update a vec3 of float in a uniform buffer.
  85027. * This is dynamic to allow compat with webgl 1 and 2.
  85028. * You will need to pass the name of the uniform as well as the value.
  85029. */
  85030. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85031. /**
  85032. * Lambda to Update a vec4 of float in a uniform buffer.
  85033. * This is dynamic to allow compat with webgl 1 and 2.
  85034. * You will need to pass the name of the uniform as well as the value.
  85035. */
  85036. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85037. /**
  85038. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85039. * This is dynamic to allow compat with webgl 1 and 2.
  85040. * You will need to pass the name of the uniform as well as the value.
  85041. */
  85042. updateMatrix: (name: string, mat: Matrix) => void;
  85043. /**
  85044. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85045. * This is dynamic to allow compat with webgl 1 and 2.
  85046. * You will need to pass the name of the uniform as well as the value.
  85047. */
  85048. updateVector3: (name: string, vector: Vector3) => void;
  85049. /**
  85050. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85051. * This is dynamic to allow compat with webgl 1 and 2.
  85052. * You will need to pass the name of the uniform as well as the value.
  85053. */
  85054. updateVector4: (name: string, vector: Vector4) => void;
  85055. /**
  85056. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85057. * This is dynamic to allow compat with webgl 1 and 2.
  85058. * You will need to pass the name of the uniform as well as the value.
  85059. */
  85060. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85061. /**
  85062. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85063. * This is dynamic to allow compat with webgl 1 and 2.
  85064. * You will need to pass the name of the uniform as well as the value.
  85065. */
  85066. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85067. /**
  85068. * Instantiates a new Uniform buffer objects.
  85069. *
  85070. * Handles blocks of uniform on the GPU.
  85071. *
  85072. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85073. *
  85074. * For more information, please refer to :
  85075. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85076. * @param engine Define the engine the buffer is associated with
  85077. * @param data Define the data contained in the buffer
  85078. * @param dynamic Define if the buffer is updatable
  85079. */
  85080. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85081. /**
  85082. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85083. * or just falling back on setUniformXXX calls.
  85084. */
  85085. get useUbo(): boolean;
  85086. /**
  85087. * Indicates if the WebGL underlying uniform buffer is in sync
  85088. * with the javascript cache data.
  85089. */
  85090. get isSync(): boolean;
  85091. /**
  85092. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85093. * Also, a dynamic UniformBuffer will disable cache verification and always
  85094. * update the underlying WebGL uniform buffer to the GPU.
  85095. * @returns if Dynamic, otherwise false
  85096. */
  85097. isDynamic(): boolean;
  85098. /**
  85099. * The data cache on JS side.
  85100. * @returns the underlying data as a float array
  85101. */
  85102. getData(): Float32Array;
  85103. /**
  85104. * The underlying WebGL Uniform buffer.
  85105. * @returns the webgl buffer
  85106. */
  85107. getBuffer(): Nullable<DataBuffer>;
  85108. /**
  85109. * std140 layout specifies how to align data within an UBO structure.
  85110. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85111. * for specs.
  85112. */
  85113. private _fillAlignment;
  85114. /**
  85115. * Adds an uniform in the buffer.
  85116. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85117. * for the layout to be correct !
  85118. * @param name Name of the uniform, as used in the uniform block in the shader.
  85119. * @param size Data size, or data directly.
  85120. */
  85121. addUniform(name: string, size: number | number[]): void;
  85122. /**
  85123. * Adds a Matrix 4x4 to the uniform buffer.
  85124. * @param name Name of the uniform, as used in the uniform block in the shader.
  85125. * @param mat A 4x4 matrix.
  85126. */
  85127. addMatrix(name: string, mat: Matrix): void;
  85128. /**
  85129. * Adds a vec2 to the uniform buffer.
  85130. * @param name Name of the uniform, as used in the uniform block in the shader.
  85131. * @param x Define the x component value of the vec2
  85132. * @param y Define the y component value of the vec2
  85133. */
  85134. addFloat2(name: string, x: number, y: number): void;
  85135. /**
  85136. * Adds a vec3 to the uniform buffer.
  85137. * @param name Name of the uniform, as used in the uniform block in the shader.
  85138. * @param x Define the x component value of the vec3
  85139. * @param y Define the y component value of the vec3
  85140. * @param z Define the z component value of the vec3
  85141. */
  85142. addFloat3(name: string, x: number, y: number, z: number): void;
  85143. /**
  85144. * Adds a vec3 to the uniform buffer.
  85145. * @param name Name of the uniform, as used in the uniform block in the shader.
  85146. * @param color Define the vec3 from a Color
  85147. */
  85148. addColor3(name: string, color: Color3): void;
  85149. /**
  85150. * Adds a vec4 to the uniform buffer.
  85151. * @param name Name of the uniform, as used in the uniform block in the shader.
  85152. * @param color Define the rgb components from a Color
  85153. * @param alpha Define the a component of the vec4
  85154. */
  85155. addColor4(name: string, color: Color3, alpha: number): void;
  85156. /**
  85157. * Adds a vec3 to the uniform buffer.
  85158. * @param name Name of the uniform, as used in the uniform block in the shader.
  85159. * @param vector Define the vec3 components from a Vector
  85160. */
  85161. addVector3(name: string, vector: Vector3): void;
  85162. /**
  85163. * Adds a Matrix 3x3 to the uniform buffer.
  85164. * @param name Name of the uniform, as used in the uniform block in the shader.
  85165. */
  85166. addMatrix3x3(name: string): void;
  85167. /**
  85168. * Adds a Matrix 2x2 to the uniform buffer.
  85169. * @param name Name of the uniform, as used in the uniform block in the shader.
  85170. */
  85171. addMatrix2x2(name: string): void;
  85172. /**
  85173. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85174. */
  85175. create(): void;
  85176. /** @hidden */
  85177. _rebuild(): void;
  85178. /**
  85179. * Updates the WebGL Uniform Buffer on the GPU.
  85180. * If the `dynamic` flag is set to true, no cache comparison is done.
  85181. * Otherwise, the buffer will be updated only if the cache differs.
  85182. */
  85183. update(): void;
  85184. /**
  85185. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85186. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85187. * @param data Define the flattened data
  85188. * @param size Define the size of the data.
  85189. */
  85190. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85191. private _valueCache;
  85192. private _cacheMatrix;
  85193. private _updateMatrix3x3ForUniform;
  85194. private _updateMatrix3x3ForEffect;
  85195. private _updateMatrix2x2ForEffect;
  85196. private _updateMatrix2x2ForUniform;
  85197. private _updateFloatForEffect;
  85198. private _updateFloatForUniform;
  85199. private _updateFloat2ForEffect;
  85200. private _updateFloat2ForUniform;
  85201. private _updateFloat3ForEffect;
  85202. private _updateFloat3ForUniform;
  85203. private _updateFloat4ForEffect;
  85204. private _updateFloat4ForUniform;
  85205. private _updateMatrixForEffect;
  85206. private _updateMatrixForUniform;
  85207. private _updateVector3ForEffect;
  85208. private _updateVector3ForUniform;
  85209. private _updateVector4ForEffect;
  85210. private _updateVector4ForUniform;
  85211. private _updateColor3ForEffect;
  85212. private _updateColor3ForUniform;
  85213. private _updateColor4ForEffect;
  85214. private _updateColor4ForUniform;
  85215. /**
  85216. * Sets a sampler uniform on the effect.
  85217. * @param name Define the name of the sampler.
  85218. * @param texture Define the texture to set in the sampler
  85219. */
  85220. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85221. /**
  85222. * Directly updates the value of the uniform in the cache AND on the GPU.
  85223. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85224. * @param data Define the flattened data
  85225. */
  85226. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85227. /**
  85228. * Binds this uniform buffer to an effect.
  85229. * @param effect Define the effect to bind the buffer to
  85230. * @param name Name of the uniform block in the shader.
  85231. */
  85232. bindToEffect(effect: Effect, name: string): void;
  85233. /**
  85234. * Disposes the uniform buffer.
  85235. */
  85236. dispose(): void;
  85237. }
  85238. }
  85239. declare module BABYLON {
  85240. /**
  85241. * Enum that determines the text-wrapping mode to use.
  85242. */
  85243. export enum InspectableType {
  85244. /**
  85245. * Checkbox for booleans
  85246. */
  85247. Checkbox = 0,
  85248. /**
  85249. * Sliders for numbers
  85250. */
  85251. Slider = 1,
  85252. /**
  85253. * Vector3
  85254. */
  85255. Vector3 = 2,
  85256. /**
  85257. * Quaternions
  85258. */
  85259. Quaternion = 3,
  85260. /**
  85261. * Color3
  85262. */
  85263. Color3 = 4,
  85264. /**
  85265. * String
  85266. */
  85267. String = 5
  85268. }
  85269. /**
  85270. * Interface used to define custom inspectable properties.
  85271. * This interface is used by the inspector to display custom property grids
  85272. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85273. */
  85274. export interface IInspectable {
  85275. /**
  85276. * Gets the label to display
  85277. */
  85278. label: string;
  85279. /**
  85280. * Gets the name of the property to edit
  85281. */
  85282. propertyName: string;
  85283. /**
  85284. * Gets the type of the editor to use
  85285. */
  85286. type: InspectableType;
  85287. /**
  85288. * Gets the minimum value of the property when using in "slider" mode
  85289. */
  85290. min?: number;
  85291. /**
  85292. * Gets the maximum value of the property when using in "slider" mode
  85293. */
  85294. max?: number;
  85295. /**
  85296. * Gets the setp to use when using in "slider" mode
  85297. */
  85298. step?: number;
  85299. }
  85300. }
  85301. declare module BABYLON {
  85302. /**
  85303. * Class used to provide helper for timing
  85304. */
  85305. export class TimingTools {
  85306. /**
  85307. * Polyfill for setImmediate
  85308. * @param action defines the action to execute after the current execution block
  85309. */
  85310. static SetImmediate(action: () => void): void;
  85311. }
  85312. }
  85313. declare module BABYLON {
  85314. /**
  85315. * Class used to enable instatition of objects by class name
  85316. */
  85317. export class InstantiationTools {
  85318. /**
  85319. * Use this object to register external classes like custom textures or material
  85320. * to allow the laoders to instantiate them
  85321. */
  85322. static RegisteredExternalClasses: {
  85323. [key: string]: Object;
  85324. };
  85325. /**
  85326. * Tries to instantiate a new object from a given class name
  85327. * @param className defines the class name to instantiate
  85328. * @returns the new object or null if the system was not able to do the instantiation
  85329. */
  85330. static Instantiate(className: string): any;
  85331. }
  85332. }
  85333. declare module BABYLON {
  85334. /**
  85335. * Define options used to create a depth texture
  85336. */
  85337. export class DepthTextureCreationOptions {
  85338. /** Specifies whether or not a stencil should be allocated in the texture */
  85339. generateStencil?: boolean;
  85340. /** Specifies whether or not bilinear filtering is enable on the texture */
  85341. bilinearFiltering?: boolean;
  85342. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85343. comparisonFunction?: number;
  85344. /** Specifies if the created texture is a cube texture */
  85345. isCube?: boolean;
  85346. }
  85347. }
  85348. declare module BABYLON {
  85349. interface ThinEngine {
  85350. /**
  85351. * Creates a depth stencil cube texture.
  85352. * This is only available in WebGL 2.
  85353. * @param size The size of face edge in the cube texture.
  85354. * @param options The options defining the cube texture.
  85355. * @returns The cube texture
  85356. */
  85357. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85358. /**
  85359. * Creates a cube texture
  85360. * @param rootUrl defines the url where the files to load is located
  85361. * @param scene defines the current scene
  85362. * @param files defines the list of files to load (1 per face)
  85363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85364. * @param onLoad defines an optional callback raised when the texture is loaded
  85365. * @param onError defines an optional callback raised if there is an issue to load the texture
  85366. * @param format defines the format of the data
  85367. * @param forcedExtension defines the extension to use to pick the right loader
  85368. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85371. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85372. * @returns the cube texture as an InternalTexture
  85373. */
  85374. 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;
  85375. /**
  85376. * Creates a cube texture
  85377. * @param rootUrl defines the url where the files to load is located
  85378. * @param scene defines the current scene
  85379. * @param files defines the list of files to load (1 per face)
  85380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85381. * @param onLoad defines an optional callback raised when the texture is loaded
  85382. * @param onError defines an optional callback raised if there is an issue to load the texture
  85383. * @param format defines the format of the data
  85384. * @param forcedExtension defines the extension to use to pick the right loader
  85385. * @returns the cube texture as an InternalTexture
  85386. */
  85387. 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;
  85388. /**
  85389. * Creates a cube texture
  85390. * @param rootUrl defines the url where the files to load is located
  85391. * @param scene defines the current scene
  85392. * @param files defines the list of files to load (1 per face)
  85393. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85394. * @param onLoad defines an optional callback raised when the texture is loaded
  85395. * @param onError defines an optional callback raised if there is an issue to load the texture
  85396. * @param format defines the format of the data
  85397. * @param forcedExtension defines the extension to use to pick the right loader
  85398. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85401. * @returns the cube texture as an InternalTexture
  85402. */
  85403. 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;
  85404. /** @hidden */
  85405. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85406. /** @hidden */
  85407. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85408. /** @hidden */
  85409. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85410. /** @hidden */
  85411. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85412. /**
  85413. * @hidden
  85414. */
  85415. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85416. }
  85417. }
  85418. declare module BABYLON {
  85419. /**
  85420. * Class for creating a cube texture
  85421. */
  85422. export class CubeTexture extends BaseTexture {
  85423. private _delayedOnLoad;
  85424. /**
  85425. * Observable triggered once the texture has been loaded.
  85426. */
  85427. onLoadObservable: Observable<CubeTexture>;
  85428. /**
  85429. * The url of the texture
  85430. */
  85431. url: string;
  85432. /**
  85433. * Gets or sets the center of the bounding box associated with the cube texture.
  85434. * It must define where the camera used to render the texture was set
  85435. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85436. */
  85437. boundingBoxPosition: Vector3;
  85438. private _boundingBoxSize;
  85439. /**
  85440. * Gets or sets the size of the bounding box associated with the cube texture
  85441. * When defined, the cubemap will switch to local mode
  85442. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85443. * @example https://www.babylonjs-playground.com/#RNASML
  85444. */
  85445. set boundingBoxSize(value: Vector3);
  85446. /**
  85447. * Returns the bounding box size
  85448. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85449. */
  85450. get boundingBoxSize(): Vector3;
  85451. protected _rotationY: number;
  85452. /**
  85453. * Sets texture matrix rotation angle around Y axis in radians.
  85454. */
  85455. set rotationY(value: number);
  85456. /**
  85457. * Gets texture matrix rotation angle around Y axis radians.
  85458. */
  85459. get rotationY(): number;
  85460. /**
  85461. * Are mip maps generated for this texture or not.
  85462. */
  85463. get noMipmap(): boolean;
  85464. private _noMipmap;
  85465. private _files;
  85466. protected _forcedExtension: Nullable<string>;
  85467. private _extensions;
  85468. private _textureMatrix;
  85469. private _format;
  85470. private _createPolynomials;
  85471. /**
  85472. * Creates a cube texture from an array of image urls
  85473. * @param files defines an array of image urls
  85474. * @param scene defines the hosting scene
  85475. * @param noMipmap specifies if mip maps are not used
  85476. * @returns a cube texture
  85477. */
  85478. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85479. /**
  85480. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85481. * @param url defines the url of the prefiltered texture
  85482. * @param scene defines the scene the texture is attached to
  85483. * @param forcedExtension defines the extension of the file if different from the url
  85484. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85485. * @return the prefiltered texture
  85486. */
  85487. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85488. /**
  85489. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85490. * as prefiltered data.
  85491. * @param rootUrl defines the url of the texture or the root name of the six images
  85492. * @param null defines the scene or engine the texture is attached to
  85493. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85494. * @param noMipmap defines if mipmaps should be created or not
  85495. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85496. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85497. * @param onError defines a callback triggered in case of error during load
  85498. * @param format defines the internal format to use for the texture once loaded
  85499. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85500. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85501. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85502. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85503. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85504. * @return the cube texture
  85505. */
  85506. 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);
  85507. /**
  85508. * Get the current class name of the texture useful for serialization or dynamic coding.
  85509. * @returns "CubeTexture"
  85510. */
  85511. getClassName(): string;
  85512. /**
  85513. * Update the url (and optional buffer) of this texture if url was null during construction.
  85514. * @param url the url of the texture
  85515. * @param forcedExtension defines the extension to use
  85516. * @param onLoad callback called when the texture is loaded (defaults to null)
  85517. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85518. */
  85519. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85520. /**
  85521. * Delays loading of the cube texture
  85522. * @param forcedExtension defines the extension to use
  85523. */
  85524. delayLoad(forcedExtension?: string): void;
  85525. /**
  85526. * Returns the reflection texture matrix
  85527. * @returns the reflection texture matrix
  85528. */
  85529. getReflectionTextureMatrix(): Matrix;
  85530. /**
  85531. * Sets the reflection texture matrix
  85532. * @param value Reflection texture matrix
  85533. */
  85534. setReflectionTextureMatrix(value: Matrix): void;
  85535. /**
  85536. * Parses text to create a cube texture
  85537. * @param parsedTexture define the serialized text to read from
  85538. * @param scene defines the hosting scene
  85539. * @param rootUrl defines the root url of the cube texture
  85540. * @returns a cube texture
  85541. */
  85542. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85543. /**
  85544. * Makes a clone, or deep copy, of the cube texture
  85545. * @returns a new cube texture
  85546. */
  85547. clone(): CubeTexture;
  85548. }
  85549. }
  85550. declare module BABYLON {
  85551. /**
  85552. * Manages the defines for the Material
  85553. */
  85554. export class MaterialDefines {
  85555. /** @hidden */
  85556. protected _keys: string[];
  85557. private _isDirty;
  85558. /** @hidden */
  85559. _renderId: number;
  85560. /** @hidden */
  85561. _areLightsDirty: boolean;
  85562. /** @hidden */
  85563. _areLightsDisposed: boolean;
  85564. /** @hidden */
  85565. _areAttributesDirty: boolean;
  85566. /** @hidden */
  85567. _areTexturesDirty: boolean;
  85568. /** @hidden */
  85569. _areFresnelDirty: boolean;
  85570. /** @hidden */
  85571. _areMiscDirty: boolean;
  85572. /** @hidden */
  85573. _areImageProcessingDirty: boolean;
  85574. /** @hidden */
  85575. _normals: boolean;
  85576. /** @hidden */
  85577. _uvs: boolean;
  85578. /** @hidden */
  85579. _needNormals: boolean;
  85580. /** @hidden */
  85581. _needUVs: boolean;
  85582. [id: string]: any;
  85583. /**
  85584. * Specifies if the material needs to be re-calculated
  85585. */
  85586. get isDirty(): boolean;
  85587. /**
  85588. * Marks the material to indicate that it has been re-calculated
  85589. */
  85590. markAsProcessed(): void;
  85591. /**
  85592. * Marks the material to indicate that it needs to be re-calculated
  85593. */
  85594. markAsUnprocessed(): void;
  85595. /**
  85596. * Marks the material to indicate all of its defines need to be re-calculated
  85597. */
  85598. markAllAsDirty(): void;
  85599. /**
  85600. * Marks the material to indicate that image processing needs to be re-calculated
  85601. */
  85602. markAsImageProcessingDirty(): void;
  85603. /**
  85604. * Marks the material to indicate the lights need to be re-calculated
  85605. * @param disposed Defines whether the light is dirty due to dispose or not
  85606. */
  85607. markAsLightDirty(disposed?: boolean): void;
  85608. /**
  85609. * Marks the attribute state as changed
  85610. */
  85611. markAsAttributesDirty(): void;
  85612. /**
  85613. * Marks the texture state as changed
  85614. */
  85615. markAsTexturesDirty(): void;
  85616. /**
  85617. * Marks the fresnel state as changed
  85618. */
  85619. markAsFresnelDirty(): void;
  85620. /**
  85621. * Marks the misc state as changed
  85622. */
  85623. markAsMiscDirty(): void;
  85624. /**
  85625. * Rebuilds the material defines
  85626. */
  85627. rebuild(): void;
  85628. /**
  85629. * Specifies if two material defines are equal
  85630. * @param other - A material define instance to compare to
  85631. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85632. */
  85633. isEqual(other: MaterialDefines): boolean;
  85634. /**
  85635. * Clones this instance's defines to another instance
  85636. * @param other - material defines to clone values to
  85637. */
  85638. cloneTo(other: MaterialDefines): void;
  85639. /**
  85640. * Resets the material define values
  85641. */
  85642. reset(): void;
  85643. /**
  85644. * Converts the material define values to a string
  85645. * @returns - String of material define information
  85646. */
  85647. toString(): string;
  85648. }
  85649. }
  85650. declare module BABYLON {
  85651. /**
  85652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85654. * 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;
  85655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85656. */
  85657. export class ColorCurves {
  85658. private _dirty;
  85659. private _tempColor;
  85660. private _globalCurve;
  85661. private _highlightsCurve;
  85662. private _midtonesCurve;
  85663. private _shadowsCurve;
  85664. private _positiveCurve;
  85665. private _negativeCurve;
  85666. private _globalHue;
  85667. private _globalDensity;
  85668. private _globalSaturation;
  85669. private _globalExposure;
  85670. /**
  85671. * Gets the global Hue value.
  85672. * 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).
  85673. */
  85674. get globalHue(): number;
  85675. /**
  85676. * Sets the global Hue value.
  85677. * 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).
  85678. */
  85679. set globalHue(value: number);
  85680. /**
  85681. * Gets the global Density value.
  85682. * 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.
  85683. * Values less than zero provide a filter of opposite hue.
  85684. */
  85685. get globalDensity(): number;
  85686. /**
  85687. * Sets the global Density value.
  85688. * 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.
  85689. * Values less than zero provide a filter of opposite hue.
  85690. */
  85691. set globalDensity(value: number);
  85692. /**
  85693. * Gets the global Saturation value.
  85694. * 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.
  85695. */
  85696. get globalSaturation(): number;
  85697. /**
  85698. * Sets the global Saturation value.
  85699. * 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.
  85700. */
  85701. set globalSaturation(value: number);
  85702. /**
  85703. * Gets the global Exposure value.
  85704. * 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.
  85705. */
  85706. get globalExposure(): number;
  85707. /**
  85708. * Sets the global Exposure value.
  85709. * 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.
  85710. */
  85711. set globalExposure(value: number);
  85712. private _highlightsHue;
  85713. private _highlightsDensity;
  85714. private _highlightsSaturation;
  85715. private _highlightsExposure;
  85716. /**
  85717. * Gets the highlights Hue value.
  85718. * 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).
  85719. */
  85720. get highlightsHue(): number;
  85721. /**
  85722. * Sets the highlights Hue value.
  85723. * 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).
  85724. */
  85725. set highlightsHue(value: number);
  85726. /**
  85727. * Gets the highlights Density value.
  85728. * 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.
  85729. * Values less than zero provide a filter of opposite hue.
  85730. */
  85731. get highlightsDensity(): number;
  85732. /**
  85733. * Sets the highlights Density value.
  85734. * 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.
  85735. * Values less than zero provide a filter of opposite hue.
  85736. */
  85737. set highlightsDensity(value: number);
  85738. /**
  85739. * Gets the highlights Saturation value.
  85740. * 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.
  85741. */
  85742. get highlightsSaturation(): number;
  85743. /**
  85744. * Sets the highlights Saturation value.
  85745. * 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.
  85746. */
  85747. set highlightsSaturation(value: number);
  85748. /**
  85749. * Gets the highlights Exposure value.
  85750. * 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.
  85751. */
  85752. get highlightsExposure(): number;
  85753. /**
  85754. * Sets the highlights Exposure value.
  85755. * 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.
  85756. */
  85757. set highlightsExposure(value: number);
  85758. private _midtonesHue;
  85759. private _midtonesDensity;
  85760. private _midtonesSaturation;
  85761. private _midtonesExposure;
  85762. /**
  85763. * Gets the midtones Hue value.
  85764. * 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).
  85765. */
  85766. get midtonesHue(): number;
  85767. /**
  85768. * Sets the midtones Hue value.
  85769. * 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).
  85770. */
  85771. set midtonesHue(value: number);
  85772. /**
  85773. * Gets the midtones Density value.
  85774. * 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.
  85775. * Values less than zero provide a filter of opposite hue.
  85776. */
  85777. get midtonesDensity(): number;
  85778. /**
  85779. * Sets the midtones Density value.
  85780. * 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.
  85781. * Values less than zero provide a filter of opposite hue.
  85782. */
  85783. set midtonesDensity(value: number);
  85784. /**
  85785. * Gets the midtones Saturation value.
  85786. * 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.
  85787. */
  85788. get midtonesSaturation(): number;
  85789. /**
  85790. * Sets the midtones Saturation value.
  85791. * 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.
  85792. */
  85793. set midtonesSaturation(value: number);
  85794. /**
  85795. * Gets the midtones Exposure value.
  85796. * 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.
  85797. */
  85798. get midtonesExposure(): number;
  85799. /**
  85800. * Sets the midtones Exposure value.
  85801. * 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.
  85802. */
  85803. set midtonesExposure(value: number);
  85804. private _shadowsHue;
  85805. private _shadowsDensity;
  85806. private _shadowsSaturation;
  85807. private _shadowsExposure;
  85808. /**
  85809. * Gets the shadows Hue value.
  85810. * 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).
  85811. */
  85812. get shadowsHue(): number;
  85813. /**
  85814. * Sets the shadows Hue value.
  85815. * 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).
  85816. */
  85817. set shadowsHue(value: number);
  85818. /**
  85819. * Gets the shadows Density value.
  85820. * 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.
  85821. * Values less than zero provide a filter of opposite hue.
  85822. */
  85823. get shadowsDensity(): number;
  85824. /**
  85825. * Sets the shadows Density value.
  85826. * 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.
  85827. * Values less than zero provide a filter of opposite hue.
  85828. */
  85829. set shadowsDensity(value: number);
  85830. /**
  85831. * Gets the shadows Saturation value.
  85832. * 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.
  85833. */
  85834. get shadowsSaturation(): number;
  85835. /**
  85836. * Sets the shadows Saturation value.
  85837. * 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.
  85838. */
  85839. set shadowsSaturation(value: number);
  85840. /**
  85841. * Gets the shadows Exposure value.
  85842. * 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.
  85843. */
  85844. get shadowsExposure(): number;
  85845. /**
  85846. * Sets the shadows Exposure value.
  85847. * 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.
  85848. */
  85849. set shadowsExposure(value: number);
  85850. /**
  85851. * Returns the class name
  85852. * @returns The class name
  85853. */
  85854. getClassName(): string;
  85855. /**
  85856. * Binds the color curves to the shader.
  85857. * @param colorCurves The color curve to bind
  85858. * @param effect The effect to bind to
  85859. * @param positiveUniform The positive uniform shader parameter
  85860. * @param neutralUniform The neutral uniform shader parameter
  85861. * @param negativeUniform The negative uniform shader parameter
  85862. */
  85863. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85864. /**
  85865. * Prepare the list of uniforms associated with the ColorCurves effects.
  85866. * @param uniformsList The list of uniforms used in the effect
  85867. */
  85868. static PrepareUniforms(uniformsList: string[]): void;
  85869. /**
  85870. * Returns color grading data based on a hue, density, saturation and exposure value.
  85871. * @param filterHue The hue of the color filter.
  85872. * @param filterDensity The density of the color filter.
  85873. * @param saturation The saturation.
  85874. * @param exposure The exposure.
  85875. * @param result The result data container.
  85876. */
  85877. private getColorGradingDataToRef;
  85878. /**
  85879. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85880. * @param value The input slider value in range [-100,100].
  85881. * @returns Adjusted value.
  85882. */
  85883. private static applyColorGradingSliderNonlinear;
  85884. /**
  85885. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85886. * @param hue The hue (H) input.
  85887. * @param saturation The saturation (S) input.
  85888. * @param brightness The brightness (B) input.
  85889. * @result An RGBA color represented as Vector4.
  85890. */
  85891. private static fromHSBToRef;
  85892. /**
  85893. * Returns a value clamped between min and max
  85894. * @param value The value to clamp
  85895. * @param min The minimum of value
  85896. * @param max The maximum of value
  85897. * @returns The clamped value.
  85898. */
  85899. private static clamp;
  85900. /**
  85901. * Clones the current color curve instance.
  85902. * @return The cloned curves
  85903. */
  85904. clone(): ColorCurves;
  85905. /**
  85906. * Serializes the current color curve instance to a json representation.
  85907. * @return a JSON representation
  85908. */
  85909. serialize(): any;
  85910. /**
  85911. * Parses the color curve from a json representation.
  85912. * @param source the JSON source to parse
  85913. * @return The parsed curves
  85914. */
  85915. static Parse(source: any): ColorCurves;
  85916. }
  85917. }
  85918. declare module BABYLON {
  85919. /**
  85920. * Interface to follow in your material defines to integrate easily the
  85921. * Image proccessing functions.
  85922. * @hidden
  85923. */
  85924. export interface IImageProcessingConfigurationDefines {
  85925. IMAGEPROCESSING: boolean;
  85926. VIGNETTE: boolean;
  85927. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85928. VIGNETTEBLENDMODEOPAQUE: boolean;
  85929. TONEMAPPING: boolean;
  85930. TONEMAPPING_ACES: boolean;
  85931. CONTRAST: boolean;
  85932. EXPOSURE: boolean;
  85933. COLORCURVES: boolean;
  85934. COLORGRADING: boolean;
  85935. COLORGRADING3D: boolean;
  85936. SAMPLER3DGREENDEPTH: boolean;
  85937. SAMPLER3DBGRMAP: boolean;
  85938. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85939. }
  85940. /**
  85941. * @hidden
  85942. */
  85943. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85944. IMAGEPROCESSING: boolean;
  85945. VIGNETTE: boolean;
  85946. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85947. VIGNETTEBLENDMODEOPAQUE: boolean;
  85948. TONEMAPPING: boolean;
  85949. TONEMAPPING_ACES: boolean;
  85950. CONTRAST: boolean;
  85951. COLORCURVES: boolean;
  85952. COLORGRADING: boolean;
  85953. COLORGRADING3D: boolean;
  85954. SAMPLER3DGREENDEPTH: boolean;
  85955. SAMPLER3DBGRMAP: boolean;
  85956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85957. EXPOSURE: boolean;
  85958. constructor();
  85959. }
  85960. /**
  85961. * This groups together the common properties used for image processing either in direct forward pass
  85962. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85963. * or not.
  85964. */
  85965. export class ImageProcessingConfiguration {
  85966. /**
  85967. * Default tone mapping applied in BabylonJS.
  85968. */
  85969. static readonly TONEMAPPING_STANDARD: number;
  85970. /**
  85971. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85972. * to other engines rendering to increase portability.
  85973. */
  85974. static readonly TONEMAPPING_ACES: number;
  85975. /**
  85976. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85977. */
  85978. colorCurves: Nullable<ColorCurves>;
  85979. private _colorCurvesEnabled;
  85980. /**
  85981. * Gets wether the color curves effect is enabled.
  85982. */
  85983. get colorCurvesEnabled(): boolean;
  85984. /**
  85985. * Sets wether the color curves effect is enabled.
  85986. */
  85987. set colorCurvesEnabled(value: boolean);
  85988. private _colorGradingTexture;
  85989. /**
  85990. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85991. */
  85992. get colorGradingTexture(): Nullable<BaseTexture>;
  85993. /**
  85994. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85995. */
  85996. set colorGradingTexture(value: Nullable<BaseTexture>);
  85997. private _colorGradingEnabled;
  85998. /**
  85999. * Gets wether the color grading effect is enabled.
  86000. */
  86001. get colorGradingEnabled(): boolean;
  86002. /**
  86003. * Sets wether the color grading effect is enabled.
  86004. */
  86005. set colorGradingEnabled(value: boolean);
  86006. private _colorGradingWithGreenDepth;
  86007. /**
  86008. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86009. */
  86010. get colorGradingWithGreenDepth(): boolean;
  86011. /**
  86012. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86013. */
  86014. set colorGradingWithGreenDepth(value: boolean);
  86015. private _colorGradingBGR;
  86016. /**
  86017. * Gets wether the color grading texture contains BGR values.
  86018. */
  86019. get colorGradingBGR(): boolean;
  86020. /**
  86021. * Sets wether the color grading texture contains BGR values.
  86022. */
  86023. set colorGradingBGR(value: boolean);
  86024. /** @hidden */
  86025. _exposure: number;
  86026. /**
  86027. * Gets the Exposure used in the effect.
  86028. */
  86029. get exposure(): number;
  86030. /**
  86031. * Sets the Exposure used in the effect.
  86032. */
  86033. set exposure(value: number);
  86034. private _toneMappingEnabled;
  86035. /**
  86036. * Gets wether the tone mapping effect is enabled.
  86037. */
  86038. get toneMappingEnabled(): boolean;
  86039. /**
  86040. * Sets wether the tone mapping effect is enabled.
  86041. */
  86042. set toneMappingEnabled(value: boolean);
  86043. private _toneMappingType;
  86044. /**
  86045. * Gets the type of tone mapping effect.
  86046. */
  86047. get toneMappingType(): number;
  86048. /**
  86049. * Sets the type of tone mapping effect used in BabylonJS.
  86050. */
  86051. set toneMappingType(value: number);
  86052. protected _contrast: number;
  86053. /**
  86054. * Gets the contrast used in the effect.
  86055. */
  86056. get contrast(): number;
  86057. /**
  86058. * Sets the contrast used in the effect.
  86059. */
  86060. set contrast(value: number);
  86061. /**
  86062. * Vignette stretch size.
  86063. */
  86064. vignetteStretch: number;
  86065. /**
  86066. * Vignette centre X Offset.
  86067. */
  86068. vignetteCentreX: number;
  86069. /**
  86070. * Vignette centre Y Offset.
  86071. */
  86072. vignetteCentreY: number;
  86073. /**
  86074. * Vignette weight or intensity of the vignette effect.
  86075. */
  86076. vignetteWeight: number;
  86077. /**
  86078. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86079. * if vignetteEnabled is set to true.
  86080. */
  86081. vignetteColor: Color4;
  86082. /**
  86083. * Camera field of view used by the Vignette effect.
  86084. */
  86085. vignetteCameraFov: number;
  86086. private _vignetteBlendMode;
  86087. /**
  86088. * Gets the vignette blend mode allowing different kind of effect.
  86089. */
  86090. get vignetteBlendMode(): number;
  86091. /**
  86092. * Sets the vignette blend mode allowing different kind of effect.
  86093. */
  86094. set vignetteBlendMode(value: number);
  86095. private _vignetteEnabled;
  86096. /**
  86097. * Gets wether the vignette effect is enabled.
  86098. */
  86099. get vignetteEnabled(): boolean;
  86100. /**
  86101. * Sets wether the vignette effect is enabled.
  86102. */
  86103. set vignetteEnabled(value: boolean);
  86104. private _applyByPostProcess;
  86105. /**
  86106. * Gets wether the image processing is applied through a post process or not.
  86107. */
  86108. get applyByPostProcess(): boolean;
  86109. /**
  86110. * Sets wether the image processing is applied through a post process or not.
  86111. */
  86112. set applyByPostProcess(value: boolean);
  86113. private _isEnabled;
  86114. /**
  86115. * Gets wether the image processing is enabled or not.
  86116. */
  86117. get isEnabled(): boolean;
  86118. /**
  86119. * Sets wether the image processing is enabled or not.
  86120. */
  86121. set isEnabled(value: boolean);
  86122. /**
  86123. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86124. */
  86125. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86126. /**
  86127. * Method called each time the image processing information changes requires to recompile the effect.
  86128. */
  86129. protected _updateParameters(): void;
  86130. /**
  86131. * Gets the current class name.
  86132. * @return "ImageProcessingConfiguration"
  86133. */
  86134. getClassName(): string;
  86135. /**
  86136. * Prepare the list of uniforms associated with the Image Processing effects.
  86137. * @param uniforms The list of uniforms used in the effect
  86138. * @param defines the list of defines currently in use
  86139. */
  86140. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86141. /**
  86142. * Prepare the list of samplers associated with the Image Processing effects.
  86143. * @param samplersList The list of uniforms used in the effect
  86144. * @param defines the list of defines currently in use
  86145. */
  86146. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86147. /**
  86148. * Prepare the list of defines associated to the shader.
  86149. * @param defines the list of defines to complete
  86150. * @param forPostProcess Define if we are currently in post process mode or not
  86151. */
  86152. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86153. /**
  86154. * Returns true if all the image processing information are ready.
  86155. * @returns True if ready, otherwise, false
  86156. */
  86157. isReady(): boolean;
  86158. /**
  86159. * Binds the image processing to the shader.
  86160. * @param effect The effect to bind to
  86161. * @param overrideAspectRatio Override the aspect ratio of the effect
  86162. */
  86163. bind(effect: Effect, overrideAspectRatio?: number): void;
  86164. /**
  86165. * Clones the current image processing instance.
  86166. * @return The cloned image processing
  86167. */
  86168. clone(): ImageProcessingConfiguration;
  86169. /**
  86170. * Serializes the current image processing instance to a json representation.
  86171. * @return a JSON representation
  86172. */
  86173. serialize(): any;
  86174. /**
  86175. * Parses the image processing from a json representation.
  86176. * @param source the JSON source to parse
  86177. * @return The parsed image processing
  86178. */
  86179. static Parse(source: any): ImageProcessingConfiguration;
  86180. private static _VIGNETTEMODE_MULTIPLY;
  86181. private static _VIGNETTEMODE_OPAQUE;
  86182. /**
  86183. * Used to apply the vignette as a mix with the pixel color.
  86184. */
  86185. static get VIGNETTEMODE_MULTIPLY(): number;
  86186. /**
  86187. * Used to apply the vignette as a replacement of the pixel color.
  86188. */
  86189. static get VIGNETTEMODE_OPAQUE(): number;
  86190. }
  86191. }
  86192. declare module BABYLON {
  86193. /** @hidden */
  86194. export var postprocessVertexShader: {
  86195. name: string;
  86196. shader: string;
  86197. };
  86198. }
  86199. declare module BABYLON {
  86200. interface ThinEngine {
  86201. /**
  86202. * Creates a new render target texture
  86203. * @param size defines the size of the texture
  86204. * @param options defines the options used to create the texture
  86205. * @returns a new render target texture stored in an InternalTexture
  86206. */
  86207. createRenderTargetTexture(size: number | {
  86208. width: number;
  86209. height: number;
  86210. layers?: number;
  86211. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86212. /**
  86213. * Creates a depth stencil texture.
  86214. * This is only available in WebGL 2 or with the depth texture extension available.
  86215. * @param size The size of face edge in the texture.
  86216. * @param options The options defining the texture.
  86217. * @returns The texture
  86218. */
  86219. createDepthStencilTexture(size: number | {
  86220. width: number;
  86221. height: number;
  86222. layers?: number;
  86223. }, options: DepthTextureCreationOptions): InternalTexture;
  86224. /** @hidden */
  86225. _createDepthStencilTexture(size: number | {
  86226. width: number;
  86227. height: number;
  86228. layers?: number;
  86229. }, options: DepthTextureCreationOptions): InternalTexture;
  86230. }
  86231. }
  86232. declare module BABYLON {
  86233. /**
  86234. * Defines the kind of connection point for node based material
  86235. */
  86236. export enum NodeMaterialBlockConnectionPointTypes {
  86237. /** Float */
  86238. Float = 1,
  86239. /** Int */
  86240. Int = 2,
  86241. /** Vector2 */
  86242. Vector2 = 4,
  86243. /** Vector3 */
  86244. Vector3 = 8,
  86245. /** Vector4 */
  86246. Vector4 = 16,
  86247. /** Color3 */
  86248. Color3 = 32,
  86249. /** Color4 */
  86250. Color4 = 64,
  86251. /** Matrix */
  86252. Matrix = 128,
  86253. /** Custom object */
  86254. Object = 256,
  86255. /** Detect type based on connection */
  86256. AutoDetect = 1024,
  86257. /** Output type that will be defined by input type */
  86258. BasedOnInput = 2048
  86259. }
  86260. }
  86261. declare module BABYLON {
  86262. /**
  86263. * Enum used to define the target of a block
  86264. */
  86265. export enum NodeMaterialBlockTargets {
  86266. /** Vertex shader */
  86267. Vertex = 1,
  86268. /** Fragment shader */
  86269. Fragment = 2,
  86270. /** Neutral */
  86271. Neutral = 4,
  86272. /** Vertex and Fragment */
  86273. VertexAndFragment = 3
  86274. }
  86275. }
  86276. declare module BABYLON {
  86277. /**
  86278. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86279. */
  86280. export enum NodeMaterialBlockConnectionPointMode {
  86281. /** Value is an uniform */
  86282. Uniform = 0,
  86283. /** Value is a mesh attribute */
  86284. Attribute = 1,
  86285. /** Value is a varying between vertex and fragment shaders */
  86286. Varying = 2,
  86287. /** Mode is undefined */
  86288. Undefined = 3
  86289. }
  86290. }
  86291. declare module BABYLON {
  86292. /**
  86293. * Enum used to define system values e.g. values automatically provided by the system
  86294. */
  86295. export enum NodeMaterialSystemValues {
  86296. /** World */
  86297. World = 1,
  86298. /** View */
  86299. View = 2,
  86300. /** Projection */
  86301. Projection = 3,
  86302. /** ViewProjection */
  86303. ViewProjection = 4,
  86304. /** WorldView */
  86305. WorldView = 5,
  86306. /** WorldViewProjection */
  86307. WorldViewProjection = 6,
  86308. /** CameraPosition */
  86309. CameraPosition = 7,
  86310. /** Fog Color */
  86311. FogColor = 8,
  86312. /** Delta time */
  86313. DeltaTime = 9
  86314. }
  86315. }
  86316. declare module BABYLON {
  86317. /** Defines supported spaces */
  86318. export enum Space {
  86319. /** Local (object) space */
  86320. LOCAL = 0,
  86321. /** World space */
  86322. WORLD = 1,
  86323. /** Bone space */
  86324. BONE = 2
  86325. }
  86326. /** Defines the 3 main axes */
  86327. export class Axis {
  86328. /** X axis */
  86329. static X: Vector3;
  86330. /** Y axis */
  86331. static Y: Vector3;
  86332. /** Z axis */
  86333. static Z: Vector3;
  86334. }
  86335. }
  86336. declare module BABYLON {
  86337. /**
  86338. * Represents a camera frustum
  86339. */
  86340. export class Frustum {
  86341. /**
  86342. * Gets the planes representing the frustum
  86343. * @param transform matrix to be applied to the returned planes
  86344. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86345. */
  86346. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86347. /**
  86348. * Gets the near frustum plane transformed by the transform matrix
  86349. * @param transform transformation matrix to be applied to the resulting frustum plane
  86350. * @param frustumPlane the resuling frustum plane
  86351. */
  86352. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86353. /**
  86354. * Gets the far frustum plane transformed by the transform matrix
  86355. * @param transform transformation matrix to be applied to the resulting frustum plane
  86356. * @param frustumPlane the resuling frustum plane
  86357. */
  86358. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86359. /**
  86360. * Gets the left frustum plane transformed by the transform matrix
  86361. * @param transform transformation matrix to be applied to the resulting frustum plane
  86362. * @param frustumPlane the resuling frustum plane
  86363. */
  86364. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86365. /**
  86366. * Gets the right frustum plane transformed by the transform matrix
  86367. * @param transform transformation matrix to be applied to the resulting frustum plane
  86368. * @param frustumPlane the resuling frustum plane
  86369. */
  86370. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86371. /**
  86372. * Gets the top frustum plane transformed by the transform matrix
  86373. * @param transform transformation matrix to be applied to the resulting frustum plane
  86374. * @param frustumPlane the resuling frustum plane
  86375. */
  86376. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86377. /**
  86378. * Gets the bottom frustum plane transformed by the transform matrix
  86379. * @param transform transformation matrix to be applied to the resulting frustum plane
  86380. * @param frustumPlane the resuling frustum plane
  86381. */
  86382. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86383. /**
  86384. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86385. * @param transform transformation matrix to be applied to the resulting frustum planes
  86386. * @param frustumPlanes the resuling frustum planes
  86387. */
  86388. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86389. }
  86390. }
  86391. declare module BABYLON {
  86392. /**
  86393. * Interface for the size containing width and height
  86394. */
  86395. export interface ISize {
  86396. /**
  86397. * Width
  86398. */
  86399. width: number;
  86400. /**
  86401. * Heighht
  86402. */
  86403. height: number;
  86404. }
  86405. /**
  86406. * Size containing widht and height
  86407. */
  86408. export class Size implements ISize {
  86409. /**
  86410. * Width
  86411. */
  86412. width: number;
  86413. /**
  86414. * Height
  86415. */
  86416. height: number;
  86417. /**
  86418. * Creates a Size object from the given width and height (floats).
  86419. * @param width width of the new size
  86420. * @param height height of the new size
  86421. */
  86422. constructor(width: number, height: number);
  86423. /**
  86424. * Returns a string with the Size width and height
  86425. * @returns a string with the Size width and height
  86426. */
  86427. toString(): string;
  86428. /**
  86429. * "Size"
  86430. * @returns the string "Size"
  86431. */
  86432. getClassName(): string;
  86433. /**
  86434. * Returns the Size hash code.
  86435. * @returns a hash code for a unique width and height
  86436. */
  86437. getHashCode(): number;
  86438. /**
  86439. * Updates the current size from the given one.
  86440. * @param src the given size
  86441. */
  86442. copyFrom(src: Size): void;
  86443. /**
  86444. * Updates in place the current Size from the given floats.
  86445. * @param width width of the new size
  86446. * @param height height of the new size
  86447. * @returns the updated Size.
  86448. */
  86449. copyFromFloats(width: number, height: number): Size;
  86450. /**
  86451. * Updates in place the current Size from the given floats.
  86452. * @param width width to set
  86453. * @param height height to set
  86454. * @returns the updated Size.
  86455. */
  86456. set(width: number, height: number): Size;
  86457. /**
  86458. * Multiplies the width and height by numbers
  86459. * @param w factor to multiple the width by
  86460. * @param h factor to multiple the height by
  86461. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86462. */
  86463. multiplyByFloats(w: number, h: number): Size;
  86464. /**
  86465. * Clones the size
  86466. * @returns a new Size copied from the given one.
  86467. */
  86468. clone(): Size;
  86469. /**
  86470. * True if the current Size and the given one width and height are strictly equal.
  86471. * @param other the other size to compare against
  86472. * @returns True if the current Size and the given one width and height are strictly equal.
  86473. */
  86474. equals(other: Size): boolean;
  86475. /**
  86476. * The surface of the Size : width * height (float).
  86477. */
  86478. get surface(): number;
  86479. /**
  86480. * Create a new size of zero
  86481. * @returns a new Size set to (0.0, 0.0)
  86482. */
  86483. static Zero(): Size;
  86484. /**
  86485. * Sums the width and height of two sizes
  86486. * @param otherSize size to add to this size
  86487. * @returns a new Size set as the addition result of the current Size and the given one.
  86488. */
  86489. add(otherSize: Size): Size;
  86490. /**
  86491. * Subtracts the width and height of two
  86492. * @param otherSize size to subtract to this size
  86493. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86494. */
  86495. subtract(otherSize: Size): Size;
  86496. /**
  86497. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86498. * @param start starting size to lerp between
  86499. * @param end end size to lerp between
  86500. * @param amount amount to lerp between the start and end values
  86501. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86502. */
  86503. static Lerp(start: Size, end: Size, amount: number): Size;
  86504. }
  86505. }
  86506. declare module BABYLON {
  86507. /**
  86508. * Contains position and normal vectors for a vertex
  86509. */
  86510. export class PositionNormalVertex {
  86511. /** the position of the vertex (defaut: 0,0,0) */
  86512. position: Vector3;
  86513. /** the normal of the vertex (defaut: 0,1,0) */
  86514. normal: Vector3;
  86515. /**
  86516. * Creates a PositionNormalVertex
  86517. * @param position the position of the vertex (defaut: 0,0,0)
  86518. * @param normal the normal of the vertex (defaut: 0,1,0)
  86519. */
  86520. constructor(
  86521. /** the position of the vertex (defaut: 0,0,0) */
  86522. position?: Vector3,
  86523. /** the normal of the vertex (defaut: 0,1,0) */
  86524. normal?: Vector3);
  86525. /**
  86526. * Clones the PositionNormalVertex
  86527. * @returns the cloned PositionNormalVertex
  86528. */
  86529. clone(): PositionNormalVertex;
  86530. }
  86531. /**
  86532. * Contains position, normal and uv vectors for a vertex
  86533. */
  86534. export class PositionNormalTextureVertex {
  86535. /** the position of the vertex (defaut: 0,0,0) */
  86536. position: Vector3;
  86537. /** the normal of the vertex (defaut: 0,1,0) */
  86538. normal: Vector3;
  86539. /** the uv of the vertex (default: 0,0) */
  86540. uv: Vector2;
  86541. /**
  86542. * Creates a PositionNormalTextureVertex
  86543. * @param position the position of the vertex (defaut: 0,0,0)
  86544. * @param normal the normal of the vertex (defaut: 0,1,0)
  86545. * @param uv the uv of the vertex (default: 0,0)
  86546. */
  86547. constructor(
  86548. /** the position of the vertex (defaut: 0,0,0) */
  86549. position?: Vector3,
  86550. /** the normal of the vertex (defaut: 0,1,0) */
  86551. normal?: Vector3,
  86552. /** the uv of the vertex (default: 0,0) */
  86553. uv?: Vector2);
  86554. /**
  86555. * Clones the PositionNormalTextureVertex
  86556. * @returns the cloned PositionNormalTextureVertex
  86557. */
  86558. clone(): PositionNormalTextureVertex;
  86559. }
  86560. }
  86561. declare module BABYLON {
  86562. /**
  86563. * Enum defining the type of animations supported by InputBlock
  86564. */
  86565. export enum AnimatedInputBlockTypes {
  86566. /** No animation */
  86567. None = 0,
  86568. /** Time based animation. Will only work for floats */
  86569. Time = 1
  86570. }
  86571. }
  86572. declare module BABYLON {
  86573. /**
  86574. * Interface describing all the common properties and methods a shadow light needs to implement.
  86575. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86576. * as well as binding the different shadow properties to the effects.
  86577. */
  86578. export interface IShadowLight extends Light {
  86579. /**
  86580. * The light id in the scene (used in scene.findLighById for instance)
  86581. */
  86582. id: string;
  86583. /**
  86584. * The position the shdow will be casted from.
  86585. */
  86586. position: Vector3;
  86587. /**
  86588. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86589. */
  86590. direction: Vector3;
  86591. /**
  86592. * The transformed position. Position of the light in world space taking parenting in account.
  86593. */
  86594. transformedPosition: Vector3;
  86595. /**
  86596. * The transformed direction. Direction of the light in world space taking parenting in account.
  86597. */
  86598. transformedDirection: Vector3;
  86599. /**
  86600. * The friendly name of the light in the scene.
  86601. */
  86602. name: string;
  86603. /**
  86604. * Defines the shadow projection clipping minimum z value.
  86605. */
  86606. shadowMinZ: number;
  86607. /**
  86608. * Defines the shadow projection clipping maximum z value.
  86609. */
  86610. shadowMaxZ: number;
  86611. /**
  86612. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86613. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86614. */
  86615. computeTransformedInformation(): boolean;
  86616. /**
  86617. * Gets the scene the light belongs to.
  86618. * @returns The scene
  86619. */
  86620. getScene(): Scene;
  86621. /**
  86622. * Callback defining a custom Projection Matrix Builder.
  86623. * This can be used to override the default projection matrix computation.
  86624. */
  86625. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86626. /**
  86627. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86628. * @param matrix The materix to updated with the projection information
  86629. * @param viewMatrix The transform matrix of the light
  86630. * @param renderList The list of mesh to render in the map
  86631. * @returns The current light
  86632. */
  86633. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86634. /**
  86635. * Gets the current depth scale used in ESM.
  86636. * @returns The scale
  86637. */
  86638. getDepthScale(): number;
  86639. /**
  86640. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86641. * @returns true if a cube texture needs to be use
  86642. */
  86643. needCube(): boolean;
  86644. /**
  86645. * Detects if the projection matrix requires to be recomputed this frame.
  86646. * @returns true if it requires to be recomputed otherwise, false.
  86647. */
  86648. needProjectionMatrixCompute(): boolean;
  86649. /**
  86650. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86651. */
  86652. forceProjectionMatrixCompute(): void;
  86653. /**
  86654. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86655. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86656. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86657. */
  86658. getShadowDirection(faceIndex?: number): Vector3;
  86659. /**
  86660. * Gets the minZ used for shadow according to both the scene and the light.
  86661. * @param activeCamera The camera we are returning the min for
  86662. * @returns the depth min z
  86663. */
  86664. getDepthMinZ(activeCamera: Camera): number;
  86665. /**
  86666. * Gets the maxZ used for shadow according to both the scene and the light.
  86667. * @param activeCamera The camera we are returning the max for
  86668. * @returns the depth max z
  86669. */
  86670. getDepthMaxZ(activeCamera: Camera): number;
  86671. }
  86672. /**
  86673. * Base implementation IShadowLight
  86674. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86675. */
  86676. export abstract class ShadowLight extends Light implements IShadowLight {
  86677. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86678. protected _position: Vector3;
  86679. protected _setPosition(value: Vector3): void;
  86680. /**
  86681. * Sets the position the shadow will be casted from. Also use as the light position for both
  86682. * point and spot lights.
  86683. */
  86684. get position(): Vector3;
  86685. /**
  86686. * Sets the position the shadow will be casted from. Also use as the light position for both
  86687. * point and spot lights.
  86688. */
  86689. set position(value: Vector3);
  86690. protected _direction: Vector3;
  86691. protected _setDirection(value: Vector3): void;
  86692. /**
  86693. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86694. * Also use as the light direction on spot and directional lights.
  86695. */
  86696. get direction(): Vector3;
  86697. /**
  86698. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86699. * Also use as the light direction on spot and directional lights.
  86700. */
  86701. set direction(value: Vector3);
  86702. protected _shadowMinZ: number;
  86703. /**
  86704. * Gets the shadow projection clipping minimum z value.
  86705. */
  86706. get shadowMinZ(): number;
  86707. /**
  86708. * Sets the shadow projection clipping minimum z value.
  86709. */
  86710. set shadowMinZ(value: number);
  86711. protected _shadowMaxZ: number;
  86712. /**
  86713. * Sets the shadow projection clipping maximum z value.
  86714. */
  86715. get shadowMaxZ(): number;
  86716. /**
  86717. * Gets the shadow projection clipping maximum z value.
  86718. */
  86719. set shadowMaxZ(value: number);
  86720. /**
  86721. * Callback defining a custom Projection Matrix Builder.
  86722. * This can be used to override the default projection matrix computation.
  86723. */
  86724. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86725. /**
  86726. * The transformed position. Position of the light in world space taking parenting in account.
  86727. */
  86728. transformedPosition: Vector3;
  86729. /**
  86730. * The transformed direction. Direction of the light in world space taking parenting in account.
  86731. */
  86732. transformedDirection: Vector3;
  86733. private _needProjectionMatrixCompute;
  86734. /**
  86735. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86736. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86737. */
  86738. computeTransformedInformation(): boolean;
  86739. /**
  86740. * Return the depth scale used for the shadow map.
  86741. * @returns the depth scale.
  86742. */
  86743. getDepthScale(): number;
  86744. /**
  86745. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86746. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86747. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86748. */
  86749. getShadowDirection(faceIndex?: number): Vector3;
  86750. /**
  86751. * Returns the ShadowLight absolute position in the World.
  86752. * @returns the position vector in world space
  86753. */
  86754. getAbsolutePosition(): Vector3;
  86755. /**
  86756. * Sets the ShadowLight direction toward the passed target.
  86757. * @param target The point to target in local space
  86758. * @returns the updated ShadowLight direction
  86759. */
  86760. setDirectionToTarget(target: Vector3): Vector3;
  86761. /**
  86762. * Returns the light rotation in euler definition.
  86763. * @returns the x y z rotation in local space.
  86764. */
  86765. getRotation(): Vector3;
  86766. /**
  86767. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86768. * @returns true if a cube texture needs to be use
  86769. */
  86770. needCube(): boolean;
  86771. /**
  86772. * Detects if the projection matrix requires to be recomputed this frame.
  86773. * @returns true if it requires to be recomputed otherwise, false.
  86774. */
  86775. needProjectionMatrixCompute(): boolean;
  86776. /**
  86777. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86778. */
  86779. forceProjectionMatrixCompute(): void;
  86780. /** @hidden */
  86781. _initCache(): void;
  86782. /** @hidden */
  86783. _isSynchronized(): boolean;
  86784. /**
  86785. * Computes the world matrix of the node
  86786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86787. * @returns the world matrix
  86788. */
  86789. computeWorldMatrix(force?: boolean): Matrix;
  86790. /**
  86791. * Gets the minZ used for shadow according to both the scene and the light.
  86792. * @param activeCamera The camera we are returning the min for
  86793. * @returns the depth min z
  86794. */
  86795. getDepthMinZ(activeCamera: Camera): number;
  86796. /**
  86797. * Gets the maxZ used for shadow according to both the scene and the light.
  86798. * @param activeCamera The camera we are returning the max for
  86799. * @returns the depth max z
  86800. */
  86801. getDepthMaxZ(activeCamera: Camera): number;
  86802. /**
  86803. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86804. * @param matrix The materix to updated with the projection information
  86805. * @param viewMatrix The transform matrix of the light
  86806. * @param renderList The list of mesh to render in the map
  86807. * @returns The current light
  86808. */
  86809. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86810. }
  86811. }
  86812. declare module BABYLON {
  86813. /** @hidden */
  86814. export var packingFunctions: {
  86815. name: string;
  86816. shader: string;
  86817. };
  86818. }
  86819. declare module BABYLON {
  86820. /** @hidden */
  86821. export var bayerDitherFunctions: {
  86822. name: string;
  86823. shader: string;
  86824. };
  86825. }
  86826. declare module BABYLON {
  86827. /** @hidden */
  86828. export var shadowMapFragmentDeclaration: {
  86829. name: string;
  86830. shader: string;
  86831. };
  86832. }
  86833. declare module BABYLON {
  86834. /** @hidden */
  86835. export var clipPlaneFragmentDeclaration: {
  86836. name: string;
  86837. shader: string;
  86838. };
  86839. }
  86840. declare module BABYLON {
  86841. /** @hidden */
  86842. export var clipPlaneFragment: {
  86843. name: string;
  86844. shader: string;
  86845. };
  86846. }
  86847. declare module BABYLON {
  86848. /** @hidden */
  86849. export var shadowMapFragment: {
  86850. name: string;
  86851. shader: string;
  86852. };
  86853. }
  86854. declare module BABYLON {
  86855. /** @hidden */
  86856. export var shadowMapPixelShader: {
  86857. name: string;
  86858. shader: string;
  86859. };
  86860. }
  86861. declare module BABYLON {
  86862. /** @hidden */
  86863. export var bonesDeclaration: {
  86864. name: string;
  86865. shader: string;
  86866. };
  86867. }
  86868. declare module BABYLON {
  86869. /** @hidden */
  86870. export var morphTargetsVertexGlobalDeclaration: {
  86871. name: string;
  86872. shader: string;
  86873. };
  86874. }
  86875. declare module BABYLON {
  86876. /** @hidden */
  86877. export var morphTargetsVertexDeclaration: {
  86878. name: string;
  86879. shader: string;
  86880. };
  86881. }
  86882. declare module BABYLON {
  86883. /** @hidden */
  86884. export var instancesDeclaration: {
  86885. name: string;
  86886. shader: string;
  86887. };
  86888. }
  86889. declare module BABYLON {
  86890. /** @hidden */
  86891. export var helperFunctions: {
  86892. name: string;
  86893. shader: string;
  86894. };
  86895. }
  86896. declare module BABYLON {
  86897. /** @hidden */
  86898. export var shadowMapVertexDeclaration: {
  86899. name: string;
  86900. shader: string;
  86901. };
  86902. }
  86903. declare module BABYLON {
  86904. /** @hidden */
  86905. export var clipPlaneVertexDeclaration: {
  86906. name: string;
  86907. shader: string;
  86908. };
  86909. }
  86910. declare module BABYLON {
  86911. /** @hidden */
  86912. export var morphTargetsVertex: {
  86913. name: string;
  86914. shader: string;
  86915. };
  86916. }
  86917. declare module BABYLON {
  86918. /** @hidden */
  86919. export var instancesVertex: {
  86920. name: string;
  86921. shader: string;
  86922. };
  86923. }
  86924. declare module BABYLON {
  86925. /** @hidden */
  86926. export var bonesVertex: {
  86927. name: string;
  86928. shader: string;
  86929. };
  86930. }
  86931. declare module BABYLON {
  86932. /** @hidden */
  86933. export var shadowMapVertexNormalBias: {
  86934. name: string;
  86935. shader: string;
  86936. };
  86937. }
  86938. declare module BABYLON {
  86939. /** @hidden */
  86940. export var shadowMapVertexMetric: {
  86941. name: string;
  86942. shader: string;
  86943. };
  86944. }
  86945. declare module BABYLON {
  86946. /** @hidden */
  86947. export var clipPlaneVertex: {
  86948. name: string;
  86949. shader: string;
  86950. };
  86951. }
  86952. declare module BABYLON {
  86953. /** @hidden */
  86954. export var shadowMapVertexShader: {
  86955. name: string;
  86956. shader: string;
  86957. };
  86958. }
  86959. declare module BABYLON {
  86960. /** @hidden */
  86961. export var depthBoxBlurPixelShader: {
  86962. name: string;
  86963. shader: string;
  86964. };
  86965. }
  86966. declare module BABYLON {
  86967. /** @hidden */
  86968. export var shadowMapFragmentSoftTransparentShadow: {
  86969. name: string;
  86970. shader: string;
  86971. };
  86972. }
  86973. declare module BABYLON {
  86974. /**
  86975. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86976. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86977. */
  86978. export class EffectFallbacks implements IEffectFallbacks {
  86979. private _defines;
  86980. private _currentRank;
  86981. private _maxRank;
  86982. private _mesh;
  86983. /**
  86984. * Removes the fallback from the bound mesh.
  86985. */
  86986. unBindMesh(): void;
  86987. /**
  86988. * Adds a fallback on the specified property.
  86989. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86990. * @param define The name of the define in the shader
  86991. */
  86992. addFallback(rank: number, define: string): void;
  86993. /**
  86994. * Sets the mesh to use CPU skinning when needing to fallback.
  86995. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86996. * @param mesh The mesh to use the fallbacks.
  86997. */
  86998. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86999. /**
  87000. * Checks to see if more fallbacks are still availible.
  87001. */
  87002. get hasMoreFallbacks(): boolean;
  87003. /**
  87004. * Removes the defines that should be removed when falling back.
  87005. * @param currentDefines defines the current define statements for the shader.
  87006. * @param effect defines the current effect we try to compile
  87007. * @returns The resulting defines with defines of the current rank removed.
  87008. */
  87009. reduce(currentDefines: string, effect: Effect): string;
  87010. }
  87011. }
  87012. declare module BABYLON {
  87013. /**
  87014. * Interface used to define Action
  87015. */
  87016. export interface IAction {
  87017. /**
  87018. * Trigger for the action
  87019. */
  87020. trigger: number;
  87021. /** Options of the trigger */
  87022. triggerOptions: any;
  87023. /**
  87024. * Gets the trigger parameters
  87025. * @returns the trigger parameters
  87026. */
  87027. getTriggerParameter(): any;
  87028. /**
  87029. * Internal only - executes current action event
  87030. * @hidden
  87031. */
  87032. _executeCurrent(evt?: ActionEvent): void;
  87033. /**
  87034. * Serialize placeholder for child classes
  87035. * @param parent of child
  87036. * @returns the serialized object
  87037. */
  87038. serialize(parent: any): any;
  87039. /**
  87040. * Internal only
  87041. * @hidden
  87042. */
  87043. _prepare(): void;
  87044. /**
  87045. * Internal only - manager for action
  87046. * @hidden
  87047. */
  87048. _actionManager: AbstractActionManager;
  87049. /**
  87050. * Adds action to chain of actions, may be a DoNothingAction
  87051. * @param action defines the next action to execute
  87052. * @returns The action passed in
  87053. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87054. */
  87055. then(action: IAction): IAction;
  87056. }
  87057. /**
  87058. * The action to be carried out following a trigger
  87059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87060. */
  87061. export class Action implements IAction {
  87062. /** the trigger, with or without parameters, for the action */
  87063. triggerOptions: any;
  87064. /**
  87065. * Trigger for the action
  87066. */
  87067. trigger: number;
  87068. /**
  87069. * Internal only - manager for action
  87070. * @hidden
  87071. */
  87072. _actionManager: ActionManager;
  87073. private _nextActiveAction;
  87074. private _child;
  87075. private _condition?;
  87076. private _triggerParameter;
  87077. /**
  87078. * An event triggered prior to action being executed.
  87079. */
  87080. onBeforeExecuteObservable: Observable<Action>;
  87081. /**
  87082. * Creates a new Action
  87083. * @param triggerOptions the trigger, with or without parameters, for the action
  87084. * @param condition an optional determinant of action
  87085. */
  87086. constructor(
  87087. /** the trigger, with or without parameters, for the action */
  87088. triggerOptions: any, condition?: Condition);
  87089. /**
  87090. * Internal only
  87091. * @hidden
  87092. */
  87093. _prepare(): void;
  87094. /**
  87095. * Gets the trigger parameters
  87096. * @returns the trigger parameters
  87097. */
  87098. getTriggerParameter(): any;
  87099. /**
  87100. * Internal only - executes current action event
  87101. * @hidden
  87102. */
  87103. _executeCurrent(evt?: ActionEvent): void;
  87104. /**
  87105. * Execute placeholder for child classes
  87106. * @param evt optional action event
  87107. */
  87108. execute(evt?: ActionEvent): void;
  87109. /**
  87110. * Skips to next active action
  87111. */
  87112. skipToNextActiveAction(): void;
  87113. /**
  87114. * Adds action to chain of actions, may be a DoNothingAction
  87115. * @param action defines the next action to execute
  87116. * @returns The action passed in
  87117. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87118. */
  87119. then(action: Action): Action;
  87120. /**
  87121. * Internal only
  87122. * @hidden
  87123. */
  87124. _getProperty(propertyPath: string): string;
  87125. /**
  87126. * Internal only
  87127. * @hidden
  87128. */
  87129. _getEffectiveTarget(target: any, propertyPath: string): any;
  87130. /**
  87131. * Serialize placeholder for child classes
  87132. * @param parent of child
  87133. * @returns the serialized object
  87134. */
  87135. serialize(parent: any): any;
  87136. /**
  87137. * Internal only called by serialize
  87138. * @hidden
  87139. */
  87140. protected _serialize(serializedAction: any, parent?: any): any;
  87141. /**
  87142. * Internal only
  87143. * @hidden
  87144. */
  87145. static _SerializeValueAsString: (value: any) => string;
  87146. /**
  87147. * Internal only
  87148. * @hidden
  87149. */
  87150. static _GetTargetProperty: (target: Node | Scene) => {
  87151. name: string;
  87152. targetType: string;
  87153. value: string;
  87154. };
  87155. }
  87156. }
  87157. declare module BABYLON {
  87158. /**
  87159. * A Condition applied to an Action
  87160. */
  87161. export class Condition {
  87162. /**
  87163. * Internal only - manager for action
  87164. * @hidden
  87165. */
  87166. _actionManager: ActionManager;
  87167. /**
  87168. * Internal only
  87169. * @hidden
  87170. */
  87171. _evaluationId: number;
  87172. /**
  87173. * Internal only
  87174. * @hidden
  87175. */
  87176. _currentResult: boolean;
  87177. /**
  87178. * Creates a new Condition
  87179. * @param actionManager the manager of the action the condition is applied to
  87180. */
  87181. constructor(actionManager: ActionManager);
  87182. /**
  87183. * Check if the current condition is valid
  87184. * @returns a boolean
  87185. */
  87186. isValid(): boolean;
  87187. /**
  87188. * Internal only
  87189. * @hidden
  87190. */
  87191. _getProperty(propertyPath: string): string;
  87192. /**
  87193. * Internal only
  87194. * @hidden
  87195. */
  87196. _getEffectiveTarget(target: any, propertyPath: string): any;
  87197. /**
  87198. * Serialize placeholder for child classes
  87199. * @returns the serialized object
  87200. */
  87201. serialize(): any;
  87202. /**
  87203. * Internal only
  87204. * @hidden
  87205. */
  87206. protected _serialize(serializedCondition: any): any;
  87207. }
  87208. /**
  87209. * Defines specific conditional operators as extensions of Condition
  87210. */
  87211. export class ValueCondition extends Condition {
  87212. /** path to specify the property of the target the conditional operator uses */
  87213. propertyPath: string;
  87214. /** the value compared by the conditional operator against the current value of the property */
  87215. value: any;
  87216. /** the conditional operator, default ValueCondition.IsEqual */
  87217. operator: number;
  87218. /**
  87219. * Internal only
  87220. * @hidden
  87221. */
  87222. private static _IsEqual;
  87223. /**
  87224. * Internal only
  87225. * @hidden
  87226. */
  87227. private static _IsDifferent;
  87228. /**
  87229. * Internal only
  87230. * @hidden
  87231. */
  87232. private static _IsGreater;
  87233. /**
  87234. * Internal only
  87235. * @hidden
  87236. */
  87237. private static _IsLesser;
  87238. /**
  87239. * returns the number for IsEqual
  87240. */
  87241. static get IsEqual(): number;
  87242. /**
  87243. * Returns the number for IsDifferent
  87244. */
  87245. static get IsDifferent(): number;
  87246. /**
  87247. * Returns the number for IsGreater
  87248. */
  87249. static get IsGreater(): number;
  87250. /**
  87251. * Returns the number for IsLesser
  87252. */
  87253. static get IsLesser(): number;
  87254. /**
  87255. * Internal only The action manager for the condition
  87256. * @hidden
  87257. */
  87258. _actionManager: ActionManager;
  87259. /**
  87260. * Internal only
  87261. * @hidden
  87262. */
  87263. private _target;
  87264. /**
  87265. * Internal only
  87266. * @hidden
  87267. */
  87268. private _effectiveTarget;
  87269. /**
  87270. * Internal only
  87271. * @hidden
  87272. */
  87273. private _property;
  87274. /**
  87275. * Creates a new ValueCondition
  87276. * @param actionManager manager for the action the condition applies to
  87277. * @param target for the action
  87278. * @param propertyPath path to specify the property of the target the conditional operator uses
  87279. * @param value the value compared by the conditional operator against the current value of the property
  87280. * @param operator the conditional operator, default ValueCondition.IsEqual
  87281. */
  87282. constructor(actionManager: ActionManager, target: any,
  87283. /** path to specify the property of the target the conditional operator uses */
  87284. propertyPath: string,
  87285. /** the value compared by the conditional operator against the current value of the property */
  87286. value: any,
  87287. /** the conditional operator, default ValueCondition.IsEqual */
  87288. operator?: number);
  87289. /**
  87290. * Compares the given value with the property value for the specified conditional operator
  87291. * @returns the result of the comparison
  87292. */
  87293. isValid(): boolean;
  87294. /**
  87295. * Serialize the ValueCondition into a JSON compatible object
  87296. * @returns serialization object
  87297. */
  87298. serialize(): any;
  87299. /**
  87300. * Gets the name of the conditional operator for the ValueCondition
  87301. * @param operator the conditional operator
  87302. * @returns the name
  87303. */
  87304. static GetOperatorName(operator: number): string;
  87305. }
  87306. /**
  87307. * Defines a predicate condition as an extension of Condition
  87308. */
  87309. export class PredicateCondition extends Condition {
  87310. /** defines the predicate function used to validate the condition */
  87311. predicate: () => boolean;
  87312. /**
  87313. * Internal only - manager for action
  87314. * @hidden
  87315. */
  87316. _actionManager: ActionManager;
  87317. /**
  87318. * Creates a new PredicateCondition
  87319. * @param actionManager manager for the action the condition applies to
  87320. * @param predicate defines the predicate function used to validate the condition
  87321. */
  87322. constructor(actionManager: ActionManager,
  87323. /** defines the predicate function used to validate the condition */
  87324. predicate: () => boolean);
  87325. /**
  87326. * @returns the validity of the predicate condition
  87327. */
  87328. isValid(): boolean;
  87329. }
  87330. /**
  87331. * Defines a state condition as an extension of Condition
  87332. */
  87333. export class StateCondition extends Condition {
  87334. /** Value to compare with target state */
  87335. value: string;
  87336. /**
  87337. * Internal only - manager for action
  87338. * @hidden
  87339. */
  87340. _actionManager: ActionManager;
  87341. /**
  87342. * Internal only
  87343. * @hidden
  87344. */
  87345. private _target;
  87346. /**
  87347. * Creates a new StateCondition
  87348. * @param actionManager manager for the action the condition applies to
  87349. * @param target of the condition
  87350. * @param value to compare with target state
  87351. */
  87352. constructor(actionManager: ActionManager, target: any,
  87353. /** Value to compare with target state */
  87354. value: string);
  87355. /**
  87356. * Gets a boolean indicating if the current condition is met
  87357. * @returns the validity of the state
  87358. */
  87359. isValid(): boolean;
  87360. /**
  87361. * Serialize the StateCondition into a JSON compatible object
  87362. * @returns serialization object
  87363. */
  87364. serialize(): any;
  87365. }
  87366. }
  87367. declare module BABYLON {
  87368. /**
  87369. * This defines an action responsible to toggle a boolean once triggered.
  87370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87371. */
  87372. export class SwitchBooleanAction extends Action {
  87373. /**
  87374. * The path to the boolean property in the target object
  87375. */
  87376. propertyPath: string;
  87377. private _target;
  87378. private _effectiveTarget;
  87379. private _property;
  87380. /**
  87381. * Instantiate the action
  87382. * @param triggerOptions defines the trigger options
  87383. * @param target defines the object containing the boolean
  87384. * @param propertyPath defines the path to the boolean property in the target object
  87385. * @param condition defines the trigger related conditions
  87386. */
  87387. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87388. /** @hidden */
  87389. _prepare(): void;
  87390. /**
  87391. * Execute the action toggle the boolean value.
  87392. */
  87393. execute(): void;
  87394. /**
  87395. * Serializes the actions and its related information.
  87396. * @param parent defines the object to serialize in
  87397. * @returns the serialized object
  87398. */
  87399. serialize(parent: any): any;
  87400. }
  87401. /**
  87402. * This defines an action responsible to set a the state field of the target
  87403. * to a desired value once triggered.
  87404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87405. */
  87406. export class SetStateAction extends Action {
  87407. /**
  87408. * The value to store in the state field.
  87409. */
  87410. value: string;
  87411. private _target;
  87412. /**
  87413. * Instantiate the action
  87414. * @param triggerOptions defines the trigger options
  87415. * @param target defines the object containing the state property
  87416. * @param value defines the value to store in the state field
  87417. * @param condition defines the trigger related conditions
  87418. */
  87419. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87420. /**
  87421. * Execute the action and store the value on the target state property.
  87422. */
  87423. execute(): void;
  87424. /**
  87425. * Serializes the actions and its related information.
  87426. * @param parent defines the object to serialize in
  87427. * @returns the serialized object
  87428. */
  87429. serialize(parent: any): any;
  87430. }
  87431. /**
  87432. * This defines an action responsible to set a property of the target
  87433. * to a desired value once triggered.
  87434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87435. */
  87436. export class SetValueAction extends Action {
  87437. /**
  87438. * The path of the property to set in the target.
  87439. */
  87440. propertyPath: string;
  87441. /**
  87442. * The value to set in the property
  87443. */
  87444. value: any;
  87445. private _target;
  87446. private _effectiveTarget;
  87447. private _property;
  87448. /**
  87449. * Instantiate the action
  87450. * @param triggerOptions defines the trigger options
  87451. * @param target defines the object containing the property
  87452. * @param propertyPath defines the path of the property to set in the target
  87453. * @param value defines the value to set in the property
  87454. * @param condition defines the trigger related conditions
  87455. */
  87456. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87457. /** @hidden */
  87458. _prepare(): void;
  87459. /**
  87460. * Execute the action and set the targetted property to the desired value.
  87461. */
  87462. execute(): void;
  87463. /**
  87464. * Serializes the actions and its related information.
  87465. * @param parent defines the object to serialize in
  87466. * @returns the serialized object
  87467. */
  87468. serialize(parent: any): any;
  87469. }
  87470. /**
  87471. * This defines an action responsible to increment the target value
  87472. * to a desired value once triggered.
  87473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87474. */
  87475. export class IncrementValueAction extends Action {
  87476. /**
  87477. * The path of the property to increment in the target.
  87478. */
  87479. propertyPath: string;
  87480. /**
  87481. * The value we should increment the property by.
  87482. */
  87483. value: any;
  87484. private _target;
  87485. private _effectiveTarget;
  87486. private _property;
  87487. /**
  87488. * Instantiate the action
  87489. * @param triggerOptions defines the trigger options
  87490. * @param target defines the object containing the property
  87491. * @param propertyPath defines the path of the property to increment in the target
  87492. * @param value defines the value value we should increment the property by
  87493. * @param condition defines the trigger related conditions
  87494. */
  87495. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87496. /** @hidden */
  87497. _prepare(): void;
  87498. /**
  87499. * Execute the action and increment the target of the value amount.
  87500. */
  87501. execute(): void;
  87502. /**
  87503. * Serializes the actions and its related information.
  87504. * @param parent defines the object to serialize in
  87505. * @returns the serialized object
  87506. */
  87507. serialize(parent: any): any;
  87508. }
  87509. /**
  87510. * This defines an action responsible to start an animation once triggered.
  87511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87512. */
  87513. export class PlayAnimationAction extends Action {
  87514. /**
  87515. * Where the animation should start (animation frame)
  87516. */
  87517. from: number;
  87518. /**
  87519. * Where the animation should stop (animation frame)
  87520. */
  87521. to: number;
  87522. /**
  87523. * Define if the animation should loop or stop after the first play.
  87524. */
  87525. loop?: boolean;
  87526. private _target;
  87527. /**
  87528. * Instantiate the action
  87529. * @param triggerOptions defines the trigger options
  87530. * @param target defines the target animation or animation name
  87531. * @param from defines from where the animation should start (animation frame)
  87532. * @param end defines where the animation should stop (animation frame)
  87533. * @param loop defines if the animation should loop or stop after the first play
  87534. * @param condition defines the trigger related conditions
  87535. */
  87536. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87537. /** @hidden */
  87538. _prepare(): void;
  87539. /**
  87540. * Execute the action and play the animation.
  87541. */
  87542. execute(): void;
  87543. /**
  87544. * Serializes the actions and its related information.
  87545. * @param parent defines the object to serialize in
  87546. * @returns the serialized object
  87547. */
  87548. serialize(parent: any): any;
  87549. }
  87550. /**
  87551. * This defines an action responsible to stop an animation once triggered.
  87552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87553. */
  87554. export class StopAnimationAction extends Action {
  87555. private _target;
  87556. /**
  87557. * Instantiate the action
  87558. * @param triggerOptions defines the trigger options
  87559. * @param target defines the target animation or animation name
  87560. * @param condition defines the trigger related conditions
  87561. */
  87562. constructor(triggerOptions: any, target: any, condition?: Condition);
  87563. /** @hidden */
  87564. _prepare(): void;
  87565. /**
  87566. * Execute the action and stop the animation.
  87567. */
  87568. execute(): void;
  87569. /**
  87570. * Serializes the actions and its related information.
  87571. * @param parent defines the object to serialize in
  87572. * @returns the serialized object
  87573. */
  87574. serialize(parent: any): any;
  87575. }
  87576. /**
  87577. * This defines an action responsible that does nothing once triggered.
  87578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87579. */
  87580. export class DoNothingAction extends Action {
  87581. /**
  87582. * Instantiate the action
  87583. * @param triggerOptions defines the trigger options
  87584. * @param condition defines the trigger related conditions
  87585. */
  87586. constructor(triggerOptions?: any, condition?: Condition);
  87587. /**
  87588. * Execute the action and do nothing.
  87589. */
  87590. execute(): void;
  87591. /**
  87592. * Serializes the actions and its related information.
  87593. * @param parent defines the object to serialize in
  87594. * @returns the serialized object
  87595. */
  87596. serialize(parent: any): any;
  87597. }
  87598. /**
  87599. * This defines an action responsible to trigger several actions once triggered.
  87600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87601. */
  87602. export class CombineAction extends Action {
  87603. /**
  87604. * The list of aggregated animations to run.
  87605. */
  87606. children: Action[];
  87607. /**
  87608. * Instantiate the action
  87609. * @param triggerOptions defines the trigger options
  87610. * @param children defines the list of aggregated animations to run
  87611. * @param condition defines the trigger related conditions
  87612. */
  87613. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87614. /** @hidden */
  87615. _prepare(): void;
  87616. /**
  87617. * Execute the action and executes all the aggregated actions.
  87618. */
  87619. execute(evt: ActionEvent): void;
  87620. /**
  87621. * Serializes the actions and its related information.
  87622. * @param parent defines the object to serialize in
  87623. * @returns the serialized object
  87624. */
  87625. serialize(parent: any): any;
  87626. }
  87627. /**
  87628. * This defines an action responsible to run code (external event) once triggered.
  87629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87630. */
  87631. export class ExecuteCodeAction extends Action {
  87632. /**
  87633. * The callback function to run.
  87634. */
  87635. func: (evt: ActionEvent) => void;
  87636. /**
  87637. * Instantiate the action
  87638. * @param triggerOptions defines the trigger options
  87639. * @param func defines the callback function to run
  87640. * @param condition defines the trigger related conditions
  87641. */
  87642. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87643. /**
  87644. * Execute the action and run the attached code.
  87645. */
  87646. execute(evt: ActionEvent): void;
  87647. }
  87648. /**
  87649. * This defines an action responsible to set the parent property of the target once triggered.
  87650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87651. */
  87652. export class SetParentAction extends Action {
  87653. private _parent;
  87654. private _target;
  87655. /**
  87656. * Instantiate the action
  87657. * @param triggerOptions defines the trigger options
  87658. * @param target defines the target containing the parent property
  87659. * @param parent defines from where the animation should start (animation frame)
  87660. * @param condition defines the trigger related conditions
  87661. */
  87662. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87663. /** @hidden */
  87664. _prepare(): void;
  87665. /**
  87666. * Execute the action and set the parent property.
  87667. */
  87668. execute(): void;
  87669. /**
  87670. * Serializes the actions and its related information.
  87671. * @param parent defines the object to serialize in
  87672. * @returns the serialized object
  87673. */
  87674. serialize(parent: any): any;
  87675. }
  87676. }
  87677. declare module BABYLON {
  87678. /**
  87679. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87680. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87682. */
  87683. export class ActionManager extends AbstractActionManager {
  87684. /**
  87685. * Nothing
  87686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87687. */
  87688. static readonly NothingTrigger: number;
  87689. /**
  87690. * On pick
  87691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87692. */
  87693. static readonly OnPickTrigger: number;
  87694. /**
  87695. * On left pick
  87696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87697. */
  87698. static readonly OnLeftPickTrigger: number;
  87699. /**
  87700. * On right pick
  87701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87702. */
  87703. static readonly OnRightPickTrigger: number;
  87704. /**
  87705. * On center pick
  87706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87707. */
  87708. static readonly OnCenterPickTrigger: number;
  87709. /**
  87710. * On pick down
  87711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87712. */
  87713. static readonly OnPickDownTrigger: number;
  87714. /**
  87715. * On double pick
  87716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87717. */
  87718. static readonly OnDoublePickTrigger: number;
  87719. /**
  87720. * On pick up
  87721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87722. */
  87723. static readonly OnPickUpTrigger: number;
  87724. /**
  87725. * On pick out.
  87726. * This trigger will only be raised if you also declared a OnPickDown
  87727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87728. */
  87729. static readonly OnPickOutTrigger: number;
  87730. /**
  87731. * On long press
  87732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87733. */
  87734. static readonly OnLongPressTrigger: number;
  87735. /**
  87736. * On pointer over
  87737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87738. */
  87739. static readonly OnPointerOverTrigger: number;
  87740. /**
  87741. * On pointer out
  87742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87743. */
  87744. static readonly OnPointerOutTrigger: number;
  87745. /**
  87746. * On every frame
  87747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87748. */
  87749. static readonly OnEveryFrameTrigger: number;
  87750. /**
  87751. * On intersection enter
  87752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87753. */
  87754. static readonly OnIntersectionEnterTrigger: number;
  87755. /**
  87756. * On intersection exit
  87757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87758. */
  87759. static readonly OnIntersectionExitTrigger: number;
  87760. /**
  87761. * On key down
  87762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87763. */
  87764. static readonly OnKeyDownTrigger: number;
  87765. /**
  87766. * On key up
  87767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87768. */
  87769. static readonly OnKeyUpTrigger: number;
  87770. private _scene;
  87771. /**
  87772. * Creates a new action manager
  87773. * @param scene defines the hosting scene
  87774. */
  87775. constructor(scene: Scene);
  87776. /**
  87777. * Releases all associated resources
  87778. */
  87779. dispose(): void;
  87780. /**
  87781. * Gets hosting scene
  87782. * @returns the hosting scene
  87783. */
  87784. getScene(): Scene;
  87785. /**
  87786. * Does this action manager handles actions of any of the given triggers
  87787. * @param triggers defines the triggers to be tested
  87788. * @return a boolean indicating whether one (or more) of the triggers is handled
  87789. */
  87790. hasSpecificTriggers(triggers: number[]): boolean;
  87791. /**
  87792. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87793. * speed.
  87794. * @param triggerA defines the trigger to be tested
  87795. * @param triggerB defines the trigger to be tested
  87796. * @return a boolean indicating whether one (or more) of the triggers is handled
  87797. */
  87798. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87799. /**
  87800. * Does this action manager handles actions of a given trigger
  87801. * @param trigger defines the trigger to be tested
  87802. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87803. * @return whether the trigger is handled
  87804. */
  87805. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87806. /**
  87807. * Does this action manager has pointer triggers
  87808. */
  87809. get hasPointerTriggers(): boolean;
  87810. /**
  87811. * Does this action manager has pick triggers
  87812. */
  87813. get hasPickTriggers(): boolean;
  87814. /**
  87815. * Registers an action to this action manager
  87816. * @param action defines the action to be registered
  87817. * @return the action amended (prepared) after registration
  87818. */
  87819. registerAction(action: IAction): Nullable<IAction>;
  87820. /**
  87821. * Unregisters an action to this action manager
  87822. * @param action defines the action to be unregistered
  87823. * @return a boolean indicating whether the action has been unregistered
  87824. */
  87825. unregisterAction(action: IAction): Boolean;
  87826. /**
  87827. * Process a specific trigger
  87828. * @param trigger defines the trigger to process
  87829. * @param evt defines the event details to be processed
  87830. */
  87831. processTrigger(trigger: number, evt?: IActionEvent): void;
  87832. /** @hidden */
  87833. _getEffectiveTarget(target: any, propertyPath: string): any;
  87834. /** @hidden */
  87835. _getProperty(propertyPath: string): string;
  87836. /**
  87837. * Serialize this manager to a JSON object
  87838. * @param name defines the property name to store this manager
  87839. * @returns a JSON representation of this manager
  87840. */
  87841. serialize(name: string): any;
  87842. /**
  87843. * Creates a new ActionManager from a JSON data
  87844. * @param parsedActions defines the JSON data to read from
  87845. * @param object defines the hosting mesh
  87846. * @param scene defines the hosting scene
  87847. */
  87848. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87849. /**
  87850. * Get a trigger name by index
  87851. * @param trigger defines the trigger index
  87852. * @returns a trigger name
  87853. */
  87854. static GetTriggerName(trigger: number): string;
  87855. }
  87856. }
  87857. declare module BABYLON {
  87858. /**
  87859. * Class used to represent a sprite
  87860. * @see http://doc.babylonjs.com/babylon101/sprites
  87861. */
  87862. export class Sprite implements IAnimatable {
  87863. /** defines the name */
  87864. name: string;
  87865. /** Gets or sets the current world position */
  87866. position: Vector3;
  87867. /** Gets or sets the main color */
  87868. color: Color4;
  87869. /** Gets or sets the width */
  87870. width: number;
  87871. /** Gets or sets the height */
  87872. height: number;
  87873. /** Gets or sets rotation angle */
  87874. angle: number;
  87875. /** Gets or sets the cell index in the sprite sheet */
  87876. cellIndex: number;
  87877. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87878. cellRef: string;
  87879. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87880. invertU: boolean;
  87881. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87882. invertV: boolean;
  87883. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87884. disposeWhenFinishedAnimating: boolean;
  87885. /** Gets the list of attached animations */
  87886. animations: Nullable<Array<Animation>>;
  87887. /** Gets or sets a boolean indicating if the sprite can be picked */
  87888. isPickable: boolean;
  87889. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87890. useAlphaForPicking: boolean;
  87891. /** @hidden */
  87892. _xOffset: number;
  87893. /** @hidden */
  87894. _yOffset: number;
  87895. /** @hidden */
  87896. _xSize: number;
  87897. /** @hidden */
  87898. _ySize: number;
  87899. /**
  87900. * Gets or sets the associated action manager
  87901. */
  87902. actionManager: Nullable<ActionManager>;
  87903. /**
  87904. * An event triggered when the control has been disposed
  87905. */
  87906. onDisposeObservable: Observable<Sprite>;
  87907. private _animationStarted;
  87908. private _loopAnimation;
  87909. private _fromIndex;
  87910. private _toIndex;
  87911. private _delay;
  87912. private _direction;
  87913. private _manager;
  87914. private _time;
  87915. private _onAnimationEnd;
  87916. /**
  87917. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87918. */
  87919. isVisible: boolean;
  87920. /**
  87921. * Gets or sets the sprite size
  87922. */
  87923. get size(): number;
  87924. set size(value: number);
  87925. /**
  87926. * Returns a boolean indicating if the animation is started
  87927. */
  87928. get animationStarted(): boolean;
  87929. /**
  87930. * Gets or sets the unique id of the sprite
  87931. */
  87932. uniqueId: number;
  87933. /**
  87934. * Gets the manager of this sprite
  87935. */
  87936. get manager(): ISpriteManager;
  87937. /**
  87938. * Creates a new Sprite
  87939. * @param name defines the name
  87940. * @param manager defines the manager
  87941. */
  87942. constructor(
  87943. /** defines the name */
  87944. name: string, manager: ISpriteManager);
  87945. /**
  87946. * Returns the string "Sprite"
  87947. * @returns "Sprite"
  87948. */
  87949. getClassName(): string;
  87950. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87951. get fromIndex(): number;
  87952. set fromIndex(value: number);
  87953. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87954. get toIndex(): number;
  87955. set toIndex(value: number);
  87956. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87957. get loopAnimation(): boolean;
  87958. set loopAnimation(value: boolean);
  87959. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87960. get delay(): number;
  87961. set delay(value: number);
  87962. /**
  87963. * Starts an animation
  87964. * @param from defines the initial key
  87965. * @param to defines the end key
  87966. * @param loop defines if the animation must loop
  87967. * @param delay defines the start delay (in ms)
  87968. * @param onAnimationEnd defines a callback to call when animation ends
  87969. */
  87970. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87971. /** Stops current animation (if any) */
  87972. stopAnimation(): void;
  87973. /** @hidden */
  87974. _animate(deltaTime: number): void;
  87975. /** Release associated resources */
  87976. dispose(): void;
  87977. /**
  87978. * Serializes the sprite to a JSON object
  87979. * @returns the JSON object
  87980. */
  87981. serialize(): any;
  87982. /**
  87983. * Parses a JSON object to create a new sprite
  87984. * @param parsedSprite The JSON object to parse
  87985. * @param manager defines the hosting manager
  87986. * @returns the new sprite
  87987. */
  87988. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87989. }
  87990. }
  87991. declare module BABYLON {
  87992. /**
  87993. * Information about the result of picking within a scene
  87994. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87995. */
  87996. export class PickingInfo {
  87997. /** @hidden */
  87998. _pickingUnavailable: boolean;
  87999. /**
  88000. * If the pick collided with an object
  88001. */
  88002. hit: boolean;
  88003. /**
  88004. * Distance away where the pick collided
  88005. */
  88006. distance: number;
  88007. /**
  88008. * The location of pick collision
  88009. */
  88010. pickedPoint: Nullable<Vector3>;
  88011. /**
  88012. * The mesh corresponding the the pick collision
  88013. */
  88014. pickedMesh: Nullable<AbstractMesh>;
  88015. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88016. bu: number;
  88017. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88018. bv: number;
  88019. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88020. faceId: number;
  88021. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88022. subMeshFaceId: number;
  88023. /** Id of the the submesh that was picked */
  88024. subMeshId: number;
  88025. /** If a sprite was picked, this will be the sprite the pick collided with */
  88026. pickedSprite: Nullable<Sprite>;
  88027. /**
  88028. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88029. */
  88030. originMesh: Nullable<AbstractMesh>;
  88031. /**
  88032. * The ray that was used to perform the picking.
  88033. */
  88034. ray: Nullable<Ray>;
  88035. /**
  88036. * Gets the normal correspodning to the face the pick collided with
  88037. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88038. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88039. * @returns The normal correspodning to the face the pick collided with
  88040. */
  88041. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88042. /**
  88043. * Gets the texture coordinates of where the pick occured
  88044. * @returns the vector containing the coordnates of the texture
  88045. */
  88046. getTextureCoordinates(): Nullable<Vector2>;
  88047. }
  88048. }
  88049. declare module BABYLON {
  88050. /**
  88051. * Class representing a ray with position and direction
  88052. */
  88053. export class Ray {
  88054. /** origin point */
  88055. origin: Vector3;
  88056. /** direction */
  88057. direction: Vector3;
  88058. /** length of the ray */
  88059. length: number;
  88060. private static readonly TmpVector3;
  88061. private _tmpRay;
  88062. /**
  88063. * Creates a new ray
  88064. * @param origin origin point
  88065. * @param direction direction
  88066. * @param length length of the ray
  88067. */
  88068. constructor(
  88069. /** origin point */
  88070. origin: Vector3,
  88071. /** direction */
  88072. direction: Vector3,
  88073. /** length of the ray */
  88074. length?: number);
  88075. /**
  88076. * Checks if the ray intersects a box
  88077. * This does not account for the ray lenght by design to improve perfs.
  88078. * @param minimum bound of the box
  88079. * @param maximum bound of the box
  88080. * @param intersectionTreshold extra extend to be added to the box in all direction
  88081. * @returns if the box was hit
  88082. */
  88083. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88084. /**
  88085. * Checks if the ray intersects a box
  88086. * This does not account for the ray lenght by design to improve perfs.
  88087. * @param box the bounding box to check
  88088. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88089. * @returns if the box was hit
  88090. */
  88091. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88092. /**
  88093. * If the ray hits a sphere
  88094. * @param sphere the bounding sphere to check
  88095. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88096. * @returns true if it hits the sphere
  88097. */
  88098. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88099. /**
  88100. * If the ray hits a triange
  88101. * @param vertex0 triangle vertex
  88102. * @param vertex1 triangle vertex
  88103. * @param vertex2 triangle vertex
  88104. * @returns intersection information if hit
  88105. */
  88106. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88107. /**
  88108. * Checks if ray intersects a plane
  88109. * @param plane the plane to check
  88110. * @returns the distance away it was hit
  88111. */
  88112. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88113. /**
  88114. * Calculate the intercept of a ray on a given axis
  88115. * @param axis to check 'x' | 'y' | 'z'
  88116. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88117. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88118. */
  88119. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88120. /**
  88121. * Checks if ray intersects a mesh
  88122. * @param mesh the mesh to check
  88123. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88124. * @returns picking info of the intersecton
  88125. */
  88126. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88127. /**
  88128. * Checks if ray intersects a mesh
  88129. * @param meshes the meshes to check
  88130. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88131. * @param results array to store result in
  88132. * @returns Array of picking infos
  88133. */
  88134. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88135. private _comparePickingInfo;
  88136. private static smallnum;
  88137. private static rayl;
  88138. /**
  88139. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88140. * @param sega the first point of the segment to test the intersection against
  88141. * @param segb the second point of the segment to test the intersection against
  88142. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88143. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88144. */
  88145. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88146. /**
  88147. * Update the ray from viewport position
  88148. * @param x position
  88149. * @param y y position
  88150. * @param viewportWidth viewport width
  88151. * @param viewportHeight viewport height
  88152. * @param world world matrix
  88153. * @param view view matrix
  88154. * @param projection projection matrix
  88155. * @returns this ray updated
  88156. */
  88157. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88158. /**
  88159. * Creates a ray with origin and direction of 0,0,0
  88160. * @returns the new ray
  88161. */
  88162. static Zero(): Ray;
  88163. /**
  88164. * Creates a new ray from screen space and viewport
  88165. * @param x position
  88166. * @param y y position
  88167. * @param viewportWidth viewport width
  88168. * @param viewportHeight viewport height
  88169. * @param world world matrix
  88170. * @param view view matrix
  88171. * @param projection projection matrix
  88172. * @returns new ray
  88173. */
  88174. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88175. /**
  88176. * 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
  88177. * transformed to the given world matrix.
  88178. * @param origin The origin point
  88179. * @param end The end point
  88180. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88181. * @returns the new ray
  88182. */
  88183. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  88184. /**
  88185. * Transforms a ray by a matrix
  88186. * @param ray ray to transform
  88187. * @param matrix matrix to apply
  88188. * @returns the resulting new ray
  88189. */
  88190. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88191. /**
  88192. * Transforms a ray by a matrix
  88193. * @param ray ray to transform
  88194. * @param matrix matrix to apply
  88195. * @param result ray to store result in
  88196. */
  88197. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88198. /**
  88199. * Unproject a ray from screen space to object space
  88200. * @param sourceX defines the screen space x coordinate to use
  88201. * @param sourceY defines the screen space y coordinate to use
  88202. * @param viewportWidth defines the current width of the viewport
  88203. * @param viewportHeight defines the current height of the viewport
  88204. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88205. * @param view defines the view matrix to use
  88206. * @param projection defines the projection matrix to use
  88207. */
  88208. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88209. }
  88210. /**
  88211. * Type used to define predicate used to select faces when a mesh intersection is detected
  88212. */
  88213. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88214. interface Scene {
  88215. /** @hidden */
  88216. _tempPickingRay: Nullable<Ray>;
  88217. /** @hidden */
  88218. _cachedRayForTransform: Ray;
  88219. /** @hidden */
  88220. _pickWithRayInverseMatrix: Matrix;
  88221. /** @hidden */
  88222. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88223. /** @hidden */
  88224. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88225. }
  88226. }
  88227. declare module BABYLON {
  88228. /**
  88229. * Groups all the scene component constants in one place to ease maintenance.
  88230. * @hidden
  88231. */
  88232. export class SceneComponentConstants {
  88233. static readonly NAME_EFFECTLAYER: string;
  88234. static readonly NAME_LAYER: string;
  88235. static readonly NAME_LENSFLARESYSTEM: string;
  88236. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88237. static readonly NAME_PARTICLESYSTEM: string;
  88238. static readonly NAME_GAMEPAD: string;
  88239. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88240. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88241. static readonly NAME_DEPTHRENDERER: string;
  88242. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88243. static readonly NAME_SPRITE: string;
  88244. static readonly NAME_OUTLINERENDERER: string;
  88245. static readonly NAME_PROCEDURALTEXTURE: string;
  88246. static readonly NAME_SHADOWGENERATOR: string;
  88247. static readonly NAME_OCTREE: string;
  88248. static readonly NAME_PHYSICSENGINE: string;
  88249. static readonly NAME_AUDIO: string;
  88250. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88251. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88252. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88253. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88254. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88255. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88256. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88257. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88258. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88259. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88260. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88261. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88262. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88263. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88264. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88265. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88267. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88269. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88270. static readonly STEP_AFTERRENDER_AUDIO: number;
  88271. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88272. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88273. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88274. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88275. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88276. static readonly STEP_POINTERMOVE_SPRITE: number;
  88277. static readonly STEP_POINTERDOWN_SPRITE: number;
  88278. static readonly STEP_POINTERUP_SPRITE: number;
  88279. }
  88280. /**
  88281. * This represents a scene component.
  88282. *
  88283. * This is used to decouple the dependency the scene is having on the different workloads like
  88284. * layers, post processes...
  88285. */
  88286. export interface ISceneComponent {
  88287. /**
  88288. * The name of the component. Each component must have a unique name.
  88289. */
  88290. name: string;
  88291. /**
  88292. * The scene the component belongs to.
  88293. */
  88294. scene: Scene;
  88295. /**
  88296. * Register the component to one instance of a scene.
  88297. */
  88298. register(): void;
  88299. /**
  88300. * Rebuilds the elements related to this component in case of
  88301. * context lost for instance.
  88302. */
  88303. rebuild(): void;
  88304. /**
  88305. * Disposes the component and the associated ressources.
  88306. */
  88307. dispose(): void;
  88308. }
  88309. /**
  88310. * This represents a SERIALIZABLE scene component.
  88311. *
  88312. * This extends Scene Component to add Serialization methods on top.
  88313. */
  88314. export interface ISceneSerializableComponent extends ISceneComponent {
  88315. /**
  88316. * Adds all the elements from the container to the scene
  88317. * @param container the container holding the elements
  88318. */
  88319. addFromContainer(container: AbstractScene): void;
  88320. /**
  88321. * Removes all the elements in the container from the scene
  88322. * @param container contains the elements to remove
  88323. * @param dispose if the removed element should be disposed (default: false)
  88324. */
  88325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88326. /**
  88327. * Serializes the component data to the specified json object
  88328. * @param serializationObject The object to serialize to
  88329. */
  88330. serialize(serializationObject: any): void;
  88331. }
  88332. /**
  88333. * Strong typing of a Mesh related stage step action
  88334. */
  88335. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88336. /**
  88337. * Strong typing of a Evaluate Sub Mesh related stage step action
  88338. */
  88339. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88340. /**
  88341. * Strong typing of a Active Mesh related stage step action
  88342. */
  88343. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88344. /**
  88345. * Strong typing of a Camera related stage step action
  88346. */
  88347. export type CameraStageAction = (camera: Camera) => void;
  88348. /**
  88349. * Strong typing of a Camera Frame buffer related stage step action
  88350. */
  88351. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88352. /**
  88353. * Strong typing of a Render Target related stage step action
  88354. */
  88355. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88356. /**
  88357. * Strong typing of a RenderingGroup related stage step action
  88358. */
  88359. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88360. /**
  88361. * Strong typing of a Mesh Render related stage step action
  88362. */
  88363. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88364. /**
  88365. * Strong typing of a simple stage step action
  88366. */
  88367. export type SimpleStageAction = () => void;
  88368. /**
  88369. * Strong typing of a render target action.
  88370. */
  88371. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88372. /**
  88373. * Strong typing of a pointer move action.
  88374. */
  88375. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88376. /**
  88377. * Strong typing of a pointer up/down action.
  88378. */
  88379. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88380. /**
  88381. * Representation of a stage in the scene (Basically a list of ordered steps)
  88382. * @hidden
  88383. */
  88384. export class Stage<T extends Function> extends Array<{
  88385. index: number;
  88386. component: ISceneComponent;
  88387. action: T;
  88388. }> {
  88389. /**
  88390. * Hide ctor from the rest of the world.
  88391. * @param items The items to add.
  88392. */
  88393. private constructor();
  88394. /**
  88395. * Creates a new Stage.
  88396. * @returns A new instance of a Stage
  88397. */
  88398. static Create<T extends Function>(): Stage<T>;
  88399. /**
  88400. * Registers a step in an ordered way in the targeted stage.
  88401. * @param index Defines the position to register the step in
  88402. * @param component Defines the component attached to the step
  88403. * @param action Defines the action to launch during the step
  88404. */
  88405. registerStep(index: number, component: ISceneComponent, action: T): void;
  88406. /**
  88407. * Clears all the steps from the stage.
  88408. */
  88409. clear(): void;
  88410. }
  88411. }
  88412. declare module BABYLON {
  88413. interface Scene {
  88414. /** @hidden */
  88415. _pointerOverSprite: Nullable<Sprite>;
  88416. /** @hidden */
  88417. _pickedDownSprite: Nullable<Sprite>;
  88418. /** @hidden */
  88419. _tempSpritePickingRay: Nullable<Ray>;
  88420. /**
  88421. * All of the sprite managers added to this scene
  88422. * @see http://doc.babylonjs.com/babylon101/sprites
  88423. */
  88424. spriteManagers: Array<ISpriteManager>;
  88425. /**
  88426. * An event triggered when sprites rendering is about to start
  88427. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88428. */
  88429. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88430. /**
  88431. * An event triggered when sprites rendering is done
  88432. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88433. */
  88434. onAfterSpritesRenderingObservable: Observable<Scene>;
  88435. /** @hidden */
  88436. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88437. /** Launch a ray to try to pick a sprite in the scene
  88438. * @param x position on screen
  88439. * @param y position on screen
  88440. * @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
  88441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88442. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88443. * @returns a PickingInfo
  88444. */
  88445. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88446. /** Use the given ray to pick a sprite in the scene
  88447. * @param ray The ray (in world space) to use to pick meshes
  88448. * @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
  88449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88450. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88451. * @returns a PickingInfo
  88452. */
  88453. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88454. /** @hidden */
  88455. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88456. /** Launch a ray to try to pick sprites in the scene
  88457. * @param x position on screen
  88458. * @param y position on screen
  88459. * @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
  88460. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88461. * @returns a PickingInfo array
  88462. */
  88463. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88464. /** Use the given ray to pick sprites in the scene
  88465. * @param ray The ray (in world space) to use to pick meshes
  88466. * @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
  88467. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88468. * @returns a PickingInfo array
  88469. */
  88470. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88471. /**
  88472. * Force the sprite under the pointer
  88473. * @param sprite defines the sprite to use
  88474. */
  88475. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88476. /**
  88477. * Gets the sprite under the pointer
  88478. * @returns a Sprite or null if no sprite is under the pointer
  88479. */
  88480. getPointerOverSprite(): Nullable<Sprite>;
  88481. }
  88482. /**
  88483. * Defines the sprite scene component responsible to manage sprites
  88484. * in a given scene.
  88485. */
  88486. export class SpriteSceneComponent implements ISceneComponent {
  88487. /**
  88488. * The component name helpfull to identify the component in the list of scene components.
  88489. */
  88490. readonly name: string;
  88491. /**
  88492. * The scene the component belongs to.
  88493. */
  88494. scene: Scene;
  88495. /** @hidden */
  88496. private _spritePredicate;
  88497. /**
  88498. * Creates a new instance of the component for the given scene
  88499. * @param scene Defines the scene to register the component in
  88500. */
  88501. constructor(scene: Scene);
  88502. /**
  88503. * Registers the component in a given scene
  88504. */
  88505. register(): void;
  88506. /**
  88507. * Rebuilds the elements related to this component in case of
  88508. * context lost for instance.
  88509. */
  88510. rebuild(): void;
  88511. /**
  88512. * Disposes the component and the associated ressources.
  88513. */
  88514. dispose(): void;
  88515. private _pickSpriteButKeepRay;
  88516. private _pointerMove;
  88517. private _pointerDown;
  88518. private _pointerUp;
  88519. }
  88520. }
  88521. declare module BABYLON {
  88522. /** @hidden */
  88523. export var fogFragmentDeclaration: {
  88524. name: string;
  88525. shader: string;
  88526. };
  88527. }
  88528. declare module BABYLON {
  88529. /** @hidden */
  88530. export var fogFragment: {
  88531. name: string;
  88532. shader: string;
  88533. };
  88534. }
  88535. declare module BABYLON {
  88536. /** @hidden */
  88537. export var spritesPixelShader: {
  88538. name: string;
  88539. shader: string;
  88540. };
  88541. }
  88542. declare module BABYLON {
  88543. /** @hidden */
  88544. export var fogVertexDeclaration: {
  88545. name: string;
  88546. shader: string;
  88547. };
  88548. }
  88549. declare module BABYLON {
  88550. /** @hidden */
  88551. export var spritesVertexShader: {
  88552. name: string;
  88553. shader: string;
  88554. };
  88555. }
  88556. declare module BABYLON {
  88557. /**
  88558. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88559. */
  88560. export interface ISpriteManager extends IDisposable {
  88561. /**
  88562. * Gets manager's name
  88563. */
  88564. name: string;
  88565. /**
  88566. * Restricts the camera to viewing objects with the same layerMask.
  88567. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88568. */
  88569. layerMask: number;
  88570. /**
  88571. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88572. */
  88573. isPickable: boolean;
  88574. /**
  88575. * Gets the hosting scene
  88576. */
  88577. scene: Scene;
  88578. /**
  88579. * Specifies the rendering group id for this mesh (0 by default)
  88580. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88581. */
  88582. renderingGroupId: number;
  88583. /**
  88584. * Defines the list of sprites managed by the manager.
  88585. */
  88586. sprites: Array<Sprite>;
  88587. /**
  88588. * Gets or sets the spritesheet texture
  88589. */
  88590. texture: Texture;
  88591. /** Defines the default width of a cell in the spritesheet */
  88592. cellWidth: number;
  88593. /** Defines the default height of a cell in the spritesheet */
  88594. cellHeight: number;
  88595. /**
  88596. * Tests the intersection of a sprite with a specific ray.
  88597. * @param ray The ray we are sending to test the collision
  88598. * @param camera The camera space we are sending rays in
  88599. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88600. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88601. * @returns picking info or null.
  88602. */
  88603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88604. /**
  88605. * Intersects the sprites with a ray
  88606. * @param ray defines the ray to intersect with
  88607. * @param camera defines the current active camera
  88608. * @param predicate defines a predicate used to select candidate sprites
  88609. * @returns null if no hit or a PickingInfo array
  88610. */
  88611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88612. /**
  88613. * Renders the list of sprites on screen.
  88614. */
  88615. render(): void;
  88616. }
  88617. /**
  88618. * Class used to manage multiple sprites on the same spritesheet
  88619. * @see http://doc.babylonjs.com/babylon101/sprites
  88620. */
  88621. export class SpriteManager implements ISpriteManager {
  88622. /** defines the manager's name */
  88623. name: string;
  88624. /** Define the Url to load snippets */
  88625. static SnippetUrl: string;
  88626. /** Snippet ID if the manager was created from the snippet server */
  88627. snippetId: string;
  88628. /** Gets the list of sprites */
  88629. sprites: Sprite[];
  88630. /** Gets or sets the rendering group id (0 by default) */
  88631. renderingGroupId: number;
  88632. /** Gets or sets camera layer mask */
  88633. layerMask: number;
  88634. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88635. fogEnabled: boolean;
  88636. /** Gets or sets a boolean indicating if the sprites are pickable */
  88637. isPickable: boolean;
  88638. /** Defines the default width of a cell in the spritesheet */
  88639. cellWidth: number;
  88640. /** Defines the default height of a cell in the spritesheet */
  88641. cellHeight: number;
  88642. /** Associative array from JSON sprite data file */
  88643. private _cellData;
  88644. /** Array of sprite names from JSON sprite data file */
  88645. private _spriteMap;
  88646. /** True when packed cell data from JSON file is ready*/
  88647. private _packedAndReady;
  88648. private _textureContent;
  88649. /**
  88650. * An event triggered when the manager is disposed.
  88651. */
  88652. onDisposeObservable: Observable<SpriteManager>;
  88653. private _onDisposeObserver;
  88654. /**
  88655. * Callback called when the manager is disposed
  88656. */
  88657. set onDispose(callback: () => void);
  88658. private _capacity;
  88659. private _fromPacked;
  88660. private _spriteTexture;
  88661. private _epsilon;
  88662. private _scene;
  88663. private _vertexData;
  88664. private _buffer;
  88665. private _vertexBuffers;
  88666. private _indexBuffer;
  88667. private _effectBase;
  88668. private _effectFog;
  88669. /**
  88670. * Gets or sets the unique id of the sprite
  88671. */
  88672. uniqueId: number;
  88673. /**
  88674. * Gets the array of sprites
  88675. */
  88676. get children(): Sprite[];
  88677. /**
  88678. * Gets the hosting scene
  88679. */
  88680. get scene(): Scene;
  88681. /**
  88682. * Gets the capacity of the manager
  88683. */
  88684. get capacity(): number;
  88685. /**
  88686. * Gets or sets the spritesheet texture
  88687. */
  88688. get texture(): Texture;
  88689. set texture(value: Texture);
  88690. private _blendMode;
  88691. /**
  88692. * Blend mode use to render the particle, it can be any of
  88693. * the static Constants.ALPHA_x properties provided in this class.
  88694. * Default value is Constants.ALPHA_COMBINE
  88695. */
  88696. get blendMode(): number;
  88697. set blendMode(blendMode: number);
  88698. /** Disables writing to the depth buffer when rendering the sprites.
  88699. * It can be handy to disable depth writing when using textures without alpha channel
  88700. * and setting some specific blend modes.
  88701. */
  88702. disableDepthWrite: boolean;
  88703. /**
  88704. * Creates a new sprite manager
  88705. * @param name defines the manager's name
  88706. * @param imgUrl defines the sprite sheet url
  88707. * @param capacity defines the maximum allowed number of sprites
  88708. * @param cellSize defines the size of a sprite cell
  88709. * @param scene defines the hosting scene
  88710. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88711. * @param samplingMode defines the smapling mode to use with spritesheet
  88712. * @param fromPacked set to false; do not alter
  88713. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88714. */
  88715. constructor(
  88716. /** defines the manager's name */
  88717. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88718. /**
  88719. * Returns the string "SpriteManager"
  88720. * @returns "SpriteManager"
  88721. */
  88722. getClassName(): string;
  88723. private _makePacked;
  88724. private _appendSpriteVertex;
  88725. private _checkTextureAlpha;
  88726. /**
  88727. * Intersects the sprites with a ray
  88728. * @param ray defines the ray to intersect with
  88729. * @param camera defines the current active camera
  88730. * @param predicate defines a predicate used to select candidate sprites
  88731. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88732. * @returns null if no hit or a PickingInfo
  88733. */
  88734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88735. /**
  88736. * Intersects the sprites with a ray
  88737. * @param ray defines the ray to intersect with
  88738. * @param camera defines the current active camera
  88739. * @param predicate defines a predicate used to select candidate sprites
  88740. * @returns null if no hit or a PickingInfo array
  88741. */
  88742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88743. /**
  88744. * Render all child sprites
  88745. */
  88746. render(): void;
  88747. /**
  88748. * Release associated resources
  88749. */
  88750. dispose(): void;
  88751. /**
  88752. * Serializes the sprite manager to a JSON object
  88753. * @param serializeTexture defines if the texture must be serialized as well
  88754. * @returns the JSON object
  88755. */
  88756. serialize(serializeTexture?: boolean): any;
  88757. /**
  88758. * Parses a JSON object to create a new sprite manager.
  88759. * @param parsedManager The JSON object to parse
  88760. * @param scene The scene to create the sprite managerin
  88761. * @param rootUrl The root url to use to load external dependencies like texture
  88762. * @returns the new sprite manager
  88763. */
  88764. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88765. /**
  88766. * Creates a sprite manager from a snippet saved in a remote file
  88767. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88768. * @param url defines the url to load from
  88769. * @param scene defines the hosting scene
  88770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88771. * @returns a promise that will resolve to the new sprite manager
  88772. */
  88773. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88774. /**
  88775. * Creates a sprite manager from a snippet saved by the sprite editor
  88776. * @param snippetId defines the snippet to load
  88777. * @param scene defines the hosting scene
  88778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88779. * @returns a promise that will resolve to the new sprite manager
  88780. */
  88781. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88782. }
  88783. }
  88784. declare module BABYLON {
  88785. /** Interface used by value gradients (color, factor, ...) */
  88786. export interface IValueGradient {
  88787. /**
  88788. * Gets or sets the gradient value (between 0 and 1)
  88789. */
  88790. gradient: number;
  88791. }
  88792. /** Class used to store color4 gradient */
  88793. export class ColorGradient implements IValueGradient {
  88794. /**
  88795. * Gets or sets the gradient value (between 0 and 1)
  88796. */
  88797. gradient: number;
  88798. /**
  88799. * Gets or sets first associated color
  88800. */
  88801. color1: Color4;
  88802. /**
  88803. * Gets or sets second associated color
  88804. */
  88805. color2?: Color4 | undefined;
  88806. /**
  88807. * Creates a new color4 gradient
  88808. * @param gradient gets or sets the gradient value (between 0 and 1)
  88809. * @param color1 gets or sets first associated color
  88810. * @param color2 gets or sets first second color
  88811. */
  88812. constructor(
  88813. /**
  88814. * Gets or sets the gradient value (between 0 and 1)
  88815. */
  88816. gradient: number,
  88817. /**
  88818. * Gets or sets first associated color
  88819. */
  88820. color1: Color4,
  88821. /**
  88822. * Gets or sets second associated color
  88823. */
  88824. color2?: Color4 | undefined);
  88825. /**
  88826. * Will get a color picked randomly between color1 and color2.
  88827. * If color2 is undefined then color1 will be used
  88828. * @param result defines the target Color4 to store the result in
  88829. */
  88830. getColorToRef(result: Color4): void;
  88831. }
  88832. /** Class used to store color 3 gradient */
  88833. export class Color3Gradient implements IValueGradient {
  88834. /**
  88835. * Gets or sets the gradient value (between 0 and 1)
  88836. */
  88837. gradient: number;
  88838. /**
  88839. * Gets or sets the associated color
  88840. */
  88841. color: Color3;
  88842. /**
  88843. * Creates a new color3 gradient
  88844. * @param gradient gets or sets the gradient value (between 0 and 1)
  88845. * @param color gets or sets associated color
  88846. */
  88847. constructor(
  88848. /**
  88849. * Gets or sets the gradient value (between 0 and 1)
  88850. */
  88851. gradient: number,
  88852. /**
  88853. * Gets or sets the associated color
  88854. */
  88855. color: Color3);
  88856. }
  88857. /** Class used to store factor gradient */
  88858. export class FactorGradient implements IValueGradient {
  88859. /**
  88860. * Gets or sets the gradient value (between 0 and 1)
  88861. */
  88862. gradient: number;
  88863. /**
  88864. * Gets or sets first associated factor
  88865. */
  88866. factor1: number;
  88867. /**
  88868. * Gets or sets second associated factor
  88869. */
  88870. factor2?: number | undefined;
  88871. /**
  88872. * Creates a new factor gradient
  88873. * @param gradient gets or sets the gradient value (between 0 and 1)
  88874. * @param factor1 gets or sets first associated factor
  88875. * @param factor2 gets or sets second associated factor
  88876. */
  88877. constructor(
  88878. /**
  88879. * Gets or sets the gradient value (between 0 and 1)
  88880. */
  88881. gradient: number,
  88882. /**
  88883. * Gets or sets first associated factor
  88884. */
  88885. factor1: number,
  88886. /**
  88887. * Gets or sets second associated factor
  88888. */
  88889. factor2?: number | undefined);
  88890. /**
  88891. * Will get a number picked randomly between factor1 and factor2.
  88892. * If factor2 is undefined then factor1 will be used
  88893. * @returns the picked number
  88894. */
  88895. getFactor(): number;
  88896. }
  88897. /**
  88898. * Helper used to simplify some generic gradient tasks
  88899. */
  88900. export class GradientHelper {
  88901. /**
  88902. * Gets the current gradient from an array of IValueGradient
  88903. * @param ratio defines the current ratio to get
  88904. * @param gradients defines the array of IValueGradient
  88905. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88906. */
  88907. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88908. }
  88909. }
  88910. declare module BABYLON {
  88911. interface ThinEngine {
  88912. /**
  88913. * Creates a dynamic texture
  88914. * @param width defines the width of the texture
  88915. * @param height defines the height of the texture
  88916. * @param generateMipMaps defines if the engine should generate the mip levels
  88917. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88918. * @returns the dynamic texture inside an InternalTexture
  88919. */
  88920. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88921. /**
  88922. * Update the content of a dynamic texture
  88923. * @param texture defines the texture to update
  88924. * @param canvas defines the canvas containing the source
  88925. * @param invertY defines if data must be stored with Y axis inverted
  88926. * @param premulAlpha defines if alpha is stored as premultiplied
  88927. * @param format defines the format of the data
  88928. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88929. */
  88930. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88931. }
  88932. }
  88933. declare module BABYLON {
  88934. /**
  88935. * Helper class used to generate a canvas to manipulate images
  88936. */
  88937. export class CanvasGenerator {
  88938. /**
  88939. * Create a new canvas (or offscreen canvas depending on the context)
  88940. * @param width defines the expected width
  88941. * @param height defines the expected height
  88942. * @return a new canvas or offscreen canvas
  88943. */
  88944. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88945. }
  88946. }
  88947. declare module BABYLON {
  88948. /**
  88949. * A class extending Texture allowing drawing on a texture
  88950. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88951. */
  88952. export class DynamicTexture extends Texture {
  88953. private _generateMipMaps;
  88954. private _canvas;
  88955. private _context;
  88956. /**
  88957. * Creates a DynamicTexture
  88958. * @param name defines the name of the texture
  88959. * @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
  88960. * @param scene defines the scene where you want the texture
  88961. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88962. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88963. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88964. */
  88965. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88966. /**
  88967. * Get the current class name of the texture useful for serialization or dynamic coding.
  88968. * @returns "DynamicTexture"
  88969. */
  88970. getClassName(): string;
  88971. /**
  88972. * Gets the current state of canRescale
  88973. */
  88974. get canRescale(): boolean;
  88975. private _recreate;
  88976. /**
  88977. * Scales the texture
  88978. * @param ratio the scale factor to apply to both width and height
  88979. */
  88980. scale(ratio: number): void;
  88981. /**
  88982. * Resizes the texture
  88983. * @param width the new width
  88984. * @param height the new height
  88985. */
  88986. scaleTo(width: number, height: number): void;
  88987. /**
  88988. * Gets the context of the canvas used by the texture
  88989. * @returns the canvas context of the dynamic texture
  88990. */
  88991. getContext(): CanvasRenderingContext2D;
  88992. /**
  88993. * Clears the texture
  88994. */
  88995. clear(): void;
  88996. /**
  88997. * Updates the texture
  88998. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88999. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  89000. */
  89001. update(invertY?: boolean, premulAlpha?: boolean): void;
  89002. /**
  89003. * Draws text onto the texture
  89004. * @param text defines the text to be drawn
  89005. * @param x defines the placement of the text from the left
  89006. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89007. * @param font defines the font to be used with font-style, font-size, font-name
  89008. * @param color defines the color used for the text
  89009. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89010. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89011. * @param update defines whether texture is immediately update (default is true)
  89012. */
  89013. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  89014. /**
  89015. * Clones the texture
  89016. * @returns the clone of the texture.
  89017. */
  89018. clone(): DynamicTexture;
  89019. /**
  89020. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89021. * @returns a serialized dynamic texture object
  89022. */
  89023. serialize(): any;
  89024. /** @hidden */
  89025. _rebuild(): void;
  89026. }
  89027. }
  89028. declare module BABYLON {
  89029. interface ThinEngine {
  89030. /**
  89031. * Creates a raw texture
  89032. * @param data defines the data to store in the texture
  89033. * @param width defines the width of the texture
  89034. * @param height defines the height of the texture
  89035. * @param format defines the format of the data
  89036. * @param generateMipMaps defines if the engine should generate the mip levels
  89037. * @param invertY defines if data must be stored with Y axis inverted
  89038. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89039. * @param compression defines the compression used (null by default)
  89040. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89041. * @returns the raw texture inside an InternalTexture
  89042. */
  89043. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89044. /**
  89045. * Update a raw texture
  89046. * @param texture defines the texture to update
  89047. * @param data defines the data to store in the texture
  89048. * @param format defines the format of the data
  89049. * @param invertY defines if data must be stored with Y axis inverted
  89050. */
  89051. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89052. /**
  89053. * Update a raw texture
  89054. * @param texture defines the texture to update
  89055. * @param data defines the data to store in the texture
  89056. * @param format defines the format of the data
  89057. * @param invertY defines if data must be stored with Y axis inverted
  89058. * @param compression defines the compression used (null by default)
  89059. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89060. */
  89061. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89062. /**
  89063. * Creates a new raw cube texture
  89064. * @param data defines the array of data to use to create each face
  89065. * @param size defines the size of the textures
  89066. * @param format defines the format of the data
  89067. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89068. * @param generateMipMaps defines if the engine should generate the mip levels
  89069. * @param invertY defines if data must be stored with Y axis inverted
  89070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89071. * @param compression defines the compression used (null by default)
  89072. * @returns the cube texture as an InternalTexture
  89073. */
  89074. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89075. /**
  89076. * Update a raw cube texture
  89077. * @param texture defines the texture to udpdate
  89078. * @param data defines the data to store
  89079. * @param format defines the data format
  89080. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89081. * @param invertY defines if data must be stored with Y axis inverted
  89082. */
  89083. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89084. /**
  89085. * Update a raw cube texture
  89086. * @param texture defines the texture to udpdate
  89087. * @param data defines the data to store
  89088. * @param format defines the data format
  89089. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89090. * @param invertY defines if data must be stored with Y axis inverted
  89091. * @param compression defines the compression used (null by default)
  89092. */
  89093. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89094. /**
  89095. * Update a raw cube texture
  89096. * @param texture defines the texture to udpdate
  89097. * @param data defines the data to store
  89098. * @param format defines the data format
  89099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89100. * @param invertY defines if data must be stored with Y axis inverted
  89101. * @param compression defines the compression used (null by default)
  89102. * @param level defines which level of the texture to update
  89103. */
  89104. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89105. /**
  89106. * Creates a new raw cube texture from a specified url
  89107. * @param url defines the url where the data is located
  89108. * @param scene defines the current scene
  89109. * @param size defines the size of the textures
  89110. * @param format defines the format of the data
  89111. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89112. * @param noMipmap defines if the engine should avoid generating the mip levels
  89113. * @param callback defines a callback used to extract texture data from loaded data
  89114. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89115. * @param onLoad defines a callback called when texture is loaded
  89116. * @param onError defines a callback called if there is an error
  89117. * @returns the cube texture as an InternalTexture
  89118. */
  89119. 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;
  89120. /**
  89121. * Creates a new raw cube texture from a specified url
  89122. * @param url defines the url where the data is located
  89123. * @param scene defines the current scene
  89124. * @param size defines the size of the textures
  89125. * @param format defines the format of the data
  89126. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89127. * @param noMipmap defines if the engine should avoid generating the mip levels
  89128. * @param callback defines a callback used to extract texture data from loaded data
  89129. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89130. * @param onLoad defines a callback called when texture is loaded
  89131. * @param onError defines a callback called if there is an error
  89132. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89133. * @param invertY defines if data must be stored with Y axis inverted
  89134. * @returns the cube texture as an InternalTexture
  89135. */
  89136. 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;
  89137. /**
  89138. * Creates a new raw 3D texture
  89139. * @param data defines the data used to create the texture
  89140. * @param width defines the width of the texture
  89141. * @param height defines the height of the texture
  89142. * @param depth defines the depth of the texture
  89143. * @param format defines the format of the texture
  89144. * @param generateMipMaps defines if the engine must generate mip levels
  89145. * @param invertY defines if data must be stored with Y axis inverted
  89146. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89147. * @param compression defines the compressed used (can be null)
  89148. * @param textureType defines the compressed used (can be null)
  89149. * @returns a new raw 3D texture (stored in an InternalTexture)
  89150. */
  89151. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89152. /**
  89153. * Update a raw 3D texture
  89154. * @param texture defines the texture to update
  89155. * @param data defines the data to store
  89156. * @param format defines the data format
  89157. * @param invertY defines if data must be stored with Y axis inverted
  89158. */
  89159. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89160. /**
  89161. * Update a raw 3D texture
  89162. * @param texture defines the texture to update
  89163. * @param data defines the data to store
  89164. * @param format defines the data format
  89165. * @param invertY defines if data must be stored with Y axis inverted
  89166. * @param compression defines the used compression (can be null)
  89167. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89168. */
  89169. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89170. /**
  89171. * Creates a new raw 2D array texture
  89172. * @param data defines the data used to create the texture
  89173. * @param width defines the width of the texture
  89174. * @param height defines the height of the texture
  89175. * @param depth defines the number of layers of the texture
  89176. * @param format defines the format of the texture
  89177. * @param generateMipMaps defines if the engine must generate mip levels
  89178. * @param invertY defines if data must be stored with Y axis inverted
  89179. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89180. * @param compression defines the compressed used (can be null)
  89181. * @param textureType defines the compressed used (can be null)
  89182. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89183. */
  89184. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89185. /**
  89186. * Update a raw 2D array texture
  89187. * @param texture defines the texture to update
  89188. * @param data defines the data to store
  89189. * @param format defines the data format
  89190. * @param invertY defines if data must be stored with Y axis inverted
  89191. */
  89192. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89193. /**
  89194. * Update a raw 2D array texture
  89195. * @param texture defines the texture to update
  89196. * @param data defines the data to store
  89197. * @param format defines the data format
  89198. * @param invertY defines if data must be stored with Y axis inverted
  89199. * @param compression defines the used compression (can be null)
  89200. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89201. */
  89202. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89203. }
  89204. }
  89205. declare module BABYLON {
  89206. /**
  89207. * Raw texture can help creating a texture directly from an array of data.
  89208. * This can be super useful if you either get the data from an uncompressed source or
  89209. * if you wish to create your texture pixel by pixel.
  89210. */
  89211. export class RawTexture extends Texture {
  89212. /**
  89213. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89214. */
  89215. format: number;
  89216. /**
  89217. * Instantiates a new RawTexture.
  89218. * Raw texture can help creating a texture directly from an array of data.
  89219. * This can be super useful if you either get the data from an uncompressed source or
  89220. * if you wish to create your texture pixel by pixel.
  89221. * @param data define the array of data to use to create the texture
  89222. * @param width define the width of the texture
  89223. * @param height define the height of the texture
  89224. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89225. * @param scene define the scene the texture belongs to
  89226. * @param generateMipMaps define whether mip maps should be generated or not
  89227. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89228. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89229. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89230. */
  89231. constructor(data: ArrayBufferView, width: number, height: number,
  89232. /**
  89233. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89234. */
  89235. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89236. /**
  89237. * Updates the texture underlying data.
  89238. * @param data Define the new data of the texture
  89239. */
  89240. update(data: ArrayBufferView): void;
  89241. /**
  89242. * Creates a luminance texture from some data.
  89243. * @param data Define the texture data
  89244. * @param width Define the width of the texture
  89245. * @param height Define the height of the texture
  89246. * @param scene Define the scene the texture belongs to
  89247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89250. * @returns the luminance texture
  89251. */
  89252. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89253. /**
  89254. * Creates a luminance alpha texture from some data.
  89255. * @param data Define the texture data
  89256. * @param width Define the width of the texture
  89257. * @param height Define the height of the texture
  89258. * @param scene Define the scene the texture belongs to
  89259. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89262. * @returns the luminance alpha texture
  89263. */
  89264. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89265. /**
  89266. * Creates an alpha texture from some data.
  89267. * @param data Define the texture data
  89268. * @param width Define the width of the texture
  89269. * @param height Define the height of the texture
  89270. * @param scene Define the scene the texture belongs to
  89271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89274. * @returns the alpha texture
  89275. */
  89276. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89277. /**
  89278. * Creates a RGB texture from some data.
  89279. * @param data Define the texture data
  89280. * @param width Define the width of the texture
  89281. * @param height Define the height of the texture
  89282. * @param scene Define the scene the texture belongs to
  89283. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89284. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89285. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89286. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89287. * @returns the RGB alpha texture
  89288. */
  89289. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89290. /**
  89291. * Creates a RGBA texture from some data.
  89292. * @param data Define the texture data
  89293. * @param width Define the width of the texture
  89294. * @param height Define the height of the texture
  89295. * @param scene Define the scene the texture belongs to
  89296. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89297. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89298. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89299. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89300. * @returns the RGBA texture
  89301. */
  89302. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89303. /**
  89304. * Creates a R texture from some data.
  89305. * @param data Define the texture data
  89306. * @param width Define the width of the texture
  89307. * @param height Define the height of the texture
  89308. * @param scene Define the scene the texture belongs to
  89309. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89312. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89313. * @returns the R texture
  89314. */
  89315. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89316. }
  89317. }
  89318. declare module BABYLON {
  89319. interface AbstractScene {
  89320. /**
  89321. * The list of procedural textures added to the scene
  89322. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89323. */
  89324. proceduralTextures: Array<ProceduralTexture>;
  89325. }
  89326. /**
  89327. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89328. * in a given scene.
  89329. */
  89330. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89331. /**
  89332. * The component name helpfull to identify the component in the list of scene components.
  89333. */
  89334. readonly name: string;
  89335. /**
  89336. * The scene the component belongs to.
  89337. */
  89338. scene: Scene;
  89339. /**
  89340. * Creates a new instance of the component for the given scene
  89341. * @param scene Defines the scene to register the component in
  89342. */
  89343. constructor(scene: Scene);
  89344. /**
  89345. * Registers the component in a given scene
  89346. */
  89347. register(): void;
  89348. /**
  89349. * Rebuilds the elements related to this component in case of
  89350. * context lost for instance.
  89351. */
  89352. rebuild(): void;
  89353. /**
  89354. * Disposes the component and the associated ressources.
  89355. */
  89356. dispose(): void;
  89357. private _beforeClear;
  89358. }
  89359. }
  89360. declare module BABYLON {
  89361. interface ThinEngine {
  89362. /**
  89363. * Creates a new render target cube texture
  89364. * @param size defines the size of the texture
  89365. * @param options defines the options used to create the texture
  89366. * @returns a new render target cube texture stored in an InternalTexture
  89367. */
  89368. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89369. }
  89370. }
  89371. declare module BABYLON {
  89372. /** @hidden */
  89373. export var proceduralVertexShader: {
  89374. name: string;
  89375. shader: string;
  89376. };
  89377. }
  89378. declare module BABYLON {
  89379. /**
  89380. * 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.
  89381. * This is the base class of any Procedural texture and contains most of the shareable code.
  89382. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89383. */
  89384. export class ProceduralTexture extends Texture {
  89385. isCube: boolean;
  89386. /**
  89387. * Define if the texture is enabled or not (disabled texture will not render)
  89388. */
  89389. isEnabled: boolean;
  89390. /**
  89391. * Define if the texture must be cleared before rendering (default is true)
  89392. */
  89393. autoClear: boolean;
  89394. /**
  89395. * Callback called when the texture is generated
  89396. */
  89397. onGenerated: () => void;
  89398. /**
  89399. * Event raised when the texture is generated
  89400. */
  89401. onGeneratedObservable: Observable<ProceduralTexture>;
  89402. /** @hidden */
  89403. _generateMipMaps: boolean;
  89404. /** @hidden **/
  89405. _effect: Effect;
  89406. /** @hidden */
  89407. _textures: {
  89408. [key: string]: Texture;
  89409. };
  89410. /** @hidden */
  89411. protected _fallbackTexture: Nullable<Texture>;
  89412. private _size;
  89413. private _currentRefreshId;
  89414. private _frameId;
  89415. private _refreshRate;
  89416. private _vertexBuffers;
  89417. private _indexBuffer;
  89418. private _uniforms;
  89419. private _samplers;
  89420. private _fragment;
  89421. private _floats;
  89422. private _ints;
  89423. private _floatsArrays;
  89424. private _colors3;
  89425. private _colors4;
  89426. private _vectors2;
  89427. private _vectors3;
  89428. private _matrices;
  89429. private _fallbackTextureUsed;
  89430. private _fullEngine;
  89431. private _cachedDefines;
  89432. private _contentUpdateId;
  89433. private _contentData;
  89434. /**
  89435. * Instantiates a new procedural texture.
  89436. * 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.
  89437. * This is the base class of any Procedural texture and contains most of the shareable code.
  89438. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89439. * @param name Define the name of the texture
  89440. * @param size Define the size of the texture to create
  89441. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89442. * @param scene Define the scene the texture belongs to
  89443. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89444. * @param generateMipMaps Define if the texture should creates mip maps or not
  89445. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89446. */
  89447. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89448. /**
  89449. * The effect that is created when initializing the post process.
  89450. * @returns The created effect corresponding the the postprocess.
  89451. */
  89452. getEffect(): Effect;
  89453. /**
  89454. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89455. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89456. */
  89457. getContent(): Nullable<ArrayBufferView>;
  89458. private _createIndexBuffer;
  89459. /** @hidden */
  89460. _rebuild(): void;
  89461. /**
  89462. * Resets the texture in order to recreate its associated resources.
  89463. * This can be called in case of context loss
  89464. */
  89465. reset(): void;
  89466. protected _getDefines(): string;
  89467. /**
  89468. * Is the texture ready to be used ? (rendered at least once)
  89469. * @returns true if ready, otherwise, false.
  89470. */
  89471. isReady(): boolean;
  89472. /**
  89473. * Resets the refresh counter of the texture and start bak from scratch.
  89474. * Could be useful to regenerate the texture if it is setup to render only once.
  89475. */
  89476. resetRefreshCounter(): void;
  89477. /**
  89478. * Set the fragment shader to use in order to render the texture.
  89479. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89480. */
  89481. setFragment(fragment: any): void;
  89482. /**
  89483. * Define the refresh rate of the texture or the rendering frequency.
  89484. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89485. */
  89486. get refreshRate(): number;
  89487. set refreshRate(value: number);
  89488. /** @hidden */
  89489. _shouldRender(): boolean;
  89490. /**
  89491. * Get the size the texture is rendering at.
  89492. * @returns the size (texture is always squared)
  89493. */
  89494. getRenderSize(): number;
  89495. /**
  89496. * Resize the texture to new value.
  89497. * @param size Define the new size the texture should have
  89498. * @param generateMipMaps Define whether the new texture should create mip maps
  89499. */
  89500. resize(size: number, generateMipMaps: boolean): void;
  89501. private _checkUniform;
  89502. /**
  89503. * Set a texture in the shader program used to render.
  89504. * @param name Define the name of the uniform samplers as defined in the shader
  89505. * @param texture Define the texture to bind to this sampler
  89506. * @return the texture itself allowing "fluent" like uniform updates
  89507. */
  89508. setTexture(name: string, texture: Texture): ProceduralTexture;
  89509. /**
  89510. * Set a float in the shader.
  89511. * @param name Define the name of the uniform as defined in the shader
  89512. * @param value Define the value to give to the uniform
  89513. * @return the texture itself allowing "fluent" like uniform updates
  89514. */
  89515. setFloat(name: string, value: number): ProceduralTexture;
  89516. /**
  89517. * Set a int in the shader.
  89518. * @param name Define the name of the uniform as defined in the shader
  89519. * @param value Define the value to give to the uniform
  89520. * @return the texture itself allowing "fluent" like uniform updates
  89521. */
  89522. setInt(name: string, value: number): ProceduralTexture;
  89523. /**
  89524. * Set an array of floats in the shader.
  89525. * @param name Define the name of the uniform as defined in the shader
  89526. * @param value Define the value to give to the uniform
  89527. * @return the texture itself allowing "fluent" like uniform updates
  89528. */
  89529. setFloats(name: string, value: number[]): ProceduralTexture;
  89530. /**
  89531. * Set a vec3 in the shader from a Color3.
  89532. * @param name Define the name of the uniform as defined in the shader
  89533. * @param value Define the value to give to the uniform
  89534. * @return the texture itself allowing "fluent" like uniform updates
  89535. */
  89536. setColor3(name: string, value: Color3): ProceduralTexture;
  89537. /**
  89538. * Set a vec4 in the shader from a Color4.
  89539. * @param name Define the name of the uniform as defined in the shader
  89540. * @param value Define the value to give to the uniform
  89541. * @return the texture itself allowing "fluent" like uniform updates
  89542. */
  89543. setColor4(name: string, value: Color4): ProceduralTexture;
  89544. /**
  89545. * Set a vec2 in the shader from a Vector2.
  89546. * @param name Define the name of the uniform as defined in the shader
  89547. * @param value Define the value to give to the uniform
  89548. * @return the texture itself allowing "fluent" like uniform updates
  89549. */
  89550. setVector2(name: string, value: Vector2): ProceduralTexture;
  89551. /**
  89552. * Set a vec3 in the shader from a Vector3.
  89553. * @param name Define the name of the uniform as defined in the shader
  89554. * @param value Define the value to give to the uniform
  89555. * @return the texture itself allowing "fluent" like uniform updates
  89556. */
  89557. setVector3(name: string, value: Vector3): ProceduralTexture;
  89558. /**
  89559. * Set a mat4 in the shader from a MAtrix.
  89560. * @param name Define the name of the uniform as defined in the shader
  89561. * @param value Define the value to give to the uniform
  89562. * @return the texture itself allowing "fluent" like uniform updates
  89563. */
  89564. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89565. /**
  89566. * Render the texture to its associated render target.
  89567. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89568. */
  89569. render(useCameraPostProcess?: boolean): void;
  89570. /**
  89571. * Clone the texture.
  89572. * @returns the cloned texture
  89573. */
  89574. clone(): ProceduralTexture;
  89575. /**
  89576. * Dispose the texture and release its asoociated resources.
  89577. */
  89578. dispose(): void;
  89579. }
  89580. }
  89581. declare module BABYLON {
  89582. /**
  89583. * This represents the base class for particle system in Babylon.
  89584. * 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.
  89585. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89586. * @example https://doc.babylonjs.com/babylon101/particles
  89587. */
  89588. export class BaseParticleSystem {
  89589. /**
  89590. * Source color is added to the destination color without alpha affecting the result
  89591. */
  89592. static BLENDMODE_ONEONE: number;
  89593. /**
  89594. * Blend current color and particle color using particle’s alpha
  89595. */
  89596. static BLENDMODE_STANDARD: number;
  89597. /**
  89598. * Add current color and particle color multiplied by particle’s alpha
  89599. */
  89600. static BLENDMODE_ADD: number;
  89601. /**
  89602. * Multiply current color with particle color
  89603. */
  89604. static BLENDMODE_MULTIPLY: number;
  89605. /**
  89606. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89607. */
  89608. static BLENDMODE_MULTIPLYADD: number;
  89609. /**
  89610. * List of animations used by the particle system.
  89611. */
  89612. animations: Animation[];
  89613. /**
  89614. * Gets or sets the unique id of the particle system
  89615. */
  89616. uniqueId: number;
  89617. /**
  89618. * The id of the Particle system.
  89619. */
  89620. id: string;
  89621. /**
  89622. * The friendly name of the Particle system.
  89623. */
  89624. name: string;
  89625. /**
  89626. * Snippet ID if the particle system was created from the snippet server
  89627. */
  89628. snippetId: string;
  89629. /**
  89630. * The rendering group used by the Particle system to chose when to render.
  89631. */
  89632. renderingGroupId: number;
  89633. /**
  89634. * The emitter represents the Mesh or position we are attaching the particle system to.
  89635. */
  89636. emitter: Nullable<AbstractMesh | Vector3>;
  89637. /**
  89638. * The maximum number of particles to emit per frame
  89639. */
  89640. emitRate: number;
  89641. /**
  89642. * If you want to launch only a few particles at once, that can be done, as well.
  89643. */
  89644. manualEmitCount: number;
  89645. /**
  89646. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89647. */
  89648. updateSpeed: number;
  89649. /**
  89650. * The amount of time the particle system is running (depends of the overall update speed).
  89651. */
  89652. targetStopDuration: number;
  89653. /**
  89654. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89655. */
  89656. disposeOnStop: boolean;
  89657. /**
  89658. * Minimum power of emitting particles.
  89659. */
  89660. minEmitPower: number;
  89661. /**
  89662. * Maximum power of emitting particles.
  89663. */
  89664. maxEmitPower: number;
  89665. /**
  89666. * Minimum life time of emitting particles.
  89667. */
  89668. minLifeTime: number;
  89669. /**
  89670. * Maximum life time of emitting particles.
  89671. */
  89672. maxLifeTime: number;
  89673. /**
  89674. * Minimum Size of emitting particles.
  89675. */
  89676. minSize: number;
  89677. /**
  89678. * Maximum Size of emitting particles.
  89679. */
  89680. maxSize: number;
  89681. /**
  89682. * Minimum scale of emitting particles on X axis.
  89683. */
  89684. minScaleX: number;
  89685. /**
  89686. * Maximum scale of emitting particles on X axis.
  89687. */
  89688. maxScaleX: number;
  89689. /**
  89690. * Minimum scale of emitting particles on Y axis.
  89691. */
  89692. minScaleY: number;
  89693. /**
  89694. * Maximum scale of emitting particles on Y axis.
  89695. */
  89696. maxScaleY: number;
  89697. /**
  89698. * Gets or sets the minimal initial rotation in radians.
  89699. */
  89700. minInitialRotation: number;
  89701. /**
  89702. * Gets or sets the maximal initial rotation in radians.
  89703. */
  89704. maxInitialRotation: number;
  89705. /**
  89706. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89707. */
  89708. minAngularSpeed: number;
  89709. /**
  89710. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89711. */
  89712. maxAngularSpeed: number;
  89713. /**
  89714. * The texture used to render each particle. (this can be a spritesheet)
  89715. */
  89716. particleTexture: Nullable<Texture>;
  89717. /**
  89718. * The layer mask we are rendering the particles through.
  89719. */
  89720. layerMask: number;
  89721. /**
  89722. * This can help using your own shader to render the particle system.
  89723. * The according effect will be created
  89724. */
  89725. customShader: any;
  89726. /**
  89727. * By default particle system starts as soon as they are created. This prevents the
  89728. * automatic start to happen and let you decide when to start emitting particles.
  89729. */
  89730. preventAutoStart: boolean;
  89731. private _noiseTexture;
  89732. /**
  89733. * Gets or sets a texture used to add random noise to particle positions
  89734. */
  89735. get noiseTexture(): Nullable<ProceduralTexture>;
  89736. set noiseTexture(value: Nullable<ProceduralTexture>);
  89737. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89738. noiseStrength: Vector3;
  89739. /**
  89740. * Callback triggered when the particle animation is ending.
  89741. */
  89742. onAnimationEnd: Nullable<() => void>;
  89743. /**
  89744. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89745. */
  89746. blendMode: number;
  89747. /**
  89748. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89749. * to override the particles.
  89750. */
  89751. forceDepthWrite: boolean;
  89752. /** 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 */
  89753. preWarmCycles: number;
  89754. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89755. preWarmStepOffset: number;
  89756. /**
  89757. * 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)
  89758. */
  89759. spriteCellChangeSpeed: number;
  89760. /**
  89761. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89762. */
  89763. startSpriteCellID: number;
  89764. /**
  89765. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89766. */
  89767. endSpriteCellID: number;
  89768. /**
  89769. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89770. */
  89771. spriteCellWidth: number;
  89772. /**
  89773. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89774. */
  89775. spriteCellHeight: number;
  89776. /**
  89777. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89778. */
  89779. spriteRandomStartCell: boolean;
  89780. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89781. translationPivot: Vector2;
  89782. /** @hidden */
  89783. protected _isAnimationSheetEnabled: boolean;
  89784. /**
  89785. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89786. */
  89787. beginAnimationOnStart: boolean;
  89788. /**
  89789. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89790. */
  89791. beginAnimationFrom: number;
  89792. /**
  89793. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89794. */
  89795. beginAnimationTo: number;
  89796. /**
  89797. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89798. */
  89799. beginAnimationLoop: boolean;
  89800. /**
  89801. * Gets or sets a world offset applied to all particles
  89802. */
  89803. worldOffset: Vector3;
  89804. /**
  89805. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89806. */
  89807. get isAnimationSheetEnabled(): boolean;
  89808. set isAnimationSheetEnabled(value: boolean);
  89809. /**
  89810. * Get hosting scene
  89811. * @returns the scene
  89812. */
  89813. getScene(): Scene;
  89814. /**
  89815. * You can use gravity if you want to give an orientation to your particles.
  89816. */
  89817. gravity: Vector3;
  89818. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89819. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89820. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89821. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89822. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89823. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89824. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89825. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89826. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89827. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89828. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89829. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89830. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89831. /**
  89832. * Defines the delay in milliseconds before starting the system (0 by default)
  89833. */
  89834. startDelay: number;
  89835. /**
  89836. * Gets the current list of drag gradients.
  89837. * You must use addDragGradient and removeDragGradient to udpate this list
  89838. * @returns the list of drag gradients
  89839. */
  89840. getDragGradients(): Nullable<Array<FactorGradient>>;
  89841. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89842. limitVelocityDamping: number;
  89843. /**
  89844. * Gets the current list of limit velocity gradients.
  89845. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89846. * @returns the list of limit velocity gradients
  89847. */
  89848. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89849. /**
  89850. * Gets the current list of color gradients.
  89851. * You must use addColorGradient and removeColorGradient to udpate this list
  89852. * @returns the list of color gradients
  89853. */
  89854. getColorGradients(): Nullable<Array<ColorGradient>>;
  89855. /**
  89856. * Gets the current list of size gradients.
  89857. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89858. * @returns the list of size gradients
  89859. */
  89860. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89861. /**
  89862. * Gets the current list of color remap gradients.
  89863. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89864. * @returns the list of color remap gradients
  89865. */
  89866. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89867. /**
  89868. * Gets the current list of alpha remap gradients.
  89869. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89870. * @returns the list of alpha remap gradients
  89871. */
  89872. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89873. /**
  89874. * Gets the current list of life time gradients.
  89875. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89876. * @returns the list of life time gradients
  89877. */
  89878. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89879. /**
  89880. * Gets the current list of angular speed gradients.
  89881. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89882. * @returns the list of angular speed gradients
  89883. */
  89884. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89885. /**
  89886. * Gets the current list of velocity gradients.
  89887. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89888. * @returns the list of velocity gradients
  89889. */
  89890. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89891. /**
  89892. * Gets the current list of start size gradients.
  89893. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89894. * @returns the list of start size gradients
  89895. */
  89896. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89897. /**
  89898. * Gets the current list of emit rate gradients.
  89899. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89900. * @returns the list of emit rate gradients
  89901. */
  89902. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89903. /**
  89904. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89905. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89906. */
  89907. get direction1(): Vector3;
  89908. set direction1(value: Vector3);
  89909. /**
  89910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89911. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89912. */
  89913. get direction2(): Vector3;
  89914. set direction2(value: Vector3);
  89915. /**
  89916. * 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.
  89917. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89918. */
  89919. get minEmitBox(): Vector3;
  89920. set minEmitBox(value: Vector3);
  89921. /**
  89922. * 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.
  89923. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89924. */
  89925. get maxEmitBox(): Vector3;
  89926. set maxEmitBox(value: Vector3);
  89927. /**
  89928. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89929. */
  89930. color1: Color4;
  89931. /**
  89932. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89933. */
  89934. color2: Color4;
  89935. /**
  89936. * Color the particle will have at the end of its lifetime
  89937. */
  89938. colorDead: Color4;
  89939. /**
  89940. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89941. */
  89942. textureMask: Color4;
  89943. /**
  89944. * The particle emitter type defines the emitter used by the particle system.
  89945. * It can be for example box, sphere, or cone...
  89946. */
  89947. particleEmitterType: IParticleEmitterType;
  89948. /** @hidden */
  89949. _isSubEmitter: boolean;
  89950. /**
  89951. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89952. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89953. */
  89954. billboardMode: number;
  89955. protected _isBillboardBased: boolean;
  89956. /**
  89957. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89958. */
  89959. get isBillboardBased(): boolean;
  89960. set isBillboardBased(value: boolean);
  89961. /**
  89962. * The scene the particle system belongs to.
  89963. */
  89964. protected _scene: Scene;
  89965. /**
  89966. * Local cache of defines for image processing.
  89967. */
  89968. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89969. /**
  89970. * Default configuration related to image processing available in the standard Material.
  89971. */
  89972. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89973. /**
  89974. * Gets the image processing configuration used either in this material.
  89975. */
  89976. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89977. /**
  89978. * Sets the Default image processing configuration used either in the this material.
  89979. *
  89980. * If sets to null, the scene one is in use.
  89981. */
  89982. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89983. /**
  89984. * Attaches a new image processing configuration to the Standard Material.
  89985. * @param configuration
  89986. */
  89987. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89988. /** @hidden */
  89989. protected _reset(): void;
  89990. /** @hidden */
  89991. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89992. /**
  89993. * Instantiates a particle system.
  89994. * 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.
  89995. * @param name The name of the particle system
  89996. */
  89997. constructor(name: string);
  89998. /**
  89999. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90000. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90001. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90002. * @returns the emitter
  90003. */
  90004. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90005. /**
  90006. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90007. * @param radius The radius of the hemisphere to emit from
  90008. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90009. * @returns the emitter
  90010. */
  90011. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90012. /**
  90013. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90014. * @param radius The radius of the sphere to emit from
  90015. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90016. * @returns the emitter
  90017. */
  90018. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90019. /**
  90020. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90021. * @param radius The radius of the sphere to emit from
  90022. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90023. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90024. * @returns the emitter
  90025. */
  90026. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90027. /**
  90028. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90029. * @param radius The radius of the emission cylinder
  90030. * @param height The height of the emission cylinder
  90031. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90032. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90033. * @returns the emitter
  90034. */
  90035. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90036. /**
  90037. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90038. * @param radius The radius of the cylinder to emit from
  90039. * @param height The height of the emission cylinder
  90040. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90041. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90042. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90043. * @returns the emitter
  90044. */
  90045. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90046. /**
  90047. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90048. * @param radius The radius of the cone to emit from
  90049. * @param angle The base angle of the cone
  90050. * @returns the emitter
  90051. */
  90052. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90053. /**
  90054. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90055. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90056. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90057. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90058. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90059. * @returns the emitter
  90060. */
  90061. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90062. }
  90063. }
  90064. declare module BABYLON {
  90065. /**
  90066. * Type of sub emitter
  90067. */
  90068. export enum SubEmitterType {
  90069. /**
  90070. * Attached to the particle over it's lifetime
  90071. */
  90072. ATTACHED = 0,
  90073. /**
  90074. * Created when the particle dies
  90075. */
  90076. END = 1
  90077. }
  90078. /**
  90079. * Sub emitter class used to emit particles from an existing particle
  90080. */
  90081. export class SubEmitter {
  90082. /**
  90083. * the particle system to be used by the sub emitter
  90084. */
  90085. particleSystem: ParticleSystem;
  90086. /**
  90087. * Type of the submitter (Default: END)
  90088. */
  90089. type: SubEmitterType;
  90090. /**
  90091. * 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)
  90092. * Note: This only is supported when using an emitter of type Mesh
  90093. */
  90094. inheritDirection: boolean;
  90095. /**
  90096. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90097. */
  90098. inheritedVelocityAmount: number;
  90099. /**
  90100. * Creates a sub emitter
  90101. * @param particleSystem the particle system to be used by the sub emitter
  90102. */
  90103. constructor(
  90104. /**
  90105. * the particle system to be used by the sub emitter
  90106. */
  90107. particleSystem: ParticleSystem);
  90108. /**
  90109. * Clones the sub emitter
  90110. * @returns the cloned sub emitter
  90111. */
  90112. clone(): SubEmitter;
  90113. /**
  90114. * Serialize current object to a JSON object
  90115. * @returns the serialized object
  90116. */
  90117. serialize(): any;
  90118. /** @hidden */
  90119. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90120. /**
  90121. * Creates a new SubEmitter from a serialized JSON version
  90122. * @param serializationObject defines the JSON object to read from
  90123. * @param scene defines the hosting scene
  90124. * @param rootUrl defines the rootUrl for data loading
  90125. * @returns a new SubEmitter
  90126. */
  90127. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90128. /** Release associated resources */
  90129. dispose(): void;
  90130. }
  90131. }
  90132. declare module BABYLON {
  90133. /** @hidden */
  90134. export var imageProcessingDeclaration: {
  90135. name: string;
  90136. shader: string;
  90137. };
  90138. }
  90139. declare module BABYLON {
  90140. /** @hidden */
  90141. export var imageProcessingFunctions: {
  90142. name: string;
  90143. shader: string;
  90144. };
  90145. }
  90146. declare module BABYLON {
  90147. /** @hidden */
  90148. export var particlesPixelShader: {
  90149. name: string;
  90150. shader: string;
  90151. };
  90152. }
  90153. declare module BABYLON {
  90154. /** @hidden */
  90155. export var particlesVertexShader: {
  90156. name: string;
  90157. shader: string;
  90158. };
  90159. }
  90160. declare module BABYLON {
  90161. /**
  90162. * This represents a particle system in Babylon.
  90163. * 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.
  90164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90165. * @example https://doc.babylonjs.com/babylon101/particles
  90166. */
  90167. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90168. /**
  90169. * Billboard mode will only apply to Y axis
  90170. */
  90171. static readonly BILLBOARDMODE_Y: number;
  90172. /**
  90173. * Billboard mode will apply to all axes
  90174. */
  90175. static readonly BILLBOARDMODE_ALL: number;
  90176. /**
  90177. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90178. */
  90179. static readonly BILLBOARDMODE_STRETCHED: number;
  90180. /**
  90181. * This function can be defined to provide custom update for active particles.
  90182. * This function will be called instead of regular update (age, position, color, etc.).
  90183. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90184. */
  90185. updateFunction: (particles: Particle[]) => void;
  90186. private _emitterWorldMatrix;
  90187. /**
  90188. * This function can be defined to specify initial direction for every new particle.
  90189. * It by default use the emitterType defined function
  90190. */
  90191. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90192. /**
  90193. * This function can be defined to specify initial position for every new particle.
  90194. * It by default use the emitterType defined function
  90195. */
  90196. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90197. /**
  90198. * @hidden
  90199. */
  90200. _inheritedVelocityOffset: Vector3;
  90201. /**
  90202. * An event triggered when the system is disposed
  90203. */
  90204. onDisposeObservable: Observable<IParticleSystem>;
  90205. private _onDisposeObserver;
  90206. /**
  90207. * Sets a callback that will be triggered when the system is disposed
  90208. */
  90209. set onDispose(callback: () => void);
  90210. private _particles;
  90211. private _epsilon;
  90212. private _capacity;
  90213. private _stockParticles;
  90214. private _newPartsExcess;
  90215. private _vertexData;
  90216. private _vertexBuffer;
  90217. private _vertexBuffers;
  90218. private _spriteBuffer;
  90219. private _indexBuffer;
  90220. private _effect;
  90221. private _customEffect;
  90222. private _cachedDefines;
  90223. private _scaledColorStep;
  90224. private _colorDiff;
  90225. private _scaledDirection;
  90226. private _scaledGravity;
  90227. private _currentRenderId;
  90228. private _alive;
  90229. private _useInstancing;
  90230. private _started;
  90231. private _stopped;
  90232. private _actualFrame;
  90233. private _scaledUpdateSpeed;
  90234. private _vertexBufferSize;
  90235. /** @hidden */
  90236. _currentEmitRateGradient: Nullable<FactorGradient>;
  90237. /** @hidden */
  90238. _currentEmitRate1: number;
  90239. /** @hidden */
  90240. _currentEmitRate2: number;
  90241. /** @hidden */
  90242. _currentStartSizeGradient: Nullable<FactorGradient>;
  90243. /** @hidden */
  90244. _currentStartSize1: number;
  90245. /** @hidden */
  90246. _currentStartSize2: number;
  90247. private readonly _rawTextureWidth;
  90248. private _rampGradientsTexture;
  90249. private _useRampGradients;
  90250. /** Gets or sets a boolean indicating that ramp gradients must be used
  90251. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90252. */
  90253. get useRampGradients(): boolean;
  90254. set useRampGradients(value: boolean);
  90255. /**
  90256. * 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.
  90257. * 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: [])
  90258. */
  90259. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90260. private _subEmitters;
  90261. /**
  90262. * @hidden
  90263. * If the particle systems emitter should be disposed when the particle system is disposed
  90264. */
  90265. _disposeEmitterOnDispose: boolean;
  90266. /**
  90267. * The current active Sub-systems, this property is used by the root particle system only.
  90268. */
  90269. activeSubSystems: Array<ParticleSystem>;
  90270. /**
  90271. * Specifies if the particles are updated in emitter local space or world space
  90272. */
  90273. isLocal: boolean;
  90274. private _rootParticleSystem;
  90275. /**
  90276. * Gets the current list of active particles
  90277. */
  90278. get particles(): Particle[];
  90279. /**
  90280. * Gets the number of particles active at the same time.
  90281. * @returns The number of active particles.
  90282. */
  90283. getActiveCount(): number;
  90284. /**
  90285. * Returns the string "ParticleSystem"
  90286. * @returns a string containing the class name
  90287. */
  90288. getClassName(): string;
  90289. /**
  90290. * Gets a boolean indicating that the system is stopping
  90291. * @returns true if the system is currently stopping
  90292. */
  90293. isStopping(): boolean;
  90294. /**
  90295. * Gets the custom effect used to render the particles
  90296. * @param blendMode Blend mode for which the effect should be retrieved
  90297. * @returns The effect
  90298. */
  90299. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90300. /**
  90301. * Sets the custom effect used to render the particles
  90302. * @param effect The effect to set
  90303. * @param blendMode Blend mode for which the effect should be set
  90304. */
  90305. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90306. /** @hidden */
  90307. private _onBeforeDrawParticlesObservable;
  90308. /**
  90309. * Observable that will be called just before the particles are drawn
  90310. */
  90311. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90312. /**
  90313. * Gets the name of the particle vertex shader
  90314. */
  90315. get vertexShaderName(): string;
  90316. /**
  90317. * Instantiates a particle system.
  90318. * 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.
  90319. * @param name The name of the particle system
  90320. * @param capacity The max number of particles alive at the same time
  90321. * @param scene The scene the particle system belongs to
  90322. * @param customEffect a custom effect used to change the way particles are rendered by default
  90323. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90324. * @param epsilon Offset used to render the particles
  90325. */
  90326. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90327. private _addFactorGradient;
  90328. private _removeFactorGradient;
  90329. /**
  90330. * Adds a new life time gradient
  90331. * @param gradient defines the gradient to use (between 0 and 1)
  90332. * @param factor defines the life time factor to affect to the specified gradient
  90333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90334. * @returns the current particle system
  90335. */
  90336. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90337. /**
  90338. * Remove a specific life time gradient
  90339. * @param gradient defines the gradient to remove
  90340. * @returns the current particle system
  90341. */
  90342. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90343. /**
  90344. * Adds a new size gradient
  90345. * @param gradient defines the gradient to use (between 0 and 1)
  90346. * @param factor defines the size factor to affect to the specified gradient
  90347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90348. * @returns the current particle system
  90349. */
  90350. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90351. /**
  90352. * Remove a specific size gradient
  90353. * @param gradient defines the gradient to remove
  90354. * @returns the current particle system
  90355. */
  90356. removeSizeGradient(gradient: number): IParticleSystem;
  90357. /**
  90358. * Adds a new color remap gradient
  90359. * @param gradient defines the gradient to use (between 0 and 1)
  90360. * @param min defines the color remap minimal range
  90361. * @param max defines the color remap maximal range
  90362. * @returns the current particle system
  90363. */
  90364. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90365. /**
  90366. * Remove a specific color remap gradient
  90367. * @param gradient defines the gradient to remove
  90368. * @returns the current particle system
  90369. */
  90370. removeColorRemapGradient(gradient: number): IParticleSystem;
  90371. /**
  90372. * Adds a new alpha remap gradient
  90373. * @param gradient defines the gradient to use (between 0 and 1)
  90374. * @param min defines the alpha remap minimal range
  90375. * @param max defines the alpha remap maximal range
  90376. * @returns the current particle system
  90377. */
  90378. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90379. /**
  90380. * Remove a specific alpha remap gradient
  90381. * @param gradient defines the gradient to remove
  90382. * @returns the current particle system
  90383. */
  90384. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90385. /**
  90386. * Adds a new angular speed gradient
  90387. * @param gradient defines the gradient to use (between 0 and 1)
  90388. * @param factor defines the angular speed to affect to the specified gradient
  90389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90390. * @returns the current particle system
  90391. */
  90392. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90393. /**
  90394. * Remove a specific angular speed gradient
  90395. * @param gradient defines the gradient to remove
  90396. * @returns the current particle system
  90397. */
  90398. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90399. /**
  90400. * Adds a new velocity gradient
  90401. * @param gradient defines the gradient to use (between 0 and 1)
  90402. * @param factor defines the velocity to affect to the specified gradient
  90403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90404. * @returns the current particle system
  90405. */
  90406. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90407. /**
  90408. * Remove a specific velocity gradient
  90409. * @param gradient defines the gradient to remove
  90410. * @returns the current particle system
  90411. */
  90412. removeVelocityGradient(gradient: number): IParticleSystem;
  90413. /**
  90414. * Adds a new limit velocity gradient
  90415. * @param gradient defines the gradient to use (between 0 and 1)
  90416. * @param factor defines the limit velocity value to affect to the specified gradient
  90417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90418. * @returns the current particle system
  90419. */
  90420. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90421. /**
  90422. * Remove a specific limit velocity gradient
  90423. * @param gradient defines the gradient to remove
  90424. * @returns the current particle system
  90425. */
  90426. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90427. /**
  90428. * Adds a new drag gradient
  90429. * @param gradient defines the gradient to use (between 0 and 1)
  90430. * @param factor defines the drag value to affect to the specified gradient
  90431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90432. * @returns the current particle system
  90433. */
  90434. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90435. /**
  90436. * Remove a specific drag gradient
  90437. * @param gradient defines the gradient to remove
  90438. * @returns the current particle system
  90439. */
  90440. removeDragGradient(gradient: number): IParticleSystem;
  90441. /**
  90442. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90443. * @param gradient defines the gradient to use (between 0 and 1)
  90444. * @param factor defines the emit rate value to affect to the specified gradient
  90445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90446. * @returns the current particle system
  90447. */
  90448. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90449. /**
  90450. * Remove a specific emit rate gradient
  90451. * @param gradient defines the gradient to remove
  90452. * @returns the current particle system
  90453. */
  90454. removeEmitRateGradient(gradient: number): IParticleSystem;
  90455. /**
  90456. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90457. * @param gradient defines the gradient to use (between 0 and 1)
  90458. * @param factor defines the start size value to affect to the specified gradient
  90459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90460. * @returns the current particle system
  90461. */
  90462. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90463. /**
  90464. * Remove a specific start size gradient
  90465. * @param gradient defines the gradient to remove
  90466. * @returns the current particle system
  90467. */
  90468. removeStartSizeGradient(gradient: number): IParticleSystem;
  90469. private _createRampGradientTexture;
  90470. /**
  90471. * Gets the current list of ramp gradients.
  90472. * You must use addRampGradient and removeRampGradient to udpate this list
  90473. * @returns the list of ramp gradients
  90474. */
  90475. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90476. /** Force the system to rebuild all gradients that need to be resync */
  90477. forceRefreshGradients(): void;
  90478. private _syncRampGradientTexture;
  90479. /**
  90480. * Adds a new ramp gradient used to remap particle colors
  90481. * @param gradient defines the gradient to use (between 0 and 1)
  90482. * @param color defines the color to affect to the specified gradient
  90483. * @returns the current particle system
  90484. */
  90485. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90486. /**
  90487. * Remove a specific ramp gradient
  90488. * @param gradient defines the gradient to remove
  90489. * @returns the current particle system
  90490. */
  90491. removeRampGradient(gradient: number): ParticleSystem;
  90492. /**
  90493. * Adds a new color gradient
  90494. * @param gradient defines the gradient to use (between 0 and 1)
  90495. * @param color1 defines the color to affect to the specified gradient
  90496. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90497. * @returns this particle system
  90498. */
  90499. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90500. /**
  90501. * Remove a specific color gradient
  90502. * @param gradient defines the gradient to remove
  90503. * @returns this particle system
  90504. */
  90505. removeColorGradient(gradient: number): IParticleSystem;
  90506. private _fetchR;
  90507. protected _reset(): void;
  90508. private _resetEffect;
  90509. private _createVertexBuffers;
  90510. private _createIndexBuffer;
  90511. /**
  90512. * Gets the maximum number of particles active at the same time.
  90513. * @returns The max number of active particles.
  90514. */
  90515. getCapacity(): number;
  90516. /**
  90517. * Gets whether there are still active particles in the system.
  90518. * @returns True if it is alive, otherwise false.
  90519. */
  90520. isAlive(): boolean;
  90521. /**
  90522. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90523. * @returns True if it has been started, otherwise false.
  90524. */
  90525. isStarted(): boolean;
  90526. private _prepareSubEmitterInternalArray;
  90527. /**
  90528. * Starts the particle system and begins to emit
  90529. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90530. */
  90531. start(delay?: number): void;
  90532. /**
  90533. * Stops the particle system.
  90534. * @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.
  90535. */
  90536. stop(stopSubEmitters?: boolean): void;
  90537. /**
  90538. * Remove all active particles
  90539. */
  90540. reset(): void;
  90541. /**
  90542. * @hidden (for internal use only)
  90543. */
  90544. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90545. /**
  90546. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90547. * Its lifetime will start back at 0.
  90548. */
  90549. recycleParticle: (particle: Particle) => void;
  90550. private _stopSubEmitters;
  90551. private _createParticle;
  90552. private _removeFromRoot;
  90553. private _emitFromParticle;
  90554. private _update;
  90555. /** @hidden */
  90556. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90557. /** @hidden */
  90558. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90559. /**
  90560. * Fill the defines array according to the current settings of the particle system
  90561. * @param defines Array to be updated
  90562. * @param blendMode blend mode to take into account when updating the array
  90563. */
  90564. fillDefines(defines: Array<string>, blendMode: number): void;
  90565. /**
  90566. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90567. * @param uniforms Uniforms array to fill
  90568. * @param attributes Attributes array to fill
  90569. * @param samplers Samplers array to fill
  90570. */
  90571. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90572. /** @hidden */
  90573. private _getEffect;
  90574. /**
  90575. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90576. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90577. */
  90578. animate(preWarmOnly?: boolean): void;
  90579. private _appendParticleVertices;
  90580. /**
  90581. * Rebuilds the particle system.
  90582. */
  90583. rebuild(): void;
  90584. /**
  90585. * Is this system ready to be used/rendered
  90586. * @return true if the system is ready
  90587. */
  90588. isReady(): boolean;
  90589. private _render;
  90590. /**
  90591. * Renders the particle system in its current state.
  90592. * @returns the current number of particles
  90593. */
  90594. render(): number;
  90595. /**
  90596. * Disposes the particle system and free the associated resources
  90597. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90598. */
  90599. dispose(disposeTexture?: boolean): void;
  90600. /**
  90601. * Clones the particle system.
  90602. * @param name The name of the cloned object
  90603. * @param newEmitter The new emitter to use
  90604. * @returns the cloned particle system
  90605. */
  90606. clone(name: string, newEmitter: any): ParticleSystem;
  90607. /**
  90608. * Serializes the particle system to a JSON object
  90609. * @param serializeTexture defines if the texture must be serialized as well
  90610. * @returns the JSON object
  90611. */
  90612. serialize(serializeTexture?: boolean): any;
  90613. /** @hidden */
  90614. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90615. /** @hidden */
  90616. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90617. /**
  90618. * Parses a JSON object to create a particle system.
  90619. * @param parsedParticleSystem The JSON object to parse
  90620. * @param scene The scene to create the particle system in
  90621. * @param rootUrl The root url to use to load external dependencies like texture
  90622. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90623. * @returns the Parsed particle system
  90624. */
  90625. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90626. }
  90627. }
  90628. declare module BABYLON {
  90629. /**
  90630. * A particle represents one of the element emitted by a particle system.
  90631. * This is mainly define by its coordinates, direction, velocity and age.
  90632. */
  90633. export class Particle {
  90634. /**
  90635. * The particle system the particle belongs to.
  90636. */
  90637. particleSystem: ParticleSystem;
  90638. private static _Count;
  90639. /**
  90640. * Unique ID of the particle
  90641. */
  90642. id: number;
  90643. /**
  90644. * The world position of the particle in the scene.
  90645. */
  90646. position: Vector3;
  90647. /**
  90648. * The world direction of the particle in the scene.
  90649. */
  90650. direction: Vector3;
  90651. /**
  90652. * The color of the particle.
  90653. */
  90654. color: Color4;
  90655. /**
  90656. * The color change of the particle per step.
  90657. */
  90658. colorStep: Color4;
  90659. /**
  90660. * Defines how long will the life of the particle be.
  90661. */
  90662. lifeTime: number;
  90663. /**
  90664. * The current age of the particle.
  90665. */
  90666. age: number;
  90667. /**
  90668. * The current size of the particle.
  90669. */
  90670. size: number;
  90671. /**
  90672. * The current scale of the particle.
  90673. */
  90674. scale: Vector2;
  90675. /**
  90676. * The current angle of the particle.
  90677. */
  90678. angle: number;
  90679. /**
  90680. * Defines how fast is the angle changing.
  90681. */
  90682. angularSpeed: number;
  90683. /**
  90684. * Defines the cell index used by the particle to be rendered from a sprite.
  90685. */
  90686. cellIndex: number;
  90687. /**
  90688. * The information required to support color remapping
  90689. */
  90690. remapData: Vector4;
  90691. /** @hidden */
  90692. _randomCellOffset?: number;
  90693. /** @hidden */
  90694. _initialDirection: Nullable<Vector3>;
  90695. /** @hidden */
  90696. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90697. /** @hidden */
  90698. _initialStartSpriteCellID: number;
  90699. /** @hidden */
  90700. _initialEndSpriteCellID: number;
  90701. /** @hidden */
  90702. _currentColorGradient: Nullable<ColorGradient>;
  90703. /** @hidden */
  90704. _currentColor1: Color4;
  90705. /** @hidden */
  90706. _currentColor2: Color4;
  90707. /** @hidden */
  90708. _currentSizeGradient: Nullable<FactorGradient>;
  90709. /** @hidden */
  90710. _currentSize1: number;
  90711. /** @hidden */
  90712. _currentSize2: number;
  90713. /** @hidden */
  90714. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90715. /** @hidden */
  90716. _currentAngularSpeed1: number;
  90717. /** @hidden */
  90718. _currentAngularSpeed2: number;
  90719. /** @hidden */
  90720. _currentVelocityGradient: Nullable<FactorGradient>;
  90721. /** @hidden */
  90722. _currentVelocity1: number;
  90723. /** @hidden */
  90724. _currentVelocity2: number;
  90725. /** @hidden */
  90726. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90727. /** @hidden */
  90728. _currentLimitVelocity1: number;
  90729. /** @hidden */
  90730. _currentLimitVelocity2: number;
  90731. /** @hidden */
  90732. _currentDragGradient: Nullable<FactorGradient>;
  90733. /** @hidden */
  90734. _currentDrag1: number;
  90735. /** @hidden */
  90736. _currentDrag2: number;
  90737. /** @hidden */
  90738. _randomNoiseCoordinates1: Vector3;
  90739. /** @hidden */
  90740. _randomNoiseCoordinates2: Vector3;
  90741. /** @hidden */
  90742. _localPosition?: Vector3;
  90743. /**
  90744. * Creates a new instance Particle
  90745. * @param particleSystem the particle system the particle belongs to
  90746. */
  90747. constructor(
  90748. /**
  90749. * The particle system the particle belongs to.
  90750. */
  90751. particleSystem: ParticleSystem);
  90752. private updateCellInfoFromSystem;
  90753. /**
  90754. * Defines how the sprite cell index is updated for the particle
  90755. */
  90756. updateCellIndex(): void;
  90757. /** @hidden */
  90758. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90759. /** @hidden */
  90760. _inheritParticleInfoToSubEmitters(): void;
  90761. /** @hidden */
  90762. _reset(): void;
  90763. /**
  90764. * Copy the properties of particle to another one.
  90765. * @param other the particle to copy the information to.
  90766. */
  90767. copyTo(other: Particle): void;
  90768. }
  90769. }
  90770. declare module BABYLON {
  90771. /**
  90772. * Particle emitter represents a volume emitting particles.
  90773. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90774. */
  90775. export interface IParticleEmitterType {
  90776. /**
  90777. * Called by the particle System when the direction is computed for the created particle.
  90778. * @param worldMatrix is the world matrix of the particle system
  90779. * @param directionToUpdate is the direction vector to update with the result
  90780. * @param particle is the particle we are computed the direction for
  90781. * @param isLocal defines if the direction should be set in local space
  90782. */
  90783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90784. /**
  90785. * Called by the particle System when the position is computed for the created particle.
  90786. * @param worldMatrix is the world matrix of the particle system
  90787. * @param positionToUpdate is the position vector to update with the result
  90788. * @param particle is the particle we are computed the position for
  90789. * @param isLocal defines if the position should be set in local space
  90790. */
  90791. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90792. /**
  90793. * Clones the current emitter and returns a copy of it
  90794. * @returns the new emitter
  90795. */
  90796. clone(): IParticleEmitterType;
  90797. /**
  90798. * Called by the GPUParticleSystem to setup the update shader
  90799. * @param effect defines the update shader
  90800. */
  90801. applyToShader(effect: Effect): void;
  90802. /**
  90803. * Returns a string to use to update the GPU particles update shader
  90804. * @returns the effect defines string
  90805. */
  90806. getEffectDefines(): string;
  90807. /**
  90808. * Returns a string representing the class name
  90809. * @returns a string containing the class name
  90810. */
  90811. getClassName(): string;
  90812. /**
  90813. * Serializes the particle system to a JSON object.
  90814. * @returns the JSON object
  90815. */
  90816. serialize(): any;
  90817. /**
  90818. * Parse properties from a JSON object
  90819. * @param serializationObject defines the JSON object
  90820. * @param scene defines the hosting scene
  90821. */
  90822. parse(serializationObject: any, scene: Scene): void;
  90823. }
  90824. }
  90825. declare module BABYLON {
  90826. /**
  90827. * Particle emitter emitting particles from the inside of a box.
  90828. * It emits the particles randomly between 2 given directions.
  90829. */
  90830. export class BoxParticleEmitter implements IParticleEmitterType {
  90831. /**
  90832. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90833. */
  90834. direction1: Vector3;
  90835. /**
  90836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90837. */
  90838. direction2: Vector3;
  90839. /**
  90840. * 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.
  90841. */
  90842. minEmitBox: Vector3;
  90843. /**
  90844. * 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.
  90845. */
  90846. maxEmitBox: Vector3;
  90847. /**
  90848. * Creates a new instance BoxParticleEmitter
  90849. */
  90850. constructor();
  90851. /**
  90852. * Called by the particle System when the direction is computed for the created particle.
  90853. * @param worldMatrix is the world matrix of the particle system
  90854. * @param directionToUpdate is the direction vector to update with the result
  90855. * @param particle is the particle we are computed the direction for
  90856. * @param isLocal defines if the direction should be set in local space
  90857. */
  90858. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90859. /**
  90860. * Called by the particle System when the position is computed for the created particle.
  90861. * @param worldMatrix is the world matrix of the particle system
  90862. * @param positionToUpdate is the position vector to update with the result
  90863. * @param particle is the particle we are computed the position for
  90864. * @param isLocal defines if the position should be set in local space
  90865. */
  90866. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90867. /**
  90868. * Clones the current emitter and returns a copy of it
  90869. * @returns the new emitter
  90870. */
  90871. clone(): BoxParticleEmitter;
  90872. /**
  90873. * Called by the GPUParticleSystem to setup the update shader
  90874. * @param effect defines the update shader
  90875. */
  90876. applyToShader(effect: Effect): void;
  90877. /**
  90878. * Returns a string to use to update the GPU particles update shader
  90879. * @returns a string containng the defines string
  90880. */
  90881. getEffectDefines(): string;
  90882. /**
  90883. * Returns the string "BoxParticleEmitter"
  90884. * @returns a string containing the class name
  90885. */
  90886. getClassName(): string;
  90887. /**
  90888. * Serializes the particle system to a JSON object.
  90889. * @returns the JSON object
  90890. */
  90891. serialize(): any;
  90892. /**
  90893. * Parse properties from a JSON object
  90894. * @param serializationObject defines the JSON object
  90895. */
  90896. parse(serializationObject: any): void;
  90897. }
  90898. }
  90899. declare module BABYLON {
  90900. /**
  90901. * Particle emitter emitting particles from the inside of a cone.
  90902. * It emits the particles alongside the cone volume from the base to the particle.
  90903. * The emission direction might be randomized.
  90904. */
  90905. export class ConeParticleEmitter implements IParticleEmitterType {
  90906. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90907. directionRandomizer: number;
  90908. private _radius;
  90909. private _angle;
  90910. private _height;
  90911. /**
  90912. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90913. */
  90914. radiusRange: number;
  90915. /**
  90916. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90917. */
  90918. heightRange: number;
  90919. /**
  90920. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90921. */
  90922. emitFromSpawnPointOnly: boolean;
  90923. /**
  90924. * Gets or sets the radius of the emission cone
  90925. */
  90926. get radius(): number;
  90927. set radius(value: number);
  90928. /**
  90929. * Gets or sets the angle of the emission cone
  90930. */
  90931. get angle(): number;
  90932. set angle(value: number);
  90933. private _buildHeight;
  90934. /**
  90935. * Creates a new instance ConeParticleEmitter
  90936. * @param radius the radius of the emission cone (1 by default)
  90937. * @param angle the cone base angle (PI by default)
  90938. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90939. */
  90940. constructor(radius?: number, angle?: number,
  90941. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90942. directionRandomizer?: number);
  90943. /**
  90944. * Called by the particle System when the direction is computed for the created particle.
  90945. * @param worldMatrix is the world matrix of the particle system
  90946. * @param directionToUpdate is the direction vector to update with the result
  90947. * @param particle is the particle we are computed the direction for
  90948. * @param isLocal defines if the direction should be set in local space
  90949. */
  90950. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90951. /**
  90952. * Called by the particle System when the position is computed for the created particle.
  90953. * @param worldMatrix is the world matrix of the particle system
  90954. * @param positionToUpdate is the position vector to update with the result
  90955. * @param particle is the particle we are computed the position for
  90956. * @param isLocal defines if the position should be set in local space
  90957. */
  90958. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90959. /**
  90960. * Clones the current emitter and returns a copy of it
  90961. * @returns the new emitter
  90962. */
  90963. clone(): ConeParticleEmitter;
  90964. /**
  90965. * Called by the GPUParticleSystem to setup the update shader
  90966. * @param effect defines the update shader
  90967. */
  90968. applyToShader(effect: Effect): void;
  90969. /**
  90970. * Returns a string to use to update the GPU particles update shader
  90971. * @returns a string containng the defines string
  90972. */
  90973. getEffectDefines(): string;
  90974. /**
  90975. * Returns the string "ConeParticleEmitter"
  90976. * @returns a string containing the class name
  90977. */
  90978. getClassName(): string;
  90979. /**
  90980. * Serializes the particle system to a JSON object.
  90981. * @returns the JSON object
  90982. */
  90983. serialize(): any;
  90984. /**
  90985. * Parse properties from a JSON object
  90986. * @param serializationObject defines the JSON object
  90987. */
  90988. parse(serializationObject: any): void;
  90989. }
  90990. }
  90991. declare module BABYLON {
  90992. /**
  90993. * Particle emitter emitting particles from the inside of a cylinder.
  90994. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90995. */
  90996. export class CylinderParticleEmitter implements IParticleEmitterType {
  90997. /**
  90998. * The radius of the emission cylinder.
  90999. */
  91000. radius: number;
  91001. /**
  91002. * The height of the emission cylinder.
  91003. */
  91004. height: number;
  91005. /**
  91006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91007. */
  91008. radiusRange: number;
  91009. /**
  91010. * How much to randomize the particle direction [0-1].
  91011. */
  91012. directionRandomizer: number;
  91013. /**
  91014. * Creates a new instance CylinderParticleEmitter
  91015. * @param radius the radius of the emission cylinder (1 by default)
  91016. * @param height the height of the emission cylinder (1 by default)
  91017. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91018. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91019. */
  91020. constructor(
  91021. /**
  91022. * The radius of the emission cylinder.
  91023. */
  91024. radius?: number,
  91025. /**
  91026. * The height of the emission cylinder.
  91027. */
  91028. height?: number,
  91029. /**
  91030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91031. */
  91032. radiusRange?: number,
  91033. /**
  91034. * How much to randomize the particle direction [0-1].
  91035. */
  91036. directionRandomizer?: number);
  91037. /**
  91038. * Called by the particle System when the direction is computed for the created particle.
  91039. * @param worldMatrix is the world matrix of the particle system
  91040. * @param directionToUpdate is the direction vector to update with the result
  91041. * @param particle is the particle we are computed the direction for
  91042. * @param isLocal defines if the direction should be set in local space
  91043. */
  91044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91045. /**
  91046. * Called by the particle System when the position is computed for the created particle.
  91047. * @param worldMatrix is the world matrix of the particle system
  91048. * @param positionToUpdate is the position vector to update with the result
  91049. * @param particle is the particle we are computed the position for
  91050. * @param isLocal defines if the position should be set in local space
  91051. */
  91052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91053. /**
  91054. * Clones the current emitter and returns a copy of it
  91055. * @returns the new emitter
  91056. */
  91057. clone(): CylinderParticleEmitter;
  91058. /**
  91059. * Called by the GPUParticleSystem to setup the update shader
  91060. * @param effect defines the update shader
  91061. */
  91062. applyToShader(effect: Effect): void;
  91063. /**
  91064. * Returns a string to use to update the GPU particles update shader
  91065. * @returns a string containng the defines string
  91066. */
  91067. getEffectDefines(): string;
  91068. /**
  91069. * Returns the string "CylinderParticleEmitter"
  91070. * @returns a string containing the class name
  91071. */
  91072. getClassName(): string;
  91073. /**
  91074. * Serializes the particle system to a JSON object.
  91075. * @returns the JSON object
  91076. */
  91077. serialize(): any;
  91078. /**
  91079. * Parse properties from a JSON object
  91080. * @param serializationObject defines the JSON object
  91081. */
  91082. parse(serializationObject: any): void;
  91083. }
  91084. /**
  91085. * Particle emitter emitting particles from the inside of a cylinder.
  91086. * It emits the particles randomly between two vectors.
  91087. */
  91088. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91089. /**
  91090. * The min limit of the emission direction.
  91091. */
  91092. direction1: Vector3;
  91093. /**
  91094. * The max limit of the emission direction.
  91095. */
  91096. direction2: Vector3;
  91097. /**
  91098. * Creates a new instance CylinderDirectedParticleEmitter
  91099. * @param radius the radius of the emission cylinder (1 by default)
  91100. * @param height the height of the emission cylinder (1 by default)
  91101. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91102. * @param direction1 the min limit of the emission direction (up vector by default)
  91103. * @param direction2 the max limit of the emission direction (up vector by default)
  91104. */
  91105. constructor(radius?: number, height?: number, radiusRange?: number,
  91106. /**
  91107. * The min limit of the emission direction.
  91108. */
  91109. direction1?: Vector3,
  91110. /**
  91111. * The max limit of the emission direction.
  91112. */
  91113. direction2?: Vector3);
  91114. /**
  91115. * Called by the particle System when the direction is computed for the created particle.
  91116. * @param worldMatrix is the world matrix of the particle system
  91117. * @param directionToUpdate is the direction vector to update with the result
  91118. * @param particle is the particle we are computed the direction for
  91119. */
  91120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91121. /**
  91122. * Clones the current emitter and returns a copy of it
  91123. * @returns the new emitter
  91124. */
  91125. clone(): CylinderDirectedParticleEmitter;
  91126. /**
  91127. * Called by the GPUParticleSystem to setup the update shader
  91128. * @param effect defines the update shader
  91129. */
  91130. applyToShader(effect: Effect): void;
  91131. /**
  91132. * Returns a string to use to update the GPU particles update shader
  91133. * @returns a string containng the defines string
  91134. */
  91135. getEffectDefines(): string;
  91136. /**
  91137. * Returns the string "CylinderDirectedParticleEmitter"
  91138. * @returns a string containing the class name
  91139. */
  91140. getClassName(): string;
  91141. /**
  91142. * Serializes the particle system to a JSON object.
  91143. * @returns the JSON object
  91144. */
  91145. serialize(): any;
  91146. /**
  91147. * Parse properties from a JSON object
  91148. * @param serializationObject defines the JSON object
  91149. */
  91150. parse(serializationObject: any): void;
  91151. }
  91152. }
  91153. declare module BABYLON {
  91154. /**
  91155. * Particle emitter emitting particles from the inside of a hemisphere.
  91156. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91157. */
  91158. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91159. /**
  91160. * The radius of the emission hemisphere.
  91161. */
  91162. radius: number;
  91163. /**
  91164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91165. */
  91166. radiusRange: number;
  91167. /**
  91168. * How much to randomize the particle direction [0-1].
  91169. */
  91170. directionRandomizer: number;
  91171. /**
  91172. * Creates a new instance HemisphericParticleEmitter
  91173. * @param radius the radius of the emission hemisphere (1 by default)
  91174. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91175. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91176. */
  91177. constructor(
  91178. /**
  91179. * The radius of the emission hemisphere.
  91180. */
  91181. radius?: number,
  91182. /**
  91183. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91184. */
  91185. radiusRange?: number,
  91186. /**
  91187. * How much to randomize the particle direction [0-1].
  91188. */
  91189. directionRandomizer?: number);
  91190. /**
  91191. * Called by the particle System when the direction is computed for the created particle.
  91192. * @param worldMatrix is the world matrix of the particle system
  91193. * @param directionToUpdate is the direction vector to update with the result
  91194. * @param particle is the particle we are computed the direction for
  91195. * @param isLocal defines if the direction should be set in local space
  91196. */
  91197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91198. /**
  91199. * Called by the particle System when the position is computed for the created particle.
  91200. * @param worldMatrix is the world matrix of the particle system
  91201. * @param positionToUpdate is the position vector to update with the result
  91202. * @param particle is the particle we are computed the position for
  91203. * @param isLocal defines if the position should be set in local space
  91204. */
  91205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91206. /**
  91207. * Clones the current emitter and returns a copy of it
  91208. * @returns the new emitter
  91209. */
  91210. clone(): HemisphericParticleEmitter;
  91211. /**
  91212. * Called by the GPUParticleSystem to setup the update shader
  91213. * @param effect defines the update shader
  91214. */
  91215. applyToShader(effect: Effect): void;
  91216. /**
  91217. * Returns a string to use to update the GPU particles update shader
  91218. * @returns a string containng the defines string
  91219. */
  91220. getEffectDefines(): string;
  91221. /**
  91222. * Returns the string "HemisphericParticleEmitter"
  91223. * @returns a string containing the class name
  91224. */
  91225. getClassName(): string;
  91226. /**
  91227. * Serializes the particle system to a JSON object.
  91228. * @returns the JSON object
  91229. */
  91230. serialize(): any;
  91231. /**
  91232. * Parse properties from a JSON object
  91233. * @param serializationObject defines the JSON object
  91234. */
  91235. parse(serializationObject: any): void;
  91236. }
  91237. }
  91238. declare module BABYLON {
  91239. /**
  91240. * Particle emitter emitting particles from a point.
  91241. * It emits the particles randomly between 2 given directions.
  91242. */
  91243. export class PointParticleEmitter implements IParticleEmitterType {
  91244. /**
  91245. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91246. */
  91247. direction1: Vector3;
  91248. /**
  91249. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91250. */
  91251. direction2: Vector3;
  91252. /**
  91253. * Creates a new instance PointParticleEmitter
  91254. */
  91255. constructor();
  91256. /**
  91257. * Called by the particle System when the direction is computed for the created particle.
  91258. * @param worldMatrix is the world matrix of the particle system
  91259. * @param directionToUpdate is the direction vector to update with the result
  91260. * @param particle is the particle we are computed the direction for
  91261. * @param isLocal defines if the direction should be set in local space
  91262. */
  91263. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91264. /**
  91265. * Called by the particle System when the position is computed for the created particle.
  91266. * @param worldMatrix is the world matrix of the particle system
  91267. * @param positionToUpdate is the position vector to update with the result
  91268. * @param particle is the particle we are computed the position for
  91269. * @param isLocal defines if the position should be set in local space
  91270. */
  91271. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91272. /**
  91273. * Clones the current emitter and returns a copy of it
  91274. * @returns the new emitter
  91275. */
  91276. clone(): PointParticleEmitter;
  91277. /**
  91278. * Called by the GPUParticleSystem to setup the update shader
  91279. * @param effect defines the update shader
  91280. */
  91281. applyToShader(effect: Effect): void;
  91282. /**
  91283. * Returns a string to use to update the GPU particles update shader
  91284. * @returns a string containng the defines string
  91285. */
  91286. getEffectDefines(): string;
  91287. /**
  91288. * Returns the string "PointParticleEmitter"
  91289. * @returns a string containing the class name
  91290. */
  91291. getClassName(): string;
  91292. /**
  91293. * Serializes the particle system to a JSON object.
  91294. * @returns the JSON object
  91295. */
  91296. serialize(): any;
  91297. /**
  91298. * Parse properties from a JSON object
  91299. * @param serializationObject defines the JSON object
  91300. */
  91301. parse(serializationObject: any): void;
  91302. }
  91303. }
  91304. declare module BABYLON {
  91305. /**
  91306. * Particle emitter emitting particles from the inside of a sphere.
  91307. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91308. */
  91309. export class SphereParticleEmitter implements IParticleEmitterType {
  91310. /**
  91311. * The radius of the emission sphere.
  91312. */
  91313. radius: number;
  91314. /**
  91315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91316. */
  91317. radiusRange: number;
  91318. /**
  91319. * How much to randomize the particle direction [0-1].
  91320. */
  91321. directionRandomizer: number;
  91322. /**
  91323. * Creates a new instance SphereParticleEmitter
  91324. * @param radius the radius of the emission sphere (1 by default)
  91325. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91326. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91327. */
  91328. constructor(
  91329. /**
  91330. * The radius of the emission sphere.
  91331. */
  91332. radius?: number,
  91333. /**
  91334. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91335. */
  91336. radiusRange?: number,
  91337. /**
  91338. * How much to randomize the particle direction [0-1].
  91339. */
  91340. directionRandomizer?: number);
  91341. /**
  91342. * Called by the particle System when the direction is computed for the created particle.
  91343. * @param worldMatrix is the world matrix of the particle system
  91344. * @param directionToUpdate is the direction vector to update with the result
  91345. * @param particle is the particle we are computed the direction for
  91346. * @param isLocal defines if the direction should be set in local space
  91347. */
  91348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91349. /**
  91350. * Called by the particle System when the position is computed for the created particle.
  91351. * @param worldMatrix is the world matrix of the particle system
  91352. * @param positionToUpdate is the position vector to update with the result
  91353. * @param particle is the particle we are computed the position for
  91354. * @param isLocal defines if the position should be set in local space
  91355. */
  91356. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91357. /**
  91358. * Clones the current emitter and returns a copy of it
  91359. * @returns the new emitter
  91360. */
  91361. clone(): SphereParticleEmitter;
  91362. /**
  91363. * Called by the GPUParticleSystem to setup the update shader
  91364. * @param effect defines the update shader
  91365. */
  91366. applyToShader(effect: Effect): void;
  91367. /**
  91368. * Returns a string to use to update the GPU particles update shader
  91369. * @returns a string containng the defines string
  91370. */
  91371. getEffectDefines(): string;
  91372. /**
  91373. * Returns the string "SphereParticleEmitter"
  91374. * @returns a string containing the class name
  91375. */
  91376. getClassName(): string;
  91377. /**
  91378. * Serializes the particle system to a JSON object.
  91379. * @returns the JSON object
  91380. */
  91381. serialize(): any;
  91382. /**
  91383. * Parse properties from a JSON object
  91384. * @param serializationObject defines the JSON object
  91385. */
  91386. parse(serializationObject: any): void;
  91387. }
  91388. /**
  91389. * Particle emitter emitting particles from the inside of a sphere.
  91390. * It emits the particles randomly between two vectors.
  91391. */
  91392. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91393. /**
  91394. * The min limit of the emission direction.
  91395. */
  91396. direction1: Vector3;
  91397. /**
  91398. * The max limit of the emission direction.
  91399. */
  91400. direction2: Vector3;
  91401. /**
  91402. * Creates a new instance SphereDirectedParticleEmitter
  91403. * @param radius the radius of the emission sphere (1 by default)
  91404. * @param direction1 the min limit of the emission direction (up vector by default)
  91405. * @param direction2 the max limit of the emission direction (up vector by default)
  91406. */
  91407. constructor(radius?: number,
  91408. /**
  91409. * The min limit of the emission direction.
  91410. */
  91411. direction1?: Vector3,
  91412. /**
  91413. * The max limit of the emission direction.
  91414. */
  91415. direction2?: Vector3);
  91416. /**
  91417. * Called by the particle System when the direction is computed for the created particle.
  91418. * @param worldMatrix is the world matrix of the particle system
  91419. * @param directionToUpdate is the direction vector to update with the result
  91420. * @param particle is the particle we are computed the direction for
  91421. */
  91422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91423. /**
  91424. * Clones the current emitter and returns a copy of it
  91425. * @returns the new emitter
  91426. */
  91427. clone(): SphereDirectedParticleEmitter;
  91428. /**
  91429. * Called by the GPUParticleSystem to setup the update shader
  91430. * @param effect defines the update shader
  91431. */
  91432. applyToShader(effect: Effect): void;
  91433. /**
  91434. * Returns a string to use to update the GPU particles update shader
  91435. * @returns a string containng the defines string
  91436. */
  91437. getEffectDefines(): string;
  91438. /**
  91439. * Returns the string "SphereDirectedParticleEmitter"
  91440. * @returns a string containing the class name
  91441. */
  91442. getClassName(): string;
  91443. /**
  91444. * Serializes the particle system to a JSON object.
  91445. * @returns the JSON object
  91446. */
  91447. serialize(): any;
  91448. /**
  91449. * Parse properties from a JSON object
  91450. * @param serializationObject defines the JSON object
  91451. */
  91452. parse(serializationObject: any): void;
  91453. }
  91454. }
  91455. declare module BABYLON {
  91456. /**
  91457. * Particle emitter emitting particles from a custom list of positions.
  91458. */
  91459. export class CustomParticleEmitter implements IParticleEmitterType {
  91460. /**
  91461. * Gets or sets the position generator that will create the inital position of each particle.
  91462. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91463. */
  91464. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91465. /**
  91466. * Gets or sets the destination generator that will create the final destination of each particle.
  91467. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91468. */
  91469. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91470. /**
  91471. * Creates a new instance CustomParticleEmitter
  91472. */
  91473. constructor();
  91474. /**
  91475. * Called by the particle System when the direction is computed for the created particle.
  91476. * @param worldMatrix is the world matrix of the particle system
  91477. * @param directionToUpdate is the direction vector to update with the result
  91478. * @param particle is the particle we are computed the direction for
  91479. * @param isLocal defines if the direction should be set in local space
  91480. */
  91481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91482. /**
  91483. * Called by the particle System when the position is computed for the created particle.
  91484. * @param worldMatrix is the world matrix of the particle system
  91485. * @param positionToUpdate is the position vector to update with the result
  91486. * @param particle is the particle we are computed the position for
  91487. * @param isLocal defines if the position should be set in local space
  91488. */
  91489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91490. /**
  91491. * Clones the current emitter and returns a copy of it
  91492. * @returns the new emitter
  91493. */
  91494. clone(): CustomParticleEmitter;
  91495. /**
  91496. * Called by the GPUParticleSystem to setup the update shader
  91497. * @param effect defines the update shader
  91498. */
  91499. applyToShader(effect: Effect): void;
  91500. /**
  91501. * Returns a string to use to update the GPU particles update shader
  91502. * @returns a string containng the defines string
  91503. */
  91504. getEffectDefines(): string;
  91505. /**
  91506. * Returns the string "PointParticleEmitter"
  91507. * @returns a string containing the class name
  91508. */
  91509. getClassName(): string;
  91510. /**
  91511. * Serializes the particle system to a JSON object.
  91512. * @returns the JSON object
  91513. */
  91514. serialize(): any;
  91515. /**
  91516. * Parse properties from a JSON object
  91517. * @param serializationObject defines the JSON object
  91518. */
  91519. parse(serializationObject: any): void;
  91520. }
  91521. }
  91522. declare module BABYLON {
  91523. /**
  91524. * Particle emitter emitting particles from the inside of a box.
  91525. * It emits the particles randomly between 2 given directions.
  91526. */
  91527. export class MeshParticleEmitter implements IParticleEmitterType {
  91528. private _indices;
  91529. private _positions;
  91530. private _normals;
  91531. private _storedNormal;
  91532. private _mesh;
  91533. /**
  91534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91535. */
  91536. direction1: Vector3;
  91537. /**
  91538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91539. */
  91540. direction2: Vector3;
  91541. /**
  91542. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91543. */
  91544. useMeshNormalsForDirection: boolean;
  91545. /** Defines the mesh to use as source */
  91546. get mesh(): Nullable<AbstractMesh>;
  91547. set mesh(value: Nullable<AbstractMesh>);
  91548. /**
  91549. * Creates a new instance MeshParticleEmitter
  91550. * @param mesh defines the mesh to use as source
  91551. */
  91552. constructor(mesh?: Nullable<AbstractMesh>);
  91553. /**
  91554. * Called by the particle System when the direction is computed for the created particle.
  91555. * @param worldMatrix is the world matrix of the particle system
  91556. * @param directionToUpdate is the direction vector to update with the result
  91557. * @param particle is the particle we are computed the direction for
  91558. * @param isLocal defines if the direction should be set in local space
  91559. */
  91560. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91561. /**
  91562. * Called by the particle System when the position is computed for the created particle.
  91563. * @param worldMatrix is the world matrix of the particle system
  91564. * @param positionToUpdate is the position vector to update with the result
  91565. * @param particle is the particle we are computed the position for
  91566. * @param isLocal defines if the position should be set in local space
  91567. */
  91568. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91569. /**
  91570. * Clones the current emitter and returns a copy of it
  91571. * @returns the new emitter
  91572. */
  91573. clone(): MeshParticleEmitter;
  91574. /**
  91575. * Called by the GPUParticleSystem to setup the update shader
  91576. * @param effect defines the update shader
  91577. */
  91578. applyToShader(effect: Effect): void;
  91579. /**
  91580. * Returns a string to use to update the GPU particles update shader
  91581. * @returns a string containng the defines string
  91582. */
  91583. getEffectDefines(): string;
  91584. /**
  91585. * Returns the string "BoxParticleEmitter"
  91586. * @returns a string containing the class name
  91587. */
  91588. getClassName(): string;
  91589. /**
  91590. * Serializes the particle system to a JSON object.
  91591. * @returns the JSON object
  91592. */
  91593. serialize(): any;
  91594. /**
  91595. * Parse properties from a JSON object
  91596. * @param serializationObject defines the JSON object
  91597. * @param scene defines the hosting scene
  91598. */
  91599. parse(serializationObject: any, scene: Scene): void;
  91600. }
  91601. }
  91602. declare module BABYLON {
  91603. /**
  91604. * Interface representing a particle system in Babylon.js.
  91605. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91606. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91607. */
  91608. export interface IParticleSystem {
  91609. /**
  91610. * List of animations used by the particle system.
  91611. */
  91612. animations: Animation[];
  91613. /**
  91614. * The id of the Particle system.
  91615. */
  91616. id: string;
  91617. /**
  91618. * The name of the Particle system.
  91619. */
  91620. name: string;
  91621. /**
  91622. * The emitter represents the Mesh or position we are attaching the particle system to.
  91623. */
  91624. emitter: Nullable<AbstractMesh | Vector3>;
  91625. /**
  91626. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91627. */
  91628. isBillboardBased: boolean;
  91629. /**
  91630. * The rendering group used by the Particle system to chose when to render.
  91631. */
  91632. renderingGroupId: number;
  91633. /**
  91634. * The layer mask we are rendering the particles through.
  91635. */
  91636. layerMask: number;
  91637. /**
  91638. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91639. */
  91640. updateSpeed: number;
  91641. /**
  91642. * The amount of time the particle system is running (depends of the overall update speed).
  91643. */
  91644. targetStopDuration: number;
  91645. /**
  91646. * The texture used to render each particle. (this can be a spritesheet)
  91647. */
  91648. particleTexture: Nullable<Texture>;
  91649. /**
  91650. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91651. */
  91652. blendMode: number;
  91653. /**
  91654. * Minimum life time of emitting particles.
  91655. */
  91656. minLifeTime: number;
  91657. /**
  91658. * Maximum life time of emitting particles.
  91659. */
  91660. maxLifeTime: number;
  91661. /**
  91662. * Minimum Size of emitting particles.
  91663. */
  91664. minSize: number;
  91665. /**
  91666. * Maximum Size of emitting particles.
  91667. */
  91668. maxSize: number;
  91669. /**
  91670. * Minimum scale of emitting particles on X axis.
  91671. */
  91672. minScaleX: number;
  91673. /**
  91674. * Maximum scale of emitting particles on X axis.
  91675. */
  91676. maxScaleX: number;
  91677. /**
  91678. * Minimum scale of emitting particles on Y axis.
  91679. */
  91680. minScaleY: number;
  91681. /**
  91682. * Maximum scale of emitting particles on Y axis.
  91683. */
  91684. maxScaleY: number;
  91685. /**
  91686. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91687. */
  91688. color1: Color4;
  91689. /**
  91690. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91691. */
  91692. color2: Color4;
  91693. /**
  91694. * Color the particle will have at the end of its lifetime.
  91695. */
  91696. colorDead: Color4;
  91697. /**
  91698. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91699. */
  91700. emitRate: number;
  91701. /**
  91702. * You can use gravity if you want to give an orientation to your particles.
  91703. */
  91704. gravity: Vector3;
  91705. /**
  91706. * Minimum power of emitting particles.
  91707. */
  91708. minEmitPower: number;
  91709. /**
  91710. * Maximum power of emitting particles.
  91711. */
  91712. maxEmitPower: number;
  91713. /**
  91714. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91715. */
  91716. minAngularSpeed: number;
  91717. /**
  91718. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91719. */
  91720. maxAngularSpeed: number;
  91721. /**
  91722. * Gets or sets the minimal initial rotation in radians.
  91723. */
  91724. minInitialRotation: number;
  91725. /**
  91726. * Gets or sets the maximal initial rotation in radians.
  91727. */
  91728. maxInitialRotation: number;
  91729. /**
  91730. * The particle emitter type defines the emitter used by the particle system.
  91731. * It can be for example box, sphere, or cone...
  91732. */
  91733. particleEmitterType: Nullable<IParticleEmitterType>;
  91734. /**
  91735. * Defines the delay in milliseconds before starting the system (0 by default)
  91736. */
  91737. startDelay: number;
  91738. /**
  91739. * 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
  91740. */
  91741. preWarmCycles: number;
  91742. /**
  91743. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91744. */
  91745. preWarmStepOffset: number;
  91746. /**
  91747. * 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)
  91748. */
  91749. spriteCellChangeSpeed: number;
  91750. /**
  91751. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91752. */
  91753. startSpriteCellID: number;
  91754. /**
  91755. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91756. */
  91757. endSpriteCellID: number;
  91758. /**
  91759. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91760. */
  91761. spriteCellWidth: number;
  91762. /**
  91763. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91764. */
  91765. spriteCellHeight: number;
  91766. /**
  91767. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91768. */
  91769. spriteRandomStartCell: boolean;
  91770. /**
  91771. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91772. */
  91773. isAnimationSheetEnabled: boolean;
  91774. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91775. translationPivot: Vector2;
  91776. /**
  91777. * Gets or sets a texture used to add random noise to particle positions
  91778. */
  91779. noiseTexture: Nullable<BaseTexture>;
  91780. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91781. noiseStrength: Vector3;
  91782. /**
  91783. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91784. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91785. */
  91786. billboardMode: number;
  91787. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91788. limitVelocityDamping: number;
  91789. /**
  91790. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91791. */
  91792. beginAnimationOnStart: boolean;
  91793. /**
  91794. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91795. */
  91796. beginAnimationFrom: number;
  91797. /**
  91798. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91799. */
  91800. beginAnimationTo: number;
  91801. /**
  91802. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91803. */
  91804. beginAnimationLoop: boolean;
  91805. /**
  91806. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91807. */
  91808. disposeOnStop: boolean;
  91809. /**
  91810. * Specifies if the particles are updated in emitter local space or world space
  91811. */
  91812. isLocal: boolean;
  91813. /** Snippet ID if the particle system was created from the snippet server */
  91814. snippetId: string;
  91815. /**
  91816. * Gets the maximum number of particles active at the same time.
  91817. * @returns The max number of active particles.
  91818. */
  91819. getCapacity(): number;
  91820. /**
  91821. * Gets the number of particles active at the same time.
  91822. * @returns The number of active particles.
  91823. */
  91824. getActiveCount(): number;
  91825. /**
  91826. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91827. * @returns True if it has been started, otherwise false.
  91828. */
  91829. isStarted(): boolean;
  91830. /**
  91831. * Animates the particle system for this frame.
  91832. */
  91833. animate(): void;
  91834. /**
  91835. * Renders the particle system in its current state.
  91836. * @returns the current number of particles
  91837. */
  91838. render(): number;
  91839. /**
  91840. * Dispose the particle system and frees its associated resources.
  91841. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91842. */
  91843. dispose(disposeTexture?: boolean): void;
  91844. /**
  91845. * An event triggered when the system is disposed
  91846. */
  91847. onDisposeObservable: Observable<IParticleSystem>;
  91848. /**
  91849. * Clones the particle system.
  91850. * @param name The name of the cloned object
  91851. * @param newEmitter The new emitter to use
  91852. * @returns the cloned particle system
  91853. */
  91854. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91855. /**
  91856. * Serializes the particle system to a JSON object
  91857. * @param serializeTexture defines if the texture must be serialized as well
  91858. * @returns the JSON object
  91859. */
  91860. serialize(serializeTexture: boolean): any;
  91861. /**
  91862. * Rebuild the particle system
  91863. */
  91864. rebuild(): void;
  91865. /** Force the system to rebuild all gradients that need to be resync */
  91866. forceRefreshGradients(): void;
  91867. /**
  91868. * Starts the particle system and begins to emit
  91869. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91870. */
  91871. start(delay?: number): void;
  91872. /**
  91873. * Stops the particle system.
  91874. */
  91875. stop(): void;
  91876. /**
  91877. * Remove all active particles
  91878. */
  91879. reset(): void;
  91880. /**
  91881. * Gets a boolean indicating that the system is stopping
  91882. * @returns true if the system is currently stopping
  91883. */
  91884. isStopping(): boolean;
  91885. /**
  91886. * Is this system ready to be used/rendered
  91887. * @return true if the system is ready
  91888. */
  91889. isReady(): boolean;
  91890. /**
  91891. * Returns the string "ParticleSystem"
  91892. * @returns a string containing the class name
  91893. */
  91894. getClassName(): string;
  91895. /**
  91896. * Gets the custom effect used to render the particles
  91897. * @param blendMode Blend mode for which the effect should be retrieved
  91898. * @returns The effect
  91899. */
  91900. getCustomEffect(blendMode: number): Nullable<Effect>;
  91901. /**
  91902. * Sets the custom effect used to render the particles
  91903. * @param effect The effect to set
  91904. * @param blendMode Blend mode for which the effect should be set
  91905. */
  91906. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91907. /**
  91908. * Fill the defines array according to the current settings of the particle system
  91909. * @param defines Array to be updated
  91910. * @param blendMode blend mode to take into account when updating the array
  91911. */
  91912. fillDefines(defines: Array<string>, blendMode: number): void;
  91913. /**
  91914. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91915. * @param uniforms Uniforms array to fill
  91916. * @param attributes Attributes array to fill
  91917. * @param samplers Samplers array to fill
  91918. */
  91919. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91920. /**
  91921. * Observable that will be called just before the particles are drawn
  91922. */
  91923. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91924. /**
  91925. * Gets the name of the particle vertex shader
  91926. */
  91927. vertexShaderName: string;
  91928. /**
  91929. * Adds a new color gradient
  91930. * @param gradient defines the gradient to use (between 0 and 1)
  91931. * @param color1 defines the color to affect to the specified gradient
  91932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91933. * @returns the current particle system
  91934. */
  91935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91936. /**
  91937. * Remove a specific color gradient
  91938. * @param gradient defines the gradient to remove
  91939. * @returns the current particle system
  91940. */
  91941. removeColorGradient(gradient: number): IParticleSystem;
  91942. /**
  91943. * Adds a new size gradient
  91944. * @param gradient defines the gradient to use (between 0 and 1)
  91945. * @param factor defines the size factor to affect to the specified gradient
  91946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91947. * @returns the current particle system
  91948. */
  91949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91950. /**
  91951. * Remove a specific size gradient
  91952. * @param gradient defines the gradient to remove
  91953. * @returns the current particle system
  91954. */
  91955. removeSizeGradient(gradient: number): IParticleSystem;
  91956. /**
  91957. * Gets the current list of color gradients.
  91958. * You must use addColorGradient and removeColorGradient to udpate this list
  91959. * @returns the list of color gradients
  91960. */
  91961. getColorGradients(): Nullable<Array<ColorGradient>>;
  91962. /**
  91963. * Gets the current list of size gradients.
  91964. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91965. * @returns the list of size gradients
  91966. */
  91967. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91968. /**
  91969. * Gets the current list of angular speed gradients.
  91970. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91971. * @returns the list of angular speed gradients
  91972. */
  91973. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91974. /**
  91975. * Adds a new angular speed gradient
  91976. * @param gradient defines the gradient to use (between 0 and 1)
  91977. * @param factor defines the angular speed to affect to the specified gradient
  91978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91979. * @returns the current particle system
  91980. */
  91981. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91982. /**
  91983. * Remove a specific angular speed gradient
  91984. * @param gradient defines the gradient to remove
  91985. * @returns the current particle system
  91986. */
  91987. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91988. /**
  91989. * Gets the current list of velocity gradients.
  91990. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91991. * @returns the list of velocity gradients
  91992. */
  91993. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91994. /**
  91995. * Adds a new velocity gradient
  91996. * @param gradient defines the gradient to use (between 0 and 1)
  91997. * @param factor defines the velocity to affect to the specified gradient
  91998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91999. * @returns the current particle system
  92000. */
  92001. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92002. /**
  92003. * Remove a specific velocity gradient
  92004. * @param gradient defines the gradient to remove
  92005. * @returns the current particle system
  92006. */
  92007. removeVelocityGradient(gradient: number): IParticleSystem;
  92008. /**
  92009. * Gets the current list of limit velocity gradients.
  92010. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92011. * @returns the list of limit velocity gradients
  92012. */
  92013. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92014. /**
  92015. * Adds a new limit velocity gradient
  92016. * @param gradient defines the gradient to use (between 0 and 1)
  92017. * @param factor defines the limit velocity to affect to the specified gradient
  92018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92019. * @returns the current particle system
  92020. */
  92021. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92022. /**
  92023. * Remove a specific limit velocity gradient
  92024. * @param gradient defines the gradient to remove
  92025. * @returns the current particle system
  92026. */
  92027. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92028. /**
  92029. * Adds a new drag gradient
  92030. * @param gradient defines the gradient to use (between 0 and 1)
  92031. * @param factor defines the drag to affect to the specified gradient
  92032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92033. * @returns the current particle system
  92034. */
  92035. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92036. /**
  92037. * Remove a specific drag gradient
  92038. * @param gradient defines the gradient to remove
  92039. * @returns the current particle system
  92040. */
  92041. removeDragGradient(gradient: number): IParticleSystem;
  92042. /**
  92043. * Gets the current list of drag gradients.
  92044. * You must use addDragGradient and removeDragGradient to udpate this list
  92045. * @returns the list of drag gradients
  92046. */
  92047. getDragGradients(): Nullable<Array<FactorGradient>>;
  92048. /**
  92049. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92050. * @param gradient defines the gradient to use (between 0 and 1)
  92051. * @param factor defines the emit rate to affect to the specified gradient
  92052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92053. * @returns the current particle system
  92054. */
  92055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92056. /**
  92057. * Remove a specific emit rate gradient
  92058. * @param gradient defines the gradient to remove
  92059. * @returns the current particle system
  92060. */
  92061. removeEmitRateGradient(gradient: number): IParticleSystem;
  92062. /**
  92063. * Gets the current list of emit rate gradients.
  92064. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92065. * @returns the list of emit rate gradients
  92066. */
  92067. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92068. /**
  92069. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92070. * @param gradient defines the gradient to use (between 0 and 1)
  92071. * @param factor defines the start size to affect to the specified gradient
  92072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92073. * @returns the current particle system
  92074. */
  92075. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92076. /**
  92077. * Remove a specific start size gradient
  92078. * @param gradient defines the gradient to remove
  92079. * @returns the current particle system
  92080. */
  92081. removeStartSizeGradient(gradient: number): IParticleSystem;
  92082. /**
  92083. * Gets the current list of start size gradients.
  92084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92085. * @returns the list of start size gradients
  92086. */
  92087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92088. /**
  92089. * Adds a new life time gradient
  92090. * @param gradient defines the gradient to use (between 0 and 1)
  92091. * @param factor defines the life time factor to affect to the specified gradient
  92092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92093. * @returns the current particle system
  92094. */
  92095. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92096. /**
  92097. * Remove a specific life time gradient
  92098. * @param gradient defines the gradient to remove
  92099. * @returns the current particle system
  92100. */
  92101. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92102. /**
  92103. * Gets the current list of life time gradients.
  92104. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92105. * @returns the list of life time gradients
  92106. */
  92107. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92108. /**
  92109. * Gets the current list of color gradients.
  92110. * You must use addColorGradient and removeColorGradient to udpate this list
  92111. * @returns the list of color gradients
  92112. */
  92113. getColorGradients(): Nullable<Array<ColorGradient>>;
  92114. /**
  92115. * Adds a new ramp gradient used to remap particle colors
  92116. * @param gradient defines the gradient to use (between 0 and 1)
  92117. * @param color defines the color to affect to the specified gradient
  92118. * @returns the current particle system
  92119. */
  92120. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92121. /**
  92122. * Gets the current list of ramp gradients.
  92123. * You must use addRampGradient and removeRampGradient to udpate this list
  92124. * @returns the list of ramp gradients
  92125. */
  92126. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92127. /** Gets or sets a boolean indicating that ramp gradients must be used
  92128. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92129. */
  92130. useRampGradients: boolean;
  92131. /**
  92132. * Adds a new color remap gradient
  92133. * @param gradient defines the gradient to use (between 0 and 1)
  92134. * @param min defines the color remap minimal range
  92135. * @param max defines the color remap maximal range
  92136. * @returns the current particle system
  92137. */
  92138. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92139. /**
  92140. * Gets the current list of color remap gradients.
  92141. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92142. * @returns the list of color remap gradients
  92143. */
  92144. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92145. /**
  92146. * Adds a new alpha remap gradient
  92147. * @param gradient defines the gradient to use (between 0 and 1)
  92148. * @param min defines the alpha remap minimal range
  92149. * @param max defines the alpha remap maximal range
  92150. * @returns the current particle system
  92151. */
  92152. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92153. /**
  92154. * Gets the current list of alpha remap gradients.
  92155. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92156. * @returns the list of alpha remap gradients
  92157. */
  92158. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92159. /**
  92160. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92163. * @returns the emitter
  92164. */
  92165. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92166. /**
  92167. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92168. * @param radius The radius of the hemisphere to emit from
  92169. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92170. * @returns the emitter
  92171. */
  92172. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92173. /**
  92174. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92175. * @param radius The radius of the sphere to emit from
  92176. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92177. * @returns the emitter
  92178. */
  92179. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92180. /**
  92181. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92182. * @param radius The radius of the sphere to emit from
  92183. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92184. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92185. * @returns the emitter
  92186. */
  92187. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92188. /**
  92189. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92190. * @param radius The radius of the emission cylinder
  92191. * @param height The height of the emission cylinder
  92192. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92193. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92194. * @returns the emitter
  92195. */
  92196. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92197. /**
  92198. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92199. * @param radius The radius of the cylinder to emit from
  92200. * @param height The height of the emission cylinder
  92201. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92202. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92203. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92204. * @returns the emitter
  92205. */
  92206. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92207. /**
  92208. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92209. * @param radius The radius of the cone to emit from
  92210. * @param angle The base angle of the cone
  92211. * @returns the emitter
  92212. */
  92213. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92214. /**
  92215. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92216. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92217. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92218. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92219. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92220. * @returns the emitter
  92221. */
  92222. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92223. /**
  92224. * Get hosting scene
  92225. * @returns the scene
  92226. */
  92227. getScene(): Scene;
  92228. }
  92229. }
  92230. declare module BABYLON {
  92231. /**
  92232. * 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.
  92233. * @see https://doc.babylonjs.com/how_to/transformnode
  92234. */
  92235. export class TransformNode extends Node {
  92236. /**
  92237. * Object will not rotate to face the camera
  92238. */
  92239. static BILLBOARDMODE_NONE: number;
  92240. /**
  92241. * Object will rotate to face the camera but only on the x axis
  92242. */
  92243. static BILLBOARDMODE_X: number;
  92244. /**
  92245. * Object will rotate to face the camera but only on the y axis
  92246. */
  92247. static BILLBOARDMODE_Y: number;
  92248. /**
  92249. * Object will rotate to face the camera but only on the z axis
  92250. */
  92251. static BILLBOARDMODE_Z: number;
  92252. /**
  92253. * Object will rotate to face the camera
  92254. */
  92255. static BILLBOARDMODE_ALL: number;
  92256. /**
  92257. * Object will rotate to face the camera's position instead of orientation
  92258. */
  92259. static BILLBOARDMODE_USE_POSITION: number;
  92260. private _forward;
  92261. private _forwardInverted;
  92262. private _up;
  92263. private _right;
  92264. private _rightInverted;
  92265. private _position;
  92266. private _rotation;
  92267. private _rotationQuaternion;
  92268. protected _scaling: Vector3;
  92269. protected _isDirty: boolean;
  92270. private _transformToBoneReferal;
  92271. private _isAbsoluteSynced;
  92272. private _billboardMode;
  92273. /**
  92274. * Gets or sets the billboard mode. Default is 0.
  92275. *
  92276. * | Value | Type | Description |
  92277. * | --- | --- | --- |
  92278. * | 0 | BILLBOARDMODE_NONE | |
  92279. * | 1 | BILLBOARDMODE_X | |
  92280. * | 2 | BILLBOARDMODE_Y | |
  92281. * | 4 | BILLBOARDMODE_Z | |
  92282. * | 7 | BILLBOARDMODE_ALL | |
  92283. *
  92284. */
  92285. get billboardMode(): number;
  92286. set billboardMode(value: number);
  92287. private _preserveParentRotationForBillboard;
  92288. /**
  92289. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92290. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92291. */
  92292. get preserveParentRotationForBillboard(): boolean;
  92293. set preserveParentRotationForBillboard(value: boolean);
  92294. /**
  92295. * 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
  92296. */
  92297. scalingDeterminant: number;
  92298. private _infiniteDistance;
  92299. /**
  92300. * Gets or sets the distance of the object to max, often used by skybox
  92301. */
  92302. get infiniteDistance(): boolean;
  92303. set infiniteDistance(value: boolean);
  92304. /**
  92305. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92306. * By default the system will update normals to compensate
  92307. */
  92308. ignoreNonUniformScaling: boolean;
  92309. /**
  92310. * 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
  92311. */
  92312. reIntegrateRotationIntoRotationQuaternion: boolean;
  92313. /** @hidden */
  92314. _poseMatrix: Nullable<Matrix>;
  92315. /** @hidden */
  92316. _localMatrix: Matrix;
  92317. private _usePivotMatrix;
  92318. private _absolutePosition;
  92319. private _absoluteScaling;
  92320. private _absoluteRotationQuaternion;
  92321. private _pivotMatrix;
  92322. private _pivotMatrixInverse;
  92323. protected _postMultiplyPivotMatrix: boolean;
  92324. protected _isWorldMatrixFrozen: boolean;
  92325. /** @hidden */
  92326. _indexInSceneTransformNodesArray: number;
  92327. /**
  92328. * An event triggered after the world matrix is updated
  92329. */
  92330. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92331. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92332. /**
  92333. * Gets a string identifying the name of the class
  92334. * @returns "TransformNode" string
  92335. */
  92336. getClassName(): string;
  92337. /**
  92338. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92339. */
  92340. get position(): Vector3;
  92341. set position(newPosition: Vector3);
  92342. /**
  92343. * 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)).
  92344. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92345. */
  92346. get rotation(): Vector3;
  92347. set rotation(newRotation: Vector3);
  92348. /**
  92349. * 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)).
  92350. */
  92351. get scaling(): Vector3;
  92352. set scaling(newScaling: Vector3);
  92353. /**
  92354. * 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).
  92355. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92356. */
  92357. get rotationQuaternion(): Nullable<Quaternion>;
  92358. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92359. /**
  92360. * The forward direction of that transform in world space.
  92361. */
  92362. get forward(): Vector3;
  92363. /**
  92364. * The up direction of that transform in world space.
  92365. */
  92366. get up(): Vector3;
  92367. /**
  92368. * The right direction of that transform in world space.
  92369. */
  92370. get right(): Vector3;
  92371. /**
  92372. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92373. * @param matrix the matrix to copy the pose from
  92374. * @returns this TransformNode.
  92375. */
  92376. updatePoseMatrix(matrix: Matrix): TransformNode;
  92377. /**
  92378. * Returns the mesh Pose matrix.
  92379. * @returns the pose matrix
  92380. */
  92381. getPoseMatrix(): Matrix;
  92382. /** @hidden */
  92383. _isSynchronized(): boolean;
  92384. /** @hidden */
  92385. _initCache(): void;
  92386. /**
  92387. * Flag the transform node as dirty (Forcing it to update everything)
  92388. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92389. * @returns this transform node
  92390. */
  92391. markAsDirty(property: string): TransformNode;
  92392. /**
  92393. * Returns the current mesh absolute position.
  92394. * Returns a Vector3.
  92395. */
  92396. get absolutePosition(): Vector3;
  92397. /**
  92398. * Returns the current mesh absolute scaling.
  92399. * Returns a Vector3.
  92400. */
  92401. get absoluteScaling(): Vector3;
  92402. /**
  92403. * Returns the current mesh absolute rotation.
  92404. * Returns a Quaternion.
  92405. */
  92406. get absoluteRotationQuaternion(): Quaternion;
  92407. /**
  92408. * Sets a new matrix to apply before all other transformation
  92409. * @param matrix defines the transform matrix
  92410. * @returns the current TransformNode
  92411. */
  92412. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92413. /**
  92414. * Sets a new pivot matrix to the current node
  92415. * @param matrix defines the new pivot matrix to use
  92416. * @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
  92417. * @returns the current TransformNode
  92418. */
  92419. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92420. /**
  92421. * Returns the mesh pivot matrix.
  92422. * Default : Identity.
  92423. * @returns the matrix
  92424. */
  92425. getPivotMatrix(): Matrix;
  92426. /**
  92427. * Instantiate (when possible) or clone that node with its hierarchy
  92428. * @param newParent defines the new parent to use for the instance (or clone)
  92429. * @param options defines options to configure how copy is done
  92430. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92431. * @returns an instance (or a clone) of the current node with its hiearchy
  92432. */
  92433. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92434. doNotInstantiate: boolean;
  92435. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92436. /**
  92437. * Prevents the World matrix to be computed any longer
  92438. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92439. * @returns the TransformNode.
  92440. */
  92441. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92442. /**
  92443. * Allows back the World matrix computation.
  92444. * @returns the TransformNode.
  92445. */
  92446. unfreezeWorldMatrix(): this;
  92447. /**
  92448. * True if the World matrix has been frozen.
  92449. */
  92450. get isWorldMatrixFrozen(): boolean;
  92451. /**
  92452. * Retuns the mesh absolute position in the World.
  92453. * @returns a Vector3.
  92454. */
  92455. getAbsolutePosition(): Vector3;
  92456. /**
  92457. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92458. * @param absolutePosition the absolute position to set
  92459. * @returns the TransformNode.
  92460. */
  92461. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92462. /**
  92463. * Sets the mesh position in its local space.
  92464. * @param vector3 the position to set in localspace
  92465. * @returns the TransformNode.
  92466. */
  92467. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92468. /**
  92469. * Returns the mesh position in the local space from the current World matrix values.
  92470. * @returns a new Vector3.
  92471. */
  92472. getPositionExpressedInLocalSpace(): Vector3;
  92473. /**
  92474. * Translates the mesh along the passed Vector3 in its local space.
  92475. * @param vector3 the distance to translate in localspace
  92476. * @returns the TransformNode.
  92477. */
  92478. locallyTranslate(vector3: Vector3): TransformNode;
  92479. private static _lookAtVectorCache;
  92480. /**
  92481. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92482. * @param targetPoint the position (must be in same space as current mesh) to look at
  92483. * @param yawCor optional yaw (y-axis) correction in radians
  92484. * @param pitchCor optional pitch (x-axis) correction in radians
  92485. * @param rollCor optional roll (z-axis) correction in radians
  92486. * @param space the choosen space of the target
  92487. * @returns the TransformNode.
  92488. */
  92489. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92490. /**
  92491. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92492. * This Vector3 is expressed in the World space.
  92493. * @param localAxis axis to rotate
  92494. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92495. */
  92496. getDirection(localAxis: Vector3): Vector3;
  92497. /**
  92498. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92499. * localAxis is expressed in the mesh local space.
  92500. * result is computed in the Wordl space from the mesh World matrix.
  92501. * @param localAxis axis to rotate
  92502. * @param result the resulting transformnode
  92503. * @returns this TransformNode.
  92504. */
  92505. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92506. /**
  92507. * Sets this transform node rotation to the given local axis.
  92508. * @param localAxis the axis in local space
  92509. * @param yawCor optional yaw (y-axis) correction in radians
  92510. * @param pitchCor optional pitch (x-axis) correction in radians
  92511. * @param rollCor optional roll (z-axis) correction in radians
  92512. * @returns this TransformNode
  92513. */
  92514. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92515. /**
  92516. * Sets a new pivot point to the current node
  92517. * @param point defines the new pivot point to use
  92518. * @param space defines if the point is in world or local space (local by default)
  92519. * @returns the current TransformNode
  92520. */
  92521. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92522. /**
  92523. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92524. * @returns the pivot point
  92525. */
  92526. getPivotPoint(): Vector3;
  92527. /**
  92528. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92529. * @param result the vector3 to store the result
  92530. * @returns this TransformNode.
  92531. */
  92532. getPivotPointToRef(result: Vector3): TransformNode;
  92533. /**
  92534. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92535. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92536. */
  92537. getAbsolutePivotPoint(): Vector3;
  92538. /**
  92539. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92540. * @param result vector3 to store the result
  92541. * @returns this TransformNode.
  92542. */
  92543. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92544. /**
  92545. * Defines the passed node as the parent of the current node.
  92546. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92547. * @see https://doc.babylonjs.com/how_to/parenting
  92548. * @param node the node ot set as the parent
  92549. * @returns this TransformNode.
  92550. */
  92551. setParent(node: Nullable<Node>): TransformNode;
  92552. private _nonUniformScaling;
  92553. /**
  92554. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92555. */
  92556. get nonUniformScaling(): boolean;
  92557. /** @hidden */
  92558. _updateNonUniformScalingState(value: boolean): boolean;
  92559. /**
  92560. * Attach the current TransformNode to another TransformNode associated with a bone
  92561. * @param bone Bone affecting the TransformNode
  92562. * @param affectedTransformNode TransformNode associated with the bone
  92563. * @returns this object
  92564. */
  92565. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92566. /**
  92567. * Detach the transform node if its associated with a bone
  92568. * @returns this object
  92569. */
  92570. detachFromBone(): TransformNode;
  92571. private static _rotationAxisCache;
  92572. /**
  92573. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92574. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92575. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92576. * The passed axis is also normalized.
  92577. * @param axis the axis to rotate around
  92578. * @param amount the amount to rotate in radians
  92579. * @param space Space to rotate in (Default: local)
  92580. * @returns the TransformNode.
  92581. */
  92582. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92583. /**
  92584. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92585. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92586. * The passed axis is also normalized. .
  92587. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92588. * @param point the point to rotate around
  92589. * @param axis the axis to rotate around
  92590. * @param amount the amount to rotate in radians
  92591. * @returns the TransformNode
  92592. */
  92593. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92594. /**
  92595. * Translates the mesh along the axis vector for the passed distance in the given space.
  92596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92597. * @param axis the axis to translate in
  92598. * @param distance the distance to translate
  92599. * @param space Space to rotate in (Default: local)
  92600. * @returns the TransformNode.
  92601. */
  92602. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92603. /**
  92604. * Adds a rotation step to the mesh current rotation.
  92605. * x, y, z are Euler angles expressed in radians.
  92606. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92607. * This means this rotation is made in the mesh local space only.
  92608. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92609. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92610. * ```javascript
  92611. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92612. * ```
  92613. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92614. * 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.
  92615. * @param x Rotation to add
  92616. * @param y Rotation to add
  92617. * @param z Rotation to add
  92618. * @returns the TransformNode.
  92619. */
  92620. addRotation(x: number, y: number, z: number): TransformNode;
  92621. /**
  92622. * @hidden
  92623. */
  92624. protected _getEffectiveParent(): Nullable<Node>;
  92625. /**
  92626. * Computes the world matrix of the node
  92627. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92628. * @returns the world matrix
  92629. */
  92630. computeWorldMatrix(force?: boolean): Matrix;
  92631. /**
  92632. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92633. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92634. */
  92635. resetLocalMatrix(independentOfChildren?: boolean): void;
  92636. protected _afterComputeWorldMatrix(): void;
  92637. /**
  92638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92639. * @param func callback function to add
  92640. *
  92641. * @returns the TransformNode.
  92642. */
  92643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92644. /**
  92645. * Removes a registered callback function.
  92646. * @param func callback function to remove
  92647. * @returns the TransformNode.
  92648. */
  92649. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92650. /**
  92651. * Gets the position of the current mesh in camera space
  92652. * @param camera defines the camera to use
  92653. * @returns a position
  92654. */
  92655. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92656. /**
  92657. * Returns the distance from the mesh to the active camera
  92658. * @param camera defines the camera to use
  92659. * @returns the distance
  92660. */
  92661. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92662. /**
  92663. * Clone the current transform node
  92664. * @param name Name of the new clone
  92665. * @param newParent New parent for the clone
  92666. * @param doNotCloneChildren Do not clone children hierarchy
  92667. * @returns the new transform node
  92668. */
  92669. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92670. /**
  92671. * Serializes the objects information.
  92672. * @param currentSerializationObject defines the object to serialize in
  92673. * @returns the serialized object
  92674. */
  92675. serialize(currentSerializationObject?: any): any;
  92676. /**
  92677. * Returns a new TransformNode object parsed from the source provided.
  92678. * @param parsedTransformNode is the source.
  92679. * @param scene the scne the object belongs to
  92680. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92681. * @returns a new TransformNode object parsed from the source provided.
  92682. */
  92683. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92684. /**
  92685. * Get all child-transformNodes of this node
  92686. * @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
  92687. * @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
  92688. * @returns an array of TransformNode
  92689. */
  92690. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92691. /**
  92692. * Releases resources associated with this transform node.
  92693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92695. */
  92696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92697. /**
  92698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92702. * @returns the current mesh
  92703. */
  92704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92705. private _syncAbsoluteScalingAndRotation;
  92706. }
  92707. }
  92708. declare module BABYLON {
  92709. /**
  92710. * Class used to override all child animations of a given target
  92711. */
  92712. export class AnimationPropertiesOverride {
  92713. /**
  92714. * Gets or sets a value indicating if animation blending must be used
  92715. */
  92716. enableBlending: boolean;
  92717. /**
  92718. * Gets or sets the blending speed to use when enableBlending is true
  92719. */
  92720. blendingSpeed: number;
  92721. /**
  92722. * Gets or sets the default loop mode to use
  92723. */
  92724. loopMode: number;
  92725. }
  92726. }
  92727. declare module BABYLON {
  92728. /**
  92729. * Class used to store bone information
  92730. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92731. */
  92732. export class Bone extends Node {
  92733. /**
  92734. * defines the bone name
  92735. */
  92736. name: string;
  92737. private static _tmpVecs;
  92738. private static _tmpQuat;
  92739. private static _tmpMats;
  92740. /**
  92741. * Gets the list of child bones
  92742. */
  92743. children: Bone[];
  92744. /** Gets the animations associated with this bone */
  92745. animations: Animation[];
  92746. /**
  92747. * Gets or sets bone length
  92748. */
  92749. length: number;
  92750. /**
  92751. * @hidden Internal only
  92752. * Set this value to map this bone to a different index in the transform matrices
  92753. * Set this value to -1 to exclude the bone from the transform matrices
  92754. */
  92755. _index: Nullable<number>;
  92756. private _skeleton;
  92757. private _localMatrix;
  92758. private _restPose;
  92759. private _baseMatrix;
  92760. private _absoluteTransform;
  92761. private _invertedAbsoluteTransform;
  92762. private _parent;
  92763. private _scalingDeterminant;
  92764. private _worldTransform;
  92765. private _localScaling;
  92766. private _localRotation;
  92767. private _localPosition;
  92768. private _needToDecompose;
  92769. private _needToCompose;
  92770. /** @hidden */
  92771. _linkedTransformNode: Nullable<TransformNode>;
  92772. /** @hidden */
  92773. _waitingTransformNodeId: Nullable<string>;
  92774. /** @hidden */
  92775. get _matrix(): Matrix;
  92776. /** @hidden */
  92777. set _matrix(value: Matrix);
  92778. /**
  92779. * Create a new bone
  92780. * @param name defines the bone name
  92781. * @param skeleton defines the parent skeleton
  92782. * @param parentBone defines the parent (can be null if the bone is the root)
  92783. * @param localMatrix defines the local matrix
  92784. * @param restPose defines the rest pose matrix
  92785. * @param baseMatrix defines the base matrix
  92786. * @param index defines index of the bone in the hiearchy
  92787. */
  92788. constructor(
  92789. /**
  92790. * defines the bone name
  92791. */
  92792. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92793. /**
  92794. * Gets the current object class name.
  92795. * @return the class name
  92796. */
  92797. getClassName(): string;
  92798. /**
  92799. * Gets the parent skeleton
  92800. * @returns a skeleton
  92801. */
  92802. getSkeleton(): Skeleton;
  92803. /**
  92804. * Gets parent bone
  92805. * @returns a bone or null if the bone is the root of the bone hierarchy
  92806. */
  92807. getParent(): Nullable<Bone>;
  92808. /**
  92809. * Returns an array containing the root bones
  92810. * @returns an array containing the root bones
  92811. */
  92812. getChildren(): Array<Bone>;
  92813. /**
  92814. * Gets the node index in matrix array generated for rendering
  92815. * @returns the node index
  92816. */
  92817. getIndex(): number;
  92818. /**
  92819. * Sets the parent bone
  92820. * @param parent defines the parent (can be null if the bone is the root)
  92821. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92822. */
  92823. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92824. /**
  92825. * Gets the local matrix
  92826. * @returns a matrix
  92827. */
  92828. getLocalMatrix(): Matrix;
  92829. /**
  92830. * Gets the base matrix (initial matrix which remains unchanged)
  92831. * @returns a matrix
  92832. */
  92833. getBaseMatrix(): Matrix;
  92834. /**
  92835. * Gets the rest pose matrix
  92836. * @returns a matrix
  92837. */
  92838. getRestPose(): Matrix;
  92839. /**
  92840. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92841. */
  92842. getWorldMatrix(): Matrix;
  92843. /**
  92844. * Sets the local matrix to rest pose matrix
  92845. */
  92846. returnToRest(): void;
  92847. /**
  92848. * Gets the inverse of the absolute transform matrix.
  92849. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92850. * @returns a matrix
  92851. */
  92852. getInvertedAbsoluteTransform(): Matrix;
  92853. /**
  92854. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92855. * @returns a matrix
  92856. */
  92857. getAbsoluteTransform(): Matrix;
  92858. /**
  92859. * Links with the given transform node.
  92860. * The local matrix of this bone is copied from the transform node every frame.
  92861. * @param transformNode defines the transform node to link to
  92862. */
  92863. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92864. /**
  92865. * Gets the node used to drive the bone's transformation
  92866. * @returns a transform node or null
  92867. */
  92868. getTransformNode(): Nullable<TransformNode>;
  92869. /** Gets or sets current position (in local space) */
  92870. get position(): Vector3;
  92871. set position(newPosition: Vector3);
  92872. /** Gets or sets current rotation (in local space) */
  92873. get rotation(): Vector3;
  92874. set rotation(newRotation: Vector3);
  92875. /** Gets or sets current rotation quaternion (in local space) */
  92876. get rotationQuaternion(): Quaternion;
  92877. set rotationQuaternion(newRotation: Quaternion);
  92878. /** Gets or sets current scaling (in local space) */
  92879. get scaling(): Vector3;
  92880. set scaling(newScaling: Vector3);
  92881. /**
  92882. * Gets the animation properties override
  92883. */
  92884. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92885. private _decompose;
  92886. private _compose;
  92887. /**
  92888. * Update the base and local matrices
  92889. * @param matrix defines the new base or local matrix
  92890. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92891. * @param updateLocalMatrix defines if the local matrix should be updated
  92892. */
  92893. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92894. /** @hidden */
  92895. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92896. /**
  92897. * Flag the bone as dirty (Forcing it to update everything)
  92898. */
  92899. markAsDirty(): void;
  92900. /** @hidden */
  92901. _markAsDirtyAndCompose(): void;
  92902. private _markAsDirtyAndDecompose;
  92903. /**
  92904. * Translate the bone in local or world space
  92905. * @param vec The amount to translate the bone
  92906. * @param space The space that the translation is in
  92907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92908. */
  92909. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92910. /**
  92911. * Set the postion of the bone in local or world space
  92912. * @param position The position to set the bone
  92913. * @param space The space that the position is in
  92914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92915. */
  92916. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92917. /**
  92918. * Set the absolute position of the bone (world space)
  92919. * @param position The position to set the bone
  92920. * @param mesh The mesh that this bone is attached to
  92921. */
  92922. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92923. /**
  92924. * Scale the bone on the x, y and z axes (in local space)
  92925. * @param x The amount to scale the bone on the x axis
  92926. * @param y The amount to scale the bone on the y axis
  92927. * @param z The amount to scale the bone on the z axis
  92928. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92929. */
  92930. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92931. /**
  92932. * Set the bone scaling in local space
  92933. * @param scale defines the scaling vector
  92934. */
  92935. setScale(scale: Vector3): void;
  92936. /**
  92937. * Gets the current scaling in local space
  92938. * @returns the current scaling vector
  92939. */
  92940. getScale(): Vector3;
  92941. /**
  92942. * Gets the current scaling in local space and stores it in a target vector
  92943. * @param result defines the target vector
  92944. */
  92945. getScaleToRef(result: Vector3): void;
  92946. /**
  92947. * Set the yaw, pitch, and roll of the bone in local or world space
  92948. * @param yaw The rotation of the bone on the y axis
  92949. * @param pitch The rotation of the bone on the x axis
  92950. * @param roll The rotation of the bone on the z axis
  92951. * @param space The space that the axes of rotation are in
  92952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92953. */
  92954. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92955. /**
  92956. * Add a rotation to the bone on an axis in local or world space
  92957. * @param axis The axis to rotate the bone on
  92958. * @param amount The amount to rotate the bone
  92959. * @param space The space that the axis is in
  92960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92961. */
  92962. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92963. /**
  92964. * Set the rotation of the bone to a particular axis angle in local or world space
  92965. * @param axis The axis to rotate the bone on
  92966. * @param angle The angle that the bone should be rotated to
  92967. * @param space The space that the axis is in
  92968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92969. */
  92970. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92971. /**
  92972. * Set the euler rotation of the bone in local of world space
  92973. * @param rotation The euler rotation that the bone should be set to
  92974. * @param space The space that the rotation is in
  92975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92976. */
  92977. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92978. /**
  92979. * Set the quaternion rotation of the bone in local of world space
  92980. * @param quat The quaternion rotation that the bone should be set to
  92981. * @param space The space that the rotation is in
  92982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92983. */
  92984. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92985. /**
  92986. * Set the rotation matrix of the bone in local of world space
  92987. * @param rotMat The rotation matrix that the bone should be set to
  92988. * @param space The space that the rotation is in
  92989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92990. */
  92991. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92992. private _rotateWithMatrix;
  92993. private _getNegativeRotationToRef;
  92994. /**
  92995. * Get the position of the bone in local or world space
  92996. * @param space The space that the returned position is in
  92997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92998. * @returns The position of the bone
  92999. */
  93000. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93001. /**
  93002. * Copy the position of the bone to a vector3 in local or world space
  93003. * @param space The space that the returned position is in
  93004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93005. * @param result The vector3 to copy the position to
  93006. */
  93007. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93008. /**
  93009. * Get the absolute position of the bone (world space)
  93010. * @param mesh The mesh that this bone is attached to
  93011. * @returns The absolute position of the bone
  93012. */
  93013. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93014. /**
  93015. * Copy the absolute position of the bone (world space) to the result param
  93016. * @param mesh The mesh that this bone is attached to
  93017. * @param result The vector3 to copy the absolute position to
  93018. */
  93019. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93020. /**
  93021. * Compute the absolute transforms of this bone and its children
  93022. */
  93023. computeAbsoluteTransforms(): void;
  93024. /**
  93025. * Get the world direction from an axis that is in the local space of the bone
  93026. * @param localAxis The local direction that is used to compute the world direction
  93027. * @param mesh The mesh that this bone is attached to
  93028. * @returns The world direction
  93029. */
  93030. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93031. /**
  93032. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93033. * @param localAxis The local direction that is used to compute the world direction
  93034. * @param mesh The mesh that this bone is attached to
  93035. * @param result The vector3 that the world direction will be copied to
  93036. */
  93037. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93038. /**
  93039. * Get the euler rotation of the bone in local or world space
  93040. * @param space The space that the rotation should be in
  93041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93042. * @returns The euler rotation
  93043. */
  93044. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93045. /**
  93046. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93047. * @param space The space that the rotation should be in
  93048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93049. * @param result The vector3 that the rotation should be copied to
  93050. */
  93051. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93052. /**
  93053. * Get the quaternion rotation of the bone in either local or world space
  93054. * @param space The space that the rotation should be in
  93055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93056. * @returns The quaternion rotation
  93057. */
  93058. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93059. /**
  93060. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93061. * @param space The space that the rotation should be in
  93062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93063. * @param result The quaternion that the rotation should be copied to
  93064. */
  93065. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93066. /**
  93067. * Get the rotation matrix of the bone in local or world space
  93068. * @param space The space that the rotation should be in
  93069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93070. * @returns The rotation matrix
  93071. */
  93072. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93073. /**
  93074. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93075. * @param space The space that the rotation should be in
  93076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93077. * @param result The quaternion that the rotation should be copied to
  93078. */
  93079. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93080. /**
  93081. * Get the world position of a point that is in the local space of the bone
  93082. * @param position The local position
  93083. * @param mesh The mesh that this bone is attached to
  93084. * @returns The world position
  93085. */
  93086. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93087. /**
  93088. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93089. * @param position The local position
  93090. * @param mesh The mesh that this bone is attached to
  93091. * @param result The vector3 that the world position should be copied to
  93092. */
  93093. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93094. /**
  93095. * Get the local position of a point that is in world space
  93096. * @param position The world position
  93097. * @param mesh The mesh that this bone is attached to
  93098. * @returns The local position
  93099. */
  93100. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93101. /**
  93102. * Get the local position of a point that is in world space and copy it to the result param
  93103. * @param position The world position
  93104. * @param mesh The mesh that this bone is attached to
  93105. * @param result The vector3 that the local position should be copied to
  93106. */
  93107. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93108. }
  93109. }
  93110. declare module BABYLON {
  93111. /**
  93112. * Defines a runtime animation
  93113. */
  93114. export class RuntimeAnimation {
  93115. private _events;
  93116. /**
  93117. * The current frame of the runtime animation
  93118. */
  93119. private _currentFrame;
  93120. /**
  93121. * The animation used by the runtime animation
  93122. */
  93123. private _animation;
  93124. /**
  93125. * The target of the runtime animation
  93126. */
  93127. private _target;
  93128. /**
  93129. * The initiating animatable
  93130. */
  93131. private _host;
  93132. /**
  93133. * The original value of the runtime animation
  93134. */
  93135. private _originalValue;
  93136. /**
  93137. * The original blend value of the runtime animation
  93138. */
  93139. private _originalBlendValue;
  93140. /**
  93141. * The offsets cache of the runtime animation
  93142. */
  93143. private _offsetsCache;
  93144. /**
  93145. * The high limits cache of the runtime animation
  93146. */
  93147. private _highLimitsCache;
  93148. /**
  93149. * Specifies if the runtime animation has been stopped
  93150. */
  93151. private _stopped;
  93152. /**
  93153. * The blending factor of the runtime animation
  93154. */
  93155. private _blendingFactor;
  93156. /**
  93157. * The BabylonJS scene
  93158. */
  93159. private _scene;
  93160. /**
  93161. * The current value of the runtime animation
  93162. */
  93163. private _currentValue;
  93164. /** @hidden */
  93165. _animationState: _IAnimationState;
  93166. /**
  93167. * The active target of the runtime animation
  93168. */
  93169. private _activeTargets;
  93170. private _currentActiveTarget;
  93171. private _directTarget;
  93172. /**
  93173. * The target path of the runtime animation
  93174. */
  93175. private _targetPath;
  93176. /**
  93177. * The weight of the runtime animation
  93178. */
  93179. private _weight;
  93180. /**
  93181. * The ratio offset of the runtime animation
  93182. */
  93183. private _ratioOffset;
  93184. /**
  93185. * The previous delay of the runtime animation
  93186. */
  93187. private _previousDelay;
  93188. /**
  93189. * The previous ratio of the runtime animation
  93190. */
  93191. private _previousRatio;
  93192. private _enableBlending;
  93193. private _keys;
  93194. private _minFrame;
  93195. private _maxFrame;
  93196. private _minValue;
  93197. private _maxValue;
  93198. private _targetIsArray;
  93199. /**
  93200. * Gets the current frame of the runtime animation
  93201. */
  93202. get currentFrame(): number;
  93203. /**
  93204. * Gets the weight of the runtime animation
  93205. */
  93206. get weight(): number;
  93207. /**
  93208. * Gets the current value of the runtime animation
  93209. */
  93210. get currentValue(): any;
  93211. /**
  93212. * Gets the target path of the runtime animation
  93213. */
  93214. get targetPath(): string;
  93215. /**
  93216. * Gets the actual target of the runtime animation
  93217. */
  93218. get target(): any;
  93219. /**
  93220. * Gets the additive state of the runtime animation
  93221. */
  93222. get isAdditive(): boolean;
  93223. /** @hidden */
  93224. _onLoop: () => void;
  93225. /**
  93226. * Create a new RuntimeAnimation object
  93227. * @param target defines the target of the animation
  93228. * @param animation defines the source animation object
  93229. * @param scene defines the hosting scene
  93230. * @param host defines the initiating Animatable
  93231. */
  93232. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93233. private _preparePath;
  93234. /**
  93235. * Gets the animation from the runtime animation
  93236. */
  93237. get animation(): Animation;
  93238. /**
  93239. * Resets the runtime animation to the beginning
  93240. * @param restoreOriginal defines whether to restore the target property to the original value
  93241. */
  93242. reset(restoreOriginal?: boolean): void;
  93243. /**
  93244. * Specifies if the runtime animation is stopped
  93245. * @returns Boolean specifying if the runtime animation is stopped
  93246. */
  93247. isStopped(): boolean;
  93248. /**
  93249. * Disposes of the runtime animation
  93250. */
  93251. dispose(): void;
  93252. /**
  93253. * Apply the interpolated value to the target
  93254. * @param currentValue defines the value computed by the animation
  93255. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93256. */
  93257. setValue(currentValue: any, weight: number): void;
  93258. private _getOriginalValues;
  93259. private _setValue;
  93260. /**
  93261. * Gets the loop pmode of the runtime animation
  93262. * @returns Loop Mode
  93263. */
  93264. private _getCorrectLoopMode;
  93265. /**
  93266. * Move the current animation to a given frame
  93267. * @param frame defines the frame to move to
  93268. */
  93269. goToFrame(frame: number): void;
  93270. /**
  93271. * @hidden Internal use only
  93272. */
  93273. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93274. /**
  93275. * Execute the current animation
  93276. * @param delay defines the delay to add to the current frame
  93277. * @param from defines the lower bound of the animation range
  93278. * @param to defines the upper bound of the animation range
  93279. * @param loop defines if the current animation must loop
  93280. * @param speedRatio defines the current speed ratio
  93281. * @param weight defines the weight of the animation (default is -1 so no weight)
  93282. * @param onLoop optional callback called when animation loops
  93283. * @returns a boolean indicating if the animation is running
  93284. */
  93285. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93286. }
  93287. }
  93288. declare module BABYLON {
  93289. /**
  93290. * Class used to store an actual running animation
  93291. */
  93292. export class Animatable {
  93293. /** defines the target object */
  93294. target: any;
  93295. /** defines the starting frame number (default is 0) */
  93296. fromFrame: number;
  93297. /** defines the ending frame number (default is 100) */
  93298. toFrame: number;
  93299. /** defines if the animation must loop (default is false) */
  93300. loopAnimation: boolean;
  93301. /** defines a callback to call when animation ends if it is not looping */
  93302. onAnimationEnd?: (() => void) | null | undefined;
  93303. /** defines a callback to call when animation loops */
  93304. onAnimationLoop?: (() => void) | null | undefined;
  93305. /** defines whether the animation should be evaluated additively */
  93306. isAdditive: boolean;
  93307. private _localDelayOffset;
  93308. private _pausedDelay;
  93309. private _runtimeAnimations;
  93310. private _paused;
  93311. private _scene;
  93312. private _speedRatio;
  93313. private _weight;
  93314. private _syncRoot;
  93315. /**
  93316. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93317. * This will only apply for non looping animation (default is true)
  93318. */
  93319. disposeOnEnd: boolean;
  93320. /**
  93321. * Gets a boolean indicating if the animation has started
  93322. */
  93323. animationStarted: boolean;
  93324. /**
  93325. * Observer raised when the animation ends
  93326. */
  93327. onAnimationEndObservable: Observable<Animatable>;
  93328. /**
  93329. * Observer raised when the animation loops
  93330. */
  93331. onAnimationLoopObservable: Observable<Animatable>;
  93332. /**
  93333. * Gets the root Animatable used to synchronize and normalize animations
  93334. */
  93335. get syncRoot(): Nullable<Animatable>;
  93336. /**
  93337. * Gets the current frame of the first RuntimeAnimation
  93338. * Used to synchronize Animatables
  93339. */
  93340. get masterFrame(): number;
  93341. /**
  93342. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93343. */
  93344. get weight(): number;
  93345. set weight(value: number);
  93346. /**
  93347. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93348. */
  93349. get speedRatio(): number;
  93350. set speedRatio(value: number);
  93351. /**
  93352. * Creates a new Animatable
  93353. * @param scene defines the hosting scene
  93354. * @param target defines the target object
  93355. * @param fromFrame defines the starting frame number (default is 0)
  93356. * @param toFrame defines the ending frame number (default is 100)
  93357. * @param loopAnimation defines if the animation must loop (default is false)
  93358. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93359. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93360. * @param animations defines a group of animation to add to the new Animatable
  93361. * @param onAnimationLoop defines a callback to call when animation loops
  93362. * @param isAdditive defines whether the animation should be evaluated additively
  93363. */
  93364. constructor(scene: Scene,
  93365. /** defines the target object */
  93366. target: any,
  93367. /** defines the starting frame number (default is 0) */
  93368. fromFrame?: number,
  93369. /** defines the ending frame number (default is 100) */
  93370. toFrame?: number,
  93371. /** defines if the animation must loop (default is false) */
  93372. loopAnimation?: boolean, speedRatio?: number,
  93373. /** defines a callback to call when animation ends if it is not looping */
  93374. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93375. /** defines a callback to call when animation loops */
  93376. onAnimationLoop?: (() => void) | null | undefined,
  93377. /** defines whether the animation should be evaluated additively */
  93378. isAdditive?: boolean);
  93379. /**
  93380. * Synchronize and normalize current Animatable with a source Animatable
  93381. * This is useful when using animation weights and when animations are not of the same length
  93382. * @param root defines the root Animatable to synchronize with
  93383. * @returns the current Animatable
  93384. */
  93385. syncWith(root: Animatable): Animatable;
  93386. /**
  93387. * Gets the list of runtime animations
  93388. * @returns an array of RuntimeAnimation
  93389. */
  93390. getAnimations(): RuntimeAnimation[];
  93391. /**
  93392. * Adds more animations to the current animatable
  93393. * @param target defines the target of the animations
  93394. * @param animations defines the new animations to add
  93395. */
  93396. appendAnimations(target: any, animations: Animation[]): void;
  93397. /**
  93398. * Gets the source animation for a specific property
  93399. * @param property defines the propertyu to look for
  93400. * @returns null or the source animation for the given property
  93401. */
  93402. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93403. /**
  93404. * Gets the runtime animation for a specific property
  93405. * @param property defines the propertyu to look for
  93406. * @returns null or the runtime animation for the given property
  93407. */
  93408. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93409. /**
  93410. * Resets the animatable to its original state
  93411. */
  93412. reset(): void;
  93413. /**
  93414. * Allows the animatable to blend with current running animations
  93415. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93416. * @param blendingSpeed defines the blending speed to use
  93417. */
  93418. enableBlending(blendingSpeed: number): void;
  93419. /**
  93420. * Disable animation blending
  93421. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93422. */
  93423. disableBlending(): void;
  93424. /**
  93425. * Jump directly to a given frame
  93426. * @param frame defines the frame to jump to
  93427. */
  93428. goToFrame(frame: number): void;
  93429. /**
  93430. * Pause the animation
  93431. */
  93432. pause(): void;
  93433. /**
  93434. * Restart the animation
  93435. */
  93436. restart(): void;
  93437. private _raiseOnAnimationEnd;
  93438. /**
  93439. * Stop and delete the current animation
  93440. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93441. * @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)
  93442. */
  93443. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93444. /**
  93445. * Wait asynchronously for the animation to end
  93446. * @returns a promise which will be fullfilled when the animation ends
  93447. */
  93448. waitAsync(): Promise<Animatable>;
  93449. /** @hidden */
  93450. _animate(delay: number): boolean;
  93451. }
  93452. interface Scene {
  93453. /** @hidden */
  93454. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93455. /** @hidden */
  93456. _processLateAnimationBindingsForMatrices(holder: {
  93457. totalWeight: number;
  93458. totalAdditiveWeight: number;
  93459. animations: RuntimeAnimation[];
  93460. additiveAnimations: RuntimeAnimation[];
  93461. originalValue: Matrix;
  93462. }): any;
  93463. /** @hidden */
  93464. _processLateAnimationBindingsForQuaternions(holder: {
  93465. totalWeight: number;
  93466. totalAdditiveWeight: number;
  93467. animations: RuntimeAnimation[];
  93468. additiveAnimations: RuntimeAnimation[];
  93469. originalValue: Quaternion;
  93470. }, refQuaternion: Quaternion): Quaternion;
  93471. /** @hidden */
  93472. _processLateAnimationBindings(): void;
  93473. /**
  93474. * Will start the animation sequence of a given target
  93475. * @param target defines the target
  93476. * @param from defines from which frame should animation start
  93477. * @param to defines until which frame should animation run.
  93478. * @param weight defines the weight to apply to the animation (1.0 by default)
  93479. * @param loop defines if the animation loops
  93480. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93481. * @param onAnimationEnd defines the function to be executed when the animation ends
  93482. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93483. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93484. * @param onAnimationLoop defines the callback to call when an animation loops
  93485. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93486. * @returns the animatable object created for this animation
  93487. */
  93488. 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;
  93489. /**
  93490. * Will start the animation sequence of a given target
  93491. * @param target defines the target
  93492. * @param from defines from which frame should animation start
  93493. * @param to defines until which frame should animation run.
  93494. * @param loop defines if the animation loops
  93495. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93496. * @param onAnimationEnd defines the function to be executed when the animation ends
  93497. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93498. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93499. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93500. * @param onAnimationLoop defines the callback to call when an animation loops
  93501. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93502. * @returns the animatable object created for this animation
  93503. */
  93504. 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;
  93505. /**
  93506. * Will start the animation sequence of a given target and its hierarchy
  93507. * @param target defines the target
  93508. * @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.
  93509. * @param from defines from which frame should animation start
  93510. * @param to defines until which frame should animation run.
  93511. * @param loop defines if the animation loops
  93512. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93513. * @param onAnimationEnd defines the function to be executed when the animation ends
  93514. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93515. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93516. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93517. * @param onAnimationLoop defines the callback to call when an animation loops
  93518. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93519. * @returns the list of created animatables
  93520. */
  93521. 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[];
  93522. /**
  93523. * Begin a new animation on a given node
  93524. * @param target defines the target where the animation will take place
  93525. * @param animations defines the list of animations to start
  93526. * @param from defines the initial value
  93527. * @param to defines the final value
  93528. * @param loop defines if you want animation to loop (off by default)
  93529. * @param speedRatio defines the speed ratio to apply to all animations
  93530. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93531. * @param onAnimationLoop defines the callback to call when an animation loops
  93532. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93533. * @returns the list of created animatables
  93534. */
  93535. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93536. /**
  93537. * Begin a new animation on a given node and its hierarchy
  93538. * @param target defines the root node where the animation will take place
  93539. * @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.
  93540. * @param animations defines the list of animations to start
  93541. * @param from defines the initial value
  93542. * @param to defines the final value
  93543. * @param loop defines if you want animation to loop (off by default)
  93544. * @param speedRatio defines the speed ratio to apply to all animations
  93545. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93546. * @param onAnimationLoop defines the callback to call when an animation loops
  93547. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93548. * @returns the list of animatables created for all nodes
  93549. */
  93550. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93551. /**
  93552. * Gets the animatable associated with a specific target
  93553. * @param target defines the target of the animatable
  93554. * @returns the required animatable if found
  93555. */
  93556. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93557. /**
  93558. * Gets all animatables associated with a given target
  93559. * @param target defines the target to look animatables for
  93560. * @returns an array of Animatables
  93561. */
  93562. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93563. /**
  93564. * Stops and removes all animations that have been applied to the scene
  93565. */
  93566. stopAllAnimations(): void;
  93567. /**
  93568. * Gets the current delta time used by animation engine
  93569. */
  93570. deltaTime: number;
  93571. }
  93572. interface Bone {
  93573. /**
  93574. * Copy an animation range from another bone
  93575. * @param source defines the source bone
  93576. * @param rangeName defines the range name to copy
  93577. * @param frameOffset defines the frame offset
  93578. * @param rescaleAsRequired defines if rescaling must be applied if required
  93579. * @param skelDimensionsRatio defines the scaling ratio
  93580. * @returns true if operation was successful
  93581. */
  93582. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93583. }
  93584. }
  93585. declare module BABYLON {
  93586. /**
  93587. * Class used to handle skinning animations
  93588. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93589. */
  93590. export class Skeleton implements IAnimatable {
  93591. /** defines the skeleton name */
  93592. name: string;
  93593. /** defines the skeleton Id */
  93594. id: string;
  93595. /**
  93596. * Defines the list of child bones
  93597. */
  93598. bones: Bone[];
  93599. /**
  93600. * Defines an estimate of the dimension of the skeleton at rest
  93601. */
  93602. dimensionsAtRest: Vector3;
  93603. /**
  93604. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93605. */
  93606. needInitialSkinMatrix: boolean;
  93607. /**
  93608. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93609. */
  93610. overrideMesh: Nullable<AbstractMesh>;
  93611. /**
  93612. * Gets the list of animations attached to this skeleton
  93613. */
  93614. animations: Array<Animation>;
  93615. private _scene;
  93616. private _isDirty;
  93617. private _transformMatrices;
  93618. private _transformMatrixTexture;
  93619. private _meshesWithPoseMatrix;
  93620. private _animatables;
  93621. private _identity;
  93622. private _synchronizedWithMesh;
  93623. private _ranges;
  93624. private _lastAbsoluteTransformsUpdateId;
  93625. private _canUseTextureForBones;
  93626. private _uniqueId;
  93627. /** @hidden */
  93628. _numBonesWithLinkedTransformNode: number;
  93629. /** @hidden */
  93630. _hasWaitingData: Nullable<boolean>;
  93631. /**
  93632. * Specifies if the skeleton should be serialized
  93633. */
  93634. doNotSerialize: boolean;
  93635. private _useTextureToStoreBoneMatrices;
  93636. /**
  93637. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93638. * Please note that this option is not available if the hardware does not support it
  93639. */
  93640. get useTextureToStoreBoneMatrices(): boolean;
  93641. set useTextureToStoreBoneMatrices(value: boolean);
  93642. private _animationPropertiesOverride;
  93643. /**
  93644. * Gets or sets the animation properties override
  93645. */
  93646. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93647. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93648. /**
  93649. * List of inspectable custom properties (used by the Inspector)
  93650. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93651. */
  93652. inspectableCustomProperties: IInspectable[];
  93653. /**
  93654. * An observable triggered before computing the skeleton's matrices
  93655. */
  93656. onBeforeComputeObservable: Observable<Skeleton>;
  93657. /**
  93658. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93659. */
  93660. get isUsingTextureForMatrices(): boolean;
  93661. /**
  93662. * Gets the unique ID of this skeleton
  93663. */
  93664. get uniqueId(): number;
  93665. /**
  93666. * Creates a new skeleton
  93667. * @param name defines the skeleton name
  93668. * @param id defines the skeleton Id
  93669. * @param scene defines the hosting scene
  93670. */
  93671. constructor(
  93672. /** defines the skeleton name */
  93673. name: string,
  93674. /** defines the skeleton Id */
  93675. id: string, scene: Scene);
  93676. /**
  93677. * Gets the current object class name.
  93678. * @return the class name
  93679. */
  93680. getClassName(): string;
  93681. /**
  93682. * Returns an array containing the root bones
  93683. * @returns an array containing the root bones
  93684. */
  93685. getChildren(): Array<Bone>;
  93686. /**
  93687. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93688. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93689. * @returns a Float32Array containing matrices data
  93690. */
  93691. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93692. /**
  93693. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93694. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93695. * @returns a raw texture containing the data
  93696. */
  93697. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93698. /**
  93699. * Gets the current hosting scene
  93700. * @returns a scene object
  93701. */
  93702. getScene(): Scene;
  93703. /**
  93704. * Gets a string representing the current skeleton data
  93705. * @param fullDetails defines a boolean indicating if we want a verbose version
  93706. * @returns a string representing the current skeleton data
  93707. */
  93708. toString(fullDetails?: boolean): string;
  93709. /**
  93710. * Get bone's index searching by name
  93711. * @param name defines bone's name to search for
  93712. * @return the indice of the bone. Returns -1 if not found
  93713. */
  93714. getBoneIndexByName(name: string): number;
  93715. /**
  93716. * Creater a new animation range
  93717. * @param name defines the name of the range
  93718. * @param from defines the start key
  93719. * @param to defines the end key
  93720. */
  93721. createAnimationRange(name: string, from: number, to: number): void;
  93722. /**
  93723. * Delete a specific animation range
  93724. * @param name defines the name of the range
  93725. * @param deleteFrames defines if frames must be removed as well
  93726. */
  93727. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93728. /**
  93729. * Gets a specific animation range
  93730. * @param name defines the name of the range to look for
  93731. * @returns the requested animation range or null if not found
  93732. */
  93733. getAnimationRange(name: string): Nullable<AnimationRange>;
  93734. /**
  93735. * Gets the list of all animation ranges defined on this skeleton
  93736. * @returns an array
  93737. */
  93738. getAnimationRanges(): Nullable<AnimationRange>[];
  93739. /**
  93740. * Copy animation range from a source skeleton.
  93741. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93742. * @param source defines the source skeleton
  93743. * @param name defines the name of the range to copy
  93744. * @param rescaleAsRequired defines if rescaling must be applied if required
  93745. * @returns true if operation was successful
  93746. */
  93747. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93748. /**
  93749. * Forces the skeleton to go to rest pose
  93750. */
  93751. returnToRest(): void;
  93752. private _getHighestAnimationFrame;
  93753. /**
  93754. * Begin a specific animation range
  93755. * @param name defines the name of the range to start
  93756. * @param loop defines if looping must be turned on (false by default)
  93757. * @param speedRatio defines the speed ratio to apply (1 by default)
  93758. * @param onAnimationEnd defines a callback which will be called when animation will end
  93759. * @returns a new animatable
  93760. */
  93761. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93762. /**
  93763. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93764. * @param skeleton defines the Skeleton containing the animation range to convert
  93765. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93766. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93767. * @returns the original skeleton
  93768. */
  93769. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93770. /** @hidden */
  93771. _markAsDirty(): void;
  93772. /** @hidden */
  93773. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93774. /** @hidden */
  93775. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93776. private _computeTransformMatrices;
  93777. /**
  93778. * Build all resources required to render a skeleton
  93779. */
  93780. prepare(): void;
  93781. /**
  93782. * Gets the list of animatables currently running for this skeleton
  93783. * @returns an array of animatables
  93784. */
  93785. getAnimatables(): IAnimatable[];
  93786. /**
  93787. * Clone the current skeleton
  93788. * @param name defines the name of the new skeleton
  93789. * @param id defines the id of the new skeleton
  93790. * @returns the new skeleton
  93791. */
  93792. clone(name: string, id?: string): Skeleton;
  93793. /**
  93794. * Enable animation blending for this skeleton
  93795. * @param blendingSpeed defines the blending speed to apply
  93796. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93797. */
  93798. enableBlending(blendingSpeed?: number): void;
  93799. /**
  93800. * Releases all resources associated with the current skeleton
  93801. */
  93802. dispose(): void;
  93803. /**
  93804. * Serialize the skeleton in a JSON object
  93805. * @returns a JSON object
  93806. */
  93807. serialize(): any;
  93808. /**
  93809. * Creates a new skeleton from serialized data
  93810. * @param parsedSkeleton defines the serialized data
  93811. * @param scene defines the hosting scene
  93812. * @returns a new skeleton
  93813. */
  93814. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93815. /**
  93816. * Compute all node absolute transforms
  93817. * @param forceUpdate defines if computation must be done even if cache is up to date
  93818. */
  93819. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93820. /**
  93821. * Gets the root pose matrix
  93822. * @returns a matrix
  93823. */
  93824. getPoseMatrix(): Nullable<Matrix>;
  93825. /**
  93826. * Sorts bones per internal index
  93827. */
  93828. sortBones(): void;
  93829. private _sortBones;
  93830. }
  93831. }
  93832. declare module BABYLON {
  93833. /**
  93834. * Creates an instance based on a source mesh.
  93835. */
  93836. export class InstancedMesh extends AbstractMesh {
  93837. private _sourceMesh;
  93838. private _currentLOD;
  93839. /** @hidden */
  93840. _indexInSourceMeshInstanceArray: number;
  93841. constructor(name: string, source: Mesh);
  93842. /**
  93843. * Returns the string "InstancedMesh".
  93844. */
  93845. getClassName(): string;
  93846. /** Gets the list of lights affecting that mesh */
  93847. get lightSources(): Light[];
  93848. _resyncLightSources(): void;
  93849. _resyncLightSource(light: Light): void;
  93850. _removeLightSource(light: Light, dispose: boolean): void;
  93851. /**
  93852. * If the source mesh receives shadows
  93853. */
  93854. get receiveShadows(): boolean;
  93855. /**
  93856. * The material of the source mesh
  93857. */
  93858. get material(): Nullable<Material>;
  93859. /**
  93860. * Visibility of the source mesh
  93861. */
  93862. get visibility(): number;
  93863. /**
  93864. * Skeleton of the source mesh
  93865. */
  93866. get skeleton(): Nullable<Skeleton>;
  93867. /**
  93868. * Rendering ground id of the source mesh
  93869. */
  93870. get renderingGroupId(): number;
  93871. set renderingGroupId(value: number);
  93872. /**
  93873. * Returns the total number of vertices (integer).
  93874. */
  93875. getTotalVertices(): number;
  93876. /**
  93877. * Returns a positive integer : the total number of indices in this mesh geometry.
  93878. * @returns the numner of indices or zero if the mesh has no geometry.
  93879. */
  93880. getTotalIndices(): number;
  93881. /**
  93882. * The source mesh of the instance
  93883. */
  93884. get sourceMesh(): Mesh;
  93885. /**
  93886. * Creates a new InstancedMesh object from the mesh model.
  93887. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93888. * @param name defines the name of the new instance
  93889. * @returns a new InstancedMesh
  93890. */
  93891. createInstance(name: string): InstancedMesh;
  93892. /**
  93893. * Is this node ready to be used/rendered
  93894. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93895. * @return {boolean} is it ready
  93896. */
  93897. isReady(completeCheck?: boolean): boolean;
  93898. /**
  93899. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93900. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93901. * @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.
  93902. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93903. */
  93904. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93905. /**
  93906. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93907. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93908. * The `data` are either a numeric array either a Float32Array.
  93909. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93910. * 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).
  93911. * Note that a new underlying VertexBuffer object is created each call.
  93912. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93913. *
  93914. * Possible `kind` values :
  93915. * - VertexBuffer.PositionKind
  93916. * - VertexBuffer.UVKind
  93917. * - VertexBuffer.UV2Kind
  93918. * - VertexBuffer.UV3Kind
  93919. * - VertexBuffer.UV4Kind
  93920. * - VertexBuffer.UV5Kind
  93921. * - VertexBuffer.UV6Kind
  93922. * - VertexBuffer.ColorKind
  93923. * - VertexBuffer.MatricesIndicesKind
  93924. * - VertexBuffer.MatricesIndicesExtraKind
  93925. * - VertexBuffer.MatricesWeightsKind
  93926. * - VertexBuffer.MatricesWeightsExtraKind
  93927. *
  93928. * Returns the Mesh.
  93929. */
  93930. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93931. /**
  93932. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93933. * If the mesh has no geometry, it is simply returned as it is.
  93934. * The `data` are either a numeric array either a Float32Array.
  93935. * No new underlying VertexBuffer object is created.
  93936. * 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.
  93937. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93938. *
  93939. * Possible `kind` values :
  93940. * - VertexBuffer.PositionKind
  93941. * - VertexBuffer.UVKind
  93942. * - VertexBuffer.UV2Kind
  93943. * - VertexBuffer.UV3Kind
  93944. * - VertexBuffer.UV4Kind
  93945. * - VertexBuffer.UV5Kind
  93946. * - VertexBuffer.UV6Kind
  93947. * - VertexBuffer.ColorKind
  93948. * - VertexBuffer.MatricesIndicesKind
  93949. * - VertexBuffer.MatricesIndicesExtraKind
  93950. * - VertexBuffer.MatricesWeightsKind
  93951. * - VertexBuffer.MatricesWeightsExtraKind
  93952. *
  93953. * Returns the Mesh.
  93954. */
  93955. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93956. /**
  93957. * Sets the mesh indices.
  93958. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93959. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93960. * This method creates a new index buffer each call.
  93961. * Returns the Mesh.
  93962. */
  93963. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93964. /**
  93965. * Boolean : True if the mesh owns the requested kind of data.
  93966. */
  93967. isVerticesDataPresent(kind: string): boolean;
  93968. /**
  93969. * Returns an array of indices (IndicesArray).
  93970. */
  93971. getIndices(): Nullable<IndicesArray>;
  93972. get _positions(): Nullable<Vector3[]>;
  93973. /**
  93974. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93975. * This means the mesh underlying bounding box and sphere are recomputed.
  93976. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93977. * @returns the current mesh
  93978. */
  93979. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93980. /** @hidden */
  93981. _preActivate(): InstancedMesh;
  93982. /** @hidden */
  93983. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93984. /** @hidden */
  93985. _postActivate(): void;
  93986. getWorldMatrix(): Matrix;
  93987. get isAnInstance(): boolean;
  93988. /**
  93989. * Returns the current associated LOD AbstractMesh.
  93990. */
  93991. getLOD(camera: Camera): AbstractMesh;
  93992. /** @hidden */
  93993. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93994. /** @hidden */
  93995. _syncSubMeshes(): InstancedMesh;
  93996. /** @hidden */
  93997. _generatePointsArray(): boolean;
  93998. /**
  93999. * Creates a new InstancedMesh from the current mesh.
  94000. * - name (string) : the cloned mesh name
  94001. * - newParent (optional Node) : the optional Node to parent the clone to.
  94002. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94003. *
  94004. * Returns the clone.
  94005. */
  94006. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94007. /**
  94008. * Disposes the InstancedMesh.
  94009. * Returns nothing.
  94010. */
  94011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94012. }
  94013. interface Mesh {
  94014. /**
  94015. * Register a custom buffer that will be instanced
  94016. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94017. * @param kind defines the buffer kind
  94018. * @param stride defines the stride in floats
  94019. */
  94020. registerInstancedBuffer(kind: string, stride: number): void;
  94021. /**
  94022. * true to use the edge renderer for all instances of this mesh
  94023. */
  94024. edgesShareWithInstances: boolean;
  94025. /** @hidden */
  94026. _userInstancedBuffersStorage: {
  94027. data: {
  94028. [key: string]: Float32Array;
  94029. };
  94030. sizes: {
  94031. [key: string]: number;
  94032. };
  94033. vertexBuffers: {
  94034. [key: string]: Nullable<VertexBuffer>;
  94035. };
  94036. strides: {
  94037. [key: string]: number;
  94038. };
  94039. };
  94040. }
  94041. interface AbstractMesh {
  94042. /**
  94043. * Object used to store instanced buffers defined by user
  94044. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94045. */
  94046. instancedBuffers: {
  94047. [key: string]: any;
  94048. };
  94049. }
  94050. }
  94051. declare module BABYLON {
  94052. /**
  94053. * Defines the options associated with the creation of a shader material.
  94054. */
  94055. export interface IShaderMaterialOptions {
  94056. /**
  94057. * Does the material work in alpha blend mode
  94058. */
  94059. needAlphaBlending: boolean;
  94060. /**
  94061. * Does the material work in alpha test mode
  94062. */
  94063. needAlphaTesting: boolean;
  94064. /**
  94065. * The list of attribute names used in the shader
  94066. */
  94067. attributes: string[];
  94068. /**
  94069. * The list of unifrom names used in the shader
  94070. */
  94071. uniforms: string[];
  94072. /**
  94073. * The list of UBO names used in the shader
  94074. */
  94075. uniformBuffers: string[];
  94076. /**
  94077. * The list of sampler names used in the shader
  94078. */
  94079. samplers: string[];
  94080. /**
  94081. * The list of defines used in the shader
  94082. */
  94083. defines: string[];
  94084. }
  94085. /**
  94086. * 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.
  94087. *
  94088. * This returned material effects how the mesh will look based on the code in the shaders.
  94089. *
  94090. * @see http://doc.babylonjs.com/how_to/shader_material
  94091. */
  94092. export class ShaderMaterial extends Material {
  94093. private _shaderPath;
  94094. private _options;
  94095. private _textures;
  94096. private _textureArrays;
  94097. private _floats;
  94098. private _ints;
  94099. private _floatsArrays;
  94100. private _colors3;
  94101. private _colors3Arrays;
  94102. private _colors4;
  94103. private _colors4Arrays;
  94104. private _vectors2;
  94105. private _vectors3;
  94106. private _vectors4;
  94107. private _matrices;
  94108. private _matrixArrays;
  94109. private _matrices3x3;
  94110. private _matrices2x2;
  94111. private _vectors2Arrays;
  94112. private _vectors3Arrays;
  94113. private _vectors4Arrays;
  94114. private _cachedWorldViewMatrix;
  94115. private _cachedWorldViewProjectionMatrix;
  94116. private _renderId;
  94117. private _multiview;
  94118. private _cachedDefines;
  94119. /** Define the Url to load snippets */
  94120. static SnippetUrl: string;
  94121. /** Snippet ID if the material was created from the snippet server */
  94122. snippetId: string;
  94123. /**
  94124. * Instantiate a new shader material.
  94125. * 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.
  94126. * This returned material effects how the mesh will look based on the code in the shaders.
  94127. * @see http://doc.babylonjs.com/how_to/shader_material
  94128. * @param name Define the name of the material in the scene
  94129. * @param scene Define the scene the material belongs to
  94130. * @param shaderPath Defines the route to the shader code in one of three ways:
  94131. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94132. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94133. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94134. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94135. * @param options Define the options used to create the shader
  94136. */
  94137. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94138. /**
  94139. * Gets the shader path used to define the shader code
  94140. * It can be modified to trigger a new compilation
  94141. */
  94142. get shaderPath(): any;
  94143. /**
  94144. * Sets the shader path used to define the shader code
  94145. * It can be modified to trigger a new compilation
  94146. */
  94147. set shaderPath(shaderPath: any);
  94148. /**
  94149. * Gets the options used to compile the shader.
  94150. * They can be modified to trigger a new compilation
  94151. */
  94152. get options(): IShaderMaterialOptions;
  94153. /**
  94154. * Gets the current class name of the material e.g. "ShaderMaterial"
  94155. * Mainly use in serialization.
  94156. * @returns the class name
  94157. */
  94158. getClassName(): string;
  94159. /**
  94160. * Specifies if the material will require alpha blending
  94161. * @returns a boolean specifying if alpha blending is needed
  94162. */
  94163. needAlphaBlending(): boolean;
  94164. /**
  94165. * Specifies if this material should be rendered in alpha test mode
  94166. * @returns a boolean specifying if an alpha test is needed.
  94167. */
  94168. needAlphaTesting(): boolean;
  94169. private _checkUniform;
  94170. /**
  94171. * Set a texture in the shader.
  94172. * @param name Define the name of the uniform samplers as defined in the shader
  94173. * @param texture Define the texture to bind to this sampler
  94174. * @return the material itself allowing "fluent" like uniform updates
  94175. */
  94176. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94177. /**
  94178. * Set a texture array in the shader.
  94179. * @param name Define the name of the uniform sampler array as defined in the shader
  94180. * @param textures Define the list of textures to bind to this sampler
  94181. * @return the material itself allowing "fluent" like uniform updates
  94182. */
  94183. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94184. /**
  94185. * Set a float in the shader.
  94186. * @param name Define the name of the uniform as defined in the shader
  94187. * @param value Define the value to give to the uniform
  94188. * @return the material itself allowing "fluent" like uniform updates
  94189. */
  94190. setFloat(name: string, value: number): ShaderMaterial;
  94191. /**
  94192. * Set a int in the shader.
  94193. * @param name Define the name of the uniform as defined in the shader
  94194. * @param value Define the value to give to the uniform
  94195. * @return the material itself allowing "fluent" like uniform updates
  94196. */
  94197. setInt(name: string, value: number): ShaderMaterial;
  94198. /**
  94199. * Set an array of floats in the shader.
  94200. * @param name Define the name of the uniform as defined in the shader
  94201. * @param value Define the value to give to the uniform
  94202. * @return the material itself allowing "fluent" like uniform updates
  94203. */
  94204. setFloats(name: string, value: number[]): ShaderMaterial;
  94205. /**
  94206. * Set a vec3 in the shader from a Color3.
  94207. * @param name Define the name of the uniform as defined in the shader
  94208. * @param value Define the value to give to the uniform
  94209. * @return the material itself allowing "fluent" like uniform updates
  94210. */
  94211. setColor3(name: string, value: Color3): ShaderMaterial;
  94212. /**
  94213. * Set a vec3 array in the shader from a Color3 array.
  94214. * @param name Define the name of the uniform as defined in the shader
  94215. * @param value Define the value to give to the uniform
  94216. * @return the material itself allowing "fluent" like uniform updates
  94217. */
  94218. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94219. /**
  94220. * Set a vec4 in the shader from a Color4.
  94221. * @param name Define the name of the uniform as defined in the shader
  94222. * @param value Define the value to give to the uniform
  94223. * @return the material itself allowing "fluent" like uniform updates
  94224. */
  94225. setColor4(name: string, value: Color4): ShaderMaterial;
  94226. /**
  94227. * Set a vec4 array in the shader from a Color4 array.
  94228. * @param name Define the name of the uniform as defined in the shader
  94229. * @param value Define the value to give to the uniform
  94230. * @return the material itself allowing "fluent" like uniform updates
  94231. */
  94232. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94233. /**
  94234. * Set a vec2 in the shader from a Vector2.
  94235. * @param name Define the name of the uniform as defined in the shader
  94236. * @param value Define the value to give to the uniform
  94237. * @return the material itself allowing "fluent" like uniform updates
  94238. */
  94239. setVector2(name: string, value: Vector2): ShaderMaterial;
  94240. /**
  94241. * Set a vec3 in the shader from a Vector3.
  94242. * @param name Define the name of the uniform as defined in the shader
  94243. * @param value Define the value to give to the uniform
  94244. * @return the material itself allowing "fluent" like uniform updates
  94245. */
  94246. setVector3(name: string, value: Vector3): ShaderMaterial;
  94247. /**
  94248. * Set a vec4 in the shader from a Vector4.
  94249. * @param name Define the name of the uniform as defined in the shader
  94250. * @param value Define the value to give to the uniform
  94251. * @return the material itself allowing "fluent" like uniform updates
  94252. */
  94253. setVector4(name: string, value: Vector4): ShaderMaterial;
  94254. /**
  94255. * Set a mat4 in the shader from a Matrix.
  94256. * @param name Define the name of the uniform as defined in the shader
  94257. * @param value Define the value to give to the uniform
  94258. * @return the material itself allowing "fluent" like uniform updates
  94259. */
  94260. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94261. /**
  94262. * Set a float32Array in the shader from a matrix array.
  94263. * @param name Define the name of the uniform as defined in the shader
  94264. * @param value Define the value to give to the uniform
  94265. * @return the material itself allowing "fluent" like uniform updates
  94266. */
  94267. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94268. /**
  94269. * Set a mat3 in the shader from a Float32Array.
  94270. * @param name Define the name of the uniform as defined in the shader
  94271. * @param value Define the value to give to the uniform
  94272. * @return the material itself allowing "fluent" like uniform updates
  94273. */
  94274. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94275. /**
  94276. * Set a mat2 in the shader from a Float32Array.
  94277. * @param name Define the name of the uniform as defined in the shader
  94278. * @param value Define the value to give to the uniform
  94279. * @return the material itself allowing "fluent" like uniform updates
  94280. */
  94281. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94282. /**
  94283. * Set a vec2 array in the shader from a number array.
  94284. * @param name Define the name of the uniform as defined in the shader
  94285. * @param value Define the value to give to the uniform
  94286. * @return the material itself allowing "fluent" like uniform updates
  94287. */
  94288. setArray2(name: string, value: number[]): ShaderMaterial;
  94289. /**
  94290. * Set a vec3 array in the shader from a number array.
  94291. * @param name Define the name of the uniform as defined in the shader
  94292. * @param value Define the value to give to the uniform
  94293. * @return the material itself allowing "fluent" like uniform updates
  94294. */
  94295. setArray3(name: string, value: number[]): ShaderMaterial;
  94296. /**
  94297. * Set a vec4 array in the shader from a number array.
  94298. * @param name Define the name of the uniform as defined in the shader
  94299. * @param value Define the value to give to the uniform
  94300. * @return the material itself allowing "fluent" like uniform updates
  94301. */
  94302. setArray4(name: string, value: number[]): ShaderMaterial;
  94303. private _checkCache;
  94304. /**
  94305. * Specifies that the submesh is ready to be used
  94306. * @param mesh defines the mesh to check
  94307. * @param subMesh defines which submesh to check
  94308. * @param useInstances specifies that instances should be used
  94309. * @returns a boolean indicating that the submesh is ready or not
  94310. */
  94311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94312. /**
  94313. * Checks if the material is ready to render the requested mesh
  94314. * @param mesh Define the mesh to render
  94315. * @param useInstances Define whether or not the material is used with instances
  94316. * @returns true if ready, otherwise false
  94317. */
  94318. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94319. /**
  94320. * Binds the world matrix to the material
  94321. * @param world defines the world transformation matrix
  94322. * @param effectOverride - If provided, use this effect instead of internal effect
  94323. */
  94324. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94325. /**
  94326. * Binds the submesh to this material by preparing the effect and shader to draw
  94327. * @param world defines the world transformation matrix
  94328. * @param mesh defines the mesh containing the submesh
  94329. * @param subMesh defines the submesh to bind the material to
  94330. */
  94331. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94332. /**
  94333. * Binds the material to the mesh
  94334. * @param world defines the world transformation matrix
  94335. * @param mesh defines the mesh to bind the material to
  94336. * @param effectOverride - If provided, use this effect instead of internal effect
  94337. */
  94338. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94339. protected _afterBind(mesh?: Mesh): void;
  94340. /**
  94341. * Gets the active textures from the material
  94342. * @returns an array of textures
  94343. */
  94344. getActiveTextures(): BaseTexture[];
  94345. /**
  94346. * Specifies if the material uses a texture
  94347. * @param texture defines the texture to check against the material
  94348. * @returns a boolean specifying if the material uses the texture
  94349. */
  94350. hasTexture(texture: BaseTexture): boolean;
  94351. /**
  94352. * Makes a duplicate of the material, and gives it a new name
  94353. * @param name defines the new name for the duplicated material
  94354. * @returns the cloned material
  94355. */
  94356. clone(name: string): ShaderMaterial;
  94357. /**
  94358. * Disposes the material
  94359. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94360. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94361. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94362. */
  94363. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94364. /**
  94365. * Serializes this material in a JSON representation
  94366. * @returns the serialized material object
  94367. */
  94368. serialize(): any;
  94369. /**
  94370. * Creates a shader material from parsed shader material data
  94371. * @param source defines the JSON represnetation of the material
  94372. * @param scene defines the hosting scene
  94373. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94374. * @returns a new material
  94375. */
  94376. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94377. /**
  94378. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94379. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94380. * @param url defines the url to load from
  94381. * @param scene defines the hosting scene
  94382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94383. * @returns a promise that will resolve to the new ShaderMaterial
  94384. */
  94385. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94386. /**
  94387. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94388. * @param snippetId defines the snippet to load
  94389. * @param scene defines the hosting scene
  94390. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94391. * @returns a promise that will resolve to the new ShaderMaterial
  94392. */
  94393. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94394. }
  94395. }
  94396. declare module BABYLON {
  94397. /** @hidden */
  94398. export var colorPixelShader: {
  94399. name: string;
  94400. shader: string;
  94401. };
  94402. }
  94403. declare module BABYLON {
  94404. /** @hidden */
  94405. export var colorVertexShader: {
  94406. name: string;
  94407. shader: string;
  94408. };
  94409. }
  94410. declare module BABYLON {
  94411. /**
  94412. * Line mesh
  94413. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94414. */
  94415. export class LinesMesh extends Mesh {
  94416. /**
  94417. * If vertex color should be applied to the mesh
  94418. */
  94419. readonly useVertexColor?: boolean | undefined;
  94420. /**
  94421. * If vertex alpha should be applied to the mesh
  94422. */
  94423. readonly useVertexAlpha?: boolean | undefined;
  94424. /**
  94425. * Color of the line (Default: White)
  94426. */
  94427. color: Color3;
  94428. /**
  94429. * Alpha of the line (Default: 1)
  94430. */
  94431. alpha: number;
  94432. /**
  94433. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94434. * This margin is expressed in world space coordinates, so its value may vary.
  94435. * Default value is 0.1
  94436. */
  94437. intersectionThreshold: number;
  94438. private _colorShader;
  94439. private color4;
  94440. /**
  94441. * Creates a new LinesMesh
  94442. * @param name defines the name
  94443. * @param scene defines the hosting scene
  94444. * @param parent defines the parent mesh if any
  94445. * @param source defines the optional source LinesMesh used to clone data from
  94446. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94447. * When false, achieved by calling a clone(), also passing False.
  94448. * This will make creation of children, recursive.
  94449. * @param useVertexColor defines if this LinesMesh supports vertex color
  94450. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94451. */
  94452. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94453. /**
  94454. * If vertex color should be applied to the mesh
  94455. */
  94456. useVertexColor?: boolean | undefined,
  94457. /**
  94458. * If vertex alpha should be applied to the mesh
  94459. */
  94460. useVertexAlpha?: boolean | undefined);
  94461. private _addClipPlaneDefine;
  94462. private _removeClipPlaneDefine;
  94463. isReady(): boolean;
  94464. /**
  94465. * Returns the string "LineMesh"
  94466. */
  94467. getClassName(): string;
  94468. /**
  94469. * @hidden
  94470. */
  94471. get material(): Material;
  94472. /**
  94473. * @hidden
  94474. */
  94475. set material(value: Material);
  94476. /**
  94477. * @hidden
  94478. */
  94479. get checkCollisions(): boolean;
  94480. /** @hidden */
  94481. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94482. /** @hidden */
  94483. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94484. /**
  94485. * Disposes of the line mesh
  94486. * @param doNotRecurse If children should be disposed
  94487. */
  94488. dispose(doNotRecurse?: boolean): void;
  94489. /**
  94490. * Returns a new LineMesh object cloned from the current one.
  94491. */
  94492. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94493. /**
  94494. * Creates a new InstancedLinesMesh object from the mesh model.
  94495. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94496. * @param name defines the name of the new instance
  94497. * @returns a new InstancedLinesMesh
  94498. */
  94499. createInstance(name: string): InstancedLinesMesh;
  94500. }
  94501. /**
  94502. * Creates an instance based on a source LinesMesh
  94503. */
  94504. export class InstancedLinesMesh extends InstancedMesh {
  94505. /**
  94506. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94507. * This margin is expressed in world space coordinates, so its value may vary.
  94508. * Initilized with the intersectionThreshold value of the source LinesMesh
  94509. */
  94510. intersectionThreshold: number;
  94511. constructor(name: string, source: LinesMesh);
  94512. /**
  94513. * Returns the string "InstancedLinesMesh".
  94514. */
  94515. getClassName(): string;
  94516. }
  94517. }
  94518. declare module BABYLON {
  94519. /** @hidden */
  94520. export var linePixelShader: {
  94521. name: string;
  94522. shader: string;
  94523. };
  94524. }
  94525. declare module BABYLON {
  94526. /** @hidden */
  94527. export var lineVertexShader: {
  94528. name: string;
  94529. shader: string;
  94530. };
  94531. }
  94532. declare module BABYLON {
  94533. interface Scene {
  94534. /** @hidden */
  94535. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94536. }
  94537. interface AbstractMesh {
  94538. /**
  94539. * Gets the edgesRenderer associated with the mesh
  94540. */
  94541. edgesRenderer: Nullable<EdgesRenderer>;
  94542. }
  94543. interface LinesMesh {
  94544. /**
  94545. * Enables the edge rendering mode on the mesh.
  94546. * This mode makes the mesh edges visible
  94547. * @param epsilon defines the maximal distance between two angles to detect a face
  94548. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94549. * @returns the currentAbstractMesh
  94550. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94551. */
  94552. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94553. }
  94554. interface InstancedLinesMesh {
  94555. /**
  94556. * Enables the edge rendering mode on the mesh.
  94557. * This mode makes the mesh edges visible
  94558. * @param epsilon defines the maximal distance between two angles to detect a face
  94559. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94560. * @returns the current InstancedLinesMesh
  94561. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94562. */
  94563. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94564. }
  94565. /**
  94566. * Defines the minimum contract an Edges renderer should follow.
  94567. */
  94568. export interface IEdgesRenderer extends IDisposable {
  94569. /**
  94570. * Gets or sets a boolean indicating if the edgesRenderer is active
  94571. */
  94572. isEnabled: boolean;
  94573. /**
  94574. * Renders the edges of the attached mesh,
  94575. */
  94576. render(): void;
  94577. /**
  94578. * Checks wether or not the edges renderer is ready to render.
  94579. * @return true if ready, otherwise false.
  94580. */
  94581. isReady(): boolean;
  94582. /**
  94583. * List of instances to render in case the source mesh has instances
  94584. */
  94585. customInstances: SmartArray<Matrix>;
  94586. }
  94587. /**
  94588. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94589. */
  94590. export class EdgesRenderer implements IEdgesRenderer {
  94591. /**
  94592. * Define the size of the edges with an orthographic camera
  94593. */
  94594. edgesWidthScalerForOrthographic: number;
  94595. /**
  94596. * Define the size of the edges with a perspective camera
  94597. */
  94598. edgesWidthScalerForPerspective: number;
  94599. protected _source: AbstractMesh;
  94600. protected _linesPositions: number[];
  94601. protected _linesNormals: number[];
  94602. protected _linesIndices: number[];
  94603. protected _epsilon: number;
  94604. protected _indicesCount: number;
  94605. protected _lineShader: ShaderMaterial;
  94606. protected _ib: DataBuffer;
  94607. protected _buffers: {
  94608. [key: string]: Nullable<VertexBuffer>;
  94609. };
  94610. protected _buffersForInstances: {
  94611. [key: string]: Nullable<VertexBuffer>;
  94612. };
  94613. protected _checkVerticesInsteadOfIndices: boolean;
  94614. private _meshRebuildObserver;
  94615. private _meshDisposeObserver;
  94616. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94617. isEnabled: boolean;
  94618. /**
  94619. * List of instances to render in case the source mesh has instances
  94620. */
  94621. customInstances: SmartArray<Matrix>;
  94622. private static GetShader;
  94623. /**
  94624. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94625. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94626. * @param source Mesh used to create edges
  94627. * @param epsilon sum of angles in adjacency to check for edge
  94628. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94629. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94630. */
  94631. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94632. protected _prepareRessources(): void;
  94633. /** @hidden */
  94634. _rebuild(): void;
  94635. /**
  94636. * Releases the required resources for the edges renderer
  94637. */
  94638. dispose(): void;
  94639. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94640. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94641. /**
  94642. * Checks if the pair of p0 and p1 is en edge
  94643. * @param faceIndex
  94644. * @param edge
  94645. * @param faceNormals
  94646. * @param p0
  94647. * @param p1
  94648. * @private
  94649. */
  94650. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94651. /**
  94652. * push line into the position, normal and index buffer
  94653. * @protected
  94654. */
  94655. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94656. /**
  94657. * Generates lines edges from adjacencjes
  94658. * @private
  94659. */
  94660. _generateEdgesLines(): void;
  94661. /**
  94662. * Checks wether or not the edges renderer is ready to render.
  94663. * @return true if ready, otherwise false.
  94664. */
  94665. isReady(): boolean;
  94666. /**
  94667. * Renders the edges of the attached mesh,
  94668. */
  94669. render(): void;
  94670. }
  94671. /**
  94672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94673. */
  94674. export class LineEdgesRenderer extends EdgesRenderer {
  94675. /**
  94676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94677. * @param source LineMesh used to generate edges
  94678. * @param epsilon not important (specified angle for edge detection)
  94679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94680. */
  94681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94682. /**
  94683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94684. */
  94685. _generateEdgesLines(): void;
  94686. }
  94687. }
  94688. declare module BABYLON {
  94689. /**
  94690. * This represents the object necessary to create a rendering group.
  94691. * This is exclusively used and created by the rendering manager.
  94692. * To modify the behavior, you use the available helpers in your scene or meshes.
  94693. * @hidden
  94694. */
  94695. export class RenderingGroup {
  94696. index: number;
  94697. private static _zeroVector;
  94698. private _scene;
  94699. private _opaqueSubMeshes;
  94700. private _transparentSubMeshes;
  94701. private _alphaTestSubMeshes;
  94702. private _depthOnlySubMeshes;
  94703. private _particleSystems;
  94704. private _spriteManagers;
  94705. private _opaqueSortCompareFn;
  94706. private _alphaTestSortCompareFn;
  94707. private _transparentSortCompareFn;
  94708. private _renderOpaque;
  94709. private _renderAlphaTest;
  94710. private _renderTransparent;
  94711. /** @hidden */
  94712. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94713. onBeforeTransparentRendering: () => void;
  94714. /**
  94715. * Set the opaque sort comparison function.
  94716. * If null the sub meshes will be render in the order they were created
  94717. */
  94718. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94719. /**
  94720. * Set the alpha test sort comparison function.
  94721. * If null the sub meshes will be render in the order they were created
  94722. */
  94723. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94724. /**
  94725. * Set the transparent sort comparison function.
  94726. * If null the sub meshes will be render in the order they were created
  94727. */
  94728. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94729. /**
  94730. * Creates a new rendering group.
  94731. * @param index The rendering group index
  94732. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94733. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94734. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94735. */
  94736. 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>);
  94737. /**
  94738. * Render all the sub meshes contained in the group.
  94739. * @param customRenderFunction Used to override the default render behaviour of the group.
  94740. * @returns true if rendered some submeshes.
  94741. */
  94742. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94743. /**
  94744. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94745. * @param subMeshes The submeshes to render
  94746. */
  94747. private renderOpaqueSorted;
  94748. /**
  94749. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94750. * @param subMeshes The submeshes to render
  94751. */
  94752. private renderAlphaTestSorted;
  94753. /**
  94754. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94755. * @param subMeshes The submeshes to render
  94756. */
  94757. private renderTransparentSorted;
  94758. /**
  94759. * Renders the submeshes in a specified order.
  94760. * @param subMeshes The submeshes to sort before render
  94761. * @param sortCompareFn The comparison function use to sort
  94762. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94763. * @param transparent Specifies to activate blending if true
  94764. */
  94765. private static renderSorted;
  94766. /**
  94767. * Renders the submeshes in the order they were dispatched (no sort applied).
  94768. * @param subMeshes The submeshes to render
  94769. */
  94770. private static renderUnsorted;
  94771. /**
  94772. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94773. * are rendered back to front if in the same alpha index.
  94774. *
  94775. * @param a The first submesh
  94776. * @param b The second submesh
  94777. * @returns The result of the comparison
  94778. */
  94779. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94780. /**
  94781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94782. * are rendered back to front.
  94783. *
  94784. * @param a The first submesh
  94785. * @param b The second submesh
  94786. * @returns The result of the comparison
  94787. */
  94788. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94789. /**
  94790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94791. * are rendered front to back (prevent overdraw).
  94792. *
  94793. * @param a The first submesh
  94794. * @param b The second submesh
  94795. * @returns The result of the comparison
  94796. */
  94797. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94798. /**
  94799. * Resets the different lists of submeshes to prepare a new frame.
  94800. */
  94801. prepare(): void;
  94802. dispose(): void;
  94803. /**
  94804. * Inserts the submesh in its correct queue depending on its material.
  94805. * @param subMesh The submesh to dispatch
  94806. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94807. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94808. */
  94809. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94810. dispatchSprites(spriteManager: ISpriteManager): void;
  94811. dispatchParticles(particleSystem: IParticleSystem): void;
  94812. private _renderParticles;
  94813. private _renderSprites;
  94814. }
  94815. }
  94816. declare module BABYLON {
  94817. /**
  94818. * Interface describing the different options available in the rendering manager
  94819. * regarding Auto Clear between groups.
  94820. */
  94821. export interface IRenderingManagerAutoClearSetup {
  94822. /**
  94823. * Defines whether or not autoclear is enable.
  94824. */
  94825. autoClear: boolean;
  94826. /**
  94827. * Defines whether or not to autoclear the depth buffer.
  94828. */
  94829. depth: boolean;
  94830. /**
  94831. * Defines whether or not to autoclear the stencil buffer.
  94832. */
  94833. stencil: boolean;
  94834. }
  94835. /**
  94836. * This class is used by the onRenderingGroupObservable
  94837. */
  94838. export class RenderingGroupInfo {
  94839. /**
  94840. * The Scene that being rendered
  94841. */
  94842. scene: Scene;
  94843. /**
  94844. * The camera currently used for the rendering pass
  94845. */
  94846. camera: Nullable<Camera>;
  94847. /**
  94848. * The ID of the renderingGroup being processed
  94849. */
  94850. renderingGroupId: number;
  94851. }
  94852. /**
  94853. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94854. * It is enable to manage the different groups as well as the different necessary sort functions.
  94855. * This should not be used directly aside of the few static configurations
  94856. */
  94857. export class RenderingManager {
  94858. /**
  94859. * The max id used for rendering groups (not included)
  94860. */
  94861. static MAX_RENDERINGGROUPS: number;
  94862. /**
  94863. * The min id used for rendering groups (included)
  94864. */
  94865. static MIN_RENDERINGGROUPS: number;
  94866. /**
  94867. * Used to globally prevent autoclearing scenes.
  94868. */
  94869. static AUTOCLEAR: boolean;
  94870. /**
  94871. * @hidden
  94872. */
  94873. _useSceneAutoClearSetup: boolean;
  94874. private _scene;
  94875. private _renderingGroups;
  94876. private _depthStencilBufferAlreadyCleaned;
  94877. private _autoClearDepthStencil;
  94878. private _customOpaqueSortCompareFn;
  94879. private _customAlphaTestSortCompareFn;
  94880. private _customTransparentSortCompareFn;
  94881. private _renderingGroupInfo;
  94882. /**
  94883. * Instantiates a new rendering group for a particular scene
  94884. * @param scene Defines the scene the groups belongs to
  94885. */
  94886. constructor(scene: Scene);
  94887. private _clearDepthStencilBuffer;
  94888. /**
  94889. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94890. * @hidden
  94891. */
  94892. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94893. /**
  94894. * Resets the different information of the group to prepare a new frame
  94895. * @hidden
  94896. */
  94897. reset(): void;
  94898. /**
  94899. * Dispose and release the group and its associated resources.
  94900. * @hidden
  94901. */
  94902. dispose(): void;
  94903. /**
  94904. * Clear the info related to rendering groups preventing retention points during dispose.
  94905. */
  94906. freeRenderingGroups(): void;
  94907. private _prepareRenderingGroup;
  94908. /**
  94909. * Add a sprite manager to the rendering manager in order to render it this frame.
  94910. * @param spriteManager Define the sprite manager to render
  94911. */
  94912. dispatchSprites(spriteManager: ISpriteManager): void;
  94913. /**
  94914. * Add a particle system to the rendering manager in order to render it this frame.
  94915. * @param particleSystem Define the particle system to render
  94916. */
  94917. dispatchParticles(particleSystem: IParticleSystem): void;
  94918. /**
  94919. * Add a submesh to the manager in order to render it this frame
  94920. * @param subMesh The submesh to dispatch
  94921. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94922. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94923. */
  94924. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94925. /**
  94926. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94927. * This allowed control for front to back rendering or reversly depending of the special needs.
  94928. *
  94929. * @param renderingGroupId The rendering group id corresponding to its index
  94930. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94931. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94932. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94933. */
  94934. 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;
  94935. /**
  94936. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94937. *
  94938. * @param renderingGroupId The rendering group id corresponding to its index
  94939. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94940. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94941. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94942. */
  94943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94944. /**
  94945. * Gets the current auto clear configuration for one rendering group of the rendering
  94946. * manager.
  94947. * @param index the rendering group index to get the information for
  94948. * @returns The auto clear setup for the requested rendering group
  94949. */
  94950. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94951. }
  94952. }
  94953. declare module BABYLON {
  94954. /**
  94955. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94956. */
  94957. export interface ICustomShaderOptions {
  94958. /**
  94959. * Gets or sets the custom shader name to use
  94960. */
  94961. shaderName: string;
  94962. /**
  94963. * The list of attribute names used in the shader
  94964. */
  94965. attributes?: string[];
  94966. /**
  94967. * The list of unifrom names used in the shader
  94968. */
  94969. uniforms?: string[];
  94970. /**
  94971. * The list of sampler names used in the shader
  94972. */
  94973. samplers?: string[];
  94974. /**
  94975. * The list of defines used in the shader
  94976. */
  94977. defines?: string[];
  94978. }
  94979. /**
  94980. * Interface to implement to create a shadow generator compatible with BJS.
  94981. */
  94982. export interface IShadowGenerator {
  94983. /**
  94984. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94985. * @returns The render target texture if present otherwise, null
  94986. */
  94987. getShadowMap(): Nullable<RenderTargetTexture>;
  94988. /**
  94989. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94990. * @param subMesh The submesh we want to render in the shadow map
  94991. * @param useInstances Defines wether will draw in the map using instances
  94992. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94993. * @returns true if ready otherwise, false
  94994. */
  94995. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94996. /**
  94997. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94998. * @param defines Defines of the material we want to update
  94999. * @param lightIndex Index of the light in the enabled light list of the material
  95000. */
  95001. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95002. /**
  95003. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95004. * defined in the generator but impacting the effect).
  95005. * It implies the unifroms available on the materials are the standard BJS ones.
  95006. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95007. * @param effect The effect we are binfing the information for
  95008. */
  95009. bindShadowLight(lightIndex: string, effect: Effect): void;
  95010. /**
  95011. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95012. * (eq to shadow prjection matrix * light transform matrix)
  95013. * @returns The transform matrix used to create the shadow map
  95014. */
  95015. getTransformMatrix(): Matrix;
  95016. /**
  95017. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95018. * Cube and 2D textures for instance.
  95019. */
  95020. recreateShadowMap(): void;
  95021. /**
  95022. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95023. * @param onCompiled Callback triggered at the and of the effects compilation
  95024. * @param options Sets of optional options forcing the compilation with different modes
  95025. */
  95026. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95027. useInstances: boolean;
  95028. }>): void;
  95029. /**
  95030. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95031. * @param options Sets of optional options forcing the compilation with different modes
  95032. * @returns A promise that resolves when the compilation completes
  95033. */
  95034. forceCompilationAsync(options?: Partial<{
  95035. useInstances: boolean;
  95036. }>): Promise<void>;
  95037. /**
  95038. * Serializes the shadow generator setup to a json object.
  95039. * @returns The serialized JSON object
  95040. */
  95041. serialize(): any;
  95042. /**
  95043. * Disposes the Shadow map and related Textures and effects.
  95044. */
  95045. dispose(): void;
  95046. }
  95047. /**
  95048. * Default implementation IShadowGenerator.
  95049. * This is the main object responsible of generating shadows in the framework.
  95050. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95051. */
  95052. export class ShadowGenerator implements IShadowGenerator {
  95053. /**
  95054. * Name of the shadow generator class
  95055. */
  95056. static CLASSNAME: string;
  95057. /**
  95058. * Shadow generator mode None: no filtering applied.
  95059. */
  95060. static readonly FILTER_NONE: number;
  95061. /**
  95062. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95063. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95064. */
  95065. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95066. /**
  95067. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95068. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95069. */
  95070. static readonly FILTER_POISSONSAMPLING: number;
  95071. /**
  95072. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95073. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95074. */
  95075. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95076. /**
  95077. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95078. * edge artifacts on steep falloff.
  95079. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95080. */
  95081. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95082. /**
  95083. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95084. * edge artifacts on steep falloff.
  95085. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95086. */
  95087. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95088. /**
  95089. * Shadow generator mode PCF: Percentage Closer Filtering
  95090. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95091. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95092. */
  95093. static readonly FILTER_PCF: number;
  95094. /**
  95095. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95096. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95097. * Contact Hardening
  95098. */
  95099. static readonly FILTER_PCSS: number;
  95100. /**
  95101. * Reserved for PCF and PCSS
  95102. * Highest Quality.
  95103. *
  95104. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95105. *
  95106. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95107. */
  95108. static readonly QUALITY_HIGH: number;
  95109. /**
  95110. * Reserved for PCF and PCSS
  95111. * Good tradeoff for quality/perf cross devices
  95112. *
  95113. * Execute PCF on a 3*3 kernel.
  95114. *
  95115. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95116. */
  95117. static readonly QUALITY_MEDIUM: number;
  95118. /**
  95119. * Reserved for PCF and PCSS
  95120. * The lowest quality but the fastest.
  95121. *
  95122. * Execute PCF on a 1*1 kernel.
  95123. *
  95124. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95125. */
  95126. static readonly QUALITY_LOW: number;
  95127. /** Gets or sets the custom shader name to use */
  95128. customShaderOptions: ICustomShaderOptions;
  95129. /**
  95130. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95131. */
  95132. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95133. /**
  95134. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95135. */
  95136. onAfterShadowMapRenderObservable: Observable<Effect>;
  95137. /**
  95138. * Observable triggered before a mesh is rendered in the shadow map.
  95139. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95140. */
  95141. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95142. /**
  95143. * Observable triggered after a mesh is rendered in the shadow map.
  95144. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95145. */
  95146. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95147. protected _bias: number;
  95148. /**
  95149. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95150. */
  95151. get bias(): number;
  95152. /**
  95153. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95154. */
  95155. set bias(bias: number);
  95156. protected _normalBias: number;
  95157. /**
  95158. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95159. */
  95160. get normalBias(): number;
  95161. /**
  95162. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95163. */
  95164. set normalBias(normalBias: number);
  95165. protected _blurBoxOffset: number;
  95166. /**
  95167. * Gets the blur box offset: offset applied during the blur pass.
  95168. * Only useful if useKernelBlur = false
  95169. */
  95170. get blurBoxOffset(): number;
  95171. /**
  95172. * Sets the blur box offset: offset applied during the blur pass.
  95173. * Only useful if useKernelBlur = false
  95174. */
  95175. set blurBoxOffset(value: number);
  95176. protected _blurScale: number;
  95177. /**
  95178. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95179. * 2 means half of the size.
  95180. */
  95181. get blurScale(): number;
  95182. /**
  95183. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95184. * 2 means half of the size.
  95185. */
  95186. set blurScale(value: number);
  95187. protected _blurKernel: number;
  95188. /**
  95189. * Gets the blur kernel: kernel size of the blur pass.
  95190. * Only useful if useKernelBlur = true
  95191. */
  95192. get blurKernel(): number;
  95193. /**
  95194. * Sets the blur kernel: kernel size of the blur pass.
  95195. * Only useful if useKernelBlur = true
  95196. */
  95197. set blurKernel(value: number);
  95198. protected _useKernelBlur: boolean;
  95199. /**
  95200. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95201. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95202. */
  95203. get useKernelBlur(): boolean;
  95204. /**
  95205. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95206. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95207. */
  95208. set useKernelBlur(value: boolean);
  95209. protected _depthScale: number;
  95210. /**
  95211. * Gets the depth scale used in ESM mode.
  95212. */
  95213. get depthScale(): number;
  95214. /**
  95215. * Sets the depth scale used in ESM mode.
  95216. * This can override the scale stored on the light.
  95217. */
  95218. set depthScale(value: number);
  95219. protected _validateFilter(filter: number): number;
  95220. protected _filter: number;
  95221. /**
  95222. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95223. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95224. */
  95225. get filter(): number;
  95226. /**
  95227. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95228. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95229. */
  95230. set filter(value: number);
  95231. /**
  95232. * Gets if the current filter is set to Poisson Sampling.
  95233. */
  95234. get usePoissonSampling(): boolean;
  95235. /**
  95236. * Sets the current filter to Poisson Sampling.
  95237. */
  95238. set usePoissonSampling(value: boolean);
  95239. /**
  95240. * Gets if the current filter is set to ESM.
  95241. */
  95242. get useExponentialShadowMap(): boolean;
  95243. /**
  95244. * Sets the current filter is to ESM.
  95245. */
  95246. set useExponentialShadowMap(value: boolean);
  95247. /**
  95248. * Gets if the current filter is set to filtered ESM.
  95249. */
  95250. get useBlurExponentialShadowMap(): boolean;
  95251. /**
  95252. * Gets if the current filter is set to filtered ESM.
  95253. */
  95254. set useBlurExponentialShadowMap(value: boolean);
  95255. /**
  95256. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95257. * exponential to prevent steep falloff artifacts).
  95258. */
  95259. get useCloseExponentialShadowMap(): boolean;
  95260. /**
  95261. * Sets the current filter to "close ESM" (using the inverse of the
  95262. * exponential to prevent steep falloff artifacts).
  95263. */
  95264. set useCloseExponentialShadowMap(value: boolean);
  95265. /**
  95266. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95267. * exponential to prevent steep falloff artifacts).
  95268. */
  95269. get useBlurCloseExponentialShadowMap(): boolean;
  95270. /**
  95271. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95272. * exponential to prevent steep falloff artifacts).
  95273. */
  95274. set useBlurCloseExponentialShadowMap(value: boolean);
  95275. /**
  95276. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95277. */
  95278. get usePercentageCloserFiltering(): boolean;
  95279. /**
  95280. * Sets the current filter to "PCF" (percentage closer filtering).
  95281. */
  95282. set usePercentageCloserFiltering(value: boolean);
  95283. protected _filteringQuality: number;
  95284. /**
  95285. * Gets the PCF or PCSS Quality.
  95286. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95287. */
  95288. get filteringQuality(): number;
  95289. /**
  95290. * Sets the PCF or PCSS Quality.
  95291. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95292. */
  95293. set filteringQuality(filteringQuality: number);
  95294. /**
  95295. * Gets if the current filter is set to "PCSS" (contact hardening).
  95296. */
  95297. get useContactHardeningShadow(): boolean;
  95298. /**
  95299. * Sets the current filter to "PCSS" (contact hardening).
  95300. */
  95301. set useContactHardeningShadow(value: boolean);
  95302. protected _contactHardeningLightSizeUVRatio: number;
  95303. /**
  95304. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95305. * Using a ratio helps keeping shape stability independently of the map size.
  95306. *
  95307. * It does not account for the light projection as it was having too much
  95308. * instability during the light setup or during light position changes.
  95309. *
  95310. * Only valid if useContactHardeningShadow is true.
  95311. */
  95312. get contactHardeningLightSizeUVRatio(): number;
  95313. /**
  95314. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95315. * Using a ratio helps keeping shape stability independently of the map size.
  95316. *
  95317. * It does not account for the light projection as it was having too much
  95318. * instability during the light setup or during light position changes.
  95319. *
  95320. * Only valid if useContactHardeningShadow is true.
  95321. */
  95322. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95323. protected _darkness: number;
  95324. /** Gets or sets the actual darkness of a shadow */
  95325. get darkness(): number;
  95326. set darkness(value: number);
  95327. /**
  95328. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95329. * 0 means strongest and 1 would means no shadow.
  95330. * @returns the darkness.
  95331. */
  95332. getDarkness(): number;
  95333. /**
  95334. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95335. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95336. * @returns the shadow generator allowing fluent coding.
  95337. */
  95338. setDarkness(darkness: number): ShadowGenerator;
  95339. protected _transparencyShadow: boolean;
  95340. /** Gets or sets the ability to have transparent shadow */
  95341. get transparencyShadow(): boolean;
  95342. set transparencyShadow(value: boolean);
  95343. /**
  95344. * Sets the ability to have transparent shadow (boolean).
  95345. * @param transparent True if transparent else False
  95346. * @returns the shadow generator allowing fluent coding
  95347. */
  95348. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95349. /**
  95350. * Enables or disables shadows with varying strength based on the transparency
  95351. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95352. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95353. * mesh.visibility * alphaTexture.a
  95354. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95355. */
  95356. enableSoftTransparentShadow: boolean;
  95357. protected _shadowMap: Nullable<RenderTargetTexture>;
  95358. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95359. /**
  95360. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95361. * @returns The render target texture if present otherwise, null
  95362. */
  95363. getShadowMap(): Nullable<RenderTargetTexture>;
  95364. /**
  95365. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95366. * @returns The render target texture if the shadow map is present otherwise, null
  95367. */
  95368. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95369. /**
  95370. * Gets the class name of that object
  95371. * @returns "ShadowGenerator"
  95372. */
  95373. getClassName(): string;
  95374. /**
  95375. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95376. * @param mesh Mesh to add
  95377. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95378. * @returns the Shadow Generator itself
  95379. */
  95380. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95381. /**
  95382. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95383. * @param mesh Mesh to remove
  95384. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95385. * @returns the Shadow Generator itself
  95386. */
  95387. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95388. /**
  95389. * Controls the extent to which the shadows fade out at the edge of the frustum
  95390. */
  95391. frustumEdgeFalloff: number;
  95392. protected _light: IShadowLight;
  95393. /**
  95394. * Returns the associated light object.
  95395. * @returns the light generating the shadow
  95396. */
  95397. getLight(): IShadowLight;
  95398. /**
  95399. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95400. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95401. * It might on the other hand introduce peter panning.
  95402. */
  95403. forceBackFacesOnly: boolean;
  95404. protected _scene: Scene;
  95405. protected _lightDirection: Vector3;
  95406. protected _effect: Effect;
  95407. protected _viewMatrix: Matrix;
  95408. protected _projectionMatrix: Matrix;
  95409. protected _transformMatrix: Matrix;
  95410. protected _cachedPosition: Vector3;
  95411. protected _cachedDirection: Vector3;
  95412. protected _cachedDefines: string;
  95413. protected _currentRenderID: number;
  95414. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95415. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95416. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95417. protected _blurPostProcesses: PostProcess[];
  95418. protected _mapSize: number;
  95419. protected _currentFaceIndex: number;
  95420. protected _currentFaceIndexCache: number;
  95421. protected _textureType: number;
  95422. protected _defaultTextureMatrix: Matrix;
  95423. protected _storedUniqueId: Nullable<number>;
  95424. /** @hidden */
  95425. static _SceneComponentInitialization: (scene: Scene) => void;
  95426. /**
  95427. * Creates a ShadowGenerator object.
  95428. * A ShadowGenerator is the required tool to use the shadows.
  95429. * Each light casting shadows needs to use its own ShadowGenerator.
  95430. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95431. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95432. * @param light The light object generating the shadows.
  95433. * @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.
  95434. */
  95435. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95436. protected _initializeGenerator(): void;
  95437. protected _createTargetRenderTexture(): void;
  95438. protected _initializeShadowMap(): void;
  95439. protected _initializeBlurRTTAndPostProcesses(): void;
  95440. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95441. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95442. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95443. protected _applyFilterValues(): void;
  95444. /**
  95445. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95446. * @param onCompiled Callback triggered at the and of the effects compilation
  95447. * @param options Sets of optional options forcing the compilation with different modes
  95448. */
  95449. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95450. useInstances: boolean;
  95451. }>): void;
  95452. /**
  95453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95454. * @param options Sets of optional options forcing the compilation with different modes
  95455. * @returns A promise that resolves when the compilation completes
  95456. */
  95457. forceCompilationAsync(options?: Partial<{
  95458. useInstances: boolean;
  95459. }>): Promise<void>;
  95460. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95461. private _prepareShadowDefines;
  95462. /**
  95463. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95464. * @param subMesh The submesh we want to render in the shadow map
  95465. * @param useInstances Defines wether will draw in the map using instances
  95466. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95467. * @returns true if ready otherwise, false
  95468. */
  95469. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95470. /**
  95471. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95472. * @param defines Defines of the material we want to update
  95473. * @param lightIndex Index of the light in the enabled light list of the material
  95474. */
  95475. prepareDefines(defines: any, lightIndex: number): void;
  95476. /**
  95477. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95478. * defined in the generator but impacting the effect).
  95479. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95480. * @param effect The effect we are binfing the information for
  95481. */
  95482. bindShadowLight(lightIndex: string, effect: Effect): void;
  95483. /**
  95484. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95485. * (eq to shadow prjection matrix * light transform matrix)
  95486. * @returns The transform matrix used to create the shadow map
  95487. */
  95488. getTransformMatrix(): Matrix;
  95489. /**
  95490. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95491. * Cube and 2D textures for instance.
  95492. */
  95493. recreateShadowMap(): void;
  95494. protected _disposeBlurPostProcesses(): void;
  95495. protected _disposeRTTandPostProcesses(): void;
  95496. /**
  95497. * Disposes the ShadowGenerator.
  95498. * Returns nothing.
  95499. */
  95500. dispose(): void;
  95501. /**
  95502. * Serializes the shadow generator setup to a json object.
  95503. * @returns The serialized JSON object
  95504. */
  95505. serialize(): any;
  95506. /**
  95507. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95508. * @param parsedShadowGenerator The JSON object to parse
  95509. * @param scene The scene to create the shadow map for
  95510. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95511. * @returns The parsed shadow generator
  95512. */
  95513. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95514. }
  95515. }
  95516. declare module BABYLON {
  95517. /**
  95518. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95519. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95520. * 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.
  95521. */
  95522. export abstract class Light extends Node {
  95523. /**
  95524. * Falloff Default: light is falling off following the material specification:
  95525. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95526. */
  95527. static readonly FALLOFF_DEFAULT: number;
  95528. /**
  95529. * Falloff Physical: light is falling off following the inverse squared distance law.
  95530. */
  95531. static readonly FALLOFF_PHYSICAL: number;
  95532. /**
  95533. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95534. * to enhance interoperability with other engines.
  95535. */
  95536. static readonly FALLOFF_GLTF: number;
  95537. /**
  95538. * Falloff Standard: light is falling off like in the standard material
  95539. * to enhance interoperability with other materials.
  95540. */
  95541. static readonly FALLOFF_STANDARD: number;
  95542. /**
  95543. * If every light affecting the material is in this lightmapMode,
  95544. * material.lightmapTexture adds or multiplies
  95545. * (depends on material.useLightmapAsShadowmap)
  95546. * after every other light calculations.
  95547. */
  95548. static readonly LIGHTMAP_DEFAULT: number;
  95549. /**
  95550. * material.lightmapTexture as only diffuse lighting from this light
  95551. * adds only specular lighting from this light
  95552. * adds dynamic shadows
  95553. */
  95554. static readonly LIGHTMAP_SPECULAR: number;
  95555. /**
  95556. * material.lightmapTexture as only lighting
  95557. * no light calculation from this light
  95558. * only adds dynamic shadows from this light
  95559. */
  95560. static readonly LIGHTMAP_SHADOWSONLY: number;
  95561. /**
  95562. * Each light type uses the default quantity according to its type:
  95563. * point/spot lights use luminous intensity
  95564. * directional lights use illuminance
  95565. */
  95566. static readonly INTENSITYMODE_AUTOMATIC: number;
  95567. /**
  95568. * lumen (lm)
  95569. */
  95570. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95571. /**
  95572. * candela (lm/sr)
  95573. */
  95574. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95575. /**
  95576. * lux (lm/m^2)
  95577. */
  95578. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95579. /**
  95580. * nit (cd/m^2)
  95581. */
  95582. static readonly INTENSITYMODE_LUMINANCE: number;
  95583. /**
  95584. * Light type const id of the point light.
  95585. */
  95586. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95587. /**
  95588. * Light type const id of the directional light.
  95589. */
  95590. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95591. /**
  95592. * Light type const id of the spot light.
  95593. */
  95594. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95595. /**
  95596. * Light type const id of the hemispheric light.
  95597. */
  95598. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95599. /**
  95600. * Diffuse gives the basic color to an object.
  95601. */
  95602. diffuse: Color3;
  95603. /**
  95604. * Specular produces a highlight color on an object.
  95605. * Note: This is note affecting PBR materials.
  95606. */
  95607. specular: Color3;
  95608. /**
  95609. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95610. * falling off base on range or angle.
  95611. * This can be set to any values in Light.FALLOFF_x.
  95612. *
  95613. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95614. * other types of materials.
  95615. */
  95616. falloffType: number;
  95617. /**
  95618. * Strength of the light.
  95619. * Note: By default it is define in the framework own unit.
  95620. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95621. */
  95622. intensity: number;
  95623. private _range;
  95624. protected _inverseSquaredRange: number;
  95625. /**
  95626. * Defines how far from the source the light is impacting in scene units.
  95627. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95628. */
  95629. get range(): number;
  95630. /**
  95631. * Defines how far from the source the light is impacting in scene units.
  95632. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95633. */
  95634. set range(value: number);
  95635. /**
  95636. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95637. * of light.
  95638. */
  95639. private _photometricScale;
  95640. private _intensityMode;
  95641. /**
  95642. * Gets the photometric scale used to interpret the intensity.
  95643. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95644. */
  95645. get intensityMode(): number;
  95646. /**
  95647. * Sets the photometric scale used to interpret the intensity.
  95648. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95649. */
  95650. set intensityMode(value: number);
  95651. private _radius;
  95652. /**
  95653. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95654. */
  95655. get radius(): number;
  95656. /**
  95657. * sets the light radius used by PBR Materials to simulate soft area lights.
  95658. */
  95659. set radius(value: number);
  95660. private _renderPriority;
  95661. /**
  95662. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95663. * exceeding the number allowed of the materials.
  95664. */
  95665. renderPriority: number;
  95666. private _shadowEnabled;
  95667. /**
  95668. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95669. * the current shadow generator.
  95670. */
  95671. get shadowEnabled(): boolean;
  95672. /**
  95673. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95674. * the current shadow generator.
  95675. */
  95676. set shadowEnabled(value: boolean);
  95677. private _includedOnlyMeshes;
  95678. /**
  95679. * Gets the only meshes impacted by this light.
  95680. */
  95681. get includedOnlyMeshes(): AbstractMesh[];
  95682. /**
  95683. * Sets the only meshes impacted by this light.
  95684. */
  95685. set includedOnlyMeshes(value: AbstractMesh[]);
  95686. private _excludedMeshes;
  95687. /**
  95688. * Gets the meshes not impacted by this light.
  95689. */
  95690. get excludedMeshes(): AbstractMesh[];
  95691. /**
  95692. * Sets the meshes not impacted by this light.
  95693. */
  95694. set excludedMeshes(value: AbstractMesh[]);
  95695. private _excludeWithLayerMask;
  95696. /**
  95697. * Gets the layer id use to find what meshes are not impacted by the light.
  95698. * Inactive if 0
  95699. */
  95700. get excludeWithLayerMask(): number;
  95701. /**
  95702. * Sets the layer id use to find what meshes are not impacted by the light.
  95703. * Inactive if 0
  95704. */
  95705. set excludeWithLayerMask(value: number);
  95706. private _includeOnlyWithLayerMask;
  95707. /**
  95708. * Gets the layer id use to find what meshes are impacted by the light.
  95709. * Inactive if 0
  95710. */
  95711. get includeOnlyWithLayerMask(): number;
  95712. /**
  95713. * Sets the layer id use to find what meshes are impacted by the light.
  95714. * Inactive if 0
  95715. */
  95716. set includeOnlyWithLayerMask(value: number);
  95717. private _lightmapMode;
  95718. /**
  95719. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95720. */
  95721. get lightmapMode(): number;
  95722. /**
  95723. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95724. */
  95725. set lightmapMode(value: number);
  95726. /**
  95727. * Shadow generator associted to the light.
  95728. * @hidden Internal use only.
  95729. */
  95730. _shadowGenerator: Nullable<IShadowGenerator>;
  95731. /**
  95732. * @hidden Internal use only.
  95733. */
  95734. _excludedMeshesIds: string[];
  95735. /**
  95736. * @hidden Internal use only.
  95737. */
  95738. _includedOnlyMeshesIds: string[];
  95739. /**
  95740. * The current light unifom buffer.
  95741. * @hidden Internal use only.
  95742. */
  95743. _uniformBuffer: UniformBuffer;
  95744. /** @hidden */
  95745. _renderId: number;
  95746. /**
  95747. * Creates a Light object in the scene.
  95748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95749. * @param name The firendly name of the light
  95750. * @param scene The scene the light belongs too
  95751. */
  95752. constructor(name: string, scene: Scene);
  95753. protected abstract _buildUniformLayout(): void;
  95754. /**
  95755. * Sets the passed Effect "effect" with the Light information.
  95756. * @param effect The effect to update
  95757. * @param lightIndex The index of the light in the effect to update
  95758. * @returns The light
  95759. */
  95760. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95761. /**
  95762. * Sets the passed Effect "effect" with the Light textures.
  95763. * @param effect The effect to update
  95764. * @param lightIndex The index of the light in the effect to update
  95765. * @returns The light
  95766. */
  95767. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95768. /**
  95769. * Binds the lights information from the scene to the effect for the given mesh.
  95770. * @param lightIndex Light index
  95771. * @param scene The scene where the light belongs to
  95772. * @param effect The effect we are binding the data to
  95773. * @param useSpecular Defines if specular is supported
  95774. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95775. */
  95776. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95777. /**
  95778. * Sets the passed Effect "effect" with the Light information.
  95779. * @param effect The effect to update
  95780. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95781. * @returns The light
  95782. */
  95783. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95784. /**
  95785. * Returns the string "Light".
  95786. * @returns the class name
  95787. */
  95788. getClassName(): string;
  95789. /** @hidden */
  95790. readonly _isLight: boolean;
  95791. /**
  95792. * Converts the light information to a readable string for debug purpose.
  95793. * @param fullDetails Supports for multiple levels of logging within scene loading
  95794. * @returns the human readable light info
  95795. */
  95796. toString(fullDetails?: boolean): string;
  95797. /** @hidden */
  95798. protected _syncParentEnabledState(): void;
  95799. /**
  95800. * Set the enabled state of this node.
  95801. * @param value - the new enabled state
  95802. */
  95803. setEnabled(value: boolean): void;
  95804. /**
  95805. * Returns the Light associated shadow generator if any.
  95806. * @return the associated shadow generator.
  95807. */
  95808. getShadowGenerator(): Nullable<IShadowGenerator>;
  95809. /**
  95810. * Returns a Vector3, the absolute light position in the World.
  95811. * @returns the world space position of the light
  95812. */
  95813. getAbsolutePosition(): Vector3;
  95814. /**
  95815. * Specifies if the light will affect the passed mesh.
  95816. * @param mesh The mesh to test against the light
  95817. * @return true the mesh is affected otherwise, false.
  95818. */
  95819. canAffectMesh(mesh: AbstractMesh): boolean;
  95820. /**
  95821. * Sort function to order lights for rendering.
  95822. * @param a First Light object to compare to second.
  95823. * @param b Second Light object to compare first.
  95824. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95825. */
  95826. static CompareLightsPriority(a: Light, b: Light): number;
  95827. /**
  95828. * Releases resources associated with this node.
  95829. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95830. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95831. */
  95832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95833. /**
  95834. * Returns the light type ID (integer).
  95835. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95836. */
  95837. getTypeID(): number;
  95838. /**
  95839. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95840. * @returns the scaled intensity in intensity mode unit
  95841. */
  95842. getScaledIntensity(): number;
  95843. /**
  95844. * Returns a new Light object, named "name", from the current one.
  95845. * @param name The name of the cloned light
  95846. * @param newParent The parent of this light, if it has one
  95847. * @returns the new created light
  95848. */
  95849. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95850. /**
  95851. * Serializes the current light into a Serialization object.
  95852. * @returns the serialized object.
  95853. */
  95854. serialize(): any;
  95855. /**
  95856. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95857. * This new light is named "name" and added to the passed scene.
  95858. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95859. * @param name The friendly name of the light
  95860. * @param scene The scene the new light will belong to
  95861. * @returns the constructor function
  95862. */
  95863. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95864. /**
  95865. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95866. * @param parsedLight The JSON representation of the light
  95867. * @param scene The scene to create the parsed light in
  95868. * @returns the created light after parsing
  95869. */
  95870. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95871. private _hookArrayForExcluded;
  95872. private _hookArrayForIncludedOnly;
  95873. private _resyncMeshes;
  95874. /**
  95875. * Forces the meshes to update their light related information in their rendering used effects
  95876. * @hidden Internal Use Only
  95877. */
  95878. _markMeshesAsLightDirty(): void;
  95879. /**
  95880. * Recomputes the cached photometric scale if needed.
  95881. */
  95882. private _computePhotometricScale;
  95883. /**
  95884. * Returns the Photometric Scale according to the light type and intensity mode.
  95885. */
  95886. private _getPhotometricScale;
  95887. /**
  95888. * Reorder the light in the scene according to their defined priority.
  95889. * @hidden Internal Use Only
  95890. */
  95891. _reorderLightsInScene(): void;
  95892. /**
  95893. * Prepares the list of defines specific to the light type.
  95894. * @param defines the list of defines
  95895. * @param lightIndex defines the index of the light for the effect
  95896. */
  95897. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95903. * This is the base of the follow, arc rotate cameras and Free camera
  95904. * @see http://doc.babylonjs.com/features/cameras
  95905. */
  95906. export class TargetCamera extends Camera {
  95907. private static _RigCamTransformMatrix;
  95908. private static _TargetTransformMatrix;
  95909. private static _TargetFocalPoint;
  95910. /**
  95911. * Define the current direction the camera is moving to
  95912. */
  95913. cameraDirection: Vector3;
  95914. /**
  95915. * Define the current rotation the camera is rotating to
  95916. */
  95917. cameraRotation: Vector2;
  95918. /**
  95919. * When set, the up vector of the camera will be updated by the rotation of the camera
  95920. */
  95921. updateUpVectorFromRotation: boolean;
  95922. private _tmpQuaternion;
  95923. /**
  95924. * Define the current rotation of the camera
  95925. */
  95926. rotation: Vector3;
  95927. /**
  95928. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95929. */
  95930. rotationQuaternion: Quaternion;
  95931. /**
  95932. * Define the current speed of the camera
  95933. */
  95934. speed: number;
  95935. /**
  95936. * Add constraint to the camera to prevent it to move freely in all directions and
  95937. * around all axis.
  95938. */
  95939. noRotationConstraint: boolean;
  95940. /**
  95941. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95942. * panning
  95943. */
  95944. invertRotation: boolean;
  95945. /**
  95946. * Speed multiplier for inverse camera panning
  95947. */
  95948. inverseRotationSpeed: number;
  95949. /**
  95950. * Define the current target of the camera as an object or a position.
  95951. */
  95952. lockedTarget: any;
  95953. /** @hidden */
  95954. _currentTarget: Vector3;
  95955. /** @hidden */
  95956. _initialFocalDistance: number;
  95957. /** @hidden */
  95958. _viewMatrix: Matrix;
  95959. /** @hidden */
  95960. _camMatrix: Matrix;
  95961. /** @hidden */
  95962. _cameraTransformMatrix: Matrix;
  95963. /** @hidden */
  95964. _cameraRotationMatrix: Matrix;
  95965. /** @hidden */
  95966. _referencePoint: Vector3;
  95967. /** @hidden */
  95968. _transformedReferencePoint: Vector3;
  95969. /** @hidden */
  95970. _reset: () => void;
  95971. private _defaultUp;
  95972. /**
  95973. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95974. * This is the base of the follow, arc rotate cameras and Free camera
  95975. * @see http://doc.babylonjs.com/features/cameras
  95976. * @param name Defines the name of the camera in the scene
  95977. * @param position Defines the start position of the camera in the scene
  95978. * @param scene Defines the scene the camera belongs to
  95979. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95980. */
  95981. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95982. /**
  95983. * Gets the position in front of the camera at a given distance.
  95984. * @param distance The distance from the camera we want the position to be
  95985. * @returns the position
  95986. */
  95987. getFrontPosition(distance: number): Vector3;
  95988. /** @hidden */
  95989. _getLockedTargetPosition(): Nullable<Vector3>;
  95990. private _storedPosition;
  95991. private _storedRotation;
  95992. private _storedRotationQuaternion;
  95993. /**
  95994. * Store current camera state of the camera (fov, position, rotation, etc..)
  95995. * @returns the camera
  95996. */
  95997. storeState(): Camera;
  95998. /**
  95999. * Restored camera state. You must call storeState() first
  96000. * @returns whether it was successful or not
  96001. * @hidden
  96002. */
  96003. _restoreStateValues(): boolean;
  96004. /** @hidden */
  96005. _initCache(): void;
  96006. /** @hidden */
  96007. _updateCache(ignoreParentClass?: boolean): void;
  96008. /** @hidden */
  96009. _isSynchronizedViewMatrix(): boolean;
  96010. /** @hidden */
  96011. _computeLocalCameraSpeed(): number;
  96012. /**
  96013. * Defines the target the camera should look at.
  96014. * @param target Defines the new target as a Vector or a mesh
  96015. */
  96016. setTarget(target: Vector3): void;
  96017. /**
  96018. * Return the current target position of the camera. This value is expressed in local space.
  96019. * @returns the target position
  96020. */
  96021. getTarget(): Vector3;
  96022. /** @hidden */
  96023. _decideIfNeedsToMove(): boolean;
  96024. /** @hidden */
  96025. _updatePosition(): void;
  96026. /** @hidden */
  96027. _checkInputs(): void;
  96028. protected _updateCameraRotationMatrix(): void;
  96029. /**
  96030. * 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)
  96031. * @returns the current camera
  96032. */
  96033. private _rotateUpVectorWithCameraRotationMatrix;
  96034. private _cachedRotationZ;
  96035. private _cachedQuaternionRotationZ;
  96036. /** @hidden */
  96037. _getViewMatrix(): Matrix;
  96038. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96039. /**
  96040. * @hidden
  96041. */
  96042. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96043. /**
  96044. * @hidden
  96045. */
  96046. _updateRigCameras(): void;
  96047. private _getRigCamPositionAndTarget;
  96048. /**
  96049. * Gets the current object class name.
  96050. * @return the class name
  96051. */
  96052. getClassName(): string;
  96053. }
  96054. }
  96055. declare module BABYLON {
  96056. /**
  96057. * Gather the list of keyboard event types as constants.
  96058. */
  96059. export class KeyboardEventTypes {
  96060. /**
  96061. * The keydown event is fired when a key becomes active (pressed).
  96062. */
  96063. static readonly KEYDOWN: number;
  96064. /**
  96065. * The keyup event is fired when a key has been released.
  96066. */
  96067. static readonly KEYUP: number;
  96068. }
  96069. /**
  96070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96071. */
  96072. export class KeyboardInfo {
  96073. /**
  96074. * Defines the type of event (KeyboardEventTypes)
  96075. */
  96076. type: number;
  96077. /**
  96078. * Defines the related dom event
  96079. */
  96080. event: KeyboardEvent;
  96081. /**
  96082. * Instantiates a new keyboard info.
  96083. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96084. * @param type Defines the type of event (KeyboardEventTypes)
  96085. * @param event Defines the related dom event
  96086. */
  96087. constructor(
  96088. /**
  96089. * Defines the type of event (KeyboardEventTypes)
  96090. */
  96091. type: number,
  96092. /**
  96093. * Defines the related dom event
  96094. */
  96095. event: KeyboardEvent);
  96096. }
  96097. /**
  96098. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96099. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96100. */
  96101. export class KeyboardInfoPre extends KeyboardInfo {
  96102. /**
  96103. * Defines the type of event (KeyboardEventTypes)
  96104. */
  96105. type: number;
  96106. /**
  96107. * Defines the related dom event
  96108. */
  96109. event: KeyboardEvent;
  96110. /**
  96111. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96112. */
  96113. skipOnPointerObservable: boolean;
  96114. /**
  96115. * Instantiates a new keyboard pre info.
  96116. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96117. * @param type Defines the type of event (KeyboardEventTypes)
  96118. * @param event Defines the related dom event
  96119. */
  96120. constructor(
  96121. /**
  96122. * Defines the type of event (KeyboardEventTypes)
  96123. */
  96124. type: number,
  96125. /**
  96126. * Defines the related dom event
  96127. */
  96128. event: KeyboardEvent);
  96129. }
  96130. }
  96131. declare module BABYLON {
  96132. /**
  96133. * Manage the keyboard inputs to control the movement of a free camera.
  96134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96135. */
  96136. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96137. /**
  96138. * Defines the camera the input is attached to.
  96139. */
  96140. camera: FreeCamera;
  96141. /**
  96142. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96143. */
  96144. keysUp: number[];
  96145. /**
  96146. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96147. */
  96148. keysUpward: number[];
  96149. /**
  96150. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96151. */
  96152. keysDown: number[];
  96153. /**
  96154. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96155. */
  96156. keysDownward: number[];
  96157. /**
  96158. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96159. */
  96160. keysLeft: number[];
  96161. /**
  96162. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96163. */
  96164. keysRight: number[];
  96165. private _keys;
  96166. private _onCanvasBlurObserver;
  96167. private _onKeyboardObserver;
  96168. private _engine;
  96169. private _scene;
  96170. /**
  96171. * Attach the input controls to a specific dom element to get the input from.
  96172. * @param element Defines the element the controls should be listened from
  96173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96174. */
  96175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96176. /**
  96177. * Detach the current controls from the specified dom element.
  96178. * @param element Defines the element to stop listening the inputs from
  96179. */
  96180. detachControl(element: Nullable<HTMLElement>): void;
  96181. /**
  96182. * Update the current camera state depending on the inputs that have been used this frame.
  96183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96184. */
  96185. checkInputs(): void;
  96186. /**
  96187. * Gets the class name of the current intput.
  96188. * @returns the class name
  96189. */
  96190. getClassName(): string;
  96191. /** @hidden */
  96192. _onLostFocus(): void;
  96193. /**
  96194. * Get the friendly name associated with the input class.
  96195. * @returns the input friendly name
  96196. */
  96197. getSimpleName(): string;
  96198. }
  96199. }
  96200. declare module BABYLON {
  96201. /**
  96202. * Gather the list of pointer event types as constants.
  96203. */
  96204. export class PointerEventTypes {
  96205. /**
  96206. * 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.
  96207. */
  96208. static readonly POINTERDOWN: number;
  96209. /**
  96210. * The pointerup event is fired when a pointer is no longer active.
  96211. */
  96212. static readonly POINTERUP: number;
  96213. /**
  96214. * The pointermove event is fired when a pointer changes coordinates.
  96215. */
  96216. static readonly POINTERMOVE: number;
  96217. /**
  96218. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96219. */
  96220. static readonly POINTERWHEEL: number;
  96221. /**
  96222. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96223. */
  96224. static readonly POINTERPICK: number;
  96225. /**
  96226. * The pointertap event is fired when a the object has been touched and released without drag.
  96227. */
  96228. static readonly POINTERTAP: number;
  96229. /**
  96230. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96231. */
  96232. static readonly POINTERDOUBLETAP: number;
  96233. }
  96234. /**
  96235. * Base class of pointer info types.
  96236. */
  96237. export class PointerInfoBase {
  96238. /**
  96239. * Defines the type of event (PointerEventTypes)
  96240. */
  96241. type: number;
  96242. /**
  96243. * Defines the related dom event
  96244. */
  96245. event: PointerEvent | MouseWheelEvent;
  96246. /**
  96247. * Instantiates the base class of pointers info.
  96248. * @param type Defines the type of event (PointerEventTypes)
  96249. * @param event Defines the related dom event
  96250. */
  96251. constructor(
  96252. /**
  96253. * Defines the type of event (PointerEventTypes)
  96254. */
  96255. type: number,
  96256. /**
  96257. * Defines the related dom event
  96258. */
  96259. event: PointerEvent | MouseWheelEvent);
  96260. }
  96261. /**
  96262. * This class is used to store pointer related info for the onPrePointerObservable event.
  96263. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96264. */
  96265. export class PointerInfoPre extends PointerInfoBase {
  96266. /**
  96267. * Ray from a pointer if availible (eg. 6dof controller)
  96268. */
  96269. ray: Nullable<Ray>;
  96270. /**
  96271. * Defines the local position of the pointer on the canvas.
  96272. */
  96273. localPosition: Vector2;
  96274. /**
  96275. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96276. */
  96277. skipOnPointerObservable: boolean;
  96278. /**
  96279. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96280. * @param type Defines the type of event (PointerEventTypes)
  96281. * @param event Defines the related dom event
  96282. * @param localX Defines the local x coordinates of the pointer when the event occured
  96283. * @param localY Defines the local y coordinates of the pointer when the event occured
  96284. */
  96285. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96286. }
  96287. /**
  96288. * This type contains all the data related to a pointer event in Babylon.js.
  96289. * 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.
  96290. */
  96291. export class PointerInfo extends PointerInfoBase {
  96292. /**
  96293. * Defines the picking info associated to the info (if any)\
  96294. */
  96295. pickInfo: Nullable<PickingInfo>;
  96296. /**
  96297. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96298. * @param type Defines the type of event (PointerEventTypes)
  96299. * @param event Defines the related dom event
  96300. * @param pickInfo Defines the picking info associated to the info (if any)\
  96301. */
  96302. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96303. /**
  96304. * Defines the picking info associated to the info (if any)\
  96305. */
  96306. pickInfo: Nullable<PickingInfo>);
  96307. }
  96308. /**
  96309. * Data relating to a touch event on the screen.
  96310. */
  96311. export interface PointerTouch {
  96312. /**
  96313. * X coordinate of touch.
  96314. */
  96315. x: number;
  96316. /**
  96317. * Y coordinate of touch.
  96318. */
  96319. y: number;
  96320. /**
  96321. * Id of touch. Unique for each finger.
  96322. */
  96323. pointerId: number;
  96324. /**
  96325. * Event type passed from DOM.
  96326. */
  96327. type: any;
  96328. }
  96329. }
  96330. declare module BABYLON {
  96331. /**
  96332. * Manage the mouse inputs to control the movement of a free camera.
  96333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96334. */
  96335. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96336. /**
  96337. * Define if touch is enabled in the mouse input
  96338. */
  96339. touchEnabled: boolean;
  96340. /**
  96341. * Defines the camera the input is attached to.
  96342. */
  96343. camera: FreeCamera;
  96344. /**
  96345. * Defines the buttons associated with the input to handle camera move.
  96346. */
  96347. buttons: number[];
  96348. /**
  96349. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96350. */
  96351. angularSensibility: number;
  96352. private _pointerInput;
  96353. private _onMouseMove;
  96354. private _observer;
  96355. private previousPosition;
  96356. /**
  96357. * Observable for when a pointer move event occurs containing the move offset
  96358. */
  96359. onPointerMovedObservable: Observable<{
  96360. offsetX: number;
  96361. offsetY: number;
  96362. }>;
  96363. /**
  96364. * @hidden
  96365. * If the camera should be rotated automatically based on pointer movement
  96366. */
  96367. _allowCameraRotation: boolean;
  96368. /**
  96369. * Manage the mouse inputs to control the movement of a free camera.
  96370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96371. * @param touchEnabled Defines if touch is enabled or not
  96372. */
  96373. constructor(
  96374. /**
  96375. * Define if touch is enabled in the mouse input
  96376. */
  96377. touchEnabled?: boolean);
  96378. /**
  96379. * Attach the input controls to a specific dom element to get the input from.
  96380. * @param element Defines the element the controls should be listened from
  96381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96382. */
  96383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96384. /**
  96385. * Called on JS contextmenu event.
  96386. * Override this method to provide functionality.
  96387. */
  96388. protected onContextMenu(evt: PointerEvent): void;
  96389. /**
  96390. * Detach the current controls from the specified dom element.
  96391. * @param element Defines the element to stop listening the inputs from
  96392. */
  96393. detachControl(element: Nullable<HTMLElement>): void;
  96394. /**
  96395. * Gets the class name of the current intput.
  96396. * @returns the class name
  96397. */
  96398. getClassName(): string;
  96399. /**
  96400. * Get the friendly name associated with the input class.
  96401. * @returns the input friendly name
  96402. */
  96403. getSimpleName(): string;
  96404. }
  96405. }
  96406. declare module BABYLON {
  96407. /**
  96408. * Manage the touch inputs to control the movement of a free camera.
  96409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96410. */
  96411. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96412. /**
  96413. * Defines the camera the input is attached to.
  96414. */
  96415. camera: FreeCamera;
  96416. /**
  96417. * Defines the touch sensibility for rotation.
  96418. * The higher the faster.
  96419. */
  96420. touchAngularSensibility: number;
  96421. /**
  96422. * Defines the touch sensibility for move.
  96423. * The higher the faster.
  96424. */
  96425. touchMoveSensibility: number;
  96426. private _offsetX;
  96427. private _offsetY;
  96428. private _pointerPressed;
  96429. private _pointerInput;
  96430. private _observer;
  96431. private _onLostFocus;
  96432. /**
  96433. * Attach the input controls to a specific dom element to get the input from.
  96434. * @param element Defines the element the controls should be listened from
  96435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96436. */
  96437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96438. /**
  96439. * Detach the current controls from the specified dom element.
  96440. * @param element Defines the element to stop listening the inputs from
  96441. */
  96442. detachControl(element: Nullable<HTMLElement>): void;
  96443. /**
  96444. * Update the current camera state depending on the inputs that have been used this frame.
  96445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96446. */
  96447. checkInputs(): void;
  96448. /**
  96449. * Gets the class name of the current intput.
  96450. * @returns the class name
  96451. */
  96452. getClassName(): string;
  96453. /**
  96454. * Get the friendly name associated with the input class.
  96455. * @returns the input friendly name
  96456. */
  96457. getSimpleName(): string;
  96458. }
  96459. }
  96460. declare module BABYLON {
  96461. /**
  96462. * Default Inputs manager for the FreeCamera.
  96463. * It groups all the default supported inputs for ease of use.
  96464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96465. */
  96466. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96467. /**
  96468. * @hidden
  96469. */
  96470. _mouseInput: Nullable<FreeCameraMouseInput>;
  96471. /**
  96472. * Instantiates a new FreeCameraInputsManager.
  96473. * @param camera Defines the camera the inputs belong to
  96474. */
  96475. constructor(camera: FreeCamera);
  96476. /**
  96477. * Add keyboard input support to the input manager.
  96478. * @returns the current input manager
  96479. */
  96480. addKeyboard(): FreeCameraInputsManager;
  96481. /**
  96482. * Add mouse input support to the input manager.
  96483. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96484. * @returns the current input manager
  96485. */
  96486. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96487. /**
  96488. * Removes the mouse input support from the manager
  96489. * @returns the current input manager
  96490. */
  96491. removeMouse(): FreeCameraInputsManager;
  96492. /**
  96493. * Add touch input support to the input manager.
  96494. * @returns the current input manager
  96495. */
  96496. addTouch(): FreeCameraInputsManager;
  96497. /**
  96498. * Remove all attached input methods from a camera
  96499. */
  96500. clear(): void;
  96501. }
  96502. }
  96503. declare module BABYLON {
  96504. /**
  96505. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96506. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96507. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96508. */
  96509. export class FreeCamera extends TargetCamera {
  96510. /**
  96511. * Define the collision ellipsoid of the camera.
  96512. * This is helpful to simulate a camera body like the player body around the camera
  96513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96514. */
  96515. ellipsoid: Vector3;
  96516. /**
  96517. * Define an offset for the position of the ellipsoid around the camera.
  96518. * This can be helpful to determine the center of the body near the gravity center of the body
  96519. * instead of its head.
  96520. */
  96521. ellipsoidOffset: Vector3;
  96522. /**
  96523. * Enable or disable collisions of the camera with the rest of the scene objects.
  96524. */
  96525. checkCollisions: boolean;
  96526. /**
  96527. * Enable or disable gravity on the camera.
  96528. */
  96529. applyGravity: boolean;
  96530. /**
  96531. * Define the input manager associated to the camera.
  96532. */
  96533. inputs: FreeCameraInputsManager;
  96534. /**
  96535. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96536. * Higher values reduce sensitivity.
  96537. */
  96538. get angularSensibility(): number;
  96539. /**
  96540. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96541. * Higher values reduce sensitivity.
  96542. */
  96543. set angularSensibility(value: number);
  96544. /**
  96545. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96546. */
  96547. get keysUp(): number[];
  96548. set keysUp(value: number[]);
  96549. /**
  96550. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96551. */
  96552. get keysUpward(): number[];
  96553. set keysUpward(value: number[]);
  96554. /**
  96555. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96556. */
  96557. get keysDown(): number[];
  96558. set keysDown(value: number[]);
  96559. /**
  96560. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96561. */
  96562. get keysDownward(): number[];
  96563. set keysDownward(value: number[]);
  96564. /**
  96565. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96566. */
  96567. get keysLeft(): number[];
  96568. set keysLeft(value: number[]);
  96569. /**
  96570. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96571. */
  96572. get keysRight(): number[];
  96573. set keysRight(value: number[]);
  96574. /**
  96575. * Event raised when the camera collide with a mesh in the scene.
  96576. */
  96577. onCollide: (collidedMesh: AbstractMesh) => void;
  96578. private _collider;
  96579. private _needMoveForGravity;
  96580. private _oldPosition;
  96581. private _diffPosition;
  96582. private _newPosition;
  96583. /** @hidden */
  96584. _localDirection: Vector3;
  96585. /** @hidden */
  96586. _transformedDirection: Vector3;
  96587. /**
  96588. * Instantiates a Free Camera.
  96589. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96590. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96592. * @param name Define the name of the camera in the scene
  96593. * @param position Define the start position of the camera in the scene
  96594. * @param scene Define the scene the camera belongs to
  96595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96596. */
  96597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96598. /**
  96599. * Attached controls to the current camera.
  96600. * @param element Defines the element the controls should be listened from
  96601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96602. */
  96603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96604. /**
  96605. * Detach the current controls from the camera.
  96606. * The camera will stop reacting to inputs.
  96607. * @param element Defines the element to stop listening the inputs from
  96608. */
  96609. detachControl(element: HTMLElement): void;
  96610. private _collisionMask;
  96611. /**
  96612. * Define a collision mask to limit the list of object the camera can collide with
  96613. */
  96614. get collisionMask(): number;
  96615. set collisionMask(mask: number);
  96616. /** @hidden */
  96617. _collideWithWorld(displacement: Vector3): void;
  96618. private _onCollisionPositionChange;
  96619. /** @hidden */
  96620. _checkInputs(): void;
  96621. /** @hidden */
  96622. _decideIfNeedsToMove(): boolean;
  96623. /** @hidden */
  96624. _updatePosition(): void;
  96625. /**
  96626. * Destroy the camera and release the current resources hold by it.
  96627. */
  96628. dispose(): void;
  96629. /**
  96630. * Gets the current object class name.
  96631. * @return the class name
  96632. */
  96633. getClassName(): string;
  96634. }
  96635. }
  96636. declare module BABYLON {
  96637. /**
  96638. * Represents a gamepad control stick position
  96639. */
  96640. export class StickValues {
  96641. /**
  96642. * The x component of the control stick
  96643. */
  96644. x: number;
  96645. /**
  96646. * The y component of the control stick
  96647. */
  96648. y: number;
  96649. /**
  96650. * Initializes the gamepad x and y control stick values
  96651. * @param x The x component of the gamepad control stick value
  96652. * @param y The y component of the gamepad control stick value
  96653. */
  96654. constructor(
  96655. /**
  96656. * The x component of the control stick
  96657. */
  96658. x: number,
  96659. /**
  96660. * The y component of the control stick
  96661. */
  96662. y: number);
  96663. }
  96664. /**
  96665. * An interface which manages callbacks for gamepad button changes
  96666. */
  96667. export interface GamepadButtonChanges {
  96668. /**
  96669. * Called when a gamepad has been changed
  96670. */
  96671. changed: boolean;
  96672. /**
  96673. * Called when a gamepad press event has been triggered
  96674. */
  96675. pressChanged: boolean;
  96676. /**
  96677. * Called when a touch event has been triggered
  96678. */
  96679. touchChanged: boolean;
  96680. /**
  96681. * Called when a value has changed
  96682. */
  96683. valueChanged: boolean;
  96684. }
  96685. /**
  96686. * Represents a gamepad
  96687. */
  96688. export class Gamepad {
  96689. /**
  96690. * The id of the gamepad
  96691. */
  96692. id: string;
  96693. /**
  96694. * The index of the gamepad
  96695. */
  96696. index: number;
  96697. /**
  96698. * The browser gamepad
  96699. */
  96700. browserGamepad: any;
  96701. /**
  96702. * Specifies what type of gamepad this represents
  96703. */
  96704. type: number;
  96705. private _leftStick;
  96706. private _rightStick;
  96707. /** @hidden */
  96708. _isConnected: boolean;
  96709. private _leftStickAxisX;
  96710. private _leftStickAxisY;
  96711. private _rightStickAxisX;
  96712. private _rightStickAxisY;
  96713. /**
  96714. * Triggered when the left control stick has been changed
  96715. */
  96716. private _onleftstickchanged;
  96717. /**
  96718. * Triggered when the right control stick has been changed
  96719. */
  96720. private _onrightstickchanged;
  96721. /**
  96722. * Represents a gamepad controller
  96723. */
  96724. static GAMEPAD: number;
  96725. /**
  96726. * Represents a generic controller
  96727. */
  96728. static GENERIC: number;
  96729. /**
  96730. * Represents an XBox controller
  96731. */
  96732. static XBOX: number;
  96733. /**
  96734. * Represents a pose-enabled controller
  96735. */
  96736. static POSE_ENABLED: number;
  96737. /**
  96738. * Represents an Dual Shock controller
  96739. */
  96740. static DUALSHOCK: number;
  96741. /**
  96742. * Specifies whether the left control stick should be Y-inverted
  96743. */
  96744. protected _invertLeftStickY: boolean;
  96745. /**
  96746. * Specifies if the gamepad has been connected
  96747. */
  96748. get isConnected(): boolean;
  96749. /**
  96750. * Initializes the gamepad
  96751. * @param id The id of the gamepad
  96752. * @param index The index of the gamepad
  96753. * @param browserGamepad The browser gamepad
  96754. * @param leftStickX The x component of the left joystick
  96755. * @param leftStickY The y component of the left joystick
  96756. * @param rightStickX The x component of the right joystick
  96757. * @param rightStickY The y component of the right joystick
  96758. */
  96759. constructor(
  96760. /**
  96761. * The id of the gamepad
  96762. */
  96763. id: string,
  96764. /**
  96765. * The index of the gamepad
  96766. */
  96767. index: number,
  96768. /**
  96769. * The browser gamepad
  96770. */
  96771. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96772. /**
  96773. * Callback triggered when the left joystick has changed
  96774. * @param callback
  96775. */
  96776. onleftstickchanged(callback: (values: StickValues) => void): void;
  96777. /**
  96778. * Callback triggered when the right joystick has changed
  96779. * @param callback
  96780. */
  96781. onrightstickchanged(callback: (values: StickValues) => void): void;
  96782. /**
  96783. * Gets the left joystick
  96784. */
  96785. get leftStick(): StickValues;
  96786. /**
  96787. * Sets the left joystick values
  96788. */
  96789. set leftStick(newValues: StickValues);
  96790. /**
  96791. * Gets the right joystick
  96792. */
  96793. get rightStick(): StickValues;
  96794. /**
  96795. * Sets the right joystick value
  96796. */
  96797. set rightStick(newValues: StickValues);
  96798. /**
  96799. * Updates the gamepad joystick positions
  96800. */
  96801. update(): void;
  96802. /**
  96803. * Disposes the gamepad
  96804. */
  96805. dispose(): void;
  96806. }
  96807. /**
  96808. * Represents a generic gamepad
  96809. */
  96810. export class GenericPad extends Gamepad {
  96811. private _buttons;
  96812. private _onbuttondown;
  96813. private _onbuttonup;
  96814. /**
  96815. * Observable triggered when a button has been pressed
  96816. */
  96817. onButtonDownObservable: Observable<number>;
  96818. /**
  96819. * Observable triggered when a button has been released
  96820. */
  96821. onButtonUpObservable: Observable<number>;
  96822. /**
  96823. * Callback triggered when a button has been pressed
  96824. * @param callback Called when a button has been pressed
  96825. */
  96826. onbuttondown(callback: (buttonPressed: number) => void): void;
  96827. /**
  96828. * Callback triggered when a button has been released
  96829. * @param callback Called when a button has been released
  96830. */
  96831. onbuttonup(callback: (buttonReleased: number) => void): void;
  96832. /**
  96833. * Initializes the generic gamepad
  96834. * @param id The id of the generic gamepad
  96835. * @param index The index of the generic gamepad
  96836. * @param browserGamepad The browser gamepad
  96837. */
  96838. constructor(id: string, index: number, browserGamepad: any);
  96839. private _setButtonValue;
  96840. /**
  96841. * Updates the generic gamepad
  96842. */
  96843. update(): void;
  96844. /**
  96845. * Disposes the generic gamepad
  96846. */
  96847. dispose(): void;
  96848. }
  96849. }
  96850. declare module BABYLON {
  96851. /**
  96852. * Defines the types of pose enabled controllers that are supported
  96853. */
  96854. export enum PoseEnabledControllerType {
  96855. /**
  96856. * HTC Vive
  96857. */
  96858. VIVE = 0,
  96859. /**
  96860. * Oculus Rift
  96861. */
  96862. OCULUS = 1,
  96863. /**
  96864. * Windows mixed reality
  96865. */
  96866. WINDOWS = 2,
  96867. /**
  96868. * Samsung gear VR
  96869. */
  96870. GEAR_VR = 3,
  96871. /**
  96872. * Google Daydream
  96873. */
  96874. DAYDREAM = 4,
  96875. /**
  96876. * Generic
  96877. */
  96878. GENERIC = 5
  96879. }
  96880. /**
  96881. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96882. */
  96883. export interface MutableGamepadButton {
  96884. /**
  96885. * Value of the button/trigger
  96886. */
  96887. value: number;
  96888. /**
  96889. * If the button/trigger is currently touched
  96890. */
  96891. touched: boolean;
  96892. /**
  96893. * If the button/trigger is currently pressed
  96894. */
  96895. pressed: boolean;
  96896. }
  96897. /**
  96898. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96899. * @hidden
  96900. */
  96901. export interface ExtendedGamepadButton extends GamepadButton {
  96902. /**
  96903. * If the button/trigger is currently pressed
  96904. */
  96905. readonly pressed: boolean;
  96906. /**
  96907. * If the button/trigger is currently touched
  96908. */
  96909. readonly touched: boolean;
  96910. /**
  96911. * Value of the button/trigger
  96912. */
  96913. readonly value: number;
  96914. }
  96915. /** @hidden */
  96916. export interface _GamePadFactory {
  96917. /**
  96918. * Returns whether or not the current gamepad can be created for this type of controller.
  96919. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96920. * @returns true if it can be created, otherwise false
  96921. */
  96922. canCreate(gamepadInfo: any): boolean;
  96923. /**
  96924. * Creates a new instance of the Gamepad.
  96925. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96926. * @returns the new gamepad instance
  96927. */
  96928. create(gamepadInfo: any): Gamepad;
  96929. }
  96930. /**
  96931. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96932. */
  96933. export class PoseEnabledControllerHelper {
  96934. /** @hidden */
  96935. static _ControllerFactories: _GamePadFactory[];
  96936. /** @hidden */
  96937. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96938. /**
  96939. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96940. * @param vrGamepad the gamepad to initialized
  96941. * @returns a vr controller of the type the gamepad identified as
  96942. */
  96943. static InitiateController(vrGamepad: any): Gamepad;
  96944. }
  96945. /**
  96946. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96947. */
  96948. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96949. /**
  96950. * If the controller is used in a webXR session
  96951. */
  96952. isXR: boolean;
  96953. private _deviceRoomPosition;
  96954. private _deviceRoomRotationQuaternion;
  96955. /**
  96956. * The device position in babylon space
  96957. */
  96958. devicePosition: Vector3;
  96959. /**
  96960. * The device rotation in babylon space
  96961. */
  96962. deviceRotationQuaternion: Quaternion;
  96963. /**
  96964. * The scale factor of the device in babylon space
  96965. */
  96966. deviceScaleFactor: number;
  96967. /**
  96968. * (Likely devicePosition should be used instead) The device position in its room space
  96969. */
  96970. position: Vector3;
  96971. /**
  96972. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96973. */
  96974. rotationQuaternion: Quaternion;
  96975. /**
  96976. * The type of controller (Eg. Windows mixed reality)
  96977. */
  96978. controllerType: PoseEnabledControllerType;
  96979. protected _calculatedPosition: Vector3;
  96980. private _calculatedRotation;
  96981. /**
  96982. * The raw pose from the device
  96983. */
  96984. rawPose: DevicePose;
  96985. private _trackPosition;
  96986. private _maxRotationDistFromHeadset;
  96987. private _draggedRoomRotation;
  96988. /**
  96989. * @hidden
  96990. */
  96991. _disableTrackPosition(fixedPosition: Vector3): void;
  96992. /**
  96993. * Internal, the mesh attached to the controller
  96994. * @hidden
  96995. */
  96996. _mesh: Nullable<AbstractMesh>;
  96997. private _poseControlledCamera;
  96998. private _leftHandSystemQuaternion;
  96999. /**
  97000. * Internal, matrix used to convert room space to babylon space
  97001. * @hidden
  97002. */
  97003. _deviceToWorld: Matrix;
  97004. /**
  97005. * Node to be used when casting a ray from the controller
  97006. * @hidden
  97007. */
  97008. _pointingPoseNode: Nullable<TransformNode>;
  97009. /**
  97010. * Name of the child mesh that can be used to cast a ray from the controller
  97011. */
  97012. static readonly POINTING_POSE: string;
  97013. /**
  97014. * Creates a new PoseEnabledController from a gamepad
  97015. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97016. */
  97017. constructor(browserGamepad: any);
  97018. private _workingMatrix;
  97019. /**
  97020. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97021. */
  97022. update(): void;
  97023. /**
  97024. * Updates only the pose device and mesh without doing any button event checking
  97025. */
  97026. protected _updatePoseAndMesh(): void;
  97027. /**
  97028. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97029. * @param poseData raw pose fromthe device
  97030. */
  97031. updateFromDevice(poseData: DevicePose): void;
  97032. /**
  97033. * @hidden
  97034. */
  97035. _meshAttachedObservable: Observable<AbstractMesh>;
  97036. /**
  97037. * Attaches a mesh to the controller
  97038. * @param mesh the mesh to be attached
  97039. */
  97040. attachToMesh(mesh: AbstractMesh): void;
  97041. /**
  97042. * Attaches the controllers mesh to a camera
  97043. * @param camera the camera the mesh should be attached to
  97044. */
  97045. attachToPoseControlledCamera(camera: TargetCamera): void;
  97046. /**
  97047. * Disposes of the controller
  97048. */
  97049. dispose(): void;
  97050. /**
  97051. * The mesh that is attached to the controller
  97052. */
  97053. get mesh(): Nullable<AbstractMesh>;
  97054. /**
  97055. * Gets the ray of the controller in the direction the controller is pointing
  97056. * @param length the length the resulting ray should be
  97057. * @returns a ray in the direction the controller is pointing
  97058. */
  97059. getForwardRay(length?: number): Ray;
  97060. }
  97061. }
  97062. declare module BABYLON {
  97063. /**
  97064. * Defines the WebVRController object that represents controllers tracked in 3D space
  97065. */
  97066. export abstract class WebVRController extends PoseEnabledController {
  97067. /**
  97068. * Internal, the default controller model for the controller
  97069. */
  97070. protected _defaultModel: Nullable<AbstractMesh>;
  97071. /**
  97072. * Fired when the trigger state has changed
  97073. */
  97074. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97075. /**
  97076. * Fired when the main button state has changed
  97077. */
  97078. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97079. /**
  97080. * Fired when the secondary button state has changed
  97081. */
  97082. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97083. /**
  97084. * Fired when the pad state has changed
  97085. */
  97086. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97087. /**
  97088. * Fired when controllers stick values have changed
  97089. */
  97090. onPadValuesChangedObservable: Observable<StickValues>;
  97091. /**
  97092. * Array of button availible on the controller
  97093. */
  97094. protected _buttons: Array<MutableGamepadButton>;
  97095. private _onButtonStateChange;
  97096. /**
  97097. * Fired when a controller button's state has changed
  97098. * @param callback the callback containing the button that was modified
  97099. */
  97100. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97101. /**
  97102. * X and Y axis corresponding to the controllers joystick
  97103. */
  97104. pad: StickValues;
  97105. /**
  97106. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97107. */
  97108. hand: string;
  97109. /**
  97110. * The default controller model for the controller
  97111. */
  97112. get defaultModel(): Nullable<AbstractMesh>;
  97113. /**
  97114. * Creates a new WebVRController from a gamepad
  97115. * @param vrGamepad the gamepad that the WebVRController should be created from
  97116. */
  97117. constructor(vrGamepad: any);
  97118. /**
  97119. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97120. */
  97121. update(): void;
  97122. /**
  97123. * Function to be called when a button is modified
  97124. */
  97125. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97126. /**
  97127. * Loads a mesh and attaches it to the controller
  97128. * @param scene the scene the mesh should be added to
  97129. * @param meshLoaded callback for when the mesh has been loaded
  97130. */
  97131. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97132. private _setButtonValue;
  97133. private _changes;
  97134. private _checkChanges;
  97135. /**
  97136. * Disposes of th webVRCOntroller
  97137. */
  97138. dispose(): void;
  97139. }
  97140. }
  97141. declare module BABYLON {
  97142. /**
  97143. * The HemisphericLight simulates the ambient environment light,
  97144. * so the passed direction is the light reflection direction, not the incoming direction.
  97145. */
  97146. export class HemisphericLight extends Light {
  97147. /**
  97148. * The groundColor is the light in the opposite direction to the one specified during creation.
  97149. * 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.
  97150. */
  97151. groundColor: Color3;
  97152. /**
  97153. * The light reflection direction, not the incoming direction.
  97154. */
  97155. direction: Vector3;
  97156. /**
  97157. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97158. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97159. * The HemisphericLight can't cast shadows.
  97160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97161. * @param name The friendly name of the light
  97162. * @param direction The direction of the light reflection
  97163. * @param scene The scene the light belongs to
  97164. */
  97165. constructor(name: string, direction: Vector3, scene: Scene);
  97166. protected _buildUniformLayout(): void;
  97167. /**
  97168. * Returns the string "HemisphericLight".
  97169. * @return The class name
  97170. */
  97171. getClassName(): string;
  97172. /**
  97173. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97174. * Returns the updated direction.
  97175. * @param target The target the direction should point to
  97176. * @return The computed direction
  97177. */
  97178. setDirectionToTarget(target: Vector3): Vector3;
  97179. /**
  97180. * Returns the shadow generator associated to the light.
  97181. * @returns Always null for hemispheric lights because it does not support shadows.
  97182. */
  97183. getShadowGenerator(): Nullable<IShadowGenerator>;
  97184. /**
  97185. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97186. * @param effect The effect to update
  97187. * @param lightIndex The index of the light in the effect to update
  97188. * @returns The hemispheric light
  97189. */
  97190. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97192. /**
  97193. * Computes the world matrix of the node
  97194. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97195. * @param useWasUpdatedFlag defines a reserved property
  97196. * @returns the world matrix
  97197. */
  97198. computeWorldMatrix(): Matrix;
  97199. /**
  97200. * Returns the integer 3.
  97201. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97202. */
  97203. getTypeID(): number;
  97204. /**
  97205. * Prepares the list of defines specific to the light type.
  97206. * @param defines the list of defines
  97207. * @param lightIndex defines the index of the light for the effect
  97208. */
  97209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97210. }
  97211. }
  97212. declare module BABYLON {
  97213. /** @hidden */
  97214. export var vrMultiviewToSingleviewPixelShader: {
  97215. name: string;
  97216. shader: string;
  97217. };
  97218. }
  97219. declare module BABYLON {
  97220. /**
  97221. * Renders to multiple views with a single draw call
  97222. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97223. */
  97224. export class MultiviewRenderTarget extends RenderTargetTexture {
  97225. /**
  97226. * Creates a multiview render target
  97227. * @param scene scene used with the render target
  97228. * @param size the size of the render target (used for each view)
  97229. */
  97230. constructor(scene: Scene, size?: number | {
  97231. width: number;
  97232. height: number;
  97233. } | {
  97234. ratio: number;
  97235. });
  97236. /**
  97237. * @hidden
  97238. * @param faceIndex the face index, if its a cube texture
  97239. */
  97240. _bindFrameBuffer(faceIndex?: number): void;
  97241. /**
  97242. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97243. * @returns the view count
  97244. */
  97245. getViewCount(): number;
  97246. }
  97247. }
  97248. declare module BABYLON {
  97249. interface Engine {
  97250. /**
  97251. * Creates a new multiview render target
  97252. * @param width defines the width of the texture
  97253. * @param height defines the height of the texture
  97254. * @returns the created multiview texture
  97255. */
  97256. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97257. /**
  97258. * Binds a multiview framebuffer to be drawn to
  97259. * @param multiviewTexture texture to bind
  97260. */
  97261. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97262. }
  97263. interface Camera {
  97264. /**
  97265. * @hidden
  97266. * 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)
  97267. */
  97268. _useMultiviewToSingleView: boolean;
  97269. /**
  97270. * @hidden
  97271. * 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)
  97272. */
  97273. _multiviewTexture: Nullable<RenderTargetTexture>;
  97274. /**
  97275. * @hidden
  97276. * ensures the multiview texture of the camera exists and has the specified width/height
  97277. * @param width height to set on the multiview texture
  97278. * @param height width to set on the multiview texture
  97279. */
  97280. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97281. }
  97282. interface Scene {
  97283. /** @hidden */
  97284. _transformMatrixR: Matrix;
  97285. /** @hidden */
  97286. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97287. /** @hidden */
  97288. _createMultiviewUbo(): void;
  97289. /** @hidden */
  97290. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97291. /** @hidden */
  97292. _renderMultiviewToSingleView(camera: Camera): void;
  97293. }
  97294. }
  97295. declare module BABYLON {
  97296. /**
  97297. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97298. * This will not be used for webXR as it supports displaying texture arrays directly
  97299. */
  97300. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97301. /**
  97302. * Initializes a VRMultiviewToSingleview
  97303. * @param name name of the post process
  97304. * @param camera camera to be applied to
  97305. * @param scaleFactor scaling factor to the size of the output texture
  97306. */
  97307. constructor(name: string, camera: Camera, scaleFactor: number);
  97308. }
  97309. }
  97310. declare module BABYLON {
  97311. /**
  97312. * Interface used to define additional presentation attributes
  97313. */
  97314. export interface IVRPresentationAttributes {
  97315. /**
  97316. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97317. */
  97318. highRefreshRate: boolean;
  97319. /**
  97320. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97321. */
  97322. foveationLevel: number;
  97323. }
  97324. interface Engine {
  97325. /** @hidden */
  97326. _vrDisplay: any;
  97327. /** @hidden */
  97328. _vrSupported: boolean;
  97329. /** @hidden */
  97330. _oldSize: Size;
  97331. /** @hidden */
  97332. _oldHardwareScaleFactor: number;
  97333. /** @hidden */
  97334. _vrExclusivePointerMode: boolean;
  97335. /** @hidden */
  97336. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97337. /** @hidden */
  97338. _onVRDisplayPointerRestricted: () => void;
  97339. /** @hidden */
  97340. _onVRDisplayPointerUnrestricted: () => void;
  97341. /** @hidden */
  97342. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97343. /** @hidden */
  97344. _onVrDisplayDisconnect: Nullable<() => void>;
  97345. /** @hidden */
  97346. _onVrDisplayPresentChange: Nullable<() => void>;
  97347. /**
  97348. * Observable signaled when VR display mode changes
  97349. */
  97350. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97351. /**
  97352. * Observable signaled when VR request present is complete
  97353. */
  97354. onVRRequestPresentComplete: Observable<boolean>;
  97355. /**
  97356. * Observable signaled when VR request present starts
  97357. */
  97358. onVRRequestPresentStart: Observable<Engine>;
  97359. /**
  97360. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97361. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97362. */
  97363. isInVRExclusivePointerMode: boolean;
  97364. /**
  97365. * Gets a boolean indicating if a webVR device was detected
  97366. * @returns true if a webVR device was detected
  97367. */
  97368. isVRDevicePresent(): boolean;
  97369. /**
  97370. * Gets the current webVR device
  97371. * @returns the current webVR device (or null)
  97372. */
  97373. getVRDevice(): any;
  97374. /**
  97375. * Initializes a webVR display and starts listening to display change events
  97376. * The onVRDisplayChangedObservable will be notified upon these changes
  97377. * @returns A promise containing a VRDisplay and if vr is supported
  97378. */
  97379. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97380. /** @hidden */
  97381. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97382. /**
  97383. * Gets or sets the presentation attributes used to configure VR rendering
  97384. */
  97385. vrPresentationAttributes?: IVRPresentationAttributes;
  97386. /**
  97387. * Call this function to switch to webVR mode
  97388. * Will do nothing if webVR is not supported or if there is no webVR device
  97389. * @param options the webvr options provided to the camera. mainly used for multiview
  97390. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97391. */
  97392. enableVR(options: WebVROptions): void;
  97393. /** @hidden */
  97394. _onVRFullScreenTriggered(): void;
  97395. }
  97396. }
  97397. declare module BABYLON {
  97398. /**
  97399. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97400. * IMPORTANT!! The data is right-hand data.
  97401. * @export
  97402. * @interface DevicePose
  97403. */
  97404. export interface DevicePose {
  97405. /**
  97406. * The position of the device, values in array are [x,y,z].
  97407. */
  97408. readonly position: Nullable<Float32Array>;
  97409. /**
  97410. * The linearVelocity of the device, values in array are [x,y,z].
  97411. */
  97412. readonly linearVelocity: Nullable<Float32Array>;
  97413. /**
  97414. * The linearAcceleration of the device, values in array are [x,y,z].
  97415. */
  97416. readonly linearAcceleration: Nullable<Float32Array>;
  97417. /**
  97418. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97419. */
  97420. readonly orientation: Nullable<Float32Array>;
  97421. /**
  97422. * The angularVelocity of the device, values in array are [x,y,z].
  97423. */
  97424. readonly angularVelocity: Nullable<Float32Array>;
  97425. /**
  97426. * The angularAcceleration of the device, values in array are [x,y,z].
  97427. */
  97428. readonly angularAcceleration: Nullable<Float32Array>;
  97429. }
  97430. /**
  97431. * Interface representing a pose controlled object in Babylon.
  97432. * A pose controlled object has both regular pose values as well as pose values
  97433. * from an external device such as a VR head mounted display
  97434. */
  97435. export interface PoseControlled {
  97436. /**
  97437. * The position of the object in babylon space.
  97438. */
  97439. position: Vector3;
  97440. /**
  97441. * The rotation quaternion of the object in babylon space.
  97442. */
  97443. rotationQuaternion: Quaternion;
  97444. /**
  97445. * The position of the device in babylon space.
  97446. */
  97447. devicePosition?: Vector3;
  97448. /**
  97449. * The rotation quaternion of the device in babylon space.
  97450. */
  97451. deviceRotationQuaternion: Quaternion;
  97452. /**
  97453. * The raw pose coming from the device.
  97454. */
  97455. rawPose: Nullable<DevicePose>;
  97456. /**
  97457. * The scale of the device to be used when translating from device space to babylon space.
  97458. */
  97459. deviceScaleFactor: number;
  97460. /**
  97461. * Updates the poseControlled values based on the input device pose.
  97462. * @param poseData the pose data to update the object with
  97463. */
  97464. updateFromDevice(poseData: DevicePose): void;
  97465. }
  97466. /**
  97467. * Set of options to customize the webVRCamera
  97468. */
  97469. export interface WebVROptions {
  97470. /**
  97471. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97472. */
  97473. trackPosition?: boolean;
  97474. /**
  97475. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97476. */
  97477. positionScale?: number;
  97478. /**
  97479. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97480. */
  97481. displayName?: string;
  97482. /**
  97483. * Should the native controller meshes be initialized. (default: true)
  97484. */
  97485. controllerMeshes?: boolean;
  97486. /**
  97487. * Creating a default HemiLight only on controllers. (default: true)
  97488. */
  97489. defaultLightingOnControllers?: boolean;
  97490. /**
  97491. * If you don't want to use the default VR button of the helper. (default: false)
  97492. */
  97493. useCustomVRButton?: boolean;
  97494. /**
  97495. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97496. */
  97497. customVRButton?: HTMLButtonElement;
  97498. /**
  97499. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97500. */
  97501. rayLength?: number;
  97502. /**
  97503. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97504. */
  97505. defaultHeight?: number;
  97506. /**
  97507. * If multiview should be used if availible (default: false)
  97508. */
  97509. useMultiview?: boolean;
  97510. }
  97511. /**
  97512. * This represents a WebVR camera.
  97513. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97514. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97515. */
  97516. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97517. private webVROptions;
  97518. /**
  97519. * @hidden
  97520. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97521. */
  97522. _vrDevice: any;
  97523. /**
  97524. * The rawPose of the vrDevice.
  97525. */
  97526. rawPose: Nullable<DevicePose>;
  97527. private _onVREnabled;
  97528. private _specsVersion;
  97529. private _attached;
  97530. private _frameData;
  97531. protected _descendants: Array<Node>;
  97532. private _deviceRoomPosition;
  97533. /** @hidden */
  97534. _deviceRoomRotationQuaternion: Quaternion;
  97535. private _standingMatrix;
  97536. /**
  97537. * Represents device position in babylon space.
  97538. */
  97539. devicePosition: Vector3;
  97540. /**
  97541. * Represents device rotation in babylon space.
  97542. */
  97543. deviceRotationQuaternion: Quaternion;
  97544. /**
  97545. * The scale of the device to be used when translating from device space to babylon space.
  97546. */
  97547. deviceScaleFactor: number;
  97548. private _deviceToWorld;
  97549. private _worldToDevice;
  97550. /**
  97551. * References to the webVR controllers for the vrDevice.
  97552. */
  97553. controllers: Array<WebVRController>;
  97554. /**
  97555. * Emits an event when a controller is attached.
  97556. */
  97557. onControllersAttachedObservable: Observable<WebVRController[]>;
  97558. /**
  97559. * Emits an event when a controller's mesh has been loaded;
  97560. */
  97561. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97562. /**
  97563. * Emits an event when the HMD's pose has been updated.
  97564. */
  97565. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97566. private _poseSet;
  97567. /**
  97568. * If the rig cameras be used as parent instead of this camera.
  97569. */
  97570. rigParenting: boolean;
  97571. private _lightOnControllers;
  97572. private _defaultHeight?;
  97573. /**
  97574. * Instantiates a WebVRFreeCamera.
  97575. * @param name The name of the WebVRFreeCamera
  97576. * @param position The starting anchor position for the camera
  97577. * @param scene The scene the camera belongs to
  97578. * @param webVROptions a set of customizable options for the webVRCamera
  97579. */
  97580. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97581. /**
  97582. * Gets the device distance from the ground in meters.
  97583. * @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.
  97584. */
  97585. deviceDistanceToRoomGround(): number;
  97586. /**
  97587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97588. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97589. */
  97590. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97591. /**
  97592. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97593. * @returns A promise with a boolean set to if the standing matrix is supported.
  97594. */
  97595. useStandingMatrixAsync(): Promise<boolean>;
  97596. /**
  97597. * Disposes the camera
  97598. */
  97599. dispose(): void;
  97600. /**
  97601. * Gets a vrController by name.
  97602. * @param name The name of the controller to retreive
  97603. * @returns the controller matching the name specified or null if not found
  97604. */
  97605. getControllerByName(name: string): Nullable<WebVRController>;
  97606. private _leftController;
  97607. /**
  97608. * The controller corresponding to the users left hand.
  97609. */
  97610. get leftController(): Nullable<WebVRController>;
  97611. private _rightController;
  97612. /**
  97613. * The controller corresponding to the users right hand.
  97614. */
  97615. get rightController(): Nullable<WebVRController>;
  97616. /**
  97617. * Casts a ray forward from the vrCamera's gaze.
  97618. * @param length Length of the ray (default: 100)
  97619. * @returns the ray corresponding to the gaze
  97620. */
  97621. getForwardRay(length?: number): Ray;
  97622. /**
  97623. * @hidden
  97624. * Updates the camera based on device's frame data
  97625. */
  97626. _checkInputs(): void;
  97627. /**
  97628. * Updates the poseControlled values based on the input device pose.
  97629. * @param poseData Pose coming from the device
  97630. */
  97631. updateFromDevice(poseData: DevicePose): void;
  97632. private _htmlElementAttached;
  97633. private _detachIfAttached;
  97634. /**
  97635. * WebVR's attach control will start broadcasting frames to the device.
  97636. * Note that in certain browsers (chrome for example) this function must be called
  97637. * within a user-interaction callback. Example:
  97638. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97639. *
  97640. * @param element html element to attach the vrDevice to
  97641. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97642. */
  97643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97644. /**
  97645. * Detaches the camera from the html element and disables VR
  97646. *
  97647. * @param element html element to detach from
  97648. */
  97649. detachControl(element: HTMLElement): void;
  97650. /**
  97651. * @returns the name of this class
  97652. */
  97653. getClassName(): string;
  97654. /**
  97655. * Calls resetPose on the vrDisplay
  97656. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97657. */
  97658. resetToCurrentRotation(): void;
  97659. /**
  97660. * @hidden
  97661. * Updates the rig cameras (left and right eye)
  97662. */
  97663. _updateRigCameras(): void;
  97664. private _workingVector;
  97665. private _oneVector;
  97666. private _workingMatrix;
  97667. private updateCacheCalled;
  97668. private _correctPositionIfNotTrackPosition;
  97669. /**
  97670. * @hidden
  97671. * Updates the cached values of the camera
  97672. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97673. */
  97674. _updateCache(ignoreParentClass?: boolean): void;
  97675. /**
  97676. * @hidden
  97677. * Get current device position in babylon world
  97678. */
  97679. _computeDevicePosition(): void;
  97680. /**
  97681. * Updates the current device position and rotation in the babylon world
  97682. */
  97683. update(): void;
  97684. /**
  97685. * @hidden
  97686. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97687. * @returns an identity matrix
  97688. */
  97689. _getViewMatrix(): Matrix;
  97690. private _tmpMatrix;
  97691. /**
  97692. * This function is called by the two RIG cameras.
  97693. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97694. * @hidden
  97695. */
  97696. _getWebVRViewMatrix(): Matrix;
  97697. /** @hidden */
  97698. _getWebVRProjectionMatrix(): Matrix;
  97699. private _onGamepadConnectedObserver;
  97700. private _onGamepadDisconnectedObserver;
  97701. private _updateCacheWhenTrackingDisabledObserver;
  97702. /**
  97703. * Initializes the controllers and their meshes
  97704. */
  97705. initControllers(): void;
  97706. }
  97707. }
  97708. declare module BABYLON {
  97709. /**
  97710. * "Static Class" containing the most commonly used helper while dealing with material for
  97711. * rendering purpose.
  97712. *
  97713. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97714. *
  97715. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97716. */
  97717. export class MaterialHelper {
  97718. /**
  97719. * Bind the current view position to an effect.
  97720. * @param effect The effect to be bound
  97721. * @param scene The scene the eyes position is used from
  97722. * @param variableName name of the shader variable that will hold the eye position
  97723. */
  97724. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97725. /**
  97726. * Helps preparing the defines values about the UVs in used in the effect.
  97727. * UVs are shared as much as we can accross channels in the shaders.
  97728. * @param texture The texture we are preparing the UVs for
  97729. * @param defines The defines to update
  97730. * @param key The channel key "diffuse", "specular"... used in the shader
  97731. */
  97732. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97733. /**
  97734. * Binds a texture matrix value to its corrsponding uniform
  97735. * @param texture The texture to bind the matrix for
  97736. * @param uniformBuffer The uniform buffer receivin the data
  97737. * @param key The channel key "diffuse", "specular"... used in the shader
  97738. */
  97739. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97740. /**
  97741. * Gets the current status of the fog (should it be enabled?)
  97742. * @param mesh defines the mesh to evaluate for fog support
  97743. * @param scene defines the hosting scene
  97744. * @returns true if fog must be enabled
  97745. */
  97746. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97747. /**
  97748. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97749. * @param mesh defines the current mesh
  97750. * @param scene defines the current scene
  97751. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97752. * @param pointsCloud defines if point cloud rendering has to be turned on
  97753. * @param fogEnabled defines if fog has to be turned on
  97754. * @param alphaTest defines if alpha testing has to be turned on
  97755. * @param defines defines the current list of defines
  97756. */
  97757. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97758. /**
  97759. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97760. * @param scene defines the current scene
  97761. * @param engine defines the current engine
  97762. * @param defines specifies the list of active defines
  97763. * @param useInstances defines if instances have to be turned on
  97764. * @param useClipPlane defines if clip plane have to be turned on
  97765. * @param useInstances defines if instances have to be turned on
  97766. * @param useThinInstances defines if thin instances have to be turned on
  97767. */
  97768. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97769. /**
  97770. * Prepares the defines for bones
  97771. * @param mesh The mesh containing the geometry data we will draw
  97772. * @param defines The defines to update
  97773. */
  97774. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97775. /**
  97776. * Prepares the defines for morph targets
  97777. * @param mesh The mesh containing the geometry data we will draw
  97778. * @param defines The defines to update
  97779. */
  97780. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97781. /**
  97782. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97783. * @param mesh The mesh containing the geometry data we will draw
  97784. * @param defines The defines to update
  97785. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97786. * @param useBones Precise whether bones should be used or not (override mesh info)
  97787. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97788. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97789. * @returns false if defines are considered not dirty and have not been checked
  97790. */
  97791. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97792. /**
  97793. * Prepares the defines related to multiview
  97794. * @param scene The scene we are intending to draw
  97795. * @param defines The defines to update
  97796. */
  97797. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97798. /**
  97799. * Prepares the defines related to the light information passed in parameter
  97800. * @param scene The scene we are intending to draw
  97801. * @param mesh The mesh the effect is compiling for
  97802. * @param light The light the effect is compiling for
  97803. * @param lightIndex The index of the light
  97804. * @param defines The defines to update
  97805. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97806. * @param state Defines the current state regarding what is needed (normals, etc...)
  97807. */
  97808. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97809. needNormals: boolean;
  97810. needRebuild: boolean;
  97811. shadowEnabled: boolean;
  97812. specularEnabled: boolean;
  97813. lightmapMode: boolean;
  97814. }): void;
  97815. /**
  97816. * Prepares the defines related to the light information passed in parameter
  97817. * @param scene The scene we are intending to draw
  97818. * @param mesh The mesh the effect is compiling for
  97819. * @param defines The defines to update
  97820. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97821. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97822. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97823. * @returns true if normals will be required for the rest of the effect
  97824. */
  97825. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97826. /**
  97827. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97828. * @param lightIndex defines the light index
  97829. * @param uniformsList The uniform list
  97830. * @param samplersList The sampler list
  97831. * @param projectedLightTexture defines if projected texture must be used
  97832. * @param uniformBuffersList defines an optional list of uniform buffers
  97833. */
  97834. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97835. /**
  97836. * Prepares the uniforms and samplers list to be used in the effect
  97837. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97838. * @param samplersList The sampler list
  97839. * @param defines The defines helping in the list generation
  97840. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97841. */
  97842. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97843. /**
  97844. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97845. * @param defines The defines to update while falling back
  97846. * @param fallbacks The authorized effect fallbacks
  97847. * @param maxSimultaneousLights The maximum number of lights allowed
  97848. * @param rank the current rank of the Effect
  97849. * @returns The newly affected rank
  97850. */
  97851. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97852. private static _TmpMorphInfluencers;
  97853. /**
  97854. * Prepares the list of attributes required for morph targets according to the effect defines.
  97855. * @param attribs The current list of supported attribs
  97856. * @param mesh The mesh to prepare the morph targets attributes for
  97857. * @param influencers The number of influencers
  97858. */
  97859. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97860. /**
  97861. * Prepares the list of attributes required for morph targets according to the effect defines.
  97862. * @param attribs The current list of supported attribs
  97863. * @param mesh The mesh to prepare the morph targets attributes for
  97864. * @param defines The current Defines of the effect
  97865. */
  97866. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97867. /**
  97868. * Prepares the list of attributes required for bones according to the effect defines.
  97869. * @param attribs The current list of supported attribs
  97870. * @param mesh The mesh to prepare the bones attributes for
  97871. * @param defines The current Defines of the effect
  97872. * @param fallbacks The current efffect fallback strategy
  97873. */
  97874. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97875. /**
  97876. * Check and prepare the list of attributes required for instances according to the effect defines.
  97877. * @param attribs The current list of supported attribs
  97878. * @param defines The current MaterialDefines of the effect
  97879. */
  97880. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97881. /**
  97882. * Add the list of attributes required for instances to the attribs array.
  97883. * @param attribs The current list of supported attribs
  97884. */
  97885. static PushAttributesForInstances(attribs: string[]): void;
  97886. /**
  97887. * Binds the light information to the effect.
  97888. * @param light The light containing the generator
  97889. * @param effect The effect we are binding the data to
  97890. * @param lightIndex The light index in the effect used to render
  97891. */
  97892. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97893. /**
  97894. * Binds the lights information from the scene to the effect for the given mesh.
  97895. * @param light Light to bind
  97896. * @param lightIndex Light index
  97897. * @param scene The scene where the light belongs to
  97898. * @param effect The effect we are binding the data to
  97899. * @param useSpecular Defines if specular is supported
  97900. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97901. */
  97902. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97903. /**
  97904. * Binds the lights information from the scene to the effect for the given mesh.
  97905. * @param scene The scene the lights belongs to
  97906. * @param mesh The mesh we are binding the information to render
  97907. * @param effect The effect we are binding the data to
  97908. * @param defines The generated defines for the effect
  97909. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97910. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97911. */
  97912. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97913. private static _tempFogColor;
  97914. /**
  97915. * Binds the fog information from the scene to the effect for the given mesh.
  97916. * @param scene The scene the lights belongs to
  97917. * @param mesh The mesh we are binding the information to render
  97918. * @param effect The effect we are binding the data to
  97919. * @param linearSpace Defines if the fog effect is applied in linear space
  97920. */
  97921. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97922. /**
  97923. * Binds the bones information from the mesh to the effect.
  97924. * @param mesh The mesh we are binding the information to render
  97925. * @param effect The effect we are binding the data to
  97926. */
  97927. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97928. /**
  97929. * Binds the morph targets information from the mesh to the effect.
  97930. * @param abstractMesh The mesh we are binding the information to render
  97931. * @param effect The effect we are binding the data to
  97932. */
  97933. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97934. /**
  97935. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97936. * @param defines The generated defines used in the effect
  97937. * @param effect The effect we are binding the data to
  97938. * @param scene The scene we are willing to render with logarithmic scale for
  97939. */
  97940. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97941. /**
  97942. * Binds the clip plane information from the scene to the effect.
  97943. * @param scene The scene the clip plane information are extracted from
  97944. * @param effect The effect we are binding the data to
  97945. */
  97946. static BindClipPlane(effect: Effect, scene: Scene): void;
  97947. }
  97948. }
  97949. declare module BABYLON {
  97950. /**
  97951. * Block used to expose an input value
  97952. */
  97953. export class InputBlock extends NodeMaterialBlock {
  97954. private _mode;
  97955. private _associatedVariableName;
  97956. private _storedValue;
  97957. private _valueCallback;
  97958. private _type;
  97959. private _animationType;
  97960. /** Gets or set a value used to limit the range of float values */
  97961. min: number;
  97962. /** Gets or set a value used to limit the range of float values */
  97963. max: number;
  97964. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97965. isBoolean: boolean;
  97966. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97967. matrixMode: number;
  97968. /** @hidden */
  97969. _systemValue: Nullable<NodeMaterialSystemValues>;
  97970. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97971. visibleInInspector: boolean;
  97972. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97973. isConstant: boolean;
  97974. /** Gets or sets the group to use to display this block in the Inspector */
  97975. groupInInspector: string;
  97976. /** Gets an observable raised when the value is changed */
  97977. onValueChangedObservable: Observable<InputBlock>;
  97978. /**
  97979. * Gets or sets the connection point type (default is float)
  97980. */
  97981. get type(): NodeMaterialBlockConnectionPointTypes;
  97982. /**
  97983. * Creates a new InputBlock
  97984. * @param name defines the block name
  97985. * @param target defines the target of that block (Vertex by default)
  97986. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97987. */
  97988. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97989. /**
  97990. * Gets the output component
  97991. */
  97992. get output(): NodeMaterialConnectionPoint;
  97993. /**
  97994. * Set the source of this connection point to a vertex attribute
  97995. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97996. * @returns the current connection point
  97997. */
  97998. setAsAttribute(attributeName?: string): InputBlock;
  97999. /**
  98000. * Set the source of this connection point to a system value
  98001. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98002. * @returns the current connection point
  98003. */
  98004. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98005. /**
  98006. * Gets or sets the value of that point.
  98007. * Please note that this value will be ignored if valueCallback is defined
  98008. */
  98009. get value(): any;
  98010. set value(value: any);
  98011. /**
  98012. * Gets or sets a callback used to get the value of that point.
  98013. * Please note that setting this value will force the connection point to ignore the value property
  98014. */
  98015. get valueCallback(): () => any;
  98016. set valueCallback(value: () => any);
  98017. /**
  98018. * Gets or sets the associated variable name in the shader
  98019. */
  98020. get associatedVariableName(): string;
  98021. set associatedVariableName(value: string);
  98022. /** Gets or sets the type of animation applied to the input */
  98023. get animationType(): AnimatedInputBlockTypes;
  98024. set animationType(value: AnimatedInputBlockTypes);
  98025. /**
  98026. * Gets a boolean indicating that this connection point not defined yet
  98027. */
  98028. get isUndefined(): boolean;
  98029. /**
  98030. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98031. * In this case the connection point name must be the name of the uniform to use.
  98032. * Can only be set on inputs
  98033. */
  98034. get isUniform(): boolean;
  98035. set isUniform(value: boolean);
  98036. /**
  98037. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98038. * In this case the connection point name must be the name of the attribute to use
  98039. * Can only be set on inputs
  98040. */
  98041. get isAttribute(): boolean;
  98042. set isAttribute(value: boolean);
  98043. /**
  98044. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98045. * Can only be set on exit points
  98046. */
  98047. get isVarying(): boolean;
  98048. set isVarying(value: boolean);
  98049. /**
  98050. * Gets a boolean indicating that the current connection point is a system value
  98051. */
  98052. get isSystemValue(): boolean;
  98053. /**
  98054. * Gets or sets the current well known value or null if not defined as a system value
  98055. */
  98056. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98057. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98058. /**
  98059. * Gets the current class name
  98060. * @returns the class name
  98061. */
  98062. getClassName(): string;
  98063. /**
  98064. * Animate the input if animationType !== None
  98065. * @param scene defines the rendering scene
  98066. */
  98067. animate(scene: Scene): void;
  98068. private _emitDefine;
  98069. initialize(state: NodeMaterialBuildState): void;
  98070. /**
  98071. * Set the input block to its default value (based on its type)
  98072. */
  98073. setDefaultValue(): void;
  98074. private _emitConstant;
  98075. /** @hidden */
  98076. get _noContextSwitch(): boolean;
  98077. private _emit;
  98078. /** @hidden */
  98079. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98080. /** @hidden */
  98081. _transmit(effect: Effect, scene: Scene): void;
  98082. protected _buildBlock(state: NodeMaterialBuildState): void;
  98083. protected _dumpPropertiesCode(): string;
  98084. dispose(): void;
  98085. serialize(): any;
  98086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98087. }
  98088. }
  98089. declare module BABYLON {
  98090. /**
  98091. * Enum used to define the compatibility state between two connection points
  98092. */
  98093. export enum NodeMaterialConnectionPointCompatibilityStates {
  98094. /** Points are compatibles */
  98095. Compatible = 0,
  98096. /** Points are incompatible because of their types */
  98097. TypeIncompatible = 1,
  98098. /** Points are incompatible because of their targets (vertex vs fragment) */
  98099. TargetIncompatible = 2
  98100. }
  98101. /**
  98102. * Defines the direction of a connection point
  98103. */
  98104. export enum NodeMaterialConnectionPointDirection {
  98105. /** Input */
  98106. Input = 0,
  98107. /** Output */
  98108. Output = 1
  98109. }
  98110. /**
  98111. * Defines a connection point for a block
  98112. */
  98113. export class NodeMaterialConnectionPoint {
  98114. /** @hidden */
  98115. _ownerBlock: NodeMaterialBlock;
  98116. /** @hidden */
  98117. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98118. private _endpoints;
  98119. private _associatedVariableName;
  98120. private _direction;
  98121. /** @hidden */
  98122. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98123. /** @hidden */
  98124. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98125. private _type;
  98126. /** @hidden */
  98127. _enforceAssociatedVariableName: boolean;
  98128. /** Gets the direction of the point */
  98129. get direction(): NodeMaterialConnectionPointDirection;
  98130. /** Indicates that this connection point needs dual validation before being connected to another point */
  98131. needDualDirectionValidation: boolean;
  98132. /**
  98133. * Gets or sets the additional types supported by this connection point
  98134. */
  98135. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98136. /**
  98137. * Gets or sets the additional types excluded by this connection point
  98138. */
  98139. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98140. /**
  98141. * Observable triggered when this point is connected
  98142. */
  98143. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98144. /**
  98145. * Gets or sets the associated variable name in the shader
  98146. */
  98147. get associatedVariableName(): string;
  98148. set associatedVariableName(value: string);
  98149. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98150. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98151. /**
  98152. * Gets or sets the connection point type (default is float)
  98153. */
  98154. get type(): NodeMaterialBlockConnectionPointTypes;
  98155. set type(value: NodeMaterialBlockConnectionPointTypes);
  98156. /**
  98157. * Gets or sets the connection point name
  98158. */
  98159. name: string;
  98160. /**
  98161. * Gets or sets the connection point name
  98162. */
  98163. displayName: string;
  98164. /**
  98165. * Gets or sets a boolean indicating that this connection point can be omitted
  98166. */
  98167. isOptional: boolean;
  98168. /**
  98169. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98170. */
  98171. isExposedOnFrame: boolean;
  98172. /**
  98173. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98174. */
  98175. define: string;
  98176. /** @hidden */
  98177. _prioritizeVertex: boolean;
  98178. private _target;
  98179. /** Gets or sets the target of that connection point */
  98180. get target(): NodeMaterialBlockTargets;
  98181. set target(value: NodeMaterialBlockTargets);
  98182. /**
  98183. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98184. */
  98185. get isConnected(): boolean;
  98186. /**
  98187. * Gets a boolean indicating that the current point is connected to an input block
  98188. */
  98189. get isConnectedToInputBlock(): boolean;
  98190. /**
  98191. * Gets a the connected input block (if any)
  98192. */
  98193. get connectInputBlock(): Nullable<InputBlock>;
  98194. /** Get the other side of the connection (if any) */
  98195. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98196. /** Get the block that owns this connection point */
  98197. get ownerBlock(): NodeMaterialBlock;
  98198. /** Get the block connected on the other side of this connection (if any) */
  98199. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98200. /** Get the block connected on the endpoints of this connection (if any) */
  98201. get connectedBlocks(): Array<NodeMaterialBlock>;
  98202. /** Gets the list of connected endpoints */
  98203. get endpoints(): NodeMaterialConnectionPoint[];
  98204. /** Gets a boolean indicating if that output point is connected to at least one input */
  98205. get hasEndpoints(): boolean;
  98206. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98207. get isConnectedInVertexShader(): boolean;
  98208. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98209. get isConnectedInFragmentShader(): boolean;
  98210. /**
  98211. * Creates a block suitable to be used as an input for this input point.
  98212. * If null is returned, a block based on the point type will be created.
  98213. * @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
  98214. */
  98215. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98216. /**
  98217. * Creates a new connection point
  98218. * @param name defines the connection point name
  98219. * @param ownerBlock defines the block hosting this connection point
  98220. * @param direction defines the direction of the connection point
  98221. */
  98222. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98223. /**
  98224. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98225. * @returns the class name
  98226. */
  98227. getClassName(): string;
  98228. /**
  98229. * Gets a boolean indicating if the current point can be connected to another point
  98230. * @param connectionPoint defines the other connection point
  98231. * @returns a boolean
  98232. */
  98233. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98234. /**
  98235. * Gets a number indicating if the current point can be connected to another point
  98236. * @param connectionPoint defines the other connection point
  98237. * @returns a number defining the compatibility state
  98238. */
  98239. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98240. /**
  98241. * Connect this point to another connection point
  98242. * @param connectionPoint defines the other connection point
  98243. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98244. * @returns the current connection point
  98245. */
  98246. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98247. /**
  98248. * Disconnect this point from one of his endpoint
  98249. * @param endpoint defines the other connection point
  98250. * @returns the current connection point
  98251. */
  98252. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98253. /**
  98254. * Serializes this point in a JSON representation
  98255. * @param isInput defines if the connection point is an input (default is true)
  98256. * @returns the serialized point object
  98257. */
  98258. serialize(isInput?: boolean): any;
  98259. /**
  98260. * Release resources
  98261. */
  98262. dispose(): void;
  98263. }
  98264. }
  98265. declare module BABYLON {
  98266. /**
  98267. * Enum used to define the material modes
  98268. */
  98269. export enum NodeMaterialModes {
  98270. /** Regular material */
  98271. Material = 0,
  98272. /** For post process */
  98273. PostProcess = 1,
  98274. /** For particle system */
  98275. Particle = 2
  98276. }
  98277. }
  98278. declare module BABYLON {
  98279. /**
  98280. * Block used to read a texture from a sampler
  98281. */
  98282. export class TextureBlock extends NodeMaterialBlock {
  98283. private _defineName;
  98284. private _linearDefineName;
  98285. private _gammaDefineName;
  98286. private _tempTextureRead;
  98287. private _samplerName;
  98288. private _transformedUVName;
  98289. private _textureTransformName;
  98290. private _textureInfoName;
  98291. private _mainUVName;
  98292. private _mainUVDefineName;
  98293. private _fragmentOnly;
  98294. /**
  98295. * Gets or sets the texture associated with the node
  98296. */
  98297. texture: Nullable<Texture>;
  98298. /**
  98299. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98300. */
  98301. convertToGammaSpace: boolean;
  98302. /**
  98303. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98304. */
  98305. convertToLinearSpace: boolean;
  98306. /**
  98307. * Create a new TextureBlock
  98308. * @param name defines the block name
  98309. */
  98310. constructor(name: string, fragmentOnly?: boolean);
  98311. /**
  98312. * Gets the current class name
  98313. * @returns the class name
  98314. */
  98315. getClassName(): string;
  98316. /**
  98317. * Gets the uv input component
  98318. */
  98319. get uv(): NodeMaterialConnectionPoint;
  98320. /**
  98321. * Gets the rgba output component
  98322. */
  98323. get rgba(): NodeMaterialConnectionPoint;
  98324. /**
  98325. * Gets the rgb output component
  98326. */
  98327. get rgb(): NodeMaterialConnectionPoint;
  98328. /**
  98329. * Gets the r output component
  98330. */
  98331. get r(): NodeMaterialConnectionPoint;
  98332. /**
  98333. * Gets the g output component
  98334. */
  98335. get g(): NodeMaterialConnectionPoint;
  98336. /**
  98337. * Gets the b output component
  98338. */
  98339. get b(): NodeMaterialConnectionPoint;
  98340. /**
  98341. * Gets the a output component
  98342. */
  98343. get a(): NodeMaterialConnectionPoint;
  98344. get target(): NodeMaterialBlockTargets;
  98345. autoConfigure(material: NodeMaterial): void;
  98346. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98348. isReady(): boolean;
  98349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98350. private get _isMixed();
  98351. private _injectVertexCode;
  98352. private _writeTextureRead;
  98353. private _writeOutput;
  98354. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98355. protected _dumpPropertiesCode(): string;
  98356. serialize(): any;
  98357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98358. }
  98359. }
  98360. declare module BABYLON {
  98361. /** @hidden */
  98362. export var reflectionFunction: {
  98363. name: string;
  98364. shader: string;
  98365. };
  98366. }
  98367. declare module BABYLON {
  98368. /**
  98369. * Base block used to read a reflection texture from a sampler
  98370. */
  98371. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98372. /** @hidden */
  98373. _define3DName: string;
  98374. /** @hidden */
  98375. _defineCubicName: string;
  98376. /** @hidden */
  98377. _defineExplicitName: string;
  98378. /** @hidden */
  98379. _defineProjectionName: string;
  98380. /** @hidden */
  98381. _defineLocalCubicName: string;
  98382. /** @hidden */
  98383. _defineSphericalName: string;
  98384. /** @hidden */
  98385. _definePlanarName: string;
  98386. /** @hidden */
  98387. _defineEquirectangularName: string;
  98388. /** @hidden */
  98389. _defineMirroredEquirectangularFixedName: string;
  98390. /** @hidden */
  98391. _defineEquirectangularFixedName: string;
  98392. /** @hidden */
  98393. _defineSkyboxName: string;
  98394. /** @hidden */
  98395. _defineOppositeZ: string;
  98396. /** @hidden */
  98397. _cubeSamplerName: string;
  98398. /** @hidden */
  98399. _2DSamplerName: string;
  98400. protected _positionUVWName: string;
  98401. protected _directionWName: string;
  98402. protected _reflectionVectorName: string;
  98403. /** @hidden */
  98404. _reflectionCoordsName: string;
  98405. /** @hidden */
  98406. _reflectionMatrixName: string;
  98407. protected _reflectionColorName: string;
  98408. /**
  98409. * Gets or sets the texture associated with the node
  98410. */
  98411. texture: Nullable<BaseTexture>;
  98412. /**
  98413. * Create a new ReflectionTextureBaseBlock
  98414. * @param name defines the block name
  98415. */
  98416. constructor(name: string);
  98417. /**
  98418. * Gets the current class name
  98419. * @returns the class name
  98420. */
  98421. getClassName(): string;
  98422. /**
  98423. * Gets the world position input component
  98424. */
  98425. abstract get position(): NodeMaterialConnectionPoint;
  98426. /**
  98427. * Gets the world position input component
  98428. */
  98429. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98430. /**
  98431. * Gets the world normal input component
  98432. */
  98433. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98434. /**
  98435. * Gets the world input component
  98436. */
  98437. abstract get world(): NodeMaterialConnectionPoint;
  98438. /**
  98439. * Gets the camera (or eye) position component
  98440. */
  98441. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98442. /**
  98443. * Gets the view input component
  98444. */
  98445. abstract get view(): NodeMaterialConnectionPoint;
  98446. protected _getTexture(): Nullable<BaseTexture>;
  98447. autoConfigure(material: NodeMaterial): void;
  98448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98449. isReady(): boolean;
  98450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98451. /**
  98452. * Gets the code to inject in the vertex shader
  98453. * @param state current state of the node material building
  98454. * @returns the shader code
  98455. */
  98456. handleVertexSide(state: NodeMaterialBuildState): string;
  98457. /**
  98458. * Handles the inits for the fragment code path
  98459. * @param state node material build state
  98460. */
  98461. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98462. /**
  98463. * Generates the reflection coords code for the fragment code path
  98464. * @param worldNormalVarName name of the world normal variable
  98465. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98466. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98467. * @returns the shader code
  98468. */
  98469. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98470. /**
  98471. * Generates the reflection color code for the fragment code path
  98472. * @param lodVarName name of the lod variable
  98473. * @param swizzleLookupTexture swizzle to use for the final color variable
  98474. * @returns the shader code
  98475. */
  98476. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98477. /**
  98478. * Generates the code corresponding to the connected output points
  98479. * @param state node material build state
  98480. * @param varName name of the variable to output
  98481. * @returns the shader code
  98482. */
  98483. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98484. protected _buildBlock(state: NodeMaterialBuildState): this;
  98485. protected _dumpPropertiesCode(): string;
  98486. serialize(): any;
  98487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98488. }
  98489. }
  98490. declare module BABYLON {
  98491. /**
  98492. * Defines a connection point to be used for points with a custom object type
  98493. */
  98494. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98495. private _blockType;
  98496. private _blockName;
  98497. private _nameForCheking?;
  98498. /**
  98499. * Creates a new connection point
  98500. * @param name defines the connection point name
  98501. * @param ownerBlock defines the block hosting this connection point
  98502. * @param direction defines the direction of the connection point
  98503. */
  98504. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98505. /**
  98506. * Gets a number indicating if the current point can be connected to another point
  98507. * @param connectionPoint defines the other connection point
  98508. * @returns a number defining the compatibility state
  98509. */
  98510. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98511. /**
  98512. * Creates a block suitable to be used as an input for this input point.
  98513. * If null is returned, a block based on the point type will be created.
  98514. * @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
  98515. */
  98516. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98517. }
  98518. }
  98519. declare module BABYLON {
  98520. /**
  98521. * Enum defining the type of properties that can be edited in the property pages in the NME
  98522. */
  98523. export enum PropertyTypeForEdition {
  98524. /** property is a boolean */
  98525. Boolean = 0,
  98526. /** property is a float */
  98527. Float = 1,
  98528. /** property is a Vector2 */
  98529. Vector2 = 2,
  98530. /** property is a list of values */
  98531. List = 3
  98532. }
  98533. /**
  98534. * Interface that defines an option in a variable of type list
  98535. */
  98536. export interface IEditablePropertyListOption {
  98537. /** label of the option */
  98538. "label": string;
  98539. /** value of the option */
  98540. "value": number;
  98541. }
  98542. /**
  98543. * Interface that defines the options available for an editable property
  98544. */
  98545. export interface IEditablePropertyOption {
  98546. /** min value */
  98547. "min"?: number;
  98548. /** max value */
  98549. "max"?: number;
  98550. /** notifiers: indicates which actions to take when the property is changed */
  98551. "notifiers"?: {
  98552. /** the material should be rebuilt */
  98553. "rebuild"?: boolean;
  98554. /** the preview should be updated */
  98555. "update"?: boolean;
  98556. };
  98557. /** list of the options for a variable of type list */
  98558. "options"?: IEditablePropertyListOption[];
  98559. }
  98560. /**
  98561. * Interface that describes an editable property
  98562. */
  98563. export interface IPropertyDescriptionForEdition {
  98564. /** name of the property */
  98565. "propertyName": string;
  98566. /** display name of the property */
  98567. "displayName": string;
  98568. /** type of the property */
  98569. "type": PropertyTypeForEdition;
  98570. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98571. "groupName": string;
  98572. /** options for the property */
  98573. "options": IEditablePropertyOption;
  98574. }
  98575. /**
  98576. * Decorator that flags a property in a node material block as being editable
  98577. */
  98578. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98579. }
  98580. declare module BABYLON {
  98581. /**
  98582. * Block used to implement the refraction part of the sub surface module of the PBR material
  98583. */
  98584. export class RefractionBlock extends NodeMaterialBlock {
  98585. /** @hidden */
  98586. _define3DName: string;
  98587. /** @hidden */
  98588. _refractionMatrixName: string;
  98589. /** @hidden */
  98590. _defineLODRefractionAlpha: string;
  98591. /** @hidden */
  98592. _defineLinearSpecularRefraction: string;
  98593. /** @hidden */
  98594. _defineOppositeZ: string;
  98595. /** @hidden */
  98596. _cubeSamplerName: string;
  98597. /** @hidden */
  98598. _2DSamplerName: string;
  98599. /** @hidden */
  98600. _vRefractionMicrosurfaceInfosName: string;
  98601. /** @hidden */
  98602. _vRefractionInfosName: string;
  98603. private _scene;
  98604. /**
  98605. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98606. * Materials half opaque for instance using refraction could benefit from this control.
  98607. */
  98608. linkRefractionWithTransparency: boolean;
  98609. /**
  98610. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98611. */
  98612. invertRefractionY: boolean;
  98613. /**
  98614. * Gets or sets the texture associated with the node
  98615. */
  98616. texture: Nullable<BaseTexture>;
  98617. /**
  98618. * Create a new RefractionBlock
  98619. * @param name defines the block name
  98620. */
  98621. constructor(name: string);
  98622. /**
  98623. * Gets the current class name
  98624. * @returns the class name
  98625. */
  98626. getClassName(): string;
  98627. /**
  98628. * Gets the intensity input component
  98629. */
  98630. get intensity(): NodeMaterialConnectionPoint;
  98631. /**
  98632. * Gets the index of refraction input component
  98633. */
  98634. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98635. /**
  98636. * Gets the tint at distance input component
  98637. */
  98638. get tintAtDistance(): NodeMaterialConnectionPoint;
  98639. /**
  98640. * Gets the view input component
  98641. */
  98642. get view(): NodeMaterialConnectionPoint;
  98643. /**
  98644. * Gets the refraction object output component
  98645. */
  98646. get refraction(): NodeMaterialConnectionPoint;
  98647. /**
  98648. * Returns true if the block has a texture
  98649. */
  98650. get hasTexture(): boolean;
  98651. protected _getTexture(): Nullable<BaseTexture>;
  98652. autoConfigure(material: NodeMaterial): void;
  98653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98654. isReady(): boolean;
  98655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98656. /**
  98657. * Gets the main code of the block (fragment side)
  98658. * @param state current state of the node material building
  98659. * @returns the shader code
  98660. */
  98661. getCode(state: NodeMaterialBuildState): string;
  98662. protected _buildBlock(state: NodeMaterialBuildState): this;
  98663. protected _dumpPropertiesCode(): string;
  98664. serialize(): any;
  98665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. /**
  98670. * Base block used as input for post process
  98671. */
  98672. export class CurrentScreenBlock extends NodeMaterialBlock {
  98673. private _samplerName;
  98674. private _linearDefineName;
  98675. private _gammaDefineName;
  98676. private _mainUVName;
  98677. private _tempTextureRead;
  98678. /**
  98679. * Gets or sets the texture associated with the node
  98680. */
  98681. texture: Nullable<BaseTexture>;
  98682. /**
  98683. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98684. */
  98685. convertToGammaSpace: boolean;
  98686. /**
  98687. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98688. */
  98689. convertToLinearSpace: boolean;
  98690. /**
  98691. * Create a new CurrentScreenBlock
  98692. * @param name defines the block name
  98693. */
  98694. constructor(name: string);
  98695. /**
  98696. * Gets the current class name
  98697. * @returns the class name
  98698. */
  98699. getClassName(): string;
  98700. /**
  98701. * Gets the uv input component
  98702. */
  98703. get uv(): NodeMaterialConnectionPoint;
  98704. /**
  98705. * Gets the rgba output component
  98706. */
  98707. get rgba(): NodeMaterialConnectionPoint;
  98708. /**
  98709. * Gets the rgb output component
  98710. */
  98711. get rgb(): NodeMaterialConnectionPoint;
  98712. /**
  98713. * Gets the r output component
  98714. */
  98715. get r(): NodeMaterialConnectionPoint;
  98716. /**
  98717. * Gets the g output component
  98718. */
  98719. get g(): NodeMaterialConnectionPoint;
  98720. /**
  98721. * Gets the b output component
  98722. */
  98723. get b(): NodeMaterialConnectionPoint;
  98724. /**
  98725. * Gets the a output component
  98726. */
  98727. get a(): NodeMaterialConnectionPoint;
  98728. /**
  98729. * Initialize the block and prepare the context for build
  98730. * @param state defines the state that will be used for the build
  98731. */
  98732. initialize(state: NodeMaterialBuildState): void;
  98733. get target(): NodeMaterialBlockTargets;
  98734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98735. isReady(): boolean;
  98736. private _injectVertexCode;
  98737. private _writeTextureRead;
  98738. private _writeOutput;
  98739. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98740. serialize(): any;
  98741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98742. }
  98743. }
  98744. declare module BABYLON {
  98745. /**
  98746. * Base block used for the particle texture
  98747. */
  98748. export class ParticleTextureBlock extends NodeMaterialBlock {
  98749. private _samplerName;
  98750. private _linearDefineName;
  98751. private _gammaDefineName;
  98752. private _tempTextureRead;
  98753. /**
  98754. * Gets or sets the texture associated with the node
  98755. */
  98756. texture: Nullable<BaseTexture>;
  98757. /**
  98758. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98759. */
  98760. convertToGammaSpace: boolean;
  98761. /**
  98762. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98763. */
  98764. convertToLinearSpace: boolean;
  98765. /**
  98766. * Create a new ParticleTextureBlock
  98767. * @param name defines the block name
  98768. */
  98769. constructor(name: string);
  98770. /**
  98771. * Gets the current class name
  98772. * @returns the class name
  98773. */
  98774. getClassName(): string;
  98775. /**
  98776. * Gets the uv input component
  98777. */
  98778. get uv(): NodeMaterialConnectionPoint;
  98779. /**
  98780. * Gets the rgba output component
  98781. */
  98782. get rgba(): NodeMaterialConnectionPoint;
  98783. /**
  98784. * Gets the rgb output component
  98785. */
  98786. get rgb(): NodeMaterialConnectionPoint;
  98787. /**
  98788. * Gets the r output component
  98789. */
  98790. get r(): NodeMaterialConnectionPoint;
  98791. /**
  98792. * Gets the g output component
  98793. */
  98794. get g(): NodeMaterialConnectionPoint;
  98795. /**
  98796. * Gets the b output component
  98797. */
  98798. get b(): NodeMaterialConnectionPoint;
  98799. /**
  98800. * Gets the a output component
  98801. */
  98802. get a(): NodeMaterialConnectionPoint;
  98803. /**
  98804. * Initialize the block and prepare the context for build
  98805. * @param state defines the state that will be used for the build
  98806. */
  98807. initialize(state: NodeMaterialBuildState): void;
  98808. autoConfigure(material: NodeMaterial): void;
  98809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98810. isReady(): boolean;
  98811. private _writeOutput;
  98812. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98813. serialize(): any;
  98814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98815. }
  98816. }
  98817. declare module BABYLON {
  98818. /**
  98819. * Class used to store shared data between 2 NodeMaterialBuildState
  98820. */
  98821. export class NodeMaterialBuildStateSharedData {
  98822. /**
  98823. * Gets the list of emitted varyings
  98824. */
  98825. temps: string[];
  98826. /**
  98827. * Gets the list of emitted varyings
  98828. */
  98829. varyings: string[];
  98830. /**
  98831. * Gets the varying declaration string
  98832. */
  98833. varyingDeclaration: string;
  98834. /**
  98835. * Input blocks
  98836. */
  98837. inputBlocks: InputBlock[];
  98838. /**
  98839. * Input blocks
  98840. */
  98841. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98842. /**
  98843. * Bindable blocks (Blocks that need to set data to the effect)
  98844. */
  98845. bindableBlocks: NodeMaterialBlock[];
  98846. /**
  98847. * List of blocks that can provide a compilation fallback
  98848. */
  98849. blocksWithFallbacks: NodeMaterialBlock[];
  98850. /**
  98851. * List of blocks that can provide a define update
  98852. */
  98853. blocksWithDefines: NodeMaterialBlock[];
  98854. /**
  98855. * List of blocks that can provide a repeatable content
  98856. */
  98857. repeatableContentBlocks: NodeMaterialBlock[];
  98858. /**
  98859. * List of blocks that can provide a dynamic list of uniforms
  98860. */
  98861. dynamicUniformBlocks: NodeMaterialBlock[];
  98862. /**
  98863. * List of blocks that can block the isReady function for the material
  98864. */
  98865. blockingBlocks: NodeMaterialBlock[];
  98866. /**
  98867. * Gets the list of animated inputs
  98868. */
  98869. animatedInputs: InputBlock[];
  98870. /**
  98871. * Build Id used to avoid multiple recompilations
  98872. */
  98873. buildId: number;
  98874. /** List of emitted variables */
  98875. variableNames: {
  98876. [key: string]: number;
  98877. };
  98878. /** List of emitted defines */
  98879. defineNames: {
  98880. [key: string]: number;
  98881. };
  98882. /** Should emit comments? */
  98883. emitComments: boolean;
  98884. /** Emit build activity */
  98885. verbose: boolean;
  98886. /** Gets or sets the hosting scene */
  98887. scene: Scene;
  98888. /**
  98889. * Gets the compilation hints emitted at compilation time
  98890. */
  98891. hints: {
  98892. needWorldViewMatrix: boolean;
  98893. needWorldViewProjectionMatrix: boolean;
  98894. needAlphaBlending: boolean;
  98895. needAlphaTesting: boolean;
  98896. };
  98897. /**
  98898. * List of compilation checks
  98899. */
  98900. checks: {
  98901. emitVertex: boolean;
  98902. emitFragment: boolean;
  98903. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98904. };
  98905. /**
  98906. * Is vertex program allowed to be empty?
  98907. */
  98908. allowEmptyVertexProgram: boolean;
  98909. /** Creates a new shared data */
  98910. constructor();
  98911. /**
  98912. * Emits console errors and exceptions if there is a failing check
  98913. */
  98914. emitErrors(): void;
  98915. }
  98916. }
  98917. declare module BABYLON {
  98918. /**
  98919. * Class used to store node based material build state
  98920. */
  98921. export class NodeMaterialBuildState {
  98922. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98923. supportUniformBuffers: boolean;
  98924. /**
  98925. * Gets the list of emitted attributes
  98926. */
  98927. attributes: string[];
  98928. /**
  98929. * Gets the list of emitted uniforms
  98930. */
  98931. uniforms: string[];
  98932. /**
  98933. * Gets the list of emitted constants
  98934. */
  98935. constants: string[];
  98936. /**
  98937. * Gets the list of emitted samplers
  98938. */
  98939. samplers: string[];
  98940. /**
  98941. * Gets the list of emitted functions
  98942. */
  98943. functions: {
  98944. [key: string]: string;
  98945. };
  98946. /**
  98947. * Gets the list of emitted extensions
  98948. */
  98949. extensions: {
  98950. [key: string]: string;
  98951. };
  98952. /**
  98953. * Gets the target of the compilation state
  98954. */
  98955. target: NodeMaterialBlockTargets;
  98956. /**
  98957. * Gets the list of emitted counters
  98958. */
  98959. counters: {
  98960. [key: string]: number;
  98961. };
  98962. /**
  98963. * Shared data between multiple NodeMaterialBuildState instances
  98964. */
  98965. sharedData: NodeMaterialBuildStateSharedData;
  98966. /** @hidden */
  98967. _vertexState: NodeMaterialBuildState;
  98968. /** @hidden */
  98969. _attributeDeclaration: string;
  98970. /** @hidden */
  98971. _uniformDeclaration: string;
  98972. /** @hidden */
  98973. _constantDeclaration: string;
  98974. /** @hidden */
  98975. _samplerDeclaration: string;
  98976. /** @hidden */
  98977. _varyingTransfer: string;
  98978. /** @hidden */
  98979. _injectAtEnd: string;
  98980. private _repeatableContentAnchorIndex;
  98981. /** @hidden */
  98982. _builtCompilationString: string;
  98983. /**
  98984. * Gets the emitted compilation strings
  98985. */
  98986. compilationString: string;
  98987. /**
  98988. * Finalize the compilation strings
  98989. * @param state defines the current compilation state
  98990. */
  98991. finalize(state: NodeMaterialBuildState): void;
  98992. /** @hidden */
  98993. get _repeatableContentAnchor(): string;
  98994. /** @hidden */
  98995. _getFreeVariableName(prefix: string): string;
  98996. /** @hidden */
  98997. _getFreeDefineName(prefix: string): string;
  98998. /** @hidden */
  98999. _excludeVariableName(name: string): void;
  99000. /** @hidden */
  99001. _emit2DSampler(name: string): void;
  99002. /** @hidden */
  99003. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99004. /** @hidden */
  99005. _emitExtension(name: string, extension: string, define?: string): void;
  99006. /** @hidden */
  99007. _emitFunction(name: string, code: string, comments: string): void;
  99008. /** @hidden */
  99009. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99010. replaceStrings?: {
  99011. search: RegExp;
  99012. replace: string;
  99013. }[];
  99014. repeatKey?: string;
  99015. }): string;
  99016. /** @hidden */
  99017. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99018. repeatKey?: string;
  99019. removeAttributes?: boolean;
  99020. removeUniforms?: boolean;
  99021. removeVaryings?: boolean;
  99022. removeIfDef?: boolean;
  99023. replaceStrings?: {
  99024. search: RegExp;
  99025. replace: string;
  99026. }[];
  99027. }, storeKey?: string): void;
  99028. /** @hidden */
  99029. _registerTempVariable(name: string): boolean;
  99030. /** @hidden */
  99031. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99032. /** @hidden */
  99033. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99034. /** @hidden */
  99035. _emitFloat(value: number): string;
  99036. }
  99037. }
  99038. declare module BABYLON {
  99039. /**
  99040. * Helper class used to generate session unique ID
  99041. */
  99042. export class UniqueIdGenerator {
  99043. private static _UniqueIdCounter;
  99044. /**
  99045. * Gets an unique (relatively to the current scene) Id
  99046. */
  99047. static get UniqueId(): number;
  99048. }
  99049. }
  99050. declare module BABYLON {
  99051. /**
  99052. * Defines a block that can be used inside a node based material
  99053. */
  99054. export class NodeMaterialBlock {
  99055. private _buildId;
  99056. private _buildTarget;
  99057. private _target;
  99058. private _isFinalMerger;
  99059. private _isInput;
  99060. protected _isUnique: boolean;
  99061. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99062. inputsAreExclusive: boolean;
  99063. /** @hidden */
  99064. _codeVariableName: string;
  99065. /** @hidden */
  99066. _inputs: NodeMaterialConnectionPoint[];
  99067. /** @hidden */
  99068. _outputs: NodeMaterialConnectionPoint[];
  99069. /** @hidden */
  99070. _preparationId: number;
  99071. /**
  99072. * Gets or sets the name of the block
  99073. */
  99074. name: string;
  99075. /**
  99076. * Gets or sets the unique id of the node
  99077. */
  99078. uniqueId: number;
  99079. /**
  99080. * Gets or sets the comments associated with this block
  99081. */
  99082. comments: string;
  99083. /**
  99084. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99085. */
  99086. get isUnique(): boolean;
  99087. /**
  99088. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99089. */
  99090. get isFinalMerger(): boolean;
  99091. /**
  99092. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99093. */
  99094. get isInput(): boolean;
  99095. /**
  99096. * Gets or sets the build Id
  99097. */
  99098. get buildId(): number;
  99099. set buildId(value: number);
  99100. /**
  99101. * Gets or sets the target of the block
  99102. */
  99103. get target(): NodeMaterialBlockTargets;
  99104. set target(value: NodeMaterialBlockTargets);
  99105. /**
  99106. * Gets the list of input points
  99107. */
  99108. get inputs(): NodeMaterialConnectionPoint[];
  99109. /** Gets the list of output points */
  99110. get outputs(): NodeMaterialConnectionPoint[];
  99111. /**
  99112. * Find an input by its name
  99113. * @param name defines the name of the input to look for
  99114. * @returns the input or null if not found
  99115. */
  99116. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99117. /**
  99118. * Find an output by its name
  99119. * @param name defines the name of the outputto look for
  99120. * @returns the output or null if not found
  99121. */
  99122. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99123. /**
  99124. * Creates a new NodeMaterialBlock
  99125. * @param name defines the block name
  99126. * @param target defines the target of that block (Vertex by default)
  99127. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99128. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99129. */
  99130. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99131. /**
  99132. * Initialize the block and prepare the context for build
  99133. * @param state defines the state that will be used for the build
  99134. */
  99135. initialize(state: NodeMaterialBuildState): void;
  99136. /**
  99137. * Bind data to effect. Will only be called for blocks with isBindable === true
  99138. * @param effect defines the effect to bind data to
  99139. * @param nodeMaterial defines the hosting NodeMaterial
  99140. * @param mesh defines the mesh that will be rendered
  99141. * @param subMesh defines the submesh that will be rendered
  99142. */
  99143. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99144. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99145. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99146. protected _writeFloat(value: number): string;
  99147. /**
  99148. * Gets the current class name e.g. "NodeMaterialBlock"
  99149. * @returns the class name
  99150. */
  99151. getClassName(): string;
  99152. /**
  99153. * Register a new input. Must be called inside a block constructor
  99154. * @param name defines the connection point name
  99155. * @param type defines the connection point type
  99156. * @param isOptional defines a boolean indicating that this input can be omitted
  99157. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99158. * @param point an already created connection point. If not provided, create a new one
  99159. * @returns the current block
  99160. */
  99161. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99162. /**
  99163. * Register a new output. Must be called inside a block constructor
  99164. * @param name defines the connection point name
  99165. * @param type defines the connection point type
  99166. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99167. * @param point an already created connection point. If not provided, create a new one
  99168. * @returns the current block
  99169. */
  99170. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99171. /**
  99172. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99173. * @param forOutput defines an optional connection point to check compatibility with
  99174. * @returns the first available input or null
  99175. */
  99176. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99177. /**
  99178. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99179. * @param forBlock defines an optional block to check compatibility with
  99180. * @returns the first available input or null
  99181. */
  99182. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99183. /**
  99184. * Gets the sibling of the given output
  99185. * @param current defines the current output
  99186. * @returns the next output in the list or null
  99187. */
  99188. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99189. /**
  99190. * Connect current block with another block
  99191. * @param other defines the block to connect with
  99192. * @param options define the various options to help pick the right connections
  99193. * @returns the current block
  99194. */
  99195. connectTo(other: NodeMaterialBlock, options?: {
  99196. input?: string;
  99197. output?: string;
  99198. outputSwizzle?: string;
  99199. }): this | undefined;
  99200. protected _buildBlock(state: NodeMaterialBuildState): void;
  99201. /**
  99202. * Add uniforms, samplers and uniform buffers at compilation time
  99203. * @param state defines the state to update
  99204. * @param nodeMaterial defines the node material requesting the update
  99205. * @param defines defines the material defines to update
  99206. * @param uniformBuffers defines the list of uniform buffer names
  99207. */
  99208. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99209. /**
  99210. * Add potential fallbacks if shader compilation fails
  99211. * @param mesh defines the mesh to be rendered
  99212. * @param fallbacks defines the current prioritized list of fallbacks
  99213. */
  99214. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99215. /**
  99216. * Initialize defines for shader compilation
  99217. * @param mesh defines the mesh to be rendered
  99218. * @param nodeMaterial defines the node material requesting the update
  99219. * @param defines defines the material defines to update
  99220. * @param useInstances specifies that instances should be used
  99221. */
  99222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99223. /**
  99224. * Update defines for shader compilation
  99225. * @param mesh defines the mesh to be rendered
  99226. * @param nodeMaterial defines the node material requesting the update
  99227. * @param defines defines the material defines to update
  99228. * @param useInstances specifies that instances should be used
  99229. * @param subMesh defines which submesh to render
  99230. */
  99231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99232. /**
  99233. * Lets the block try to connect some inputs automatically
  99234. * @param material defines the hosting NodeMaterial
  99235. */
  99236. autoConfigure(material: NodeMaterial): void;
  99237. /**
  99238. * Function called when a block is declared as repeatable content generator
  99239. * @param vertexShaderState defines the current compilation state for the vertex shader
  99240. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99241. * @param mesh defines the mesh to be rendered
  99242. * @param defines defines the material defines to update
  99243. */
  99244. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99245. /**
  99246. * Checks if the block is ready
  99247. * @param mesh defines the mesh to be rendered
  99248. * @param nodeMaterial defines the node material requesting the update
  99249. * @param defines defines the material defines to update
  99250. * @param useInstances specifies that instances should be used
  99251. * @returns true if the block is ready
  99252. */
  99253. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99254. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99255. private _processBuild;
  99256. /**
  99257. * Compile the current node and generate the shader code
  99258. * @param state defines the current compilation state (uniforms, samplers, current string)
  99259. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99260. * @returns true if already built
  99261. */
  99262. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99263. protected _inputRename(name: string): string;
  99264. protected _outputRename(name: string): string;
  99265. protected _dumpPropertiesCode(): string;
  99266. /** @hidden */
  99267. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99268. /** @hidden */
  99269. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99270. /**
  99271. * Clone the current block to a new identical block
  99272. * @param scene defines the hosting scene
  99273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99274. * @returns a copy of the current block
  99275. */
  99276. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99277. /**
  99278. * Serializes this block in a JSON representation
  99279. * @returns the serialized block object
  99280. */
  99281. serialize(): any;
  99282. /** @hidden */
  99283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99284. private _deserializePortDisplayNamesAndExposedOnFrame;
  99285. /**
  99286. * Release resources
  99287. */
  99288. dispose(): void;
  99289. }
  99290. }
  99291. declare module BABYLON {
  99292. /**
  99293. * Base class of materials working in push mode in babylon JS
  99294. * @hidden
  99295. */
  99296. export class PushMaterial extends Material {
  99297. protected _activeEffect: Effect;
  99298. protected _normalMatrix: Matrix;
  99299. constructor(name: string, scene: Scene);
  99300. getEffect(): Effect;
  99301. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99302. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99303. /**
  99304. * Binds the given world matrix to the active effect
  99305. *
  99306. * @param world the matrix to bind
  99307. */
  99308. bindOnlyWorldMatrix(world: Matrix): void;
  99309. /**
  99310. * Binds the given normal matrix to the active effect
  99311. *
  99312. * @param normalMatrix the matrix to bind
  99313. */
  99314. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99315. bind(world: Matrix, mesh?: Mesh): void;
  99316. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99317. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99318. }
  99319. }
  99320. declare module BABYLON {
  99321. /**
  99322. * Root class for all node material optimizers
  99323. */
  99324. export class NodeMaterialOptimizer {
  99325. /**
  99326. * Function used to optimize a NodeMaterial graph
  99327. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99328. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99329. */
  99330. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99331. }
  99332. }
  99333. declare module BABYLON {
  99334. /**
  99335. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99336. */
  99337. export class TransformBlock extends NodeMaterialBlock {
  99338. /**
  99339. * Defines the value to use to complement W value to transform it to a Vector4
  99340. */
  99341. complementW: number;
  99342. /**
  99343. * Defines the value to use to complement z value to transform it to a Vector4
  99344. */
  99345. complementZ: number;
  99346. /**
  99347. * Creates a new TransformBlock
  99348. * @param name defines the block name
  99349. */
  99350. constructor(name: string);
  99351. /**
  99352. * Gets the current class name
  99353. * @returns the class name
  99354. */
  99355. getClassName(): string;
  99356. /**
  99357. * Gets the vector input
  99358. */
  99359. get vector(): NodeMaterialConnectionPoint;
  99360. /**
  99361. * Gets the output component
  99362. */
  99363. get output(): NodeMaterialConnectionPoint;
  99364. /**
  99365. * Gets the xyz output component
  99366. */
  99367. get xyz(): NodeMaterialConnectionPoint;
  99368. /**
  99369. * Gets the matrix transform input
  99370. */
  99371. get transform(): NodeMaterialConnectionPoint;
  99372. protected _buildBlock(state: NodeMaterialBuildState): this;
  99373. /**
  99374. * Update defines for shader compilation
  99375. * @param mesh defines the mesh to be rendered
  99376. * @param nodeMaterial defines the node material requesting the update
  99377. * @param defines defines the material defines to update
  99378. * @param useInstances specifies that instances should be used
  99379. * @param subMesh defines which submesh to render
  99380. */
  99381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99382. serialize(): any;
  99383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99384. protected _dumpPropertiesCode(): string;
  99385. }
  99386. }
  99387. declare module BABYLON {
  99388. /**
  99389. * Block used to output the vertex position
  99390. */
  99391. export class VertexOutputBlock extends NodeMaterialBlock {
  99392. /**
  99393. * Creates a new VertexOutputBlock
  99394. * @param name defines the block name
  99395. */
  99396. constructor(name: string);
  99397. /**
  99398. * Gets the current class name
  99399. * @returns the class name
  99400. */
  99401. getClassName(): string;
  99402. /**
  99403. * Gets the vector input component
  99404. */
  99405. get vector(): NodeMaterialConnectionPoint;
  99406. protected _buildBlock(state: NodeMaterialBuildState): this;
  99407. }
  99408. }
  99409. declare module BABYLON {
  99410. /**
  99411. * Block used to output the final color
  99412. */
  99413. export class FragmentOutputBlock extends NodeMaterialBlock {
  99414. /**
  99415. * Create a new FragmentOutputBlock
  99416. * @param name defines the block name
  99417. */
  99418. constructor(name: string);
  99419. /**
  99420. * Gets the current class name
  99421. * @returns the class name
  99422. */
  99423. getClassName(): string;
  99424. /**
  99425. * Gets the rgba input component
  99426. */
  99427. get rgba(): NodeMaterialConnectionPoint;
  99428. /**
  99429. * Gets the rgb input component
  99430. */
  99431. get rgb(): NodeMaterialConnectionPoint;
  99432. /**
  99433. * Gets the a input component
  99434. */
  99435. get a(): NodeMaterialConnectionPoint;
  99436. protected _buildBlock(state: NodeMaterialBuildState): this;
  99437. }
  99438. }
  99439. declare module BABYLON {
  99440. /**
  99441. * Block used for the particle ramp gradient section
  99442. */
  99443. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99444. /**
  99445. * Create a new ParticleRampGradientBlock
  99446. * @param name defines the block name
  99447. */
  99448. constructor(name: string);
  99449. /**
  99450. * Gets the current class name
  99451. * @returns the class name
  99452. */
  99453. getClassName(): string;
  99454. /**
  99455. * Gets the color input component
  99456. */
  99457. get color(): NodeMaterialConnectionPoint;
  99458. /**
  99459. * Gets the rampColor output component
  99460. */
  99461. get rampColor(): NodeMaterialConnectionPoint;
  99462. /**
  99463. * Initialize the block and prepare the context for build
  99464. * @param state defines the state that will be used for the build
  99465. */
  99466. initialize(state: NodeMaterialBuildState): void;
  99467. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99468. }
  99469. }
  99470. declare module BABYLON {
  99471. /**
  99472. * Block used for the particle blend multiply section
  99473. */
  99474. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99475. /**
  99476. * Create a new ParticleBlendMultiplyBlock
  99477. * @param name defines the block name
  99478. */
  99479. constructor(name: string);
  99480. /**
  99481. * Gets the current class name
  99482. * @returns the class name
  99483. */
  99484. getClassName(): string;
  99485. /**
  99486. * Gets the color input component
  99487. */
  99488. get color(): NodeMaterialConnectionPoint;
  99489. /**
  99490. * Gets the alphaTexture input component
  99491. */
  99492. get alphaTexture(): NodeMaterialConnectionPoint;
  99493. /**
  99494. * Gets the alphaColor input component
  99495. */
  99496. get alphaColor(): NodeMaterialConnectionPoint;
  99497. /**
  99498. * Gets the blendColor output component
  99499. */
  99500. get blendColor(): NodeMaterialConnectionPoint;
  99501. /**
  99502. * Initialize the block and prepare the context for build
  99503. * @param state defines the state that will be used for the build
  99504. */
  99505. initialize(state: NodeMaterialBuildState): void;
  99506. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. /**
  99511. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99512. */
  99513. export class VectorMergerBlock extends NodeMaterialBlock {
  99514. /**
  99515. * Create a new VectorMergerBlock
  99516. * @param name defines the block name
  99517. */
  99518. constructor(name: string);
  99519. /**
  99520. * Gets the current class name
  99521. * @returns the class name
  99522. */
  99523. getClassName(): string;
  99524. /**
  99525. * Gets the xyz component (input)
  99526. */
  99527. get xyzIn(): NodeMaterialConnectionPoint;
  99528. /**
  99529. * Gets the xy component (input)
  99530. */
  99531. get xyIn(): NodeMaterialConnectionPoint;
  99532. /**
  99533. * Gets the x component (input)
  99534. */
  99535. get x(): NodeMaterialConnectionPoint;
  99536. /**
  99537. * Gets the y component (input)
  99538. */
  99539. get y(): NodeMaterialConnectionPoint;
  99540. /**
  99541. * Gets the z component (input)
  99542. */
  99543. get z(): NodeMaterialConnectionPoint;
  99544. /**
  99545. * Gets the w component (input)
  99546. */
  99547. get w(): NodeMaterialConnectionPoint;
  99548. /**
  99549. * Gets the xyzw component (output)
  99550. */
  99551. get xyzw(): NodeMaterialConnectionPoint;
  99552. /**
  99553. * Gets the xyz component (output)
  99554. */
  99555. get xyzOut(): NodeMaterialConnectionPoint;
  99556. /**
  99557. * Gets the xy component (output)
  99558. */
  99559. get xyOut(): NodeMaterialConnectionPoint;
  99560. /**
  99561. * Gets the xy component (output)
  99562. * @deprecated Please use xyOut instead.
  99563. */
  99564. get xy(): NodeMaterialConnectionPoint;
  99565. /**
  99566. * Gets the xyz component (output)
  99567. * @deprecated Please use xyzOut instead.
  99568. */
  99569. get xyz(): NodeMaterialConnectionPoint;
  99570. protected _buildBlock(state: NodeMaterialBuildState): this;
  99571. }
  99572. }
  99573. declare module BABYLON {
  99574. /**
  99575. * Block used to remap a float from a range to a new one
  99576. */
  99577. export class RemapBlock extends NodeMaterialBlock {
  99578. /**
  99579. * Gets or sets the source range
  99580. */
  99581. sourceRange: Vector2;
  99582. /**
  99583. * Gets or sets the target range
  99584. */
  99585. targetRange: Vector2;
  99586. /**
  99587. * Creates a new RemapBlock
  99588. * @param name defines the block name
  99589. */
  99590. constructor(name: string);
  99591. /**
  99592. * Gets the current class name
  99593. * @returns the class name
  99594. */
  99595. getClassName(): string;
  99596. /**
  99597. * Gets the input component
  99598. */
  99599. get input(): NodeMaterialConnectionPoint;
  99600. /**
  99601. * Gets the source min input component
  99602. */
  99603. get sourceMin(): NodeMaterialConnectionPoint;
  99604. /**
  99605. * Gets the source max input component
  99606. */
  99607. get sourceMax(): NodeMaterialConnectionPoint;
  99608. /**
  99609. * Gets the target min input component
  99610. */
  99611. get targetMin(): NodeMaterialConnectionPoint;
  99612. /**
  99613. * Gets the target max input component
  99614. */
  99615. get targetMax(): NodeMaterialConnectionPoint;
  99616. /**
  99617. * Gets the output component
  99618. */
  99619. get output(): NodeMaterialConnectionPoint;
  99620. protected _buildBlock(state: NodeMaterialBuildState): this;
  99621. protected _dumpPropertiesCode(): string;
  99622. serialize(): any;
  99623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99624. }
  99625. }
  99626. declare module BABYLON {
  99627. /**
  99628. * Block used to multiply 2 values
  99629. */
  99630. export class MultiplyBlock extends NodeMaterialBlock {
  99631. /**
  99632. * Creates a new MultiplyBlock
  99633. * @param name defines the block name
  99634. */
  99635. constructor(name: string);
  99636. /**
  99637. * Gets the current class name
  99638. * @returns the class name
  99639. */
  99640. getClassName(): string;
  99641. /**
  99642. * Gets the left operand input component
  99643. */
  99644. get left(): NodeMaterialConnectionPoint;
  99645. /**
  99646. * Gets the right operand input component
  99647. */
  99648. get right(): NodeMaterialConnectionPoint;
  99649. /**
  99650. * Gets the output component
  99651. */
  99652. get output(): NodeMaterialConnectionPoint;
  99653. protected _buildBlock(state: NodeMaterialBuildState): this;
  99654. }
  99655. }
  99656. declare module BABYLON {
  99657. /**
  99658. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99659. */
  99660. export class ColorSplitterBlock extends NodeMaterialBlock {
  99661. /**
  99662. * Create a new ColorSplitterBlock
  99663. * @param name defines the block name
  99664. */
  99665. constructor(name: string);
  99666. /**
  99667. * Gets the current class name
  99668. * @returns the class name
  99669. */
  99670. getClassName(): string;
  99671. /**
  99672. * Gets the rgba component (input)
  99673. */
  99674. get rgba(): NodeMaterialConnectionPoint;
  99675. /**
  99676. * Gets the rgb component (input)
  99677. */
  99678. get rgbIn(): NodeMaterialConnectionPoint;
  99679. /**
  99680. * Gets the rgb component (output)
  99681. */
  99682. get rgbOut(): NodeMaterialConnectionPoint;
  99683. /**
  99684. * Gets the r component (output)
  99685. */
  99686. get r(): NodeMaterialConnectionPoint;
  99687. /**
  99688. * Gets the g component (output)
  99689. */
  99690. get g(): NodeMaterialConnectionPoint;
  99691. /**
  99692. * Gets the b component (output)
  99693. */
  99694. get b(): NodeMaterialConnectionPoint;
  99695. /**
  99696. * Gets the a component (output)
  99697. */
  99698. get a(): NodeMaterialConnectionPoint;
  99699. protected _inputRename(name: string): string;
  99700. protected _outputRename(name: string): string;
  99701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99702. }
  99703. }
  99704. declare module BABYLON {
  99705. /**
  99706. * Interface used to configure the node material editor
  99707. */
  99708. export interface INodeMaterialEditorOptions {
  99709. /** Define the URl to load node editor script */
  99710. editorURL?: string;
  99711. }
  99712. /** @hidden */
  99713. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99714. NORMAL: boolean;
  99715. TANGENT: boolean;
  99716. UV1: boolean;
  99717. /** BONES */
  99718. NUM_BONE_INFLUENCERS: number;
  99719. BonesPerMesh: number;
  99720. BONETEXTURE: boolean;
  99721. /** MORPH TARGETS */
  99722. MORPHTARGETS: boolean;
  99723. MORPHTARGETS_NORMAL: boolean;
  99724. MORPHTARGETS_TANGENT: boolean;
  99725. MORPHTARGETS_UV: boolean;
  99726. NUM_MORPH_INFLUENCERS: number;
  99727. /** IMAGE PROCESSING */
  99728. IMAGEPROCESSING: boolean;
  99729. VIGNETTE: boolean;
  99730. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99731. VIGNETTEBLENDMODEOPAQUE: boolean;
  99732. TONEMAPPING: boolean;
  99733. TONEMAPPING_ACES: boolean;
  99734. CONTRAST: boolean;
  99735. EXPOSURE: boolean;
  99736. COLORCURVES: boolean;
  99737. COLORGRADING: boolean;
  99738. COLORGRADING3D: boolean;
  99739. SAMPLER3DGREENDEPTH: boolean;
  99740. SAMPLER3DBGRMAP: boolean;
  99741. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99742. /** MISC. */
  99743. BUMPDIRECTUV: number;
  99744. constructor();
  99745. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99746. }
  99747. /**
  99748. * Class used to configure NodeMaterial
  99749. */
  99750. export interface INodeMaterialOptions {
  99751. /**
  99752. * Defines if blocks should emit comments
  99753. */
  99754. emitComments: boolean;
  99755. }
  99756. /**
  99757. * Class used to create a node based material built by assembling shader blocks
  99758. */
  99759. export class NodeMaterial extends PushMaterial {
  99760. private static _BuildIdGenerator;
  99761. private _options;
  99762. private _vertexCompilationState;
  99763. private _fragmentCompilationState;
  99764. private _sharedData;
  99765. private _buildId;
  99766. private _buildWasSuccessful;
  99767. private _cachedWorldViewMatrix;
  99768. private _cachedWorldViewProjectionMatrix;
  99769. private _optimizers;
  99770. private _animationFrame;
  99771. /** Define the Url to load node editor script */
  99772. static EditorURL: string;
  99773. /** Define the Url to load snippets */
  99774. static SnippetUrl: string;
  99775. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99776. static IgnoreTexturesAtLoadTime: boolean;
  99777. private BJSNODEMATERIALEDITOR;
  99778. /** Get the inspector from bundle or global */
  99779. private _getGlobalNodeMaterialEditor;
  99780. /**
  99781. * Snippet ID if the material was created from the snippet server
  99782. */
  99783. snippetId: string;
  99784. /**
  99785. * Gets or sets data used by visual editor
  99786. * @see https://nme.babylonjs.com
  99787. */
  99788. editorData: any;
  99789. /**
  99790. * 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)
  99791. */
  99792. ignoreAlpha: boolean;
  99793. /**
  99794. * Defines the maximum number of lights that can be used in the material
  99795. */
  99796. maxSimultaneousLights: number;
  99797. /**
  99798. * Observable raised when the material is built
  99799. */
  99800. onBuildObservable: Observable<NodeMaterial>;
  99801. /**
  99802. * Gets or sets the root nodes of the material vertex shader
  99803. */
  99804. _vertexOutputNodes: NodeMaterialBlock[];
  99805. /**
  99806. * Gets or sets the root nodes of the material fragment (pixel) shader
  99807. */
  99808. _fragmentOutputNodes: NodeMaterialBlock[];
  99809. /** Gets or sets options to control the node material overall behavior */
  99810. get options(): INodeMaterialOptions;
  99811. set options(options: INodeMaterialOptions);
  99812. /**
  99813. * Default configuration related to image processing available in the standard Material.
  99814. */
  99815. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99816. /**
  99817. * Gets the image processing configuration used either in this material.
  99818. */
  99819. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99820. /**
  99821. * Sets the Default image processing configuration used either in the this material.
  99822. *
  99823. * If sets to null, the scene one is in use.
  99824. */
  99825. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99826. /**
  99827. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99828. */
  99829. attachedBlocks: NodeMaterialBlock[];
  99830. /**
  99831. * Specifies the mode of the node material
  99832. * @hidden
  99833. */
  99834. _mode: NodeMaterialModes;
  99835. /**
  99836. * Gets the mode property
  99837. */
  99838. get mode(): NodeMaterialModes;
  99839. /**
  99840. * Create a new node based material
  99841. * @param name defines the material name
  99842. * @param scene defines the hosting scene
  99843. * @param options defines creation option
  99844. */
  99845. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99846. /**
  99847. * Gets the current class name of the material e.g. "NodeMaterial"
  99848. * @returns the class name
  99849. */
  99850. getClassName(): string;
  99851. /**
  99852. * Keep track of the image processing observer to allow dispose and replace.
  99853. */
  99854. private _imageProcessingObserver;
  99855. /**
  99856. * Attaches a new image processing configuration to the Standard Material.
  99857. * @param configuration
  99858. */
  99859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99860. /**
  99861. * Get a block by its name
  99862. * @param name defines the name of the block to retrieve
  99863. * @returns the required block or null if not found
  99864. */
  99865. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99866. /**
  99867. * Get a block by its name
  99868. * @param predicate defines the predicate used to find the good candidate
  99869. * @returns the required block or null if not found
  99870. */
  99871. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99872. /**
  99873. * Get an input block by its name
  99874. * @param predicate defines the predicate used to find the good candidate
  99875. * @returns the required input block or null if not found
  99876. */
  99877. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99878. /**
  99879. * Gets the list of input blocks attached to this material
  99880. * @returns an array of InputBlocks
  99881. */
  99882. getInputBlocks(): InputBlock[];
  99883. /**
  99884. * Adds a new optimizer to the list of optimizers
  99885. * @param optimizer defines the optimizers to add
  99886. * @returns the current material
  99887. */
  99888. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99889. /**
  99890. * Remove an optimizer from the list of optimizers
  99891. * @param optimizer defines the optimizers to remove
  99892. * @returns the current material
  99893. */
  99894. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99895. /**
  99896. * Add a new block to the list of output nodes
  99897. * @param node defines the node to add
  99898. * @returns the current material
  99899. */
  99900. addOutputNode(node: NodeMaterialBlock): this;
  99901. /**
  99902. * Remove a block from the list of root nodes
  99903. * @param node defines the node to remove
  99904. * @returns the current material
  99905. */
  99906. removeOutputNode(node: NodeMaterialBlock): this;
  99907. private _addVertexOutputNode;
  99908. private _removeVertexOutputNode;
  99909. private _addFragmentOutputNode;
  99910. private _removeFragmentOutputNode;
  99911. /**
  99912. * Specifies if the material will require alpha blending
  99913. * @returns a boolean specifying if alpha blending is needed
  99914. */
  99915. needAlphaBlending(): boolean;
  99916. /**
  99917. * Specifies if this material should be rendered in alpha test mode
  99918. * @returns a boolean specifying if an alpha test is needed.
  99919. */
  99920. needAlphaTesting(): boolean;
  99921. private _initializeBlock;
  99922. private _resetDualBlocks;
  99923. /**
  99924. * Remove a block from the current node material
  99925. * @param block defines the block to remove
  99926. */
  99927. removeBlock(block: NodeMaterialBlock): void;
  99928. /**
  99929. * Build the material and generates the inner effect
  99930. * @param verbose defines if the build should log activity
  99931. */
  99932. build(verbose?: boolean): void;
  99933. /**
  99934. * Runs an otpimization phase to try to improve the shader code
  99935. */
  99936. optimize(): void;
  99937. private _prepareDefinesForAttributes;
  99938. /**
  99939. * Create a post process from the material
  99940. * @param camera The camera to apply the render pass to.
  99941. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99943. * @param engine The engine which the post process will be applied. (default: current engine)
  99944. * @param reusable If the post process can be reused on the same frame. (default: false)
  99945. * @param textureType Type of textures used when performing the post process. (default: 0)
  99946. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99947. * @returns the post process created
  99948. */
  99949. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99950. /**
  99951. * Create the post process effect from the material
  99952. * @param postProcess The post process to create the effect for
  99953. */
  99954. createEffectForPostProcess(postProcess: PostProcess): void;
  99955. private _createEffectOrPostProcess;
  99956. private _createEffectForParticles;
  99957. /**
  99958. * Create the effect to be used as the custom effect for a particle system
  99959. * @param particleSystem Particle system to create the effect for
  99960. * @param onCompiled defines a function to call when the effect creation is successful
  99961. * @param onError defines a function to call when the effect creation has failed
  99962. */
  99963. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99964. private _processDefines;
  99965. /**
  99966. * Get if the submesh is ready to be used and all its information available.
  99967. * Child classes can use it to update shaders
  99968. * @param mesh defines the mesh to check
  99969. * @param subMesh defines which submesh to check
  99970. * @param useInstances specifies that instances should be used
  99971. * @returns a boolean indicating that the submesh is ready or not
  99972. */
  99973. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99974. /**
  99975. * Get a string representing the shaders built by the current node graph
  99976. */
  99977. get compiledShaders(): string;
  99978. /**
  99979. * Binds the world matrix to the material
  99980. * @param world defines the world transformation matrix
  99981. */
  99982. bindOnlyWorldMatrix(world: Matrix): void;
  99983. /**
  99984. * Binds the submesh to this material by preparing the effect and shader to draw
  99985. * @param world defines the world transformation matrix
  99986. * @param mesh defines the mesh containing the submesh
  99987. * @param subMesh defines the submesh to bind the material to
  99988. */
  99989. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99990. /**
  99991. * Gets the active textures from the material
  99992. * @returns an array of textures
  99993. */
  99994. getActiveTextures(): BaseTexture[];
  99995. /**
  99996. * Gets the list of texture blocks
  99997. * @returns an array of texture blocks
  99998. */
  99999. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100000. /**
  100001. * Specifies if the material uses a texture
  100002. * @param texture defines the texture to check against the material
  100003. * @returns a boolean specifying if the material uses the texture
  100004. */
  100005. hasTexture(texture: BaseTexture): boolean;
  100006. /**
  100007. * Disposes the material
  100008. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100009. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100010. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100011. */
  100012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100013. /** Creates the node editor window. */
  100014. private _createNodeEditor;
  100015. /**
  100016. * Launch the node material editor
  100017. * @param config Define the configuration of the editor
  100018. * @return a promise fulfilled when the node editor is visible
  100019. */
  100020. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100021. /**
  100022. * Clear the current material
  100023. */
  100024. clear(): void;
  100025. /**
  100026. * Clear the current material and set it to a default state
  100027. */
  100028. setToDefault(): void;
  100029. /**
  100030. * Clear the current material and set it to a default state for post process
  100031. */
  100032. setToDefaultPostProcess(): void;
  100033. /**
  100034. * Clear the current material and set it to a default state for particle
  100035. */
  100036. setToDefaultParticle(): void;
  100037. /**
  100038. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100039. * @param url defines the url to load from
  100040. * @returns a promise that will fullfil when the material is fully loaded
  100041. */
  100042. loadAsync(url: string): Promise<void>;
  100043. private _gatherBlocks;
  100044. /**
  100045. * Generate a string containing the code declaration required to create an equivalent of this material
  100046. * @returns a string
  100047. */
  100048. generateCode(): string;
  100049. /**
  100050. * Serializes this material in a JSON representation
  100051. * @returns the serialized material object
  100052. */
  100053. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100054. private _restoreConnections;
  100055. /**
  100056. * Clear the current graph and load a new one from a serialization object
  100057. * @param source defines the JSON representation of the material
  100058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100059. * @param merge defines whether or not the source must be merged or replace the current content
  100060. */
  100061. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100062. /**
  100063. * Makes a duplicate of the current material.
  100064. * @param name - name to use for the new material.
  100065. */
  100066. clone(name: string): NodeMaterial;
  100067. /**
  100068. * Creates a node material from parsed material data
  100069. * @param source defines the JSON representation of the material
  100070. * @param scene defines the hosting scene
  100071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100072. * @returns a new node material
  100073. */
  100074. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100075. /**
  100076. * Creates a node material from a snippet saved in a remote file
  100077. * @param name defines the name of the material to create
  100078. * @param url defines the url to load from
  100079. * @param scene defines the hosting scene
  100080. * @returns a promise that will resolve to the new node material
  100081. */
  100082. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100083. /**
  100084. * Creates a node material from a snippet saved by the node material editor
  100085. * @param snippetId defines the snippet to load
  100086. * @param scene defines the hosting scene
  100087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100088. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100089. * @returns a promise that will resolve to the new node material
  100090. */
  100091. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100092. /**
  100093. * Creates a new node material set to default basic configuration
  100094. * @param name defines the name of the material
  100095. * @param scene defines the hosting scene
  100096. * @returns a new NodeMaterial
  100097. */
  100098. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100099. }
  100100. }
  100101. declare module BABYLON {
  100102. /**
  100103. * Size options for a post process
  100104. */
  100105. export type PostProcessOptions = {
  100106. width: number;
  100107. height: number;
  100108. };
  100109. /**
  100110. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100111. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100112. */
  100113. export class PostProcess {
  100114. /** Name of the PostProcess. */
  100115. name: string;
  100116. /**
  100117. * Gets or sets the unique id of the post process
  100118. */
  100119. uniqueId: number;
  100120. /**
  100121. * Width of the texture to apply the post process on
  100122. */
  100123. width: number;
  100124. /**
  100125. * Height of the texture to apply the post process on
  100126. */
  100127. height: number;
  100128. /**
  100129. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100130. */
  100131. nodeMaterialSource: Nullable<NodeMaterial>;
  100132. /**
  100133. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100134. * @hidden
  100135. */
  100136. _outputTexture: Nullable<InternalTexture>;
  100137. /**
  100138. * Sampling mode used by the shader
  100139. * See https://doc.babylonjs.com/classes/3.1/texture
  100140. */
  100141. renderTargetSamplingMode: number;
  100142. /**
  100143. * Clear color to use when screen clearing
  100144. */
  100145. clearColor: Color4;
  100146. /**
  100147. * If the buffer needs to be cleared before applying the post process. (default: true)
  100148. * Should be set to false if shader will overwrite all previous pixels.
  100149. */
  100150. autoClear: boolean;
  100151. /**
  100152. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100153. */
  100154. alphaMode: number;
  100155. /**
  100156. * Sets the setAlphaBlendConstants of the babylon engine
  100157. */
  100158. alphaConstants: Color4;
  100159. /**
  100160. * Animations to be used for the post processing
  100161. */
  100162. animations: Animation[];
  100163. /**
  100164. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100165. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100166. */
  100167. enablePixelPerfectMode: boolean;
  100168. /**
  100169. * Force the postprocess to be applied without taking in account viewport
  100170. */
  100171. forceFullscreenViewport: boolean;
  100172. /**
  100173. * List of inspectable custom properties (used by the Inspector)
  100174. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100175. */
  100176. inspectableCustomProperties: IInspectable[];
  100177. /**
  100178. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100179. *
  100180. * | Value | Type | Description |
  100181. * | ----- | ----------------------------------- | ----------- |
  100182. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100183. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100184. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100185. *
  100186. */
  100187. scaleMode: number;
  100188. /**
  100189. * Force textures to be a power of two (default: false)
  100190. */
  100191. alwaysForcePOT: boolean;
  100192. private _samples;
  100193. /**
  100194. * Number of sample textures (default: 1)
  100195. */
  100196. get samples(): number;
  100197. set samples(n: number);
  100198. /**
  100199. * Modify the scale of the post process to be the same as the viewport (default: false)
  100200. */
  100201. adaptScaleToCurrentViewport: boolean;
  100202. private _camera;
  100203. private _scene;
  100204. private _engine;
  100205. private _options;
  100206. private _reusable;
  100207. private _textureType;
  100208. private _textureFormat;
  100209. /**
  100210. * Smart array of input and output textures for the post process.
  100211. * @hidden
  100212. */
  100213. _textures: SmartArray<InternalTexture>;
  100214. /**
  100215. * The index in _textures that corresponds to the output texture.
  100216. * @hidden
  100217. */
  100218. _currentRenderTextureInd: number;
  100219. private _effect;
  100220. private _samplers;
  100221. private _fragmentUrl;
  100222. private _vertexUrl;
  100223. private _parameters;
  100224. private _scaleRatio;
  100225. protected _indexParameters: any;
  100226. private _shareOutputWithPostProcess;
  100227. private _texelSize;
  100228. private _forcedOutputTexture;
  100229. /**
  100230. * Returns the fragment url or shader name used in the post process.
  100231. * @returns the fragment url or name in the shader store.
  100232. */
  100233. getEffectName(): string;
  100234. /**
  100235. * An event triggered when the postprocess is activated.
  100236. */
  100237. onActivateObservable: Observable<Camera>;
  100238. private _onActivateObserver;
  100239. /**
  100240. * A function that is added to the onActivateObservable
  100241. */
  100242. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100243. /**
  100244. * An event triggered when the postprocess changes its size.
  100245. */
  100246. onSizeChangedObservable: Observable<PostProcess>;
  100247. private _onSizeChangedObserver;
  100248. /**
  100249. * A function that is added to the onSizeChangedObservable
  100250. */
  100251. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100252. /**
  100253. * An event triggered when the postprocess applies its effect.
  100254. */
  100255. onApplyObservable: Observable<Effect>;
  100256. private _onApplyObserver;
  100257. /**
  100258. * A function that is added to the onApplyObservable
  100259. */
  100260. set onApply(callback: (effect: Effect) => void);
  100261. /**
  100262. * An event triggered before rendering the postprocess
  100263. */
  100264. onBeforeRenderObservable: Observable<Effect>;
  100265. private _onBeforeRenderObserver;
  100266. /**
  100267. * A function that is added to the onBeforeRenderObservable
  100268. */
  100269. set onBeforeRender(callback: (effect: Effect) => void);
  100270. /**
  100271. * An event triggered after rendering the postprocess
  100272. */
  100273. onAfterRenderObservable: Observable<Effect>;
  100274. private _onAfterRenderObserver;
  100275. /**
  100276. * A function that is added to the onAfterRenderObservable
  100277. */
  100278. set onAfterRender(callback: (efect: Effect) => void);
  100279. /**
  100280. * 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
  100281. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100282. */
  100283. get inputTexture(): InternalTexture;
  100284. set inputTexture(value: InternalTexture);
  100285. /**
  100286. * Gets the camera which post process is applied to.
  100287. * @returns The camera the post process is applied to.
  100288. */
  100289. getCamera(): Camera;
  100290. /**
  100291. * Gets the texel size of the postprocess.
  100292. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100293. */
  100294. get texelSize(): Vector2;
  100295. /**
  100296. * Creates a new instance PostProcess
  100297. * @param name The name of the PostProcess.
  100298. * @param fragmentUrl The url of the fragment shader to be used.
  100299. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100300. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100301. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100302. * @param camera The camera to apply the render pass to.
  100303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100304. * @param engine The engine which the post process will be applied. (default: current engine)
  100305. * @param reusable If the post process can be reused on the same frame. (default: false)
  100306. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100307. * @param textureType Type of textures used when performing the post process. (default: 0)
  100308. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100309. * @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
  100310. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100311. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100312. */
  100313. constructor(
  100314. /** Name of the PostProcess. */
  100315. 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);
  100316. /**
  100317. * Gets a string idenfifying the name of the class
  100318. * @returns "PostProcess" string
  100319. */
  100320. getClassName(): string;
  100321. /**
  100322. * Gets the engine which this post process belongs to.
  100323. * @returns The engine the post process was enabled with.
  100324. */
  100325. getEngine(): Engine;
  100326. /**
  100327. * The effect that is created when initializing the post process.
  100328. * @returns The created effect corresponding the the postprocess.
  100329. */
  100330. getEffect(): Effect;
  100331. /**
  100332. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100333. * @param postProcess The post process to share the output with.
  100334. * @returns This post process.
  100335. */
  100336. shareOutputWith(postProcess: PostProcess): PostProcess;
  100337. /**
  100338. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100339. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100340. */
  100341. useOwnOutput(): void;
  100342. /**
  100343. * Updates the effect with the current post process compile time values and recompiles the shader.
  100344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100347. * @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
  100348. * @param onCompiled Called when the shader has been compiled.
  100349. * @param onError Called if there is an error when compiling a shader.
  100350. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100351. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100352. */
  100353. 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;
  100354. /**
  100355. * The post process is reusable if it can be used multiple times within one frame.
  100356. * @returns If the post process is reusable
  100357. */
  100358. isReusable(): boolean;
  100359. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100360. markTextureDirty(): void;
  100361. /**
  100362. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100363. * 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.
  100364. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100365. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100366. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100367. * @returns The target texture that was bound to be written to.
  100368. */
  100369. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100370. /**
  100371. * If the post process is supported.
  100372. */
  100373. get isSupported(): boolean;
  100374. /**
  100375. * The aspect ratio of the output texture.
  100376. */
  100377. get aspectRatio(): number;
  100378. /**
  100379. * Get a value indicating if the post-process is ready to be used
  100380. * @returns true if the post-process is ready (shader is compiled)
  100381. */
  100382. isReady(): boolean;
  100383. /**
  100384. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100385. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100386. */
  100387. apply(): Nullable<Effect>;
  100388. private _disposeTextures;
  100389. /**
  100390. * Disposes the post process.
  100391. * @param camera The camera to dispose the post process on.
  100392. */
  100393. dispose(camera?: Camera): void;
  100394. }
  100395. }
  100396. declare module BABYLON {
  100397. /** @hidden */
  100398. export var kernelBlurVaryingDeclaration: {
  100399. name: string;
  100400. shader: string;
  100401. };
  100402. }
  100403. declare module BABYLON {
  100404. /** @hidden */
  100405. export var kernelBlurFragment: {
  100406. name: string;
  100407. shader: string;
  100408. };
  100409. }
  100410. declare module BABYLON {
  100411. /** @hidden */
  100412. export var kernelBlurFragment2: {
  100413. name: string;
  100414. shader: string;
  100415. };
  100416. }
  100417. declare module BABYLON {
  100418. /** @hidden */
  100419. export var kernelBlurPixelShader: {
  100420. name: string;
  100421. shader: string;
  100422. };
  100423. }
  100424. declare module BABYLON {
  100425. /** @hidden */
  100426. export var kernelBlurVertex: {
  100427. name: string;
  100428. shader: string;
  100429. };
  100430. }
  100431. declare module BABYLON {
  100432. /** @hidden */
  100433. export var kernelBlurVertexShader: {
  100434. name: string;
  100435. shader: string;
  100436. };
  100437. }
  100438. declare module BABYLON {
  100439. /**
  100440. * The Blur Post Process which blurs an image based on a kernel and direction.
  100441. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100442. */
  100443. export class BlurPostProcess extends PostProcess {
  100444. /** The direction in which to blur the image. */
  100445. direction: Vector2;
  100446. private blockCompilation;
  100447. protected _kernel: number;
  100448. protected _idealKernel: number;
  100449. protected _packedFloat: boolean;
  100450. private _staticDefines;
  100451. /**
  100452. * Sets the length in pixels of the blur sample region
  100453. */
  100454. set kernel(v: number);
  100455. /**
  100456. * Gets the length in pixels of the blur sample region
  100457. */
  100458. get kernel(): number;
  100459. /**
  100460. * Sets wether or not the blur needs to unpack/repack floats
  100461. */
  100462. set packedFloat(v: boolean);
  100463. /**
  100464. * Gets wether or not the blur is unpacking/repacking floats
  100465. */
  100466. get packedFloat(): boolean;
  100467. /**
  100468. * Creates a new instance BlurPostProcess
  100469. * @param name The name of the effect.
  100470. * @param direction The direction in which to blur the image.
  100471. * @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.
  100472. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100473. * @param camera The camera to apply the render pass to.
  100474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100475. * @param engine The engine which the post process will be applied. (default: current engine)
  100476. * @param reusable If the post process can be reused on the same frame. (default: false)
  100477. * @param textureType Type of textures used when performing the post process. (default: 0)
  100478. * @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)
  100479. */
  100480. constructor(name: string,
  100481. /** The direction in which to blur the image. */
  100482. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100483. /**
  100484. * Updates the effect with the current post process compile time values and recompiles the shader.
  100485. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100486. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100487. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100488. * @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
  100489. * @param onCompiled Called when the shader has been compiled.
  100490. * @param onError Called if there is an error when compiling a shader.
  100491. */
  100492. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100493. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100494. /**
  100495. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100496. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100497. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100498. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100499. * The gaps between physical kernels are compensated for in the weighting of the samples
  100500. * @param idealKernel Ideal blur kernel.
  100501. * @return Nearest best kernel.
  100502. */
  100503. protected _nearestBestKernel(idealKernel: number): number;
  100504. /**
  100505. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100506. * @param x The point on the Gaussian distribution to sample.
  100507. * @return the value of the Gaussian function at x.
  100508. */
  100509. protected _gaussianWeight(x: number): number;
  100510. /**
  100511. * Generates a string that can be used as a floating point number in GLSL.
  100512. * @param x Value to print.
  100513. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100514. * @return GLSL float string.
  100515. */
  100516. protected _glslFloat(x: number, decimalFigures?: number): string;
  100517. }
  100518. }
  100519. declare module BABYLON {
  100520. /**
  100521. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100522. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100523. * You can then easily use it as a reflectionTexture on a flat surface.
  100524. * In case the surface is not a plane, please consider relying on reflection probes.
  100525. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100526. */
  100527. export class MirrorTexture extends RenderTargetTexture {
  100528. private scene;
  100529. /**
  100530. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100531. * 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.
  100532. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100533. */
  100534. mirrorPlane: Plane;
  100535. /**
  100536. * Define the blur ratio used to blur the reflection if needed.
  100537. */
  100538. set blurRatio(value: number);
  100539. get blurRatio(): number;
  100540. /**
  100541. * Define the adaptive blur kernel used to blur the reflection if needed.
  100542. * This will autocompute the closest best match for the `blurKernel`
  100543. */
  100544. set adaptiveBlurKernel(value: number);
  100545. /**
  100546. * Define the blur kernel used to blur the reflection if needed.
  100547. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100548. */
  100549. set blurKernel(value: number);
  100550. /**
  100551. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100552. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100553. */
  100554. set blurKernelX(value: number);
  100555. get blurKernelX(): number;
  100556. /**
  100557. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100558. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100559. */
  100560. set blurKernelY(value: number);
  100561. get blurKernelY(): number;
  100562. private _autoComputeBlurKernel;
  100563. protected _onRatioRescale(): void;
  100564. private _updateGammaSpace;
  100565. private _imageProcessingConfigChangeObserver;
  100566. private _transformMatrix;
  100567. private _mirrorMatrix;
  100568. private _savedViewMatrix;
  100569. private _blurX;
  100570. private _blurY;
  100571. private _adaptiveBlurKernel;
  100572. private _blurKernelX;
  100573. private _blurKernelY;
  100574. private _blurRatio;
  100575. /**
  100576. * Instantiates a Mirror Texture.
  100577. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100578. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100579. * You can then easily use it as a reflectionTexture on a flat surface.
  100580. * In case the surface is not a plane, please consider relying on reflection probes.
  100581. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100582. * @param name
  100583. * @param size
  100584. * @param scene
  100585. * @param generateMipMaps
  100586. * @param type
  100587. * @param samplingMode
  100588. * @param generateDepthBuffer
  100589. */
  100590. constructor(name: string, size: number | {
  100591. width: number;
  100592. height: number;
  100593. } | {
  100594. ratio: number;
  100595. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100596. private _preparePostProcesses;
  100597. /**
  100598. * Clone the mirror texture.
  100599. * @returns the cloned texture
  100600. */
  100601. clone(): MirrorTexture;
  100602. /**
  100603. * Serialize the texture to a JSON representation you could use in Parse later on
  100604. * @returns the serialized JSON representation
  100605. */
  100606. serialize(): any;
  100607. /**
  100608. * Dispose the texture and release its associated resources.
  100609. */
  100610. dispose(): void;
  100611. }
  100612. }
  100613. declare module BABYLON {
  100614. /**
  100615. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100616. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100617. */
  100618. export class Texture extends BaseTexture {
  100619. /**
  100620. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100621. */
  100622. static SerializeBuffers: boolean;
  100623. /** @hidden */
  100624. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100625. /** @hidden */
  100626. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100627. /** @hidden */
  100628. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100629. /** nearest is mag = nearest and min = nearest and mip = linear */
  100630. static readonly NEAREST_SAMPLINGMODE: number;
  100631. /** nearest is mag = nearest and min = nearest and mip = linear */
  100632. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100633. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100634. static readonly BILINEAR_SAMPLINGMODE: number;
  100635. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100636. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100637. /** Trilinear is mag = linear and min = linear and mip = linear */
  100638. static readonly TRILINEAR_SAMPLINGMODE: number;
  100639. /** Trilinear is mag = linear and min = linear and mip = linear */
  100640. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100641. /** mag = nearest and min = nearest and mip = nearest */
  100642. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100643. /** mag = nearest and min = linear and mip = nearest */
  100644. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100645. /** mag = nearest and min = linear and mip = linear */
  100646. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100647. /** mag = nearest and min = linear and mip = none */
  100648. static readonly NEAREST_LINEAR: number;
  100649. /** mag = nearest and min = nearest and mip = none */
  100650. static readonly NEAREST_NEAREST: number;
  100651. /** mag = linear and min = nearest and mip = nearest */
  100652. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100653. /** mag = linear and min = nearest and mip = linear */
  100654. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100655. /** mag = linear and min = linear and mip = none */
  100656. static readonly LINEAR_LINEAR: number;
  100657. /** mag = linear and min = nearest and mip = none */
  100658. static readonly LINEAR_NEAREST: number;
  100659. /** Explicit coordinates mode */
  100660. static readonly EXPLICIT_MODE: number;
  100661. /** Spherical coordinates mode */
  100662. static readonly SPHERICAL_MODE: number;
  100663. /** Planar coordinates mode */
  100664. static readonly PLANAR_MODE: number;
  100665. /** Cubic coordinates mode */
  100666. static readonly CUBIC_MODE: number;
  100667. /** Projection coordinates mode */
  100668. static readonly PROJECTION_MODE: number;
  100669. /** Inverse Cubic coordinates mode */
  100670. static readonly SKYBOX_MODE: number;
  100671. /** Inverse Cubic coordinates mode */
  100672. static readonly INVCUBIC_MODE: number;
  100673. /** Equirectangular coordinates mode */
  100674. static readonly EQUIRECTANGULAR_MODE: number;
  100675. /** Equirectangular Fixed coordinates mode */
  100676. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100677. /** Equirectangular Fixed Mirrored coordinates mode */
  100678. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100679. /** Texture is not repeating outside of 0..1 UVs */
  100680. static readonly CLAMP_ADDRESSMODE: number;
  100681. /** Texture is repeating outside of 0..1 UVs */
  100682. static readonly WRAP_ADDRESSMODE: number;
  100683. /** Texture is repeating and mirrored */
  100684. static readonly MIRROR_ADDRESSMODE: number;
  100685. /**
  100686. * 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
  100687. */
  100688. static UseSerializedUrlIfAny: boolean;
  100689. /**
  100690. * Define the url of the texture.
  100691. */
  100692. url: Nullable<string>;
  100693. /**
  100694. * Define an offset on the texture to offset the u coordinates of the UVs
  100695. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100696. */
  100697. uOffset: number;
  100698. /**
  100699. * Define an offset on the texture to offset the v coordinates of the UVs
  100700. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100701. */
  100702. vOffset: number;
  100703. /**
  100704. * Define an offset on the texture to scale the u coordinates of the UVs
  100705. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100706. */
  100707. uScale: number;
  100708. /**
  100709. * Define an offset on the texture to scale the v coordinates of the UVs
  100710. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100711. */
  100712. vScale: number;
  100713. /**
  100714. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100715. * @see http://doc.babylonjs.com/how_to/more_materials
  100716. */
  100717. uAng: number;
  100718. /**
  100719. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100720. * @see http://doc.babylonjs.com/how_to/more_materials
  100721. */
  100722. vAng: number;
  100723. /**
  100724. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100725. * @see http://doc.babylonjs.com/how_to/more_materials
  100726. */
  100727. wAng: number;
  100728. /**
  100729. * Defines the center of rotation (U)
  100730. */
  100731. uRotationCenter: number;
  100732. /**
  100733. * Defines the center of rotation (V)
  100734. */
  100735. vRotationCenter: number;
  100736. /**
  100737. * Defines the center of rotation (W)
  100738. */
  100739. wRotationCenter: number;
  100740. /**
  100741. * Are mip maps generated for this texture or not.
  100742. */
  100743. get noMipmap(): boolean;
  100744. /**
  100745. * List of inspectable custom properties (used by the Inspector)
  100746. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100747. */
  100748. inspectableCustomProperties: Nullable<IInspectable[]>;
  100749. private _noMipmap;
  100750. /** @hidden */
  100751. _invertY: boolean;
  100752. private _rowGenerationMatrix;
  100753. private _cachedTextureMatrix;
  100754. private _projectionModeMatrix;
  100755. private _t0;
  100756. private _t1;
  100757. private _t2;
  100758. private _cachedUOffset;
  100759. private _cachedVOffset;
  100760. private _cachedUScale;
  100761. private _cachedVScale;
  100762. private _cachedUAng;
  100763. private _cachedVAng;
  100764. private _cachedWAng;
  100765. private _cachedProjectionMatrixId;
  100766. private _cachedCoordinatesMode;
  100767. /** @hidden */
  100768. protected _initialSamplingMode: number;
  100769. /** @hidden */
  100770. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100771. private _deleteBuffer;
  100772. protected _format: Nullable<number>;
  100773. private _delayedOnLoad;
  100774. private _delayedOnError;
  100775. private _mimeType?;
  100776. /**
  100777. * Observable triggered once the texture has been loaded.
  100778. */
  100779. onLoadObservable: Observable<Texture>;
  100780. protected _isBlocking: boolean;
  100781. /**
  100782. * Is the texture preventing material to render while loading.
  100783. * If false, a default texture will be used instead of the loading one during the preparation step.
  100784. */
  100785. set isBlocking(value: boolean);
  100786. get isBlocking(): boolean;
  100787. /**
  100788. * Get the current sampling mode associated with the texture.
  100789. */
  100790. get samplingMode(): number;
  100791. /**
  100792. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100793. */
  100794. get invertY(): boolean;
  100795. /**
  100796. * Instantiates a new texture.
  100797. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100798. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100799. * @param url defines the url of the picture to load as a texture
  100800. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100801. * @param noMipmap defines if the texture will require mip maps or not
  100802. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100803. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100804. * @param onLoad defines a callback triggered when the texture has been loaded
  100805. * @param onError defines a callback triggered when an error occurred during the loading session
  100806. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100807. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100808. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100809. * @param mimeType defines an optional mime type information
  100810. */
  100811. 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);
  100812. /**
  100813. * Update the url (and optional buffer) of this texture if url was null during construction.
  100814. * @param url the url of the texture
  100815. * @param buffer the buffer of the texture (defaults to null)
  100816. * @param onLoad callback called when the texture is loaded (defaults to null)
  100817. */
  100818. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100819. /**
  100820. * Finish the loading sequence of a texture flagged as delayed load.
  100821. * @hidden
  100822. */
  100823. delayLoad(): void;
  100824. private _prepareRowForTextureGeneration;
  100825. /**
  100826. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100827. * @returns the transform matrix of the texture.
  100828. */
  100829. getTextureMatrix(uBase?: number): Matrix;
  100830. /**
  100831. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100832. * @returns The reflection texture transform
  100833. */
  100834. getReflectionTextureMatrix(): Matrix;
  100835. /**
  100836. * Clones the texture.
  100837. * @returns the cloned texture
  100838. */
  100839. clone(): Texture;
  100840. /**
  100841. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100842. * @returns The JSON representation of the texture
  100843. */
  100844. serialize(): any;
  100845. /**
  100846. * Get the current class name of the texture useful for serialization or dynamic coding.
  100847. * @returns "Texture"
  100848. */
  100849. getClassName(): string;
  100850. /**
  100851. * Dispose the texture and release its associated resources.
  100852. */
  100853. dispose(): void;
  100854. /**
  100855. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100856. * @param parsedTexture Define the JSON representation of the texture
  100857. * @param scene Define the scene the parsed texture should be instantiated in
  100858. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100859. * @returns The parsed texture if successful
  100860. */
  100861. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100862. /**
  100863. * Creates a texture from its base 64 representation.
  100864. * @param data Define the base64 payload without the data: prefix
  100865. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100866. * @param scene Define the scene the texture should belong to
  100867. * @param noMipmap Forces the texture to not create mip map information if true
  100868. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100869. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100870. * @param onLoad define a callback triggered when the texture has been loaded
  100871. * @param onError define a callback triggered when an error occurred during the loading session
  100872. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100873. * @returns the created texture
  100874. */
  100875. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100876. /**
  100877. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100878. * @param data Define the base64 payload without the data: prefix
  100879. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100880. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100881. * @param scene Define the scene the texture should belong to
  100882. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100883. * @param noMipmap Forces the texture to not create mip map information if true
  100884. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100885. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100886. * @param onLoad define a callback triggered when the texture has been loaded
  100887. * @param onError define a callback triggered when an error occurred during the loading session
  100888. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100889. * @returns the created texture
  100890. */
  100891. 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;
  100892. }
  100893. }
  100894. declare module BABYLON {
  100895. /**
  100896. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100897. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100898. */
  100899. export class PostProcessManager {
  100900. private _scene;
  100901. private _indexBuffer;
  100902. private _vertexBuffers;
  100903. /**
  100904. * Creates a new instance PostProcess
  100905. * @param scene The scene that the post process is associated with.
  100906. */
  100907. constructor(scene: Scene);
  100908. private _prepareBuffers;
  100909. private _buildIndexBuffer;
  100910. /**
  100911. * Rebuilds the vertex buffers of the manager.
  100912. * @hidden
  100913. */
  100914. _rebuild(): void;
  100915. /**
  100916. * Prepares a frame to be run through a post process.
  100917. * @param sourceTexture The input texture to the post procesess. (default: null)
  100918. * @param postProcesses An array of post processes to be run. (default: null)
  100919. * @returns True if the post processes were able to be run.
  100920. * @hidden
  100921. */
  100922. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100923. /**
  100924. * Manually render a set of post processes to a texture.
  100925. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100926. * @param postProcesses An array of post processes to be run.
  100927. * @param targetTexture The target texture to render to.
  100928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100929. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100930. * @param lodLevel defines which lod of the texture to render to
  100931. */
  100932. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100933. /**
  100934. * Finalize the result of the output of the postprocesses.
  100935. * @param doNotPresent If true the result will not be displayed to the screen.
  100936. * @param targetTexture The target texture to render to.
  100937. * @param faceIndex The index of the face to bind the target texture to.
  100938. * @param postProcesses The array of post processes to render.
  100939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100940. * @hidden
  100941. */
  100942. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100943. /**
  100944. * Disposes of the post process manager.
  100945. */
  100946. dispose(): void;
  100947. }
  100948. }
  100949. declare module BABYLON {
  100950. /**
  100951. * This Helps creating a texture that will be created from a camera in your scene.
  100952. * It is basically a dynamic texture that could be used to create special effects for instance.
  100953. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100954. */
  100955. export class RenderTargetTexture extends Texture {
  100956. isCube: boolean;
  100957. /**
  100958. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100959. */
  100960. static readonly REFRESHRATE_RENDER_ONCE: number;
  100961. /**
  100962. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100963. */
  100964. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100965. /**
  100966. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100967. * the central point of your effect and can save a lot of performances.
  100968. */
  100969. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100970. /**
  100971. * Use this predicate to dynamically define the list of mesh you want to render.
  100972. * If set, the renderList property will be overwritten.
  100973. */
  100974. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100975. private _renderList;
  100976. /**
  100977. * Use this list to define the list of mesh you want to render.
  100978. */
  100979. get renderList(): Nullable<Array<AbstractMesh>>;
  100980. set renderList(value: Nullable<Array<AbstractMesh>>);
  100981. /**
  100982. * Use this function to overload the renderList array at rendering time.
  100983. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100984. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100985. * the cube (if the RTT is a cube, else layerOrFace=0).
  100986. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100987. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100988. * hold dummy elements!
  100989. */
  100990. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100991. private _hookArray;
  100992. /**
  100993. * Define if particles should be rendered in your texture.
  100994. */
  100995. renderParticles: boolean;
  100996. /**
  100997. * Define if sprites should be rendered in your texture.
  100998. */
  100999. renderSprites: boolean;
  101000. /**
  101001. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101002. */
  101003. coordinatesMode: number;
  101004. /**
  101005. * Define the camera used to render the texture.
  101006. */
  101007. activeCamera: Nullable<Camera>;
  101008. /**
  101009. * Override the mesh isReady function with your own one.
  101010. */
  101011. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101012. /**
  101013. * Override the render function of the texture with your own one.
  101014. */
  101015. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101016. /**
  101017. * Define if camera post processes should be use while rendering the texture.
  101018. */
  101019. useCameraPostProcesses: boolean;
  101020. /**
  101021. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101022. */
  101023. ignoreCameraViewport: boolean;
  101024. private _postProcessManager;
  101025. private _postProcesses;
  101026. private _resizeObserver;
  101027. /**
  101028. * An event triggered when the texture is unbind.
  101029. */
  101030. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101031. /**
  101032. * An event triggered when the texture is unbind.
  101033. */
  101034. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101035. private _onAfterUnbindObserver;
  101036. /**
  101037. * Set a after unbind callback in the texture.
  101038. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101039. */
  101040. set onAfterUnbind(callback: () => void);
  101041. /**
  101042. * An event triggered before rendering the texture
  101043. */
  101044. onBeforeRenderObservable: Observable<number>;
  101045. private _onBeforeRenderObserver;
  101046. /**
  101047. * Set a before render callback in the texture.
  101048. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101049. */
  101050. set onBeforeRender(callback: (faceIndex: number) => void);
  101051. /**
  101052. * An event triggered after rendering the texture
  101053. */
  101054. onAfterRenderObservable: Observable<number>;
  101055. private _onAfterRenderObserver;
  101056. /**
  101057. * Set a after render callback in the texture.
  101058. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101059. */
  101060. set onAfterRender(callback: (faceIndex: number) => void);
  101061. /**
  101062. * An event triggered after the texture clear
  101063. */
  101064. onClearObservable: Observable<Engine>;
  101065. private _onClearObserver;
  101066. /**
  101067. * Set a clear callback in the texture.
  101068. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101069. */
  101070. set onClear(callback: (Engine: Engine) => void);
  101071. /**
  101072. * An event triggered when the texture is resized.
  101073. */
  101074. onResizeObservable: Observable<RenderTargetTexture>;
  101075. /**
  101076. * Define the clear color of the Render Target if it should be different from the scene.
  101077. */
  101078. clearColor: Color4;
  101079. protected _size: number | {
  101080. width: number;
  101081. height: number;
  101082. layers?: number;
  101083. };
  101084. protected _initialSizeParameter: number | {
  101085. width: number;
  101086. height: number;
  101087. } | {
  101088. ratio: number;
  101089. };
  101090. protected _sizeRatio: Nullable<number>;
  101091. /** @hidden */
  101092. _generateMipMaps: boolean;
  101093. protected _renderingManager: RenderingManager;
  101094. /** @hidden */
  101095. _waitingRenderList: string[];
  101096. protected _doNotChangeAspectRatio: boolean;
  101097. protected _currentRefreshId: number;
  101098. protected _refreshRate: number;
  101099. protected _textureMatrix: Matrix;
  101100. protected _samples: number;
  101101. protected _renderTargetOptions: RenderTargetCreationOptions;
  101102. /**
  101103. * Gets render target creation options that were used.
  101104. */
  101105. get renderTargetOptions(): RenderTargetCreationOptions;
  101106. protected _onRatioRescale(): void;
  101107. /**
  101108. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101109. * It must define where the camera used to render the texture is set
  101110. */
  101111. boundingBoxPosition: Vector3;
  101112. private _boundingBoxSize;
  101113. /**
  101114. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101115. * When defined, the cubemap will switch to local mode
  101116. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101117. * @example https://www.babylonjs-playground.com/#RNASML
  101118. */
  101119. set boundingBoxSize(value: Vector3);
  101120. get boundingBoxSize(): Vector3;
  101121. /**
  101122. * In case the RTT has been created with a depth texture, get the associated
  101123. * depth texture.
  101124. * Otherwise, return null.
  101125. */
  101126. get depthStencilTexture(): Nullable<InternalTexture>;
  101127. /**
  101128. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101129. * or used a shadow, depth texture...
  101130. * @param name The friendly name of the texture
  101131. * @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)
  101132. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101133. * @param generateMipMaps True if mip maps need to be generated after render.
  101134. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101135. * @param type The type of the buffer in the RTT (int, half float, float...)
  101136. * @param isCube True if a cube texture needs to be created
  101137. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101138. * @param generateDepthBuffer True to generate a depth buffer
  101139. * @param generateStencilBuffer True to generate a stencil buffer
  101140. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101141. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101142. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101143. */
  101144. constructor(name: string, size: number | {
  101145. width: number;
  101146. height: number;
  101147. layers?: number;
  101148. } | {
  101149. ratio: number;
  101150. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101151. /**
  101152. * Creates a depth stencil texture.
  101153. * This is only available in WebGL 2 or with the depth texture extension available.
  101154. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101155. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101156. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101157. */
  101158. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101159. private _processSizeParameter;
  101160. /**
  101161. * Define the number of samples to use in case of MSAA.
  101162. * It defaults to one meaning no MSAA has been enabled.
  101163. */
  101164. get samples(): number;
  101165. set samples(value: number);
  101166. /**
  101167. * Resets the refresh counter of the texture and start bak from scratch.
  101168. * Could be useful to regenerate the texture if it is setup to render only once.
  101169. */
  101170. resetRefreshCounter(): void;
  101171. /**
  101172. * Define the refresh rate of the texture or the rendering frequency.
  101173. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101174. */
  101175. get refreshRate(): number;
  101176. set refreshRate(value: number);
  101177. /**
  101178. * Adds a post process to the render target rendering passes.
  101179. * @param postProcess define the post process to add
  101180. */
  101181. addPostProcess(postProcess: PostProcess): void;
  101182. /**
  101183. * Clear all the post processes attached to the render target
  101184. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101185. */
  101186. clearPostProcesses(dispose?: boolean): void;
  101187. /**
  101188. * Remove one of the post process from the list of attached post processes to the texture
  101189. * @param postProcess define the post process to remove from the list
  101190. */
  101191. removePostProcess(postProcess: PostProcess): void;
  101192. /** @hidden */
  101193. _shouldRender(): boolean;
  101194. /**
  101195. * Gets the actual render size of the texture.
  101196. * @returns the width of the render size
  101197. */
  101198. getRenderSize(): number;
  101199. /**
  101200. * Gets the actual render width of the texture.
  101201. * @returns the width of the render size
  101202. */
  101203. getRenderWidth(): number;
  101204. /**
  101205. * Gets the actual render height of the texture.
  101206. * @returns the height of the render size
  101207. */
  101208. getRenderHeight(): number;
  101209. /**
  101210. * Gets the actual number of layers of the texture.
  101211. * @returns the number of layers
  101212. */
  101213. getRenderLayers(): number;
  101214. /**
  101215. * Get if the texture can be rescaled or not.
  101216. */
  101217. get canRescale(): boolean;
  101218. /**
  101219. * Resize the texture using a ratio.
  101220. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101221. */
  101222. scale(ratio: number): void;
  101223. /**
  101224. * Get the texture reflection matrix used to rotate/transform the reflection.
  101225. * @returns the reflection matrix
  101226. */
  101227. getReflectionTextureMatrix(): Matrix;
  101228. /**
  101229. * Resize the texture to a new desired size.
  101230. * Be carrefull as it will recreate all the data in the new texture.
  101231. * @param size Define the new size. It can be:
  101232. * - a number for squared texture,
  101233. * - an object containing { width: number, height: number }
  101234. * - or an object containing a ratio { ratio: number }
  101235. */
  101236. resize(size: number | {
  101237. width: number;
  101238. height: number;
  101239. } | {
  101240. ratio: number;
  101241. }): void;
  101242. private _defaultRenderListPrepared;
  101243. /**
  101244. * Renders all the objects from the render list into the texture.
  101245. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101246. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101247. */
  101248. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101249. private _bestReflectionRenderTargetDimension;
  101250. private _prepareRenderingManager;
  101251. /**
  101252. * @hidden
  101253. * @param faceIndex face index to bind to if this is a cubetexture
  101254. * @param layer defines the index of the texture to bind in the array
  101255. */
  101256. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101257. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101258. private renderToTarget;
  101259. /**
  101260. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101261. * This allowed control for front to back rendering or reversly depending of the special needs.
  101262. *
  101263. * @param renderingGroupId The rendering group id corresponding to its index
  101264. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101265. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101266. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101267. */
  101268. 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;
  101269. /**
  101270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101271. *
  101272. * @param renderingGroupId The rendering group id corresponding to its index
  101273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101274. */
  101275. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101276. /**
  101277. * Clones the texture.
  101278. * @returns the cloned texture
  101279. */
  101280. clone(): RenderTargetTexture;
  101281. /**
  101282. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101283. * @returns The JSON representation of the texture
  101284. */
  101285. serialize(): any;
  101286. /**
  101287. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101288. */
  101289. disposeFramebufferObjects(): void;
  101290. /**
  101291. * Dispose the texture and release its associated resources.
  101292. */
  101293. dispose(): void;
  101294. /** @hidden */
  101295. _rebuild(): void;
  101296. /**
  101297. * Clear the info related to rendering groups preventing retention point in material dispose.
  101298. */
  101299. freeRenderingGroups(): void;
  101300. /**
  101301. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101302. * @returns the view count
  101303. */
  101304. getViewCount(): number;
  101305. }
  101306. }
  101307. declare module BABYLON {
  101308. /**
  101309. * Class used to manipulate GUIDs
  101310. */
  101311. export class GUID {
  101312. /**
  101313. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101314. * Be aware Math.random() could cause collisions, but:
  101315. * "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"
  101316. * @returns a pseudo random id
  101317. */
  101318. static RandomId(): string;
  101319. }
  101320. }
  101321. declare module BABYLON {
  101322. /**
  101323. * Options to be used when creating a shadow depth material
  101324. */
  101325. export interface IIOptionShadowDepthMaterial {
  101326. /** Variables in the vertex shader code that need to have their names remapped.
  101327. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101328. * "var_name" should be either: worldPos or vNormalW
  101329. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101330. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101331. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101332. */
  101333. remappedVariables?: string[];
  101334. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101335. standalone?: boolean;
  101336. }
  101337. /**
  101338. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101339. */
  101340. export class ShadowDepthWrapper {
  101341. private _scene;
  101342. private _options?;
  101343. private _baseMaterial;
  101344. private _onEffectCreatedObserver;
  101345. private _subMeshToEffect;
  101346. private _subMeshToDepthEffect;
  101347. private _meshes;
  101348. /** @hidden */
  101349. _matriceNames: any;
  101350. /** Gets the standalone status of the wrapper */
  101351. get standalone(): boolean;
  101352. /** Gets the base material the wrapper is built upon */
  101353. get baseMaterial(): Material;
  101354. /**
  101355. * Instantiate a new shadow depth wrapper.
  101356. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101357. * generate the shadow depth map. For more information, please refer to the documentation:
  101358. * https://doc.babylonjs.com/babylon101/shadows
  101359. * @param baseMaterial Material to wrap
  101360. * @param scene Define the scene the material belongs to
  101361. * @param options Options used to create the wrapper
  101362. */
  101363. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101364. /**
  101365. * Gets the effect to use to generate the depth map
  101366. * @param subMesh subMesh to get the effect for
  101367. * @param shadowGenerator shadow generator to get the effect for
  101368. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101369. */
  101370. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101371. /**
  101372. * Specifies that the submesh is ready to be used for depth rendering
  101373. * @param subMesh submesh to check
  101374. * @param defines the list of defines to take into account when checking the effect
  101375. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101376. * @param useInstances specifies that instances should be used
  101377. * @returns a boolean indicating that the submesh is ready or not
  101378. */
  101379. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101380. /**
  101381. * Disposes the resources
  101382. */
  101383. dispose(): void;
  101384. private _makeEffect;
  101385. }
  101386. }
  101387. declare module BABYLON {
  101388. /**
  101389. * Options for compiling materials.
  101390. */
  101391. export interface IMaterialCompilationOptions {
  101392. /**
  101393. * Defines whether clip planes are enabled.
  101394. */
  101395. clipPlane: boolean;
  101396. /**
  101397. * Defines whether instances are enabled.
  101398. */
  101399. useInstances: boolean;
  101400. }
  101401. /**
  101402. * Options passed when calling customShaderNameResolve
  101403. */
  101404. export interface ICustomShaderNameResolveOptions {
  101405. /**
  101406. * 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
  101407. */
  101408. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101409. }
  101410. /**
  101411. * Base class for the main features of a material in Babylon.js
  101412. */
  101413. export class Material implements IAnimatable {
  101414. /**
  101415. * Returns the triangle fill mode
  101416. */
  101417. static readonly TriangleFillMode: number;
  101418. /**
  101419. * Returns the wireframe mode
  101420. */
  101421. static readonly WireFrameFillMode: number;
  101422. /**
  101423. * Returns the point fill mode
  101424. */
  101425. static readonly PointFillMode: number;
  101426. /**
  101427. * Returns the point list draw mode
  101428. */
  101429. static readonly PointListDrawMode: number;
  101430. /**
  101431. * Returns the line list draw mode
  101432. */
  101433. static readonly LineListDrawMode: number;
  101434. /**
  101435. * Returns the line loop draw mode
  101436. */
  101437. static readonly LineLoopDrawMode: number;
  101438. /**
  101439. * Returns the line strip draw mode
  101440. */
  101441. static readonly LineStripDrawMode: number;
  101442. /**
  101443. * Returns the triangle strip draw mode
  101444. */
  101445. static readonly TriangleStripDrawMode: number;
  101446. /**
  101447. * Returns the triangle fan draw mode
  101448. */
  101449. static readonly TriangleFanDrawMode: number;
  101450. /**
  101451. * Stores the clock-wise side orientation
  101452. */
  101453. static readonly ClockWiseSideOrientation: number;
  101454. /**
  101455. * Stores the counter clock-wise side orientation
  101456. */
  101457. static readonly CounterClockWiseSideOrientation: number;
  101458. /**
  101459. * The dirty texture flag value
  101460. */
  101461. static readonly TextureDirtyFlag: number;
  101462. /**
  101463. * The dirty light flag value
  101464. */
  101465. static readonly LightDirtyFlag: number;
  101466. /**
  101467. * The dirty fresnel flag value
  101468. */
  101469. static readonly FresnelDirtyFlag: number;
  101470. /**
  101471. * The dirty attribute flag value
  101472. */
  101473. static readonly AttributesDirtyFlag: number;
  101474. /**
  101475. * The dirty misc flag value
  101476. */
  101477. static readonly MiscDirtyFlag: number;
  101478. /**
  101479. * The all dirty flag value
  101480. */
  101481. static readonly AllDirtyFlag: number;
  101482. /**
  101483. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101484. */
  101485. static readonly MATERIAL_OPAQUE: number;
  101486. /**
  101487. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101488. */
  101489. static readonly MATERIAL_ALPHATEST: number;
  101490. /**
  101491. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101492. */
  101493. static readonly MATERIAL_ALPHABLEND: number;
  101494. /**
  101495. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101496. * They are also discarded below the alpha cutoff threshold to improve performances.
  101497. */
  101498. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101499. /**
  101500. * The Whiteout method is used to blend normals.
  101501. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101502. */
  101503. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101504. /**
  101505. * The Reoriented Normal Mapping method is used to blend normals.
  101506. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101507. */
  101508. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101509. /**
  101510. * Custom callback helping to override the default shader used in the material.
  101511. */
  101512. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101513. /**
  101514. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101515. */
  101516. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101517. /**
  101518. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101519. * This means that the material can keep using a previous shader while a new one is being compiled.
  101520. * This is mostly used when shader parallel compilation is supported (true by default)
  101521. */
  101522. allowShaderHotSwapping: boolean;
  101523. /**
  101524. * The ID of the material
  101525. */
  101526. id: string;
  101527. /**
  101528. * Gets or sets the unique id of the material
  101529. */
  101530. uniqueId: number;
  101531. /**
  101532. * The name of the material
  101533. */
  101534. name: string;
  101535. /**
  101536. * Gets or sets user defined metadata
  101537. */
  101538. metadata: any;
  101539. /**
  101540. * For internal use only. Please do not use.
  101541. */
  101542. reservedDataStore: any;
  101543. /**
  101544. * Specifies if the ready state should be checked on each call
  101545. */
  101546. checkReadyOnEveryCall: boolean;
  101547. /**
  101548. * Specifies if the ready state should be checked once
  101549. */
  101550. checkReadyOnlyOnce: boolean;
  101551. /**
  101552. * The state of the material
  101553. */
  101554. state: string;
  101555. /**
  101556. * The alpha value of the material
  101557. */
  101558. protected _alpha: number;
  101559. /**
  101560. * List of inspectable custom properties (used by the Inspector)
  101561. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101562. */
  101563. inspectableCustomProperties: IInspectable[];
  101564. /**
  101565. * Sets the alpha value of the material
  101566. */
  101567. set alpha(value: number);
  101568. /**
  101569. * Gets the alpha value of the material
  101570. */
  101571. get alpha(): number;
  101572. /**
  101573. * Specifies if back face culling is enabled
  101574. */
  101575. protected _backFaceCulling: boolean;
  101576. /**
  101577. * Sets the back-face culling state
  101578. */
  101579. set backFaceCulling(value: boolean);
  101580. /**
  101581. * Gets the back-face culling state
  101582. */
  101583. get backFaceCulling(): boolean;
  101584. /**
  101585. * Stores the value for side orientation
  101586. */
  101587. sideOrientation: number;
  101588. /**
  101589. * Callback triggered when the material is compiled
  101590. */
  101591. onCompiled: Nullable<(effect: Effect) => void>;
  101592. /**
  101593. * Callback triggered when an error occurs
  101594. */
  101595. onError: Nullable<(effect: Effect, errors: string) => void>;
  101596. /**
  101597. * Callback triggered to get the render target textures
  101598. */
  101599. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101600. /**
  101601. * Gets a boolean indicating that current material needs to register RTT
  101602. */
  101603. get hasRenderTargetTextures(): boolean;
  101604. /**
  101605. * Specifies if the material should be serialized
  101606. */
  101607. doNotSerialize: boolean;
  101608. /**
  101609. * @hidden
  101610. */
  101611. _storeEffectOnSubMeshes: boolean;
  101612. /**
  101613. * Stores the animations for the material
  101614. */
  101615. animations: Nullable<Array<Animation>>;
  101616. /**
  101617. * An event triggered when the material is disposed
  101618. */
  101619. onDisposeObservable: Observable<Material>;
  101620. /**
  101621. * An observer which watches for dispose events
  101622. */
  101623. private _onDisposeObserver;
  101624. private _onUnBindObservable;
  101625. /**
  101626. * Called during a dispose event
  101627. */
  101628. set onDispose(callback: () => void);
  101629. private _onBindObservable;
  101630. /**
  101631. * An event triggered when the material is bound
  101632. */
  101633. get onBindObservable(): Observable<AbstractMesh>;
  101634. /**
  101635. * An observer which watches for bind events
  101636. */
  101637. private _onBindObserver;
  101638. /**
  101639. * Called during a bind event
  101640. */
  101641. set onBind(callback: (Mesh: AbstractMesh) => void);
  101642. /**
  101643. * An event triggered when the material is unbound
  101644. */
  101645. get onUnBindObservable(): Observable<Material>;
  101646. protected _onEffectCreatedObservable: Nullable<Observable<{
  101647. effect: Effect;
  101648. subMesh: Nullable<SubMesh>;
  101649. }>>;
  101650. /**
  101651. * An event triggered when the effect is (re)created
  101652. */
  101653. get onEffectCreatedObservable(): Observable<{
  101654. effect: Effect;
  101655. subMesh: Nullable<SubMesh>;
  101656. }>;
  101657. /**
  101658. * Stores the value of the alpha mode
  101659. */
  101660. private _alphaMode;
  101661. /**
  101662. * Sets the value of the alpha mode.
  101663. *
  101664. * | Value | Type | Description |
  101665. * | --- | --- | --- |
  101666. * | 0 | ALPHA_DISABLE | |
  101667. * | 1 | ALPHA_ADD | |
  101668. * | 2 | ALPHA_COMBINE | |
  101669. * | 3 | ALPHA_SUBTRACT | |
  101670. * | 4 | ALPHA_MULTIPLY | |
  101671. * | 5 | ALPHA_MAXIMIZED | |
  101672. * | 6 | ALPHA_ONEONE | |
  101673. * | 7 | ALPHA_PREMULTIPLIED | |
  101674. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101675. * | 9 | ALPHA_INTERPOLATE | |
  101676. * | 10 | ALPHA_SCREENMODE | |
  101677. *
  101678. */
  101679. set alphaMode(value: number);
  101680. /**
  101681. * Gets the value of the alpha mode
  101682. */
  101683. get alphaMode(): number;
  101684. /**
  101685. * Stores the state of the need depth pre-pass value
  101686. */
  101687. private _needDepthPrePass;
  101688. /**
  101689. * Sets the need depth pre-pass value
  101690. */
  101691. set needDepthPrePass(value: boolean);
  101692. /**
  101693. * Gets the depth pre-pass value
  101694. */
  101695. get needDepthPrePass(): boolean;
  101696. /**
  101697. * Specifies if depth writing should be disabled
  101698. */
  101699. disableDepthWrite: boolean;
  101700. /**
  101701. * Specifies if color writing should be disabled
  101702. */
  101703. disableColorWrite: boolean;
  101704. /**
  101705. * Specifies if depth writing should be forced
  101706. */
  101707. forceDepthWrite: boolean;
  101708. /**
  101709. * Specifies the depth function that should be used. 0 means the default engine function
  101710. */
  101711. depthFunction: number;
  101712. /**
  101713. * Specifies if there should be a separate pass for culling
  101714. */
  101715. separateCullingPass: boolean;
  101716. /**
  101717. * Stores the state specifing if fog should be enabled
  101718. */
  101719. private _fogEnabled;
  101720. /**
  101721. * Sets the state for enabling fog
  101722. */
  101723. set fogEnabled(value: boolean);
  101724. /**
  101725. * Gets the value of the fog enabled state
  101726. */
  101727. get fogEnabled(): boolean;
  101728. /**
  101729. * Stores the size of points
  101730. */
  101731. pointSize: number;
  101732. /**
  101733. * Stores the z offset value
  101734. */
  101735. zOffset: number;
  101736. get wireframe(): boolean;
  101737. /**
  101738. * Sets the state of wireframe mode
  101739. */
  101740. set wireframe(value: boolean);
  101741. /**
  101742. * Gets the value specifying if point clouds are enabled
  101743. */
  101744. get pointsCloud(): boolean;
  101745. /**
  101746. * Sets the state of point cloud mode
  101747. */
  101748. set pointsCloud(value: boolean);
  101749. /**
  101750. * Gets the material fill mode
  101751. */
  101752. get fillMode(): number;
  101753. /**
  101754. * Sets the material fill mode
  101755. */
  101756. set fillMode(value: number);
  101757. /**
  101758. * @hidden
  101759. * Stores the effects for the material
  101760. */
  101761. _effect: Nullable<Effect>;
  101762. /**
  101763. * Specifies if uniform buffers should be used
  101764. */
  101765. private _useUBO;
  101766. /**
  101767. * Stores a reference to the scene
  101768. */
  101769. private _scene;
  101770. /**
  101771. * Stores the fill mode state
  101772. */
  101773. private _fillMode;
  101774. /**
  101775. * Specifies if the depth write state should be cached
  101776. */
  101777. private _cachedDepthWriteState;
  101778. /**
  101779. * Specifies if the color write state should be cached
  101780. */
  101781. private _cachedColorWriteState;
  101782. /**
  101783. * Specifies if the depth function state should be cached
  101784. */
  101785. private _cachedDepthFunctionState;
  101786. /**
  101787. * Stores the uniform buffer
  101788. */
  101789. protected _uniformBuffer: UniformBuffer;
  101790. /** @hidden */
  101791. _indexInSceneMaterialArray: number;
  101792. /** @hidden */
  101793. meshMap: Nullable<{
  101794. [id: string]: AbstractMesh | undefined;
  101795. }>;
  101796. /**
  101797. * Creates a material instance
  101798. * @param name defines the name of the material
  101799. * @param scene defines the scene to reference
  101800. * @param doNotAdd specifies if the material should be added to the scene
  101801. */
  101802. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101803. /**
  101804. * Returns a string representation of the current material
  101805. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101806. * @returns a string with material information
  101807. */
  101808. toString(fullDetails?: boolean): string;
  101809. /**
  101810. * Gets the class name of the material
  101811. * @returns a string with the class name of the material
  101812. */
  101813. getClassName(): string;
  101814. /**
  101815. * Specifies if updates for the material been locked
  101816. */
  101817. get isFrozen(): boolean;
  101818. /**
  101819. * Locks updates for the material
  101820. */
  101821. freeze(): void;
  101822. /**
  101823. * Unlocks updates for the material
  101824. */
  101825. unfreeze(): void;
  101826. /**
  101827. * Specifies if the material is ready to be used
  101828. * @param mesh defines the mesh to check
  101829. * @param useInstances specifies if instances should be used
  101830. * @returns a boolean indicating if the material is ready to be used
  101831. */
  101832. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101833. /**
  101834. * Specifies that the submesh is ready to be used
  101835. * @param mesh defines the mesh to check
  101836. * @param subMesh defines which submesh to check
  101837. * @param useInstances specifies that instances should be used
  101838. * @returns a boolean indicating that the submesh is ready or not
  101839. */
  101840. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101841. /**
  101842. * Returns the material effect
  101843. * @returns the effect associated with the material
  101844. */
  101845. getEffect(): Nullable<Effect>;
  101846. /**
  101847. * Returns the current scene
  101848. * @returns a Scene
  101849. */
  101850. getScene(): Scene;
  101851. /**
  101852. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101853. */
  101854. protected _forceAlphaTest: boolean;
  101855. /**
  101856. * The transparency mode of the material.
  101857. */
  101858. protected _transparencyMode: Nullable<number>;
  101859. /**
  101860. * Gets the current transparency mode.
  101861. */
  101862. get transparencyMode(): Nullable<number>;
  101863. /**
  101864. * Sets the transparency mode of the material.
  101865. *
  101866. * | Value | Type | Description |
  101867. * | ----- | ----------------------------------- | ----------- |
  101868. * | 0 | OPAQUE | |
  101869. * | 1 | ALPHATEST | |
  101870. * | 2 | ALPHABLEND | |
  101871. * | 3 | ALPHATESTANDBLEND | |
  101872. *
  101873. */
  101874. set transparencyMode(value: Nullable<number>);
  101875. /**
  101876. * Returns true if alpha blending should be disabled.
  101877. */
  101878. protected get _disableAlphaBlending(): boolean;
  101879. /**
  101880. * Specifies whether or not this material should be rendered in alpha blend mode.
  101881. * @returns a boolean specifying if alpha blending is needed
  101882. */
  101883. needAlphaBlending(): boolean;
  101884. /**
  101885. * Specifies if the mesh will require alpha blending
  101886. * @param mesh defines the mesh to check
  101887. * @returns a boolean specifying if alpha blending is needed for the mesh
  101888. */
  101889. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101890. /**
  101891. * Specifies whether or not this material should be rendered in alpha test mode.
  101892. * @returns a boolean specifying if an alpha test is needed.
  101893. */
  101894. needAlphaTesting(): boolean;
  101895. /**
  101896. * Specifies if material alpha testing should be turned on for the mesh
  101897. * @param mesh defines the mesh to check
  101898. */
  101899. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101900. /**
  101901. * Gets the texture used for the alpha test
  101902. * @returns the texture to use for alpha testing
  101903. */
  101904. getAlphaTestTexture(): Nullable<BaseTexture>;
  101905. /**
  101906. * Marks the material to indicate that it needs to be re-calculated
  101907. */
  101908. markDirty(): void;
  101909. /** @hidden */
  101910. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101911. /**
  101912. * Binds the material to the mesh
  101913. * @param world defines the world transformation matrix
  101914. * @param mesh defines the mesh to bind the material to
  101915. */
  101916. bind(world: Matrix, mesh?: Mesh): void;
  101917. /**
  101918. * Binds the submesh to the material
  101919. * @param world defines the world transformation matrix
  101920. * @param mesh defines the mesh containing the submesh
  101921. * @param subMesh defines the submesh to bind the material to
  101922. */
  101923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101924. /**
  101925. * Binds the world matrix to the material
  101926. * @param world defines the world transformation matrix
  101927. */
  101928. bindOnlyWorldMatrix(world: Matrix): void;
  101929. /**
  101930. * Binds the scene's uniform buffer to the effect.
  101931. * @param effect defines the effect to bind to the scene uniform buffer
  101932. * @param sceneUbo defines the uniform buffer storing scene data
  101933. */
  101934. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101935. /**
  101936. * Binds the view matrix to the effect
  101937. * @param effect defines the effect to bind the view matrix to
  101938. */
  101939. bindView(effect: Effect): void;
  101940. /**
  101941. * Binds the view projection matrix to the effect
  101942. * @param effect defines the effect to bind the view projection matrix to
  101943. */
  101944. bindViewProjection(effect: Effect): void;
  101945. /**
  101946. * Processes to execute after binding the material to a mesh
  101947. * @param mesh defines the rendered mesh
  101948. */
  101949. protected _afterBind(mesh?: Mesh): void;
  101950. /**
  101951. * Unbinds the material from the mesh
  101952. */
  101953. unbind(): void;
  101954. /**
  101955. * Gets the active textures from the material
  101956. * @returns an array of textures
  101957. */
  101958. getActiveTextures(): BaseTexture[];
  101959. /**
  101960. * Specifies if the material uses a texture
  101961. * @param texture defines the texture to check against the material
  101962. * @returns a boolean specifying if the material uses the texture
  101963. */
  101964. hasTexture(texture: BaseTexture): boolean;
  101965. /**
  101966. * Makes a duplicate of the material, and gives it a new name
  101967. * @param name defines the new name for the duplicated material
  101968. * @returns the cloned material
  101969. */
  101970. clone(name: string): Nullable<Material>;
  101971. /**
  101972. * Gets the meshes bound to the material
  101973. * @returns an array of meshes bound to the material
  101974. */
  101975. getBindedMeshes(): AbstractMesh[];
  101976. /**
  101977. * Force shader compilation
  101978. * @param mesh defines the mesh associated with this material
  101979. * @param onCompiled defines a function to execute once the material is compiled
  101980. * @param options defines the options to configure the compilation
  101981. * @param onError defines a function to execute if the material fails compiling
  101982. */
  101983. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101984. /**
  101985. * Force shader compilation
  101986. * @param mesh defines the mesh that will use this material
  101987. * @param options defines additional options for compiling the shaders
  101988. * @returns a promise that resolves when the compilation completes
  101989. */
  101990. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101991. private static readonly _AllDirtyCallBack;
  101992. private static readonly _ImageProcessingDirtyCallBack;
  101993. private static readonly _TextureDirtyCallBack;
  101994. private static readonly _FresnelDirtyCallBack;
  101995. private static readonly _MiscDirtyCallBack;
  101996. private static readonly _LightsDirtyCallBack;
  101997. private static readonly _AttributeDirtyCallBack;
  101998. private static _FresnelAndMiscDirtyCallBack;
  101999. private static _TextureAndMiscDirtyCallBack;
  102000. private static readonly _DirtyCallbackArray;
  102001. private static readonly _RunDirtyCallBacks;
  102002. /**
  102003. * Marks a define in the material to indicate that it needs to be re-computed
  102004. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102005. */
  102006. markAsDirty(flag: number): void;
  102007. /**
  102008. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102009. * @param func defines a function which checks material defines against the submeshes
  102010. */
  102011. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102012. /**
  102013. * Indicates that we need to re-calculated for all submeshes
  102014. */
  102015. protected _markAllSubMeshesAsAllDirty(): void;
  102016. /**
  102017. * Indicates that image processing needs to be re-calculated for all submeshes
  102018. */
  102019. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102020. /**
  102021. * Indicates that textures need to be re-calculated for all submeshes
  102022. */
  102023. protected _markAllSubMeshesAsTexturesDirty(): void;
  102024. /**
  102025. * Indicates that fresnel needs to be re-calculated for all submeshes
  102026. */
  102027. protected _markAllSubMeshesAsFresnelDirty(): void;
  102028. /**
  102029. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102030. */
  102031. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102032. /**
  102033. * Indicates that lights need to be re-calculated for all submeshes
  102034. */
  102035. protected _markAllSubMeshesAsLightsDirty(): void;
  102036. /**
  102037. * Indicates that attributes need to be re-calculated for all submeshes
  102038. */
  102039. protected _markAllSubMeshesAsAttributesDirty(): void;
  102040. /**
  102041. * Indicates that misc needs to be re-calculated for all submeshes
  102042. */
  102043. protected _markAllSubMeshesAsMiscDirty(): void;
  102044. /**
  102045. * Indicates that textures and misc need to be re-calculated for all submeshes
  102046. */
  102047. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102048. /**
  102049. * Disposes the material
  102050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102053. */
  102054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102055. /** @hidden */
  102056. private releaseVertexArrayObject;
  102057. /**
  102058. * Serializes this material
  102059. * @returns the serialized material object
  102060. */
  102061. serialize(): any;
  102062. /**
  102063. * Creates a material from parsed material data
  102064. * @param parsedMaterial defines parsed material data
  102065. * @param scene defines the hosting scene
  102066. * @param rootUrl defines the root URL to use to load textures
  102067. * @returns a new material
  102068. */
  102069. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102070. }
  102071. }
  102072. declare module BABYLON {
  102073. /**
  102074. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102075. * separate meshes. This can be use to improve performances.
  102076. * @see http://doc.babylonjs.com/how_to/multi_materials
  102077. */
  102078. export class MultiMaterial extends Material {
  102079. private _subMaterials;
  102080. /**
  102081. * Gets or Sets the list of Materials used within the multi material.
  102082. * They need to be ordered according to the submeshes order in the associated mesh
  102083. */
  102084. get subMaterials(): Nullable<Material>[];
  102085. set subMaterials(value: Nullable<Material>[]);
  102086. /**
  102087. * Function used to align with Node.getChildren()
  102088. * @returns the list of Materials used within the multi material
  102089. */
  102090. getChildren(): Nullable<Material>[];
  102091. /**
  102092. * Instantiates a new Multi Material
  102093. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102094. * separate meshes. This can be use to improve performances.
  102095. * @see http://doc.babylonjs.com/how_to/multi_materials
  102096. * @param name Define the name in the scene
  102097. * @param scene Define the scene the material belongs to
  102098. */
  102099. constructor(name: string, scene: Scene);
  102100. private _hookArray;
  102101. /**
  102102. * Get one of the submaterial by its index in the submaterials array
  102103. * @param index The index to look the sub material at
  102104. * @returns The Material if the index has been defined
  102105. */
  102106. getSubMaterial(index: number): Nullable<Material>;
  102107. /**
  102108. * Get the list of active textures for the whole sub materials list.
  102109. * @returns All the textures that will be used during the rendering
  102110. */
  102111. getActiveTextures(): BaseTexture[];
  102112. /**
  102113. * Gets the current class name of the material e.g. "MultiMaterial"
  102114. * Mainly use in serialization.
  102115. * @returns the class name
  102116. */
  102117. getClassName(): string;
  102118. /**
  102119. * Checks if the material is ready to render the requested sub mesh
  102120. * @param mesh Define the mesh the submesh belongs to
  102121. * @param subMesh Define the sub mesh to look readyness for
  102122. * @param useInstances Define whether or not the material is used with instances
  102123. * @returns true if ready, otherwise false
  102124. */
  102125. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102126. /**
  102127. * Clones the current material and its related sub materials
  102128. * @param name Define the name of the newly cloned material
  102129. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102130. * @returns the cloned material
  102131. */
  102132. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102133. /**
  102134. * Serializes the materials into a JSON representation.
  102135. * @returns the JSON representation
  102136. */
  102137. serialize(): any;
  102138. /**
  102139. * Dispose the material and release its associated resources
  102140. * @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)
  102141. * @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)
  102142. * @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)
  102143. */
  102144. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102145. /**
  102146. * Creates a MultiMaterial from parsed MultiMaterial data.
  102147. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102148. * @param scene defines the hosting scene
  102149. * @returns a new MultiMaterial
  102150. */
  102151. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102152. }
  102153. }
  102154. declare module BABYLON {
  102155. /**
  102156. * Defines a subdivision inside a mesh
  102157. */
  102158. export class SubMesh implements ICullable {
  102159. /** the material index to use */
  102160. materialIndex: number;
  102161. /** vertex index start */
  102162. verticesStart: number;
  102163. /** vertices count */
  102164. verticesCount: number;
  102165. /** index start */
  102166. indexStart: number;
  102167. /** indices count */
  102168. indexCount: number;
  102169. /** @hidden */
  102170. _materialDefines: Nullable<MaterialDefines>;
  102171. /** @hidden */
  102172. _materialEffect: Nullable<Effect>;
  102173. /** @hidden */
  102174. _effectOverride: Nullable<Effect>;
  102175. /**
  102176. * Gets material defines used by the effect associated to the sub mesh
  102177. */
  102178. get materialDefines(): Nullable<MaterialDefines>;
  102179. /**
  102180. * Sets material defines used by the effect associated to the sub mesh
  102181. */
  102182. set materialDefines(defines: Nullable<MaterialDefines>);
  102183. /**
  102184. * Gets associated effect
  102185. */
  102186. get effect(): Nullable<Effect>;
  102187. /**
  102188. * Sets associated effect (effect used to render this submesh)
  102189. * @param effect defines the effect to associate with
  102190. * @param defines defines the set of defines used to compile this effect
  102191. */
  102192. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102193. /** @hidden */
  102194. _linesIndexCount: number;
  102195. private _mesh;
  102196. private _renderingMesh;
  102197. private _boundingInfo;
  102198. private _linesIndexBuffer;
  102199. /** @hidden */
  102200. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102201. /** @hidden */
  102202. _trianglePlanes: Plane[];
  102203. /** @hidden */
  102204. _lastColliderTransformMatrix: Nullable<Matrix>;
  102205. /** @hidden */
  102206. _renderId: number;
  102207. /** @hidden */
  102208. _alphaIndex: number;
  102209. /** @hidden */
  102210. _distanceToCamera: number;
  102211. /** @hidden */
  102212. _id: number;
  102213. private _currentMaterial;
  102214. /**
  102215. * Add a new submesh to a mesh
  102216. * @param materialIndex defines the material index to use
  102217. * @param verticesStart defines vertex index start
  102218. * @param verticesCount defines vertices count
  102219. * @param indexStart defines index start
  102220. * @param indexCount defines indices count
  102221. * @param mesh defines the parent mesh
  102222. * @param renderingMesh defines an optional rendering mesh
  102223. * @param createBoundingBox defines if bounding box should be created for this submesh
  102224. * @returns the new submesh
  102225. */
  102226. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102227. /**
  102228. * Creates a new submesh
  102229. * @param materialIndex defines the material index to use
  102230. * @param verticesStart defines vertex index start
  102231. * @param verticesCount defines vertices count
  102232. * @param indexStart defines index start
  102233. * @param indexCount defines indices count
  102234. * @param mesh defines the parent mesh
  102235. * @param renderingMesh defines an optional rendering mesh
  102236. * @param createBoundingBox defines if bounding box should be created for this submesh
  102237. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102238. */
  102239. constructor(
  102240. /** the material index to use */
  102241. materialIndex: number,
  102242. /** vertex index start */
  102243. verticesStart: number,
  102244. /** vertices count */
  102245. verticesCount: number,
  102246. /** index start */
  102247. indexStart: number,
  102248. /** indices count */
  102249. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102250. /**
  102251. * Returns true if this submesh covers the entire parent mesh
  102252. * @ignorenaming
  102253. */
  102254. get IsGlobal(): boolean;
  102255. /**
  102256. * Returns the submesh BoudingInfo object
  102257. * @returns current bounding info (or mesh's one if the submesh is global)
  102258. */
  102259. getBoundingInfo(): BoundingInfo;
  102260. /**
  102261. * Sets the submesh BoundingInfo
  102262. * @param boundingInfo defines the new bounding info to use
  102263. * @returns the SubMesh
  102264. */
  102265. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102266. /**
  102267. * Returns the mesh of the current submesh
  102268. * @return the parent mesh
  102269. */
  102270. getMesh(): AbstractMesh;
  102271. /**
  102272. * Returns the rendering mesh of the submesh
  102273. * @returns the rendering mesh (could be different from parent mesh)
  102274. */
  102275. getRenderingMesh(): Mesh;
  102276. /**
  102277. * Returns the replacement mesh of the submesh
  102278. * @returns the replacement mesh (could be different from parent mesh)
  102279. */
  102280. getReplacementMesh(): Nullable<AbstractMesh>;
  102281. /**
  102282. * Returns the effective mesh of the submesh
  102283. * @returns the effective mesh (could be different from parent mesh)
  102284. */
  102285. getEffectiveMesh(): AbstractMesh;
  102286. /**
  102287. * Returns the submesh material
  102288. * @returns null or the current material
  102289. */
  102290. getMaterial(): Nullable<Material>;
  102291. /**
  102292. * Sets a new updated BoundingInfo object to the submesh
  102293. * @param data defines an optional position array to use to determine the bounding info
  102294. * @returns the SubMesh
  102295. */
  102296. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102297. /** @hidden */
  102298. _checkCollision(collider: Collider): boolean;
  102299. /**
  102300. * Updates the submesh BoundingInfo
  102301. * @param world defines the world matrix to use to update the bounding info
  102302. * @returns the submesh
  102303. */
  102304. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102305. /**
  102306. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102307. * @param frustumPlanes defines the frustum planes
  102308. * @returns true if the submesh is intersecting with the frustum
  102309. */
  102310. isInFrustum(frustumPlanes: Plane[]): boolean;
  102311. /**
  102312. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102313. * @param frustumPlanes defines the frustum planes
  102314. * @returns true if the submesh is inside the frustum
  102315. */
  102316. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102317. /**
  102318. * Renders the submesh
  102319. * @param enableAlphaMode defines if alpha needs to be used
  102320. * @returns the submesh
  102321. */
  102322. render(enableAlphaMode: boolean): SubMesh;
  102323. /**
  102324. * @hidden
  102325. */
  102326. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102327. /**
  102328. * Checks if the submesh intersects with a ray
  102329. * @param ray defines the ray to test
  102330. * @returns true is the passed ray intersects the submesh bounding box
  102331. */
  102332. canIntersects(ray: Ray): boolean;
  102333. /**
  102334. * Intersects current submesh with a ray
  102335. * @param ray defines the ray to test
  102336. * @param positions defines mesh's positions array
  102337. * @param indices defines mesh's indices array
  102338. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102339. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102340. * @returns intersection info or null if no intersection
  102341. */
  102342. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102343. /** @hidden */
  102344. private _intersectLines;
  102345. /** @hidden */
  102346. private _intersectUnIndexedLines;
  102347. /** @hidden */
  102348. private _intersectTriangles;
  102349. /** @hidden */
  102350. private _intersectUnIndexedTriangles;
  102351. /** @hidden */
  102352. _rebuild(): void;
  102353. /**
  102354. * Creates a new submesh from the passed mesh
  102355. * @param newMesh defines the new hosting mesh
  102356. * @param newRenderingMesh defines an optional rendering mesh
  102357. * @returns the new submesh
  102358. */
  102359. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102360. /**
  102361. * Release associated resources
  102362. */
  102363. dispose(): void;
  102364. /**
  102365. * Gets the class name
  102366. * @returns the string "SubMesh".
  102367. */
  102368. getClassName(): string;
  102369. /**
  102370. * Creates a new submesh from indices data
  102371. * @param materialIndex the index of the main mesh material
  102372. * @param startIndex the index where to start the copy in the mesh indices array
  102373. * @param indexCount the number of indices to copy then from the startIndex
  102374. * @param mesh the main mesh to create the submesh from
  102375. * @param renderingMesh the optional rendering mesh
  102376. * @returns a new submesh
  102377. */
  102378. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102379. }
  102380. }
  102381. declare module BABYLON {
  102382. /**
  102383. * Class used to represent data loading progression
  102384. */
  102385. export class SceneLoaderFlags {
  102386. private static _ForceFullSceneLoadingForIncremental;
  102387. private static _ShowLoadingScreen;
  102388. private static _CleanBoneMatrixWeights;
  102389. private static _loggingLevel;
  102390. /**
  102391. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102392. */
  102393. static get ForceFullSceneLoadingForIncremental(): boolean;
  102394. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102395. /**
  102396. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102397. */
  102398. static get ShowLoadingScreen(): boolean;
  102399. static set ShowLoadingScreen(value: boolean);
  102400. /**
  102401. * Defines the current logging level (while loading the scene)
  102402. * @ignorenaming
  102403. */
  102404. static get loggingLevel(): number;
  102405. static set loggingLevel(value: number);
  102406. /**
  102407. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102408. */
  102409. static get CleanBoneMatrixWeights(): boolean;
  102410. static set CleanBoneMatrixWeights(value: boolean);
  102411. }
  102412. }
  102413. declare module BABYLON {
  102414. /**
  102415. * Class used to store geometry data (vertex buffers + index buffer)
  102416. */
  102417. export class Geometry implements IGetSetVerticesData {
  102418. /**
  102419. * Gets or sets the ID of the geometry
  102420. */
  102421. id: string;
  102422. /**
  102423. * Gets or sets the unique ID of the geometry
  102424. */
  102425. uniqueId: number;
  102426. /**
  102427. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102428. */
  102429. delayLoadState: number;
  102430. /**
  102431. * Gets the file containing the data to load when running in delay load state
  102432. */
  102433. delayLoadingFile: Nullable<string>;
  102434. /**
  102435. * Callback called when the geometry is updated
  102436. */
  102437. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102438. private _scene;
  102439. private _engine;
  102440. private _meshes;
  102441. private _totalVertices;
  102442. /** @hidden */
  102443. _indices: IndicesArray;
  102444. /** @hidden */
  102445. _vertexBuffers: {
  102446. [key: string]: VertexBuffer;
  102447. };
  102448. private _isDisposed;
  102449. private _extend;
  102450. private _boundingBias;
  102451. /** @hidden */
  102452. _delayInfo: Array<string>;
  102453. private _indexBuffer;
  102454. private _indexBufferIsUpdatable;
  102455. /** @hidden */
  102456. _boundingInfo: Nullable<BoundingInfo>;
  102457. /** @hidden */
  102458. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102459. /** @hidden */
  102460. _softwareSkinningFrameId: number;
  102461. private _vertexArrayObjects;
  102462. private _updatable;
  102463. /** @hidden */
  102464. _positions: Nullable<Vector3[]>;
  102465. /**
  102466. * 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
  102467. */
  102468. get boundingBias(): Vector2;
  102469. /**
  102470. * 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
  102471. */
  102472. set boundingBias(value: Vector2);
  102473. /**
  102474. * Static function used to attach a new empty geometry to a mesh
  102475. * @param mesh defines the mesh to attach the geometry to
  102476. * @returns the new Geometry
  102477. */
  102478. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102479. /** Get the list of meshes using this geometry */
  102480. get meshes(): Mesh[];
  102481. /**
  102482. * Creates a new geometry
  102483. * @param id defines the unique ID
  102484. * @param scene defines the hosting scene
  102485. * @param vertexData defines the VertexData used to get geometry data
  102486. * @param updatable defines if geometry must be updatable (false by default)
  102487. * @param mesh defines the mesh that will be associated with the geometry
  102488. */
  102489. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102490. /**
  102491. * Gets the current extend of the geometry
  102492. */
  102493. get extend(): {
  102494. minimum: Vector3;
  102495. maximum: Vector3;
  102496. };
  102497. /**
  102498. * Gets the hosting scene
  102499. * @returns the hosting Scene
  102500. */
  102501. getScene(): Scene;
  102502. /**
  102503. * Gets the hosting engine
  102504. * @returns the hosting Engine
  102505. */
  102506. getEngine(): Engine;
  102507. /**
  102508. * Defines if the geometry is ready to use
  102509. * @returns true if the geometry is ready to be used
  102510. */
  102511. isReady(): boolean;
  102512. /**
  102513. * Gets a value indicating that the geometry should not be serialized
  102514. */
  102515. get doNotSerialize(): boolean;
  102516. /** @hidden */
  102517. _rebuild(): void;
  102518. /**
  102519. * Affects all geometry data in one call
  102520. * @param vertexData defines the geometry data
  102521. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102522. */
  102523. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102524. /**
  102525. * Set specific vertex data
  102526. * @param kind defines the data kind (Position, normal, etc...)
  102527. * @param data defines the vertex data to use
  102528. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102529. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102530. */
  102531. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102532. /**
  102533. * Removes a specific vertex data
  102534. * @param kind defines the data kind (Position, normal, etc...)
  102535. */
  102536. removeVerticesData(kind: string): void;
  102537. /**
  102538. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102539. * @param buffer defines the vertex buffer to use
  102540. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102541. */
  102542. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102543. /**
  102544. * Update a specific vertex buffer
  102545. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102546. * It will do nothing if the buffer is not updatable
  102547. * @param kind defines the data kind (Position, normal, etc...)
  102548. * @param data defines the data to use
  102549. * @param offset defines the offset in the target buffer where to store the data
  102550. * @param useBytes set to true if the offset is in bytes
  102551. */
  102552. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102553. /**
  102554. * Update a specific vertex buffer
  102555. * This function will create a new buffer if the current one is not updatable
  102556. * @param kind defines the data kind (Position, normal, etc...)
  102557. * @param data defines the data to use
  102558. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102559. */
  102560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102561. private _updateBoundingInfo;
  102562. /** @hidden */
  102563. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102564. /**
  102565. * Gets total number of vertices
  102566. * @returns the total number of vertices
  102567. */
  102568. getTotalVertices(): number;
  102569. /**
  102570. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102571. * @param kind defines the data kind (Position, normal, etc...)
  102572. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102573. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102574. * @returns a float array containing vertex data
  102575. */
  102576. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102577. /**
  102578. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102579. * @param kind defines the data kind (Position, normal, etc...)
  102580. * @returns true if the vertex buffer with the specified kind is updatable
  102581. */
  102582. isVertexBufferUpdatable(kind: string): boolean;
  102583. /**
  102584. * Gets a specific vertex buffer
  102585. * @param kind defines the data kind (Position, normal, etc...)
  102586. * @returns a VertexBuffer
  102587. */
  102588. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102589. /**
  102590. * Returns all vertex buffers
  102591. * @return an object holding all vertex buffers indexed by kind
  102592. */
  102593. getVertexBuffers(): Nullable<{
  102594. [key: string]: VertexBuffer;
  102595. }>;
  102596. /**
  102597. * Gets a boolean indicating if specific vertex buffer is present
  102598. * @param kind defines the data kind (Position, normal, etc...)
  102599. * @returns true if data is present
  102600. */
  102601. isVerticesDataPresent(kind: string): boolean;
  102602. /**
  102603. * Gets a list of all attached data kinds (Position, normal, etc...)
  102604. * @returns a list of string containing all kinds
  102605. */
  102606. getVerticesDataKinds(): string[];
  102607. /**
  102608. * Update index buffer
  102609. * @param indices defines the indices to store in the index buffer
  102610. * @param offset defines the offset in the target buffer where to store the data
  102611. * @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)
  102612. */
  102613. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102614. /**
  102615. * Creates a new index buffer
  102616. * @param indices defines the indices to store in the index buffer
  102617. * @param totalVertices defines the total number of vertices (could be null)
  102618. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102619. */
  102620. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102621. /**
  102622. * Return the total number of indices
  102623. * @returns the total number of indices
  102624. */
  102625. getTotalIndices(): number;
  102626. /**
  102627. * Gets the index buffer array
  102628. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102629. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102630. * @returns the index buffer array
  102631. */
  102632. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102633. /**
  102634. * Gets the index buffer
  102635. * @return the index buffer
  102636. */
  102637. getIndexBuffer(): Nullable<DataBuffer>;
  102638. /** @hidden */
  102639. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102640. /**
  102641. * Release the associated resources for a specific mesh
  102642. * @param mesh defines the source mesh
  102643. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102644. */
  102645. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102646. /**
  102647. * Apply current geometry to a given mesh
  102648. * @param mesh defines the mesh to apply geometry to
  102649. */
  102650. applyToMesh(mesh: Mesh): void;
  102651. private _updateExtend;
  102652. private _applyToMesh;
  102653. private notifyUpdate;
  102654. /**
  102655. * Load the geometry if it was flagged as delay loaded
  102656. * @param scene defines the hosting scene
  102657. * @param onLoaded defines a callback called when the geometry is loaded
  102658. */
  102659. load(scene: Scene, onLoaded?: () => void): void;
  102660. private _queueLoad;
  102661. /**
  102662. * Invert the geometry to move from a right handed system to a left handed one.
  102663. */
  102664. toLeftHanded(): void;
  102665. /** @hidden */
  102666. _resetPointsArrayCache(): void;
  102667. /** @hidden */
  102668. _generatePointsArray(): boolean;
  102669. /**
  102670. * Gets a value indicating if the geometry is disposed
  102671. * @returns true if the geometry was disposed
  102672. */
  102673. isDisposed(): boolean;
  102674. private _disposeVertexArrayObjects;
  102675. /**
  102676. * Free all associated resources
  102677. */
  102678. dispose(): void;
  102679. /**
  102680. * Clone the current geometry into a new geometry
  102681. * @param id defines the unique ID of the new geometry
  102682. * @returns a new geometry object
  102683. */
  102684. copy(id: string): Geometry;
  102685. /**
  102686. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102687. * @return a JSON representation of the current geometry data (without the vertices data)
  102688. */
  102689. serialize(): any;
  102690. private toNumberArray;
  102691. /**
  102692. * Serialize all vertices data into a JSON oject
  102693. * @returns a JSON representation of the current geometry data
  102694. */
  102695. serializeVerticeData(): any;
  102696. /**
  102697. * Extracts a clone of a mesh geometry
  102698. * @param mesh defines the source mesh
  102699. * @param id defines the unique ID of the new geometry object
  102700. * @returns the new geometry object
  102701. */
  102702. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102703. /**
  102704. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102705. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102706. * Be aware Math.random() could cause collisions, but:
  102707. * "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"
  102708. * @returns a string containing a new GUID
  102709. */
  102710. static RandomId(): string;
  102711. /** @hidden */
  102712. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102713. private static _CleanMatricesWeights;
  102714. /**
  102715. * Create a new geometry from persisted data (Using .babylon file format)
  102716. * @param parsedVertexData defines the persisted data
  102717. * @param scene defines the hosting scene
  102718. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102719. * @returns the new geometry object
  102720. */
  102721. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102722. }
  102723. }
  102724. declare module BABYLON {
  102725. /**
  102726. * Define an interface for all classes that will get and set the data on vertices
  102727. */
  102728. export interface IGetSetVerticesData {
  102729. /**
  102730. * Gets a boolean indicating if specific vertex data is present
  102731. * @param kind defines the vertex data kind to use
  102732. * @returns true is data kind is present
  102733. */
  102734. isVerticesDataPresent(kind: string): boolean;
  102735. /**
  102736. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102737. * @param kind defines the data kind (Position, normal, etc...)
  102738. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102739. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102740. * @returns a float array containing vertex data
  102741. */
  102742. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102743. /**
  102744. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102745. * @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.
  102746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102747. * @returns the indices array or an empty array if the mesh has no geometry
  102748. */
  102749. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102750. /**
  102751. * Set specific vertex data
  102752. * @param kind defines the data kind (Position, normal, etc...)
  102753. * @param data defines the vertex data to use
  102754. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102755. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102756. */
  102757. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102758. /**
  102759. * Update a specific associated vertex buffer
  102760. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102761. * - VertexBuffer.PositionKind
  102762. * - VertexBuffer.UVKind
  102763. * - VertexBuffer.UV2Kind
  102764. * - VertexBuffer.UV3Kind
  102765. * - VertexBuffer.UV4Kind
  102766. * - VertexBuffer.UV5Kind
  102767. * - VertexBuffer.UV6Kind
  102768. * - VertexBuffer.ColorKind
  102769. * - VertexBuffer.MatricesIndicesKind
  102770. * - VertexBuffer.MatricesIndicesExtraKind
  102771. * - VertexBuffer.MatricesWeightsKind
  102772. * - VertexBuffer.MatricesWeightsExtraKind
  102773. * @param data defines the data source
  102774. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102775. * @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)
  102776. */
  102777. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102778. /**
  102779. * Creates a new index buffer
  102780. * @param indices defines the indices to store in the index buffer
  102781. * @param totalVertices defines the total number of vertices (could be null)
  102782. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102783. */
  102784. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102785. }
  102786. /**
  102787. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102788. */
  102789. export class VertexData {
  102790. /**
  102791. * Mesh side orientation : usually the external or front surface
  102792. */
  102793. static readonly FRONTSIDE: number;
  102794. /**
  102795. * Mesh side orientation : usually the internal or back surface
  102796. */
  102797. static readonly BACKSIDE: number;
  102798. /**
  102799. * Mesh side orientation : both internal and external or front and back surfaces
  102800. */
  102801. static readonly DOUBLESIDE: number;
  102802. /**
  102803. * Mesh side orientation : by default, `FRONTSIDE`
  102804. */
  102805. static readonly DEFAULTSIDE: number;
  102806. /**
  102807. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102808. */
  102809. positions: Nullable<FloatArray>;
  102810. /**
  102811. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102812. */
  102813. normals: Nullable<FloatArray>;
  102814. /**
  102815. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102816. */
  102817. tangents: Nullable<FloatArray>;
  102818. /**
  102819. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102820. */
  102821. uvs: Nullable<FloatArray>;
  102822. /**
  102823. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102824. */
  102825. uvs2: Nullable<FloatArray>;
  102826. /**
  102827. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102828. */
  102829. uvs3: Nullable<FloatArray>;
  102830. /**
  102831. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102832. */
  102833. uvs4: Nullable<FloatArray>;
  102834. /**
  102835. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102836. */
  102837. uvs5: Nullable<FloatArray>;
  102838. /**
  102839. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102840. */
  102841. uvs6: Nullable<FloatArray>;
  102842. /**
  102843. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102844. */
  102845. colors: Nullable<FloatArray>;
  102846. /**
  102847. * 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).
  102848. */
  102849. matricesIndices: Nullable<FloatArray>;
  102850. /**
  102851. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102852. */
  102853. matricesWeights: Nullable<FloatArray>;
  102854. /**
  102855. * An array extending the number of possible indices
  102856. */
  102857. matricesIndicesExtra: Nullable<FloatArray>;
  102858. /**
  102859. * An array extending the number of possible weights when the number of indices is extended
  102860. */
  102861. matricesWeightsExtra: Nullable<FloatArray>;
  102862. /**
  102863. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102864. */
  102865. indices: Nullable<IndicesArray>;
  102866. /**
  102867. * Uses the passed data array to set the set the values for the specified kind of data
  102868. * @param data a linear array of floating numbers
  102869. * @param kind the type of data that is being set, eg positions, colors etc
  102870. */
  102871. set(data: FloatArray, kind: string): void;
  102872. /**
  102873. * Associates the vertexData to the passed Mesh.
  102874. * Sets it as updatable or not (default `false`)
  102875. * @param mesh the mesh the vertexData is applied to
  102876. * @param updatable when used and having the value true allows new data to update the vertexData
  102877. * @returns the VertexData
  102878. */
  102879. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102880. /**
  102881. * Associates the vertexData to the passed Geometry.
  102882. * Sets it as updatable or not (default `false`)
  102883. * @param geometry the geometry the vertexData is applied to
  102884. * @param updatable when used and having the value true allows new data to update the vertexData
  102885. * @returns VertexData
  102886. */
  102887. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102888. /**
  102889. * Updates the associated mesh
  102890. * @param mesh the mesh to be updated
  102891. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102892. * @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
  102893. * @returns VertexData
  102894. */
  102895. updateMesh(mesh: Mesh): VertexData;
  102896. /**
  102897. * Updates the associated geometry
  102898. * @param geometry the geometry to be updated
  102899. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102900. * @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
  102901. * @returns VertexData.
  102902. */
  102903. updateGeometry(geometry: Geometry): VertexData;
  102904. private _applyTo;
  102905. private _update;
  102906. /**
  102907. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102908. * @param matrix the transforming matrix
  102909. * @returns the VertexData
  102910. */
  102911. transform(matrix: Matrix): VertexData;
  102912. /**
  102913. * Merges the passed VertexData into the current one
  102914. * @param other the VertexData to be merged into the current one
  102915. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102916. * @returns the modified VertexData
  102917. */
  102918. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102919. private _mergeElement;
  102920. private _validate;
  102921. /**
  102922. * Serializes the VertexData
  102923. * @returns a serialized object
  102924. */
  102925. serialize(): any;
  102926. /**
  102927. * Extracts the vertexData from a mesh
  102928. * @param mesh the mesh from which to extract the VertexData
  102929. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102930. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102931. * @returns the object VertexData associated to the passed mesh
  102932. */
  102933. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102934. /**
  102935. * Extracts the vertexData from the geometry
  102936. * @param geometry the geometry from which to extract the VertexData
  102937. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102938. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102939. * @returns the object VertexData associated to the passed mesh
  102940. */
  102941. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102942. private static _ExtractFrom;
  102943. /**
  102944. * Creates the VertexData for a Ribbon
  102945. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102946. * * pathArray array of paths, each of which an array of successive Vector3
  102947. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102948. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102949. * * 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
  102950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102951. * * 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)
  102952. * * 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)
  102953. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102954. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102955. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102956. * @returns the VertexData of the ribbon
  102957. */
  102958. static CreateRibbon(options: {
  102959. pathArray: Vector3[][];
  102960. closeArray?: boolean;
  102961. closePath?: boolean;
  102962. offset?: number;
  102963. sideOrientation?: number;
  102964. frontUVs?: Vector4;
  102965. backUVs?: Vector4;
  102966. invertUV?: boolean;
  102967. uvs?: Vector2[];
  102968. colors?: Color4[];
  102969. }): VertexData;
  102970. /**
  102971. * Creates the VertexData for a box
  102972. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102973. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102974. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102975. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102976. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102977. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102978. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102980. * * 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)
  102981. * * 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)
  102982. * @returns the VertexData of the box
  102983. */
  102984. static CreateBox(options: {
  102985. size?: number;
  102986. width?: number;
  102987. height?: number;
  102988. depth?: number;
  102989. faceUV?: Vector4[];
  102990. faceColors?: Color4[];
  102991. sideOrientation?: number;
  102992. frontUVs?: Vector4;
  102993. backUVs?: Vector4;
  102994. }): VertexData;
  102995. /**
  102996. * Creates the VertexData for a tiled box
  102997. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102998. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102999. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103000. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103002. * @returns the VertexData of the box
  103003. */
  103004. static CreateTiledBox(options: {
  103005. pattern?: number;
  103006. width?: number;
  103007. height?: number;
  103008. depth?: number;
  103009. tileSize?: number;
  103010. tileWidth?: number;
  103011. tileHeight?: number;
  103012. alignHorizontal?: number;
  103013. alignVertical?: number;
  103014. faceUV?: Vector4[];
  103015. faceColors?: Color4[];
  103016. sideOrientation?: number;
  103017. }): VertexData;
  103018. /**
  103019. * Creates the VertexData for a tiled plane
  103020. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103021. * * pattern a limited pattern arrangement depending on the number
  103022. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103023. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103024. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103026. * * 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)
  103027. * * 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)
  103028. * @returns the VertexData of the tiled plane
  103029. */
  103030. static CreateTiledPlane(options: {
  103031. pattern?: number;
  103032. tileSize?: number;
  103033. tileWidth?: number;
  103034. tileHeight?: number;
  103035. size?: number;
  103036. width?: number;
  103037. height?: number;
  103038. alignHorizontal?: number;
  103039. alignVertical?: number;
  103040. sideOrientation?: number;
  103041. frontUVs?: Vector4;
  103042. backUVs?: Vector4;
  103043. }): VertexData;
  103044. /**
  103045. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103046. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103047. * * segments sets the number of horizontal strips optional, default 32
  103048. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103049. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103050. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103051. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103052. * * 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
  103053. * * 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
  103054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103055. * * 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)
  103056. * * 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)
  103057. * @returns the VertexData of the ellipsoid
  103058. */
  103059. static CreateSphere(options: {
  103060. segments?: number;
  103061. diameter?: number;
  103062. diameterX?: number;
  103063. diameterY?: number;
  103064. diameterZ?: number;
  103065. arc?: number;
  103066. slice?: number;
  103067. sideOrientation?: number;
  103068. frontUVs?: Vector4;
  103069. backUVs?: Vector4;
  103070. }): VertexData;
  103071. /**
  103072. * Creates the VertexData for a cylinder, cone or prism
  103073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103074. * * height sets the height (y direction) of the cylinder, optional, default 2
  103075. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103076. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103077. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103078. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103079. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103080. * * 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
  103081. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103082. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103083. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103084. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103086. * * 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)
  103087. * * 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)
  103088. * @returns the VertexData of the cylinder, cone or prism
  103089. */
  103090. static CreateCylinder(options: {
  103091. height?: number;
  103092. diameterTop?: number;
  103093. diameterBottom?: number;
  103094. diameter?: number;
  103095. tessellation?: number;
  103096. subdivisions?: number;
  103097. arc?: number;
  103098. faceColors?: Color4[];
  103099. faceUV?: Vector4[];
  103100. hasRings?: boolean;
  103101. enclose?: boolean;
  103102. sideOrientation?: number;
  103103. frontUVs?: Vector4;
  103104. backUVs?: Vector4;
  103105. }): VertexData;
  103106. /**
  103107. * Creates the VertexData for a torus
  103108. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103109. * * diameter the diameter of the torus, optional default 1
  103110. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103111. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103113. * * 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)
  103114. * * 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)
  103115. * @returns the VertexData of the torus
  103116. */
  103117. static CreateTorus(options: {
  103118. diameter?: number;
  103119. thickness?: number;
  103120. tessellation?: number;
  103121. sideOrientation?: number;
  103122. frontUVs?: Vector4;
  103123. backUVs?: Vector4;
  103124. }): VertexData;
  103125. /**
  103126. * Creates the VertexData of the LineSystem
  103127. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103128. * - lines an array of lines, each line being an array of successive Vector3
  103129. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103130. * @returns the VertexData of the LineSystem
  103131. */
  103132. static CreateLineSystem(options: {
  103133. lines: Vector3[][];
  103134. colors?: Nullable<Color4[][]>;
  103135. }): VertexData;
  103136. /**
  103137. * Create the VertexData for a DashedLines
  103138. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103139. * - points an array successive Vector3
  103140. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103141. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103142. * - dashNb the intended total number of dashes, optional, default 200
  103143. * @returns the VertexData for the DashedLines
  103144. */
  103145. static CreateDashedLines(options: {
  103146. points: Vector3[];
  103147. dashSize?: number;
  103148. gapSize?: number;
  103149. dashNb?: number;
  103150. }): VertexData;
  103151. /**
  103152. * Creates the VertexData for a Ground
  103153. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103154. * - width the width (x direction) of the ground, optional, default 1
  103155. * - height the height (z direction) of the ground, optional, default 1
  103156. * - subdivisions the number of subdivisions per side, optional, default 1
  103157. * @returns the VertexData of the Ground
  103158. */
  103159. static CreateGround(options: {
  103160. width?: number;
  103161. height?: number;
  103162. subdivisions?: number;
  103163. subdivisionsX?: number;
  103164. subdivisionsY?: number;
  103165. }): VertexData;
  103166. /**
  103167. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103168. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103169. * * xmin the ground minimum X coordinate, optional, default -1
  103170. * * zmin the ground minimum Z coordinate, optional, default -1
  103171. * * xmax the ground maximum X coordinate, optional, default 1
  103172. * * zmax the ground maximum Z coordinate, optional, default 1
  103173. * * 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}
  103174. * * 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}
  103175. * @returns the VertexData of the TiledGround
  103176. */
  103177. static CreateTiledGround(options: {
  103178. xmin: number;
  103179. zmin: number;
  103180. xmax: number;
  103181. zmax: number;
  103182. subdivisions?: {
  103183. w: number;
  103184. h: number;
  103185. };
  103186. precision?: {
  103187. w: number;
  103188. h: number;
  103189. };
  103190. }): VertexData;
  103191. /**
  103192. * Creates the VertexData of the Ground designed from a heightmap
  103193. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103194. * * width the width (x direction) of the ground
  103195. * * height the height (z direction) of the ground
  103196. * * subdivisions the number of subdivisions per side
  103197. * * minHeight the minimum altitude on the ground, optional, default 0
  103198. * * maxHeight the maximum altitude on the ground, optional default 1
  103199. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103200. * * buffer the array holding the image color data
  103201. * * bufferWidth the width of image
  103202. * * bufferHeight the height of image
  103203. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103204. * @returns the VertexData of the Ground designed from a heightmap
  103205. */
  103206. static CreateGroundFromHeightMap(options: {
  103207. width: number;
  103208. height: number;
  103209. subdivisions: number;
  103210. minHeight: number;
  103211. maxHeight: number;
  103212. colorFilter: Color3;
  103213. buffer: Uint8Array;
  103214. bufferWidth: number;
  103215. bufferHeight: number;
  103216. alphaFilter: number;
  103217. }): VertexData;
  103218. /**
  103219. * Creates the VertexData for a Plane
  103220. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103221. * * size sets the width and height of the plane to the value of size, optional default 1
  103222. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103223. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103225. * * 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)
  103226. * * 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)
  103227. * @returns the VertexData of the box
  103228. */
  103229. static CreatePlane(options: {
  103230. size?: number;
  103231. width?: number;
  103232. height?: number;
  103233. sideOrientation?: number;
  103234. frontUVs?: Vector4;
  103235. backUVs?: Vector4;
  103236. }): VertexData;
  103237. /**
  103238. * Creates the VertexData of the Disc or regular Polygon
  103239. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103240. * * radius the radius of the disc, optional default 0.5
  103241. * * tessellation the number of polygon sides, optional, default 64
  103242. * * 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
  103243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103244. * * 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)
  103245. * * 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)
  103246. * @returns the VertexData of the box
  103247. */
  103248. static CreateDisc(options: {
  103249. radius?: number;
  103250. tessellation?: number;
  103251. arc?: number;
  103252. sideOrientation?: number;
  103253. frontUVs?: Vector4;
  103254. backUVs?: Vector4;
  103255. }): VertexData;
  103256. /**
  103257. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103258. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103259. * @param polygon a mesh built from polygonTriangulation.build()
  103260. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103261. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103262. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103263. * @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)
  103264. * @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)
  103265. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103266. * @returns the VertexData of the Polygon
  103267. */
  103268. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103269. /**
  103270. * Creates the VertexData of the IcoSphere
  103271. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103272. * * radius the radius of the IcoSphere, optional default 1
  103273. * * radiusX allows stretching in the x direction, optional, default radius
  103274. * * radiusY allows stretching in the y direction, optional, default radius
  103275. * * radiusZ allows stretching in the z direction, optional, default radius
  103276. * * flat when true creates a flat shaded mesh, optional, default true
  103277. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103279. * * 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)
  103280. * * 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)
  103281. * @returns the VertexData of the IcoSphere
  103282. */
  103283. static CreateIcoSphere(options: {
  103284. radius?: number;
  103285. radiusX?: number;
  103286. radiusY?: number;
  103287. radiusZ?: number;
  103288. flat?: boolean;
  103289. subdivisions?: number;
  103290. sideOrientation?: number;
  103291. frontUVs?: Vector4;
  103292. backUVs?: Vector4;
  103293. }): VertexData;
  103294. /**
  103295. * Creates the VertexData for a Polyhedron
  103296. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103297. * * type provided types are:
  103298. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103299. * * 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)
  103300. * * size the size of the IcoSphere, optional default 1
  103301. * * sizeX allows stretching in the x direction, optional, default size
  103302. * * sizeY allows stretching in the y direction, optional, default size
  103303. * * sizeZ allows stretching in the z direction, optional, default size
  103304. * * 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
  103305. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103306. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103307. * * flat when true creates a flat shaded mesh, optional, default true
  103308. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103310. * * 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)
  103311. * * 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)
  103312. * @returns the VertexData of the Polyhedron
  103313. */
  103314. static CreatePolyhedron(options: {
  103315. type?: number;
  103316. size?: number;
  103317. sizeX?: number;
  103318. sizeY?: number;
  103319. sizeZ?: number;
  103320. custom?: any;
  103321. faceUV?: Vector4[];
  103322. faceColors?: Color4[];
  103323. flat?: boolean;
  103324. sideOrientation?: number;
  103325. frontUVs?: Vector4;
  103326. backUVs?: Vector4;
  103327. }): VertexData;
  103328. /**
  103329. * Creates the VertexData for a TorusKnot
  103330. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103331. * * radius the radius of the torus knot, optional, default 2
  103332. * * tube the thickness of the tube, optional, default 0.5
  103333. * * radialSegments the number of sides on each tube segments, optional, default 32
  103334. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103335. * * p the number of windings around the z axis, optional, default 2
  103336. * * q the number of windings around the x axis, optional, default 3
  103337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103338. * * 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)
  103339. * * 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)
  103340. * @returns the VertexData of the Torus Knot
  103341. */
  103342. static CreateTorusKnot(options: {
  103343. radius?: number;
  103344. tube?: number;
  103345. radialSegments?: number;
  103346. tubularSegments?: number;
  103347. p?: number;
  103348. q?: number;
  103349. sideOrientation?: number;
  103350. frontUVs?: Vector4;
  103351. backUVs?: Vector4;
  103352. }): VertexData;
  103353. /**
  103354. * Compute normals for given positions and indices
  103355. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103356. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103357. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103358. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103359. * * facetNormals : optional array of facet normals (vector3)
  103360. * * facetPositions : optional array of facet positions (vector3)
  103361. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103362. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103363. * * bInfo : optional bounding info, required for facetPartitioning computation
  103364. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103365. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103366. * * useRightHandedSystem: optional boolean to for right handed system computation
  103367. * * depthSort : optional boolean to enable the facet depth sort computation
  103368. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103369. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103370. */
  103371. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103372. facetNormals?: any;
  103373. facetPositions?: any;
  103374. facetPartitioning?: any;
  103375. ratio?: number;
  103376. bInfo?: any;
  103377. bbSize?: Vector3;
  103378. subDiv?: any;
  103379. useRightHandedSystem?: boolean;
  103380. depthSort?: boolean;
  103381. distanceTo?: Vector3;
  103382. depthSortedFacets?: any;
  103383. }): void;
  103384. /** @hidden */
  103385. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103386. /**
  103387. * Applies VertexData created from the imported parameters to the geometry
  103388. * @param parsedVertexData the parsed data from an imported file
  103389. * @param geometry the geometry to apply the VertexData to
  103390. */
  103391. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103392. }
  103393. }
  103394. declare module BABYLON {
  103395. /**
  103396. * Defines a target to use with MorphTargetManager
  103397. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103398. */
  103399. export class MorphTarget implements IAnimatable {
  103400. /** defines the name of the target */
  103401. name: string;
  103402. /**
  103403. * Gets or sets the list of animations
  103404. */
  103405. animations: Animation[];
  103406. private _scene;
  103407. private _positions;
  103408. private _normals;
  103409. private _tangents;
  103410. private _uvs;
  103411. private _influence;
  103412. private _uniqueId;
  103413. /**
  103414. * Observable raised when the influence changes
  103415. */
  103416. onInfluenceChanged: Observable<boolean>;
  103417. /** @hidden */
  103418. _onDataLayoutChanged: Observable<void>;
  103419. /**
  103420. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103421. */
  103422. get influence(): number;
  103423. set influence(influence: number);
  103424. /**
  103425. * Gets or sets the id of the morph Target
  103426. */
  103427. id: string;
  103428. private _animationPropertiesOverride;
  103429. /**
  103430. * Gets or sets the animation properties override
  103431. */
  103432. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103433. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103434. /**
  103435. * Creates a new MorphTarget
  103436. * @param name defines the name of the target
  103437. * @param influence defines the influence to use
  103438. * @param scene defines the scene the morphtarget belongs to
  103439. */
  103440. constructor(
  103441. /** defines the name of the target */
  103442. name: string, influence?: number, scene?: Nullable<Scene>);
  103443. /**
  103444. * Gets the unique ID of this manager
  103445. */
  103446. get uniqueId(): number;
  103447. /**
  103448. * Gets a boolean defining if the target contains position data
  103449. */
  103450. get hasPositions(): boolean;
  103451. /**
  103452. * Gets a boolean defining if the target contains normal data
  103453. */
  103454. get hasNormals(): boolean;
  103455. /**
  103456. * Gets a boolean defining if the target contains tangent data
  103457. */
  103458. get hasTangents(): boolean;
  103459. /**
  103460. * Gets a boolean defining if the target contains texture coordinates data
  103461. */
  103462. get hasUVs(): boolean;
  103463. /**
  103464. * Affects position data to this target
  103465. * @param data defines the position data to use
  103466. */
  103467. setPositions(data: Nullable<FloatArray>): void;
  103468. /**
  103469. * Gets the position data stored in this target
  103470. * @returns a FloatArray containing the position data (or null if not present)
  103471. */
  103472. getPositions(): Nullable<FloatArray>;
  103473. /**
  103474. * Affects normal data to this target
  103475. * @param data defines the normal data to use
  103476. */
  103477. setNormals(data: Nullable<FloatArray>): void;
  103478. /**
  103479. * Gets the normal data stored in this target
  103480. * @returns a FloatArray containing the normal data (or null if not present)
  103481. */
  103482. getNormals(): Nullable<FloatArray>;
  103483. /**
  103484. * Affects tangent data to this target
  103485. * @param data defines the tangent data to use
  103486. */
  103487. setTangents(data: Nullable<FloatArray>): void;
  103488. /**
  103489. * Gets the tangent data stored in this target
  103490. * @returns a FloatArray containing the tangent data (or null if not present)
  103491. */
  103492. getTangents(): Nullable<FloatArray>;
  103493. /**
  103494. * Affects texture coordinates data to this target
  103495. * @param data defines the texture coordinates data to use
  103496. */
  103497. setUVs(data: Nullable<FloatArray>): void;
  103498. /**
  103499. * Gets the texture coordinates data stored in this target
  103500. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103501. */
  103502. getUVs(): Nullable<FloatArray>;
  103503. /**
  103504. * Clone the current target
  103505. * @returns a new MorphTarget
  103506. */
  103507. clone(): MorphTarget;
  103508. /**
  103509. * Serializes the current target into a Serialization object
  103510. * @returns the serialized object
  103511. */
  103512. serialize(): any;
  103513. /**
  103514. * Returns the string "MorphTarget"
  103515. * @returns "MorphTarget"
  103516. */
  103517. getClassName(): string;
  103518. /**
  103519. * Creates a new target from serialized data
  103520. * @param serializationObject defines the serialized data to use
  103521. * @returns a new MorphTarget
  103522. */
  103523. static Parse(serializationObject: any): MorphTarget;
  103524. /**
  103525. * Creates a MorphTarget from mesh data
  103526. * @param mesh defines the source mesh
  103527. * @param name defines the name to use for the new target
  103528. * @param influence defines the influence to attach to the target
  103529. * @returns a new MorphTarget
  103530. */
  103531. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103532. }
  103533. }
  103534. declare module BABYLON {
  103535. /**
  103536. * This class is used to deform meshes using morphing between different targets
  103537. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103538. */
  103539. export class MorphTargetManager {
  103540. private _targets;
  103541. private _targetInfluenceChangedObservers;
  103542. private _targetDataLayoutChangedObservers;
  103543. private _activeTargets;
  103544. private _scene;
  103545. private _influences;
  103546. private _supportsNormals;
  103547. private _supportsTangents;
  103548. private _supportsUVs;
  103549. private _vertexCount;
  103550. private _uniqueId;
  103551. private _tempInfluences;
  103552. /**
  103553. * Gets or sets a boolean indicating if normals must be morphed
  103554. */
  103555. enableNormalMorphing: boolean;
  103556. /**
  103557. * Gets or sets a boolean indicating if tangents must be morphed
  103558. */
  103559. enableTangentMorphing: boolean;
  103560. /**
  103561. * Gets or sets a boolean indicating if UV must be morphed
  103562. */
  103563. enableUVMorphing: boolean;
  103564. /**
  103565. * Creates a new MorphTargetManager
  103566. * @param scene defines the current scene
  103567. */
  103568. constructor(scene?: Nullable<Scene>);
  103569. /**
  103570. * Gets the unique ID of this manager
  103571. */
  103572. get uniqueId(): number;
  103573. /**
  103574. * Gets the number of vertices handled by this manager
  103575. */
  103576. get vertexCount(): number;
  103577. /**
  103578. * Gets a boolean indicating if this manager supports morphing of normals
  103579. */
  103580. get supportsNormals(): boolean;
  103581. /**
  103582. * Gets a boolean indicating if this manager supports morphing of tangents
  103583. */
  103584. get supportsTangents(): boolean;
  103585. /**
  103586. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103587. */
  103588. get supportsUVs(): boolean;
  103589. /**
  103590. * Gets the number of targets stored in this manager
  103591. */
  103592. get numTargets(): number;
  103593. /**
  103594. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103595. */
  103596. get numInfluencers(): number;
  103597. /**
  103598. * Gets the list of influences (one per target)
  103599. */
  103600. get influences(): Float32Array;
  103601. /**
  103602. * Gets the active target at specified index. An active target is a target with an influence > 0
  103603. * @param index defines the index to check
  103604. * @returns the requested target
  103605. */
  103606. getActiveTarget(index: number): MorphTarget;
  103607. /**
  103608. * Gets the target at specified index
  103609. * @param index defines the index to check
  103610. * @returns the requested target
  103611. */
  103612. getTarget(index: number): MorphTarget;
  103613. /**
  103614. * Add a new target to this manager
  103615. * @param target defines the target to add
  103616. */
  103617. addTarget(target: MorphTarget): void;
  103618. /**
  103619. * Removes a target from the manager
  103620. * @param target defines the target to remove
  103621. */
  103622. removeTarget(target: MorphTarget): void;
  103623. /**
  103624. * Clone the current manager
  103625. * @returns a new MorphTargetManager
  103626. */
  103627. clone(): MorphTargetManager;
  103628. /**
  103629. * Serializes the current manager into a Serialization object
  103630. * @returns the serialized object
  103631. */
  103632. serialize(): any;
  103633. private _syncActiveTargets;
  103634. /**
  103635. * Syncrhonize the targets with all the meshes using this morph target manager
  103636. */
  103637. synchronize(): void;
  103638. /**
  103639. * Creates a new MorphTargetManager from serialized data
  103640. * @param serializationObject defines the serialized data
  103641. * @param scene defines the hosting scene
  103642. * @returns the new MorphTargetManager
  103643. */
  103644. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * Class used to represent a specific level of detail of a mesh
  103650. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103651. */
  103652. export class MeshLODLevel {
  103653. /** Defines the distance where this level should start being displayed */
  103654. distance: number;
  103655. /** Defines the mesh to use to render this level */
  103656. mesh: Nullable<Mesh>;
  103657. /**
  103658. * Creates a new LOD level
  103659. * @param distance defines the distance where this level should star being displayed
  103660. * @param mesh defines the mesh to use to render this level
  103661. */
  103662. constructor(
  103663. /** Defines the distance where this level should start being displayed */
  103664. distance: number,
  103665. /** Defines the mesh to use to render this level */
  103666. mesh: Nullable<Mesh>);
  103667. }
  103668. }
  103669. declare module BABYLON {
  103670. /**
  103671. * Mesh representing the gorund
  103672. */
  103673. export class GroundMesh extends Mesh {
  103674. /** If octree should be generated */
  103675. generateOctree: boolean;
  103676. private _heightQuads;
  103677. /** @hidden */
  103678. _subdivisionsX: number;
  103679. /** @hidden */
  103680. _subdivisionsY: number;
  103681. /** @hidden */
  103682. _width: number;
  103683. /** @hidden */
  103684. _height: number;
  103685. /** @hidden */
  103686. _minX: number;
  103687. /** @hidden */
  103688. _maxX: number;
  103689. /** @hidden */
  103690. _minZ: number;
  103691. /** @hidden */
  103692. _maxZ: number;
  103693. constructor(name: string, scene: Scene);
  103694. /**
  103695. * "GroundMesh"
  103696. * @returns "GroundMesh"
  103697. */
  103698. getClassName(): string;
  103699. /**
  103700. * The minimum of x and y subdivisions
  103701. */
  103702. get subdivisions(): number;
  103703. /**
  103704. * X subdivisions
  103705. */
  103706. get subdivisionsX(): number;
  103707. /**
  103708. * Y subdivisions
  103709. */
  103710. get subdivisionsY(): number;
  103711. /**
  103712. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103713. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103714. * @param chunksCount the number of subdivisions for x and y
  103715. * @param octreeBlocksSize (Default: 32)
  103716. */
  103717. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103718. /**
  103719. * Returns a height (y) value in the Worl system :
  103720. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103721. * @param x x coordinate
  103722. * @param z z coordinate
  103723. * @returns the ground y position if (x, z) are outside the ground surface.
  103724. */
  103725. getHeightAtCoordinates(x: number, z: number): number;
  103726. /**
  103727. * Returns a normalized vector (Vector3) orthogonal to the ground
  103728. * at the ground coordinates (x, z) expressed in the World system.
  103729. * @param x x coordinate
  103730. * @param z z coordinate
  103731. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103732. */
  103733. getNormalAtCoordinates(x: number, z: number): Vector3;
  103734. /**
  103735. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103736. * at the ground coordinates (x, z) expressed in the World system.
  103737. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103738. * @param x x coordinate
  103739. * @param z z coordinate
  103740. * @param ref vector to store the result
  103741. * @returns the GroundMesh.
  103742. */
  103743. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103744. /**
  103745. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103746. * if the ground has been updated.
  103747. * This can be used in the render loop.
  103748. * @returns the GroundMesh.
  103749. */
  103750. updateCoordinateHeights(): GroundMesh;
  103751. private _getFacetAt;
  103752. private _initHeightQuads;
  103753. private _computeHeightQuads;
  103754. /**
  103755. * Serializes this ground mesh
  103756. * @param serializationObject object to write serialization to
  103757. */
  103758. serialize(serializationObject: any): void;
  103759. /**
  103760. * Parses a serialized ground mesh
  103761. * @param parsedMesh the serialized mesh
  103762. * @param scene the scene to create the ground mesh in
  103763. * @returns the created ground mesh
  103764. */
  103765. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103766. }
  103767. }
  103768. declare module BABYLON {
  103769. /**
  103770. * Interface for Physics-Joint data
  103771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103772. */
  103773. export interface PhysicsJointData {
  103774. /**
  103775. * The main pivot of the joint
  103776. */
  103777. mainPivot?: Vector3;
  103778. /**
  103779. * The connected pivot of the joint
  103780. */
  103781. connectedPivot?: Vector3;
  103782. /**
  103783. * The main axis of the joint
  103784. */
  103785. mainAxis?: Vector3;
  103786. /**
  103787. * The connected axis of the joint
  103788. */
  103789. connectedAxis?: Vector3;
  103790. /**
  103791. * The collision of the joint
  103792. */
  103793. collision?: boolean;
  103794. /**
  103795. * Native Oimo/Cannon/Energy data
  103796. */
  103797. nativeParams?: any;
  103798. }
  103799. /**
  103800. * This is a holder class for the physics joint created by the physics plugin
  103801. * It holds a set of functions to control the underlying joint
  103802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103803. */
  103804. export class PhysicsJoint {
  103805. /**
  103806. * The type of the physics joint
  103807. */
  103808. type: number;
  103809. /**
  103810. * The data for the physics joint
  103811. */
  103812. jointData: PhysicsJointData;
  103813. private _physicsJoint;
  103814. protected _physicsPlugin: IPhysicsEnginePlugin;
  103815. /**
  103816. * Initializes the physics joint
  103817. * @param type The type of the physics joint
  103818. * @param jointData The data for the physics joint
  103819. */
  103820. constructor(
  103821. /**
  103822. * The type of the physics joint
  103823. */
  103824. type: number,
  103825. /**
  103826. * The data for the physics joint
  103827. */
  103828. jointData: PhysicsJointData);
  103829. /**
  103830. * Gets the physics joint
  103831. */
  103832. get physicsJoint(): any;
  103833. /**
  103834. * Sets the physics joint
  103835. */
  103836. set physicsJoint(newJoint: any);
  103837. /**
  103838. * Sets the physics plugin
  103839. */
  103840. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103841. /**
  103842. * Execute a function that is physics-plugin specific.
  103843. * @param {Function} func the function that will be executed.
  103844. * It accepts two parameters: the physics world and the physics joint
  103845. */
  103846. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103847. /**
  103848. * Distance-Joint type
  103849. */
  103850. static DistanceJoint: number;
  103851. /**
  103852. * Hinge-Joint type
  103853. */
  103854. static HingeJoint: number;
  103855. /**
  103856. * Ball-and-Socket joint type
  103857. */
  103858. static BallAndSocketJoint: number;
  103859. /**
  103860. * Wheel-Joint type
  103861. */
  103862. static WheelJoint: number;
  103863. /**
  103864. * Slider-Joint type
  103865. */
  103866. static SliderJoint: number;
  103867. /**
  103868. * Prismatic-Joint type
  103869. */
  103870. static PrismaticJoint: number;
  103871. /**
  103872. * Universal-Joint type
  103873. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103874. */
  103875. static UniversalJoint: number;
  103876. /**
  103877. * Hinge-Joint 2 type
  103878. */
  103879. static Hinge2Joint: number;
  103880. /**
  103881. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103882. */
  103883. static PointToPointJoint: number;
  103884. /**
  103885. * Spring-Joint type
  103886. */
  103887. static SpringJoint: number;
  103888. /**
  103889. * Lock-Joint type
  103890. */
  103891. static LockJoint: number;
  103892. }
  103893. /**
  103894. * A class representing a physics distance joint
  103895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103896. */
  103897. export class DistanceJoint extends PhysicsJoint {
  103898. /**
  103899. *
  103900. * @param jointData The data for the Distance-Joint
  103901. */
  103902. constructor(jointData: DistanceJointData);
  103903. /**
  103904. * Update the predefined distance.
  103905. * @param maxDistance The maximum preferred distance
  103906. * @param minDistance The minimum preferred distance
  103907. */
  103908. updateDistance(maxDistance: number, minDistance?: number): void;
  103909. }
  103910. /**
  103911. * Represents a Motor-Enabled Joint
  103912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103913. */
  103914. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103915. /**
  103916. * Initializes the Motor-Enabled Joint
  103917. * @param type The type of the joint
  103918. * @param jointData The physica joint data for the joint
  103919. */
  103920. constructor(type: number, jointData: PhysicsJointData);
  103921. /**
  103922. * Set the motor values.
  103923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103924. * @param force the force to apply
  103925. * @param maxForce max force for this motor.
  103926. */
  103927. setMotor(force?: number, maxForce?: number): void;
  103928. /**
  103929. * Set the motor's limits.
  103930. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103931. * @param upperLimit The upper limit of the motor
  103932. * @param lowerLimit The lower limit of the motor
  103933. */
  103934. setLimit(upperLimit: number, lowerLimit?: number): void;
  103935. }
  103936. /**
  103937. * This class represents a single physics Hinge-Joint
  103938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103939. */
  103940. export class HingeJoint extends MotorEnabledJoint {
  103941. /**
  103942. * Initializes the Hinge-Joint
  103943. * @param jointData The joint data for the Hinge-Joint
  103944. */
  103945. constructor(jointData: PhysicsJointData);
  103946. /**
  103947. * Set the motor values.
  103948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103949. * @param {number} force the force to apply
  103950. * @param {number} maxForce max force for this motor.
  103951. */
  103952. setMotor(force?: number, maxForce?: number): void;
  103953. /**
  103954. * Set the motor's limits.
  103955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103956. * @param upperLimit The upper limit of the motor
  103957. * @param lowerLimit The lower limit of the motor
  103958. */
  103959. setLimit(upperLimit: number, lowerLimit?: number): void;
  103960. }
  103961. /**
  103962. * This class represents a dual hinge physics joint (same as wheel joint)
  103963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103964. */
  103965. export class Hinge2Joint extends MotorEnabledJoint {
  103966. /**
  103967. * Initializes the Hinge2-Joint
  103968. * @param jointData The joint data for the Hinge2-Joint
  103969. */
  103970. constructor(jointData: PhysicsJointData);
  103971. /**
  103972. * Set the motor values.
  103973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103974. * @param {number} targetSpeed the speed the motor is to reach
  103975. * @param {number} maxForce max force for this motor.
  103976. * @param {motorIndex} the motor's index, 0 or 1.
  103977. */
  103978. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103979. /**
  103980. * Set the motor limits.
  103981. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103982. * @param {number} upperLimit the upper limit
  103983. * @param {number} lowerLimit lower limit
  103984. * @param {motorIndex} the motor's index, 0 or 1.
  103985. */
  103986. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103987. }
  103988. /**
  103989. * Interface for a motor enabled joint
  103990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103991. */
  103992. export interface IMotorEnabledJoint {
  103993. /**
  103994. * Physics joint
  103995. */
  103996. physicsJoint: any;
  103997. /**
  103998. * Sets the motor of the motor-enabled joint
  103999. * @param force The force of the motor
  104000. * @param maxForce The maximum force of the motor
  104001. * @param motorIndex The index of the motor
  104002. */
  104003. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104004. /**
  104005. * Sets the limit of the motor
  104006. * @param upperLimit The upper limit of the motor
  104007. * @param lowerLimit The lower limit of the motor
  104008. * @param motorIndex The index of the motor
  104009. */
  104010. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104011. }
  104012. /**
  104013. * Joint data for a Distance-Joint
  104014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104015. */
  104016. export interface DistanceJointData extends PhysicsJointData {
  104017. /**
  104018. * Max distance the 2 joint objects can be apart
  104019. */
  104020. maxDistance: number;
  104021. }
  104022. /**
  104023. * Joint data from a spring joint
  104024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104025. */
  104026. export interface SpringJointData extends PhysicsJointData {
  104027. /**
  104028. * Length of the spring
  104029. */
  104030. length: number;
  104031. /**
  104032. * Stiffness of the spring
  104033. */
  104034. stiffness: number;
  104035. /**
  104036. * Damping of the spring
  104037. */
  104038. damping: number;
  104039. /** this callback will be called when applying the force to the impostors. */
  104040. forceApplicationCallback: () => void;
  104041. }
  104042. }
  104043. declare module BABYLON {
  104044. /**
  104045. * Holds the data for the raycast result
  104046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104047. */
  104048. export class PhysicsRaycastResult {
  104049. private _hasHit;
  104050. private _hitDistance;
  104051. private _hitNormalWorld;
  104052. private _hitPointWorld;
  104053. private _rayFromWorld;
  104054. private _rayToWorld;
  104055. /**
  104056. * Gets if there was a hit
  104057. */
  104058. get hasHit(): boolean;
  104059. /**
  104060. * Gets the distance from the hit
  104061. */
  104062. get hitDistance(): number;
  104063. /**
  104064. * Gets the hit normal/direction in the world
  104065. */
  104066. get hitNormalWorld(): Vector3;
  104067. /**
  104068. * Gets the hit point in the world
  104069. */
  104070. get hitPointWorld(): Vector3;
  104071. /**
  104072. * Gets the ray "start point" of the ray in the world
  104073. */
  104074. get rayFromWorld(): Vector3;
  104075. /**
  104076. * Gets the ray "end point" of the ray in the world
  104077. */
  104078. get rayToWorld(): Vector3;
  104079. /**
  104080. * Sets the hit data (normal & point in world space)
  104081. * @param hitNormalWorld defines the normal in world space
  104082. * @param hitPointWorld defines the point in world space
  104083. */
  104084. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104085. /**
  104086. * Sets the distance from the start point to the hit point
  104087. * @param distance
  104088. */
  104089. setHitDistance(distance: number): void;
  104090. /**
  104091. * Calculates the distance manually
  104092. */
  104093. calculateHitDistance(): void;
  104094. /**
  104095. * Resets all the values to default
  104096. * @param from The from point on world space
  104097. * @param to The to point on world space
  104098. */
  104099. reset(from?: Vector3, to?: Vector3): void;
  104100. }
  104101. /**
  104102. * Interface for the size containing width and height
  104103. */
  104104. interface IXYZ {
  104105. /**
  104106. * X
  104107. */
  104108. x: number;
  104109. /**
  104110. * Y
  104111. */
  104112. y: number;
  104113. /**
  104114. * Z
  104115. */
  104116. z: number;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /**
  104121. * Interface used to describe a physics joint
  104122. */
  104123. export interface PhysicsImpostorJoint {
  104124. /** Defines the main impostor to which the joint is linked */
  104125. mainImpostor: PhysicsImpostor;
  104126. /** Defines the impostor that is connected to the main impostor using this joint */
  104127. connectedImpostor: PhysicsImpostor;
  104128. /** Defines the joint itself */
  104129. joint: PhysicsJoint;
  104130. }
  104131. /** @hidden */
  104132. export interface IPhysicsEnginePlugin {
  104133. world: any;
  104134. name: string;
  104135. setGravity(gravity: Vector3): void;
  104136. setTimeStep(timeStep: number): void;
  104137. getTimeStep(): number;
  104138. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104139. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104140. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104141. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104142. removePhysicsBody(impostor: PhysicsImpostor): void;
  104143. generateJoint(joint: PhysicsImpostorJoint): void;
  104144. removeJoint(joint: PhysicsImpostorJoint): void;
  104145. isSupported(): boolean;
  104146. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104147. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104148. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104149. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104150. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104151. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104152. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104153. getBodyMass(impostor: PhysicsImpostor): number;
  104154. getBodyFriction(impostor: PhysicsImpostor): number;
  104155. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104156. getBodyRestitution(impostor: PhysicsImpostor): number;
  104157. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104158. getBodyPressure?(impostor: PhysicsImpostor): number;
  104159. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104160. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104161. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104162. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104163. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104164. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104165. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104166. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104167. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104168. sleepBody(impostor: PhysicsImpostor): void;
  104169. wakeUpBody(impostor: PhysicsImpostor): void;
  104170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104171. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104172. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104173. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104174. getRadius(impostor: PhysicsImpostor): number;
  104175. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104176. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104177. dispose(): void;
  104178. }
  104179. /**
  104180. * Interface used to define a physics engine
  104181. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104182. */
  104183. export interface IPhysicsEngine {
  104184. /**
  104185. * Gets the gravity vector used by the simulation
  104186. */
  104187. gravity: Vector3;
  104188. /**
  104189. * Sets the gravity vector used by the simulation
  104190. * @param gravity defines the gravity vector to use
  104191. */
  104192. setGravity(gravity: Vector3): void;
  104193. /**
  104194. * Set the time step of the physics engine.
  104195. * Default is 1/60.
  104196. * To slow it down, enter 1/600 for example.
  104197. * To speed it up, 1/30
  104198. * @param newTimeStep the new timestep to apply to this world.
  104199. */
  104200. setTimeStep(newTimeStep: number): void;
  104201. /**
  104202. * Get the time step of the physics engine.
  104203. * @returns the current time step
  104204. */
  104205. getTimeStep(): number;
  104206. /**
  104207. * Set the sub time step of the physics engine.
  104208. * Default is 0 meaning there is no sub steps
  104209. * To increase physics resolution precision, set a small value (like 1 ms)
  104210. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104211. */
  104212. setSubTimeStep(subTimeStep: number): void;
  104213. /**
  104214. * Get the sub time step of the physics engine.
  104215. * @returns the current sub time step
  104216. */
  104217. getSubTimeStep(): number;
  104218. /**
  104219. * Release all resources
  104220. */
  104221. dispose(): void;
  104222. /**
  104223. * Gets the name of the current physics plugin
  104224. * @returns the name of the plugin
  104225. */
  104226. getPhysicsPluginName(): string;
  104227. /**
  104228. * Adding a new impostor for the impostor tracking.
  104229. * This will be done by the impostor itself.
  104230. * @param impostor the impostor to add
  104231. */
  104232. addImpostor(impostor: PhysicsImpostor): void;
  104233. /**
  104234. * Remove an impostor from the engine.
  104235. * This impostor and its mesh will not longer be updated by the physics engine.
  104236. * @param impostor the impostor to remove
  104237. */
  104238. removeImpostor(impostor: PhysicsImpostor): void;
  104239. /**
  104240. * Add a joint to the physics engine
  104241. * @param mainImpostor defines the main impostor to which the joint is added.
  104242. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104243. * @param joint defines the joint that will connect both impostors.
  104244. */
  104245. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104246. /**
  104247. * Removes a joint from the simulation
  104248. * @param mainImpostor defines the impostor used with the joint
  104249. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104250. * @param joint defines the joint to remove
  104251. */
  104252. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104253. /**
  104254. * Gets the current plugin used to run the simulation
  104255. * @returns current plugin
  104256. */
  104257. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104258. /**
  104259. * Gets the list of physic impostors
  104260. * @returns an array of PhysicsImpostor
  104261. */
  104262. getImpostors(): Array<PhysicsImpostor>;
  104263. /**
  104264. * Gets the impostor for a physics enabled object
  104265. * @param object defines the object impersonated by the impostor
  104266. * @returns the PhysicsImpostor or null if not found
  104267. */
  104268. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104269. /**
  104270. * Gets the impostor for a physics body object
  104271. * @param body defines physics body used by the impostor
  104272. * @returns the PhysicsImpostor or null if not found
  104273. */
  104274. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104275. /**
  104276. * Does a raycast in the physics world
  104277. * @param from when should the ray start?
  104278. * @param to when should the ray end?
  104279. * @returns PhysicsRaycastResult
  104280. */
  104281. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104282. /**
  104283. * Called by the scene. No need to call it.
  104284. * @param delta defines the timespam between frames
  104285. */
  104286. _step(delta: number): void;
  104287. }
  104288. }
  104289. declare module BABYLON {
  104290. /**
  104291. * The interface for the physics imposter parameters
  104292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104293. */
  104294. export interface PhysicsImpostorParameters {
  104295. /**
  104296. * The mass of the physics imposter
  104297. */
  104298. mass: number;
  104299. /**
  104300. * The friction of the physics imposter
  104301. */
  104302. friction?: number;
  104303. /**
  104304. * The coefficient of restitution of the physics imposter
  104305. */
  104306. restitution?: number;
  104307. /**
  104308. * The native options of the physics imposter
  104309. */
  104310. nativeOptions?: any;
  104311. /**
  104312. * Specifies if the parent should be ignored
  104313. */
  104314. ignoreParent?: boolean;
  104315. /**
  104316. * Specifies if bi-directional transformations should be disabled
  104317. */
  104318. disableBidirectionalTransformation?: boolean;
  104319. /**
  104320. * The pressure inside the physics imposter, soft object only
  104321. */
  104322. pressure?: number;
  104323. /**
  104324. * The stiffness the physics imposter, soft object only
  104325. */
  104326. stiffness?: number;
  104327. /**
  104328. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104329. */
  104330. velocityIterations?: number;
  104331. /**
  104332. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104333. */
  104334. positionIterations?: number;
  104335. /**
  104336. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104337. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104338. * Add to fix multiple points
  104339. */
  104340. fixedPoints?: number;
  104341. /**
  104342. * The collision margin around a soft object
  104343. */
  104344. margin?: number;
  104345. /**
  104346. * The collision margin around a soft object
  104347. */
  104348. damping?: number;
  104349. /**
  104350. * The path for a rope based on an extrusion
  104351. */
  104352. path?: any;
  104353. /**
  104354. * The shape of an extrusion used for a rope based on an extrusion
  104355. */
  104356. shape?: any;
  104357. }
  104358. /**
  104359. * Interface for a physics-enabled object
  104360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104361. */
  104362. export interface IPhysicsEnabledObject {
  104363. /**
  104364. * The position of the physics-enabled object
  104365. */
  104366. position: Vector3;
  104367. /**
  104368. * The rotation of the physics-enabled object
  104369. */
  104370. rotationQuaternion: Nullable<Quaternion>;
  104371. /**
  104372. * The scale of the physics-enabled object
  104373. */
  104374. scaling: Vector3;
  104375. /**
  104376. * The rotation of the physics-enabled object
  104377. */
  104378. rotation?: Vector3;
  104379. /**
  104380. * The parent of the physics-enabled object
  104381. */
  104382. parent?: any;
  104383. /**
  104384. * The bounding info of the physics-enabled object
  104385. * @returns The bounding info of the physics-enabled object
  104386. */
  104387. getBoundingInfo(): BoundingInfo;
  104388. /**
  104389. * Computes the world matrix
  104390. * @param force Specifies if the world matrix should be computed by force
  104391. * @returns A world matrix
  104392. */
  104393. computeWorldMatrix(force: boolean): Matrix;
  104394. /**
  104395. * Gets the world matrix
  104396. * @returns A world matrix
  104397. */
  104398. getWorldMatrix?(): Matrix;
  104399. /**
  104400. * Gets the child meshes
  104401. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104402. * @returns An array of abstract meshes
  104403. */
  104404. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104405. /**
  104406. * Gets the vertex data
  104407. * @param kind The type of vertex data
  104408. * @returns A nullable array of numbers, or a float32 array
  104409. */
  104410. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104411. /**
  104412. * Gets the indices from the mesh
  104413. * @returns A nullable array of index arrays
  104414. */
  104415. getIndices?(): Nullable<IndicesArray>;
  104416. /**
  104417. * Gets the scene from the mesh
  104418. * @returns the indices array or null
  104419. */
  104420. getScene?(): Scene;
  104421. /**
  104422. * Gets the absolute position from the mesh
  104423. * @returns the absolute position
  104424. */
  104425. getAbsolutePosition(): Vector3;
  104426. /**
  104427. * Gets the absolute pivot point from the mesh
  104428. * @returns the absolute pivot point
  104429. */
  104430. getAbsolutePivotPoint(): Vector3;
  104431. /**
  104432. * Rotates the mesh
  104433. * @param axis The axis of rotation
  104434. * @param amount The amount of rotation
  104435. * @param space The space of the rotation
  104436. * @returns The rotation transform node
  104437. */
  104438. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104439. /**
  104440. * Translates the mesh
  104441. * @param axis The axis of translation
  104442. * @param distance The distance of translation
  104443. * @param space The space of the translation
  104444. * @returns The transform node
  104445. */
  104446. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104447. /**
  104448. * Sets the absolute position of the mesh
  104449. * @param absolutePosition The absolute position of the mesh
  104450. * @returns The transform node
  104451. */
  104452. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104453. /**
  104454. * Gets the class name of the mesh
  104455. * @returns The class name
  104456. */
  104457. getClassName(): string;
  104458. }
  104459. /**
  104460. * Represents a physics imposter
  104461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104462. */
  104463. export class PhysicsImpostor {
  104464. /**
  104465. * The physics-enabled object used as the physics imposter
  104466. */
  104467. object: IPhysicsEnabledObject;
  104468. /**
  104469. * The type of the physics imposter
  104470. */
  104471. type: number;
  104472. private _options;
  104473. private _scene?;
  104474. /**
  104475. * The default object size of the imposter
  104476. */
  104477. static DEFAULT_OBJECT_SIZE: Vector3;
  104478. /**
  104479. * The identity quaternion of the imposter
  104480. */
  104481. static IDENTITY_QUATERNION: Quaternion;
  104482. /** @hidden */
  104483. _pluginData: any;
  104484. private _physicsEngine;
  104485. private _physicsBody;
  104486. private _bodyUpdateRequired;
  104487. private _onBeforePhysicsStepCallbacks;
  104488. private _onAfterPhysicsStepCallbacks;
  104489. /** @hidden */
  104490. _onPhysicsCollideCallbacks: Array<{
  104491. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104492. otherImpostors: Array<PhysicsImpostor>;
  104493. }>;
  104494. private _deltaPosition;
  104495. private _deltaRotation;
  104496. private _deltaRotationConjugated;
  104497. /** @hidden */
  104498. _isFromLine: boolean;
  104499. private _parent;
  104500. private _isDisposed;
  104501. private static _tmpVecs;
  104502. private static _tmpQuat;
  104503. /**
  104504. * Specifies if the physics imposter is disposed
  104505. */
  104506. get isDisposed(): boolean;
  104507. /**
  104508. * Gets the mass of the physics imposter
  104509. */
  104510. get mass(): number;
  104511. set mass(value: number);
  104512. /**
  104513. * Gets the coefficient of friction
  104514. */
  104515. get friction(): number;
  104516. /**
  104517. * Sets the coefficient of friction
  104518. */
  104519. set friction(value: number);
  104520. /**
  104521. * Gets the coefficient of restitution
  104522. */
  104523. get restitution(): number;
  104524. /**
  104525. * Sets the coefficient of restitution
  104526. */
  104527. set restitution(value: number);
  104528. /**
  104529. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104530. */
  104531. get pressure(): number;
  104532. /**
  104533. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104534. */
  104535. set pressure(value: number);
  104536. /**
  104537. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104538. */
  104539. get stiffness(): number;
  104540. /**
  104541. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104542. */
  104543. set stiffness(value: number);
  104544. /**
  104545. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104546. */
  104547. get velocityIterations(): number;
  104548. /**
  104549. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104550. */
  104551. set velocityIterations(value: number);
  104552. /**
  104553. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104554. */
  104555. get positionIterations(): number;
  104556. /**
  104557. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104558. */
  104559. set positionIterations(value: number);
  104560. /**
  104561. * The unique id of the physics imposter
  104562. * set by the physics engine when adding this impostor to the array
  104563. */
  104564. uniqueId: number;
  104565. /**
  104566. * @hidden
  104567. */
  104568. soft: boolean;
  104569. /**
  104570. * @hidden
  104571. */
  104572. segments: number;
  104573. private _joints;
  104574. /**
  104575. * Initializes the physics imposter
  104576. * @param object The physics-enabled object used as the physics imposter
  104577. * @param type The type of the physics imposter
  104578. * @param _options The options for the physics imposter
  104579. * @param _scene The Babylon scene
  104580. */
  104581. constructor(
  104582. /**
  104583. * The physics-enabled object used as the physics imposter
  104584. */
  104585. object: IPhysicsEnabledObject,
  104586. /**
  104587. * The type of the physics imposter
  104588. */
  104589. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104590. /**
  104591. * This function will completly initialize this impostor.
  104592. * It will create a new body - but only if this mesh has no parent.
  104593. * If it has, this impostor will not be used other than to define the impostor
  104594. * of the child mesh.
  104595. * @hidden
  104596. */
  104597. _init(): void;
  104598. private _getPhysicsParent;
  104599. /**
  104600. * Should a new body be generated.
  104601. * @returns boolean specifying if body initialization is required
  104602. */
  104603. isBodyInitRequired(): boolean;
  104604. /**
  104605. * Sets the updated scaling
  104606. * @param updated Specifies if the scaling is updated
  104607. */
  104608. setScalingUpdated(): void;
  104609. /**
  104610. * Force a regeneration of this or the parent's impostor's body.
  104611. * Use under cautious - This will remove all joints already implemented.
  104612. */
  104613. forceUpdate(): void;
  104614. /**
  104615. * Gets the body that holds this impostor. Either its own, or its parent.
  104616. */
  104617. get physicsBody(): any;
  104618. /**
  104619. * Get the parent of the physics imposter
  104620. * @returns Physics imposter or null
  104621. */
  104622. get parent(): Nullable<PhysicsImpostor>;
  104623. /**
  104624. * Sets the parent of the physics imposter
  104625. */
  104626. set parent(value: Nullable<PhysicsImpostor>);
  104627. /**
  104628. * Set the physics body. Used mainly by the physics engine/plugin
  104629. */
  104630. set physicsBody(physicsBody: any);
  104631. /**
  104632. * Resets the update flags
  104633. */
  104634. resetUpdateFlags(): void;
  104635. /**
  104636. * Gets the object extend size
  104637. * @returns the object extend size
  104638. */
  104639. getObjectExtendSize(): Vector3;
  104640. /**
  104641. * Gets the object center
  104642. * @returns The object center
  104643. */
  104644. getObjectCenter(): Vector3;
  104645. /**
  104646. * Get a specific parameter from the options parameters
  104647. * @param paramName The object parameter name
  104648. * @returns The object parameter
  104649. */
  104650. getParam(paramName: string): any;
  104651. /**
  104652. * Sets a specific parameter in the options given to the physics plugin
  104653. * @param paramName The parameter name
  104654. * @param value The value of the parameter
  104655. */
  104656. setParam(paramName: string, value: number): void;
  104657. /**
  104658. * Specifically change the body's mass option. Won't recreate the physics body object
  104659. * @param mass The mass of the physics imposter
  104660. */
  104661. setMass(mass: number): void;
  104662. /**
  104663. * Gets the linear velocity
  104664. * @returns linear velocity or null
  104665. */
  104666. getLinearVelocity(): Nullable<Vector3>;
  104667. /**
  104668. * Sets the linear velocity
  104669. * @param velocity linear velocity or null
  104670. */
  104671. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104672. /**
  104673. * Gets the angular velocity
  104674. * @returns angular velocity or null
  104675. */
  104676. getAngularVelocity(): Nullable<Vector3>;
  104677. /**
  104678. * Sets the angular velocity
  104679. * @param velocity The velocity or null
  104680. */
  104681. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104682. /**
  104683. * Execute a function with the physics plugin native code
  104684. * Provide a function the will have two variables - the world object and the physics body object
  104685. * @param func The function to execute with the physics plugin native code
  104686. */
  104687. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104688. /**
  104689. * Register a function that will be executed before the physics world is stepping forward
  104690. * @param func The function to execute before the physics world is stepped forward
  104691. */
  104692. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104693. /**
  104694. * Unregister a function that will be executed before the physics world is stepping forward
  104695. * @param func The function to execute before the physics world is stepped forward
  104696. */
  104697. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104698. /**
  104699. * Register a function that will be executed after the physics step
  104700. * @param func The function to execute after physics step
  104701. */
  104702. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104703. /**
  104704. * Unregisters a function that will be executed after the physics step
  104705. * @param func The function to execute after physics step
  104706. */
  104707. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104708. /**
  104709. * register a function that will be executed when this impostor collides against a different body
  104710. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104711. * @param func Callback that is executed on collision
  104712. */
  104713. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104714. /**
  104715. * Unregisters the physics imposter on contact
  104716. * @param collideAgainst The physics object to collide against
  104717. * @param func Callback to execute on collision
  104718. */
  104719. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104720. private _tmpQuat;
  104721. private _tmpQuat2;
  104722. /**
  104723. * Get the parent rotation
  104724. * @returns The parent rotation
  104725. */
  104726. getParentsRotation(): Quaternion;
  104727. /**
  104728. * this function is executed by the physics engine.
  104729. */
  104730. beforeStep: () => void;
  104731. /**
  104732. * this function is executed by the physics engine
  104733. */
  104734. afterStep: () => void;
  104735. /**
  104736. * Legacy collision detection event support
  104737. */
  104738. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104739. /**
  104740. * event and body object due to cannon's event-based architecture.
  104741. */
  104742. onCollide: (e: {
  104743. body: any;
  104744. }) => void;
  104745. /**
  104746. * Apply a force
  104747. * @param force The force to apply
  104748. * @param contactPoint The contact point for the force
  104749. * @returns The physics imposter
  104750. */
  104751. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104752. /**
  104753. * Apply an impulse
  104754. * @param force The impulse force
  104755. * @param contactPoint The contact point for the impulse force
  104756. * @returns The physics imposter
  104757. */
  104758. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104759. /**
  104760. * A help function to create a joint
  104761. * @param otherImpostor A physics imposter used to create a joint
  104762. * @param jointType The type of joint
  104763. * @param jointData The data for the joint
  104764. * @returns The physics imposter
  104765. */
  104766. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104767. /**
  104768. * Add a joint to this impostor with a different impostor
  104769. * @param otherImpostor A physics imposter used to add a joint
  104770. * @param joint The joint to add
  104771. * @returns The physics imposter
  104772. */
  104773. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104774. /**
  104775. * Add an anchor to a cloth impostor
  104776. * @param otherImpostor rigid impostor to anchor to
  104777. * @param width ratio across width from 0 to 1
  104778. * @param height ratio up height from 0 to 1
  104779. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104780. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104781. * @returns impostor the soft imposter
  104782. */
  104783. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104784. /**
  104785. * Add a hook to a rope impostor
  104786. * @param otherImpostor rigid impostor to anchor to
  104787. * @param length ratio across rope from 0 to 1
  104788. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104789. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104790. * @returns impostor the rope imposter
  104791. */
  104792. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104793. /**
  104794. * Will keep this body still, in a sleep mode.
  104795. * @returns the physics imposter
  104796. */
  104797. sleep(): PhysicsImpostor;
  104798. /**
  104799. * Wake the body up.
  104800. * @returns The physics imposter
  104801. */
  104802. wakeUp(): PhysicsImpostor;
  104803. /**
  104804. * Clones the physics imposter
  104805. * @param newObject The physics imposter clones to this physics-enabled object
  104806. * @returns A nullable physics imposter
  104807. */
  104808. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104809. /**
  104810. * Disposes the physics imposter
  104811. */
  104812. dispose(): void;
  104813. /**
  104814. * Sets the delta position
  104815. * @param position The delta position amount
  104816. */
  104817. setDeltaPosition(position: Vector3): void;
  104818. /**
  104819. * Sets the delta rotation
  104820. * @param rotation The delta rotation amount
  104821. */
  104822. setDeltaRotation(rotation: Quaternion): void;
  104823. /**
  104824. * Gets the box size of the physics imposter and stores the result in the input parameter
  104825. * @param result Stores the box size
  104826. * @returns The physics imposter
  104827. */
  104828. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104829. /**
  104830. * Gets the radius of the physics imposter
  104831. * @returns Radius of the physics imposter
  104832. */
  104833. getRadius(): number;
  104834. /**
  104835. * Sync a bone with this impostor
  104836. * @param bone The bone to sync to the impostor.
  104837. * @param boneMesh The mesh that the bone is influencing.
  104838. * @param jointPivot The pivot of the joint / bone in local space.
  104839. * @param distToJoint Optional distance from the impostor to the joint.
  104840. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104841. */
  104842. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104843. /**
  104844. * Sync impostor to a bone
  104845. * @param bone The bone that the impostor will be synced to.
  104846. * @param boneMesh The mesh that the bone is influencing.
  104847. * @param jointPivot The pivot of the joint / bone in local space.
  104848. * @param distToJoint Optional distance from the impostor to the joint.
  104849. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104850. * @param boneAxis Optional vector3 axis the bone is aligned with
  104851. */
  104852. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104853. /**
  104854. * No-Imposter type
  104855. */
  104856. static NoImpostor: number;
  104857. /**
  104858. * Sphere-Imposter type
  104859. */
  104860. static SphereImpostor: number;
  104861. /**
  104862. * Box-Imposter type
  104863. */
  104864. static BoxImpostor: number;
  104865. /**
  104866. * Plane-Imposter type
  104867. */
  104868. static PlaneImpostor: number;
  104869. /**
  104870. * Mesh-imposter type
  104871. */
  104872. static MeshImpostor: number;
  104873. /**
  104874. * Capsule-Impostor type (Ammo.js plugin only)
  104875. */
  104876. static CapsuleImpostor: number;
  104877. /**
  104878. * Cylinder-Imposter type
  104879. */
  104880. static CylinderImpostor: number;
  104881. /**
  104882. * Particle-Imposter type
  104883. */
  104884. static ParticleImpostor: number;
  104885. /**
  104886. * Heightmap-Imposter type
  104887. */
  104888. static HeightmapImpostor: number;
  104889. /**
  104890. * ConvexHull-Impostor type (Ammo.js plugin only)
  104891. */
  104892. static ConvexHullImpostor: number;
  104893. /**
  104894. * Custom-Imposter type (Ammo.js plugin only)
  104895. */
  104896. static CustomImpostor: number;
  104897. /**
  104898. * Rope-Imposter type
  104899. */
  104900. static RopeImpostor: number;
  104901. /**
  104902. * Cloth-Imposter type
  104903. */
  104904. static ClothImpostor: number;
  104905. /**
  104906. * Softbody-Imposter type
  104907. */
  104908. static SoftbodyImpostor: number;
  104909. }
  104910. }
  104911. declare module BABYLON {
  104912. /**
  104913. * @hidden
  104914. **/
  104915. export class _CreationDataStorage {
  104916. closePath?: boolean;
  104917. closeArray?: boolean;
  104918. idx: number[];
  104919. dashSize: number;
  104920. gapSize: number;
  104921. path3D: Path3D;
  104922. pathArray: Vector3[][];
  104923. arc: number;
  104924. radius: number;
  104925. cap: number;
  104926. tessellation: number;
  104927. }
  104928. /**
  104929. * @hidden
  104930. **/
  104931. class _InstanceDataStorage {
  104932. visibleInstances: any;
  104933. batchCache: _InstancesBatch;
  104934. instancesBufferSize: number;
  104935. instancesBuffer: Nullable<Buffer>;
  104936. instancesData: Float32Array;
  104937. overridenInstanceCount: number;
  104938. isFrozen: boolean;
  104939. previousBatch: Nullable<_InstancesBatch>;
  104940. hardwareInstancedRendering: boolean;
  104941. sideOrientation: number;
  104942. manualUpdate: boolean;
  104943. }
  104944. /**
  104945. * @hidden
  104946. **/
  104947. export class _InstancesBatch {
  104948. mustReturn: boolean;
  104949. visibleInstances: Nullable<InstancedMesh[]>[];
  104950. renderSelf: boolean[];
  104951. hardwareInstancedRendering: boolean[];
  104952. }
  104953. /**
  104954. * @hidden
  104955. **/
  104956. class _ThinInstanceDataStorage {
  104957. instancesCount: number;
  104958. matrixBuffer: Nullable<Buffer>;
  104959. matrixBufferSize: number;
  104960. matrixData: Nullable<Float32Array>;
  104961. boundingVectors: Array<Vector3>;
  104962. }
  104963. /**
  104964. * Class used to represent renderable models
  104965. */
  104966. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104967. /**
  104968. * Mesh side orientation : usually the external or front surface
  104969. */
  104970. static readonly FRONTSIDE: number;
  104971. /**
  104972. * Mesh side orientation : usually the internal or back surface
  104973. */
  104974. static readonly BACKSIDE: number;
  104975. /**
  104976. * Mesh side orientation : both internal and external or front and back surfaces
  104977. */
  104978. static readonly DOUBLESIDE: number;
  104979. /**
  104980. * Mesh side orientation : by default, `FRONTSIDE`
  104981. */
  104982. static readonly DEFAULTSIDE: number;
  104983. /**
  104984. * Mesh cap setting : no cap
  104985. */
  104986. static readonly NO_CAP: number;
  104987. /**
  104988. * Mesh cap setting : one cap at the beginning of the mesh
  104989. */
  104990. static readonly CAP_START: number;
  104991. /**
  104992. * Mesh cap setting : one cap at the end of the mesh
  104993. */
  104994. static readonly CAP_END: number;
  104995. /**
  104996. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104997. */
  104998. static readonly CAP_ALL: number;
  104999. /**
  105000. * Mesh pattern setting : no flip or rotate
  105001. */
  105002. static readonly NO_FLIP: number;
  105003. /**
  105004. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105005. */
  105006. static readonly FLIP_TILE: number;
  105007. /**
  105008. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105009. */
  105010. static readonly ROTATE_TILE: number;
  105011. /**
  105012. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105013. */
  105014. static readonly FLIP_ROW: number;
  105015. /**
  105016. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105017. */
  105018. static readonly ROTATE_ROW: number;
  105019. /**
  105020. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105021. */
  105022. static readonly FLIP_N_ROTATE_TILE: number;
  105023. /**
  105024. * Mesh pattern setting : rotate pattern and rotate
  105025. */
  105026. static readonly FLIP_N_ROTATE_ROW: number;
  105027. /**
  105028. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105029. */
  105030. static readonly CENTER: number;
  105031. /**
  105032. * Mesh tile positioning : part tiles on left
  105033. */
  105034. static readonly LEFT: number;
  105035. /**
  105036. * Mesh tile positioning : part tiles on right
  105037. */
  105038. static readonly RIGHT: number;
  105039. /**
  105040. * Mesh tile positioning : part tiles on top
  105041. */
  105042. static readonly TOP: number;
  105043. /**
  105044. * Mesh tile positioning : part tiles on bottom
  105045. */
  105046. static readonly BOTTOM: number;
  105047. /**
  105048. * Gets the default side orientation.
  105049. * @param orientation the orientation to value to attempt to get
  105050. * @returns the default orientation
  105051. * @hidden
  105052. */
  105053. static _GetDefaultSideOrientation(orientation?: number): number;
  105054. private _internalMeshDataInfo;
  105055. /**
  105056. * An event triggered before rendering the mesh
  105057. */
  105058. get onBeforeRenderObservable(): Observable<Mesh>;
  105059. /**
  105060. * An event triggered before binding the mesh
  105061. */
  105062. get onBeforeBindObservable(): Observable<Mesh>;
  105063. /**
  105064. * An event triggered after rendering the mesh
  105065. */
  105066. get onAfterRenderObservable(): Observable<Mesh>;
  105067. /**
  105068. * An event triggered before drawing the mesh
  105069. */
  105070. get onBeforeDrawObservable(): Observable<Mesh>;
  105071. private _onBeforeDrawObserver;
  105072. /**
  105073. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105074. */
  105075. set onBeforeDraw(callback: () => void);
  105076. get hasInstances(): boolean;
  105077. get hasThinInstances(): boolean;
  105078. /**
  105079. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105080. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105081. */
  105082. delayLoadState: number;
  105083. /**
  105084. * Gets the list of instances created from this mesh
  105085. * it is not supposed to be modified manually.
  105086. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105087. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105088. */
  105089. instances: InstancedMesh[];
  105090. /**
  105091. * Gets the file containing delay loading data for this mesh
  105092. */
  105093. delayLoadingFile: string;
  105094. /** @hidden */
  105095. _binaryInfo: any;
  105096. /**
  105097. * User defined function used to change how LOD level selection is done
  105098. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  105099. */
  105100. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105101. /**
  105102. * Gets or sets the morph target manager
  105103. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105104. */
  105105. get morphTargetManager(): Nullable<MorphTargetManager>;
  105106. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105107. /** @hidden */
  105108. _creationDataStorage: Nullable<_CreationDataStorage>;
  105109. /** @hidden */
  105110. _geometry: Nullable<Geometry>;
  105111. /** @hidden */
  105112. _delayInfo: Array<string>;
  105113. /** @hidden */
  105114. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105115. /** @hidden */
  105116. _instanceDataStorage: _InstanceDataStorage;
  105117. /** @hidden */
  105118. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105119. private _effectiveMaterial;
  105120. /** @hidden */
  105121. _shouldGenerateFlatShading: boolean;
  105122. /** @hidden */
  105123. _originalBuilderSideOrientation: number;
  105124. /**
  105125. * Use this property to change the original side orientation defined at construction time
  105126. */
  105127. overrideMaterialSideOrientation: Nullable<number>;
  105128. /**
  105129. * Gets the source mesh (the one used to clone this one from)
  105130. */
  105131. get source(): Nullable<Mesh>;
  105132. /**
  105133. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105134. */
  105135. get isUnIndexed(): boolean;
  105136. set isUnIndexed(value: boolean);
  105137. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105138. get worldMatrixInstancedBuffer(): Float32Array;
  105139. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105140. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105141. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105142. /**
  105143. * @constructor
  105144. * @param name The value used by scene.getMeshByName() to do a lookup.
  105145. * @param scene The scene to add this mesh to.
  105146. * @param parent The parent of this mesh, if it has one
  105147. * @param source An optional Mesh from which geometry is shared, cloned.
  105148. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105149. * When false, achieved by calling a clone(), also passing False.
  105150. * This will make creation of children, recursive.
  105151. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105152. */
  105153. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105154. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105155. doNotInstantiate: boolean;
  105156. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105157. /**
  105158. * Gets the class name
  105159. * @returns the string "Mesh".
  105160. */
  105161. getClassName(): string;
  105162. /** @hidden */
  105163. get _isMesh(): boolean;
  105164. /**
  105165. * Returns a description of this mesh
  105166. * @param fullDetails define if full details about this mesh must be used
  105167. * @returns a descriptive string representing this mesh
  105168. */
  105169. toString(fullDetails?: boolean): string;
  105170. /** @hidden */
  105171. _unBindEffect(): void;
  105172. /**
  105173. * Gets a boolean indicating if this mesh has LOD
  105174. */
  105175. get hasLODLevels(): boolean;
  105176. /**
  105177. * Gets the list of MeshLODLevel associated with the current mesh
  105178. * @returns an array of MeshLODLevel
  105179. */
  105180. getLODLevels(): MeshLODLevel[];
  105181. private _sortLODLevels;
  105182. /**
  105183. * Add a mesh as LOD level triggered at the given distance.
  105184. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105185. * @param distance The distance from the center of the object to show this level
  105186. * @param mesh The mesh to be added as LOD level (can be null)
  105187. * @return This mesh (for chaining)
  105188. */
  105189. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105190. /**
  105191. * Returns the LOD level mesh at the passed distance or null if not found.
  105192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105193. * @param distance The distance from the center of the object to show this level
  105194. * @returns a Mesh or `null`
  105195. */
  105196. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105197. /**
  105198. * Remove a mesh from the LOD array
  105199. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105200. * @param mesh defines the mesh to be removed
  105201. * @return This mesh (for chaining)
  105202. */
  105203. removeLODLevel(mesh: Mesh): Mesh;
  105204. /**
  105205. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105206. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105207. * @param camera defines the camera to use to compute distance
  105208. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105209. * @return This mesh (for chaining)
  105210. */
  105211. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105212. /**
  105213. * Gets the mesh internal Geometry object
  105214. */
  105215. get geometry(): Nullable<Geometry>;
  105216. /**
  105217. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105218. * @returns the total number of vertices
  105219. */
  105220. getTotalVertices(): number;
  105221. /**
  105222. * Returns the content of an associated vertex buffer
  105223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105224. * - VertexBuffer.PositionKind
  105225. * - VertexBuffer.UVKind
  105226. * - VertexBuffer.UV2Kind
  105227. * - VertexBuffer.UV3Kind
  105228. * - VertexBuffer.UV4Kind
  105229. * - VertexBuffer.UV5Kind
  105230. * - VertexBuffer.UV6Kind
  105231. * - VertexBuffer.ColorKind
  105232. * - VertexBuffer.MatricesIndicesKind
  105233. * - VertexBuffer.MatricesIndicesExtraKind
  105234. * - VertexBuffer.MatricesWeightsKind
  105235. * - VertexBuffer.MatricesWeightsExtraKind
  105236. * @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
  105237. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105238. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105239. */
  105240. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105241. /**
  105242. * Returns the mesh VertexBuffer object from the requested `kind`
  105243. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105244. * - VertexBuffer.PositionKind
  105245. * - VertexBuffer.NormalKind
  105246. * - VertexBuffer.UVKind
  105247. * - VertexBuffer.UV2Kind
  105248. * - VertexBuffer.UV3Kind
  105249. * - VertexBuffer.UV4Kind
  105250. * - VertexBuffer.UV5Kind
  105251. * - VertexBuffer.UV6Kind
  105252. * - VertexBuffer.ColorKind
  105253. * - VertexBuffer.MatricesIndicesKind
  105254. * - VertexBuffer.MatricesIndicesExtraKind
  105255. * - VertexBuffer.MatricesWeightsKind
  105256. * - VertexBuffer.MatricesWeightsExtraKind
  105257. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105258. */
  105259. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105260. /**
  105261. * Tests if a specific vertex buffer is associated with this mesh
  105262. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105263. * - VertexBuffer.PositionKind
  105264. * - VertexBuffer.NormalKind
  105265. * - VertexBuffer.UVKind
  105266. * - VertexBuffer.UV2Kind
  105267. * - VertexBuffer.UV3Kind
  105268. * - VertexBuffer.UV4Kind
  105269. * - VertexBuffer.UV5Kind
  105270. * - VertexBuffer.UV6Kind
  105271. * - VertexBuffer.ColorKind
  105272. * - VertexBuffer.MatricesIndicesKind
  105273. * - VertexBuffer.MatricesIndicesExtraKind
  105274. * - VertexBuffer.MatricesWeightsKind
  105275. * - VertexBuffer.MatricesWeightsExtraKind
  105276. * @returns a boolean
  105277. */
  105278. isVerticesDataPresent(kind: string): boolean;
  105279. /**
  105280. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105281. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105282. * - VertexBuffer.PositionKind
  105283. * - VertexBuffer.UVKind
  105284. * - VertexBuffer.UV2Kind
  105285. * - VertexBuffer.UV3Kind
  105286. * - VertexBuffer.UV4Kind
  105287. * - VertexBuffer.UV5Kind
  105288. * - VertexBuffer.UV6Kind
  105289. * - VertexBuffer.ColorKind
  105290. * - VertexBuffer.MatricesIndicesKind
  105291. * - VertexBuffer.MatricesIndicesExtraKind
  105292. * - VertexBuffer.MatricesWeightsKind
  105293. * - VertexBuffer.MatricesWeightsExtraKind
  105294. * @returns a boolean
  105295. */
  105296. isVertexBufferUpdatable(kind: string): boolean;
  105297. /**
  105298. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105299. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105300. * - VertexBuffer.PositionKind
  105301. * - VertexBuffer.NormalKind
  105302. * - VertexBuffer.UVKind
  105303. * - VertexBuffer.UV2Kind
  105304. * - VertexBuffer.UV3Kind
  105305. * - VertexBuffer.UV4Kind
  105306. * - VertexBuffer.UV5Kind
  105307. * - VertexBuffer.UV6Kind
  105308. * - VertexBuffer.ColorKind
  105309. * - VertexBuffer.MatricesIndicesKind
  105310. * - VertexBuffer.MatricesIndicesExtraKind
  105311. * - VertexBuffer.MatricesWeightsKind
  105312. * - VertexBuffer.MatricesWeightsExtraKind
  105313. * @returns an array of strings
  105314. */
  105315. getVerticesDataKinds(): string[];
  105316. /**
  105317. * Returns a positive integer : the total number of indices in this mesh geometry.
  105318. * @returns the numner of indices or zero if the mesh has no geometry.
  105319. */
  105320. getTotalIndices(): number;
  105321. /**
  105322. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105323. * @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.
  105324. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105325. * @returns the indices array or an empty array if the mesh has no geometry
  105326. */
  105327. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105328. get isBlocked(): boolean;
  105329. /**
  105330. * Determine if the current mesh is ready to be rendered
  105331. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105332. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105333. * @returns true if all associated assets are ready (material, textures, shaders)
  105334. */
  105335. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105336. /**
  105337. * 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.
  105338. */
  105339. get areNormalsFrozen(): boolean;
  105340. /**
  105341. * 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.
  105342. * @returns the current mesh
  105343. */
  105344. freezeNormals(): Mesh;
  105345. /**
  105346. * 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
  105347. * @returns the current mesh
  105348. */
  105349. unfreezeNormals(): Mesh;
  105350. /**
  105351. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105352. */
  105353. set overridenInstanceCount(count: number);
  105354. /** @hidden */
  105355. _preActivate(): Mesh;
  105356. /** @hidden */
  105357. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105358. /** @hidden */
  105359. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105360. protected _afterComputeWorldMatrix(): void;
  105361. /** @hidden */
  105362. _postActivate(): void;
  105363. /**
  105364. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105365. * This means the mesh underlying bounding box and sphere are recomputed.
  105366. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105367. * @returns the current mesh
  105368. */
  105369. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105370. /** @hidden */
  105371. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105372. /**
  105373. * This function will subdivide the mesh into multiple submeshes
  105374. * @param count defines the expected number of submeshes
  105375. */
  105376. subdivide(count: number): void;
  105377. /**
  105378. * Copy a FloatArray into a specific associated vertex buffer
  105379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105380. * - VertexBuffer.PositionKind
  105381. * - VertexBuffer.UVKind
  105382. * - VertexBuffer.UV2Kind
  105383. * - VertexBuffer.UV3Kind
  105384. * - VertexBuffer.UV4Kind
  105385. * - VertexBuffer.UV5Kind
  105386. * - VertexBuffer.UV6Kind
  105387. * - VertexBuffer.ColorKind
  105388. * - VertexBuffer.MatricesIndicesKind
  105389. * - VertexBuffer.MatricesIndicesExtraKind
  105390. * - VertexBuffer.MatricesWeightsKind
  105391. * - VertexBuffer.MatricesWeightsExtraKind
  105392. * @param data defines the data source
  105393. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105394. * @param stride defines the data stride size (can be null)
  105395. * @returns the current mesh
  105396. */
  105397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105398. /**
  105399. * Delete a vertex buffer associated with this mesh
  105400. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105401. * - VertexBuffer.PositionKind
  105402. * - VertexBuffer.UVKind
  105403. * - VertexBuffer.UV2Kind
  105404. * - VertexBuffer.UV3Kind
  105405. * - VertexBuffer.UV4Kind
  105406. * - VertexBuffer.UV5Kind
  105407. * - VertexBuffer.UV6Kind
  105408. * - VertexBuffer.ColorKind
  105409. * - VertexBuffer.MatricesIndicesKind
  105410. * - VertexBuffer.MatricesIndicesExtraKind
  105411. * - VertexBuffer.MatricesWeightsKind
  105412. * - VertexBuffer.MatricesWeightsExtraKind
  105413. */
  105414. removeVerticesData(kind: string): void;
  105415. /**
  105416. * Flags an associated vertex buffer as updatable
  105417. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105418. * - VertexBuffer.PositionKind
  105419. * - VertexBuffer.UVKind
  105420. * - VertexBuffer.UV2Kind
  105421. * - VertexBuffer.UV3Kind
  105422. * - VertexBuffer.UV4Kind
  105423. * - VertexBuffer.UV5Kind
  105424. * - VertexBuffer.UV6Kind
  105425. * - VertexBuffer.ColorKind
  105426. * - VertexBuffer.MatricesIndicesKind
  105427. * - VertexBuffer.MatricesIndicesExtraKind
  105428. * - VertexBuffer.MatricesWeightsKind
  105429. * - VertexBuffer.MatricesWeightsExtraKind
  105430. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105431. */
  105432. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105433. /**
  105434. * Sets the mesh global Vertex Buffer
  105435. * @param buffer defines the buffer to use
  105436. * @returns the current mesh
  105437. */
  105438. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105439. /**
  105440. * Update a specific associated vertex buffer
  105441. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105442. * - VertexBuffer.PositionKind
  105443. * - VertexBuffer.UVKind
  105444. * - VertexBuffer.UV2Kind
  105445. * - VertexBuffer.UV3Kind
  105446. * - VertexBuffer.UV4Kind
  105447. * - VertexBuffer.UV5Kind
  105448. * - VertexBuffer.UV6Kind
  105449. * - VertexBuffer.ColorKind
  105450. * - VertexBuffer.MatricesIndicesKind
  105451. * - VertexBuffer.MatricesIndicesExtraKind
  105452. * - VertexBuffer.MatricesWeightsKind
  105453. * - VertexBuffer.MatricesWeightsExtraKind
  105454. * @param data defines the data source
  105455. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105456. * @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)
  105457. * @returns the current mesh
  105458. */
  105459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105460. /**
  105461. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105462. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105463. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105464. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105465. * @returns the current mesh
  105466. */
  105467. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105468. /**
  105469. * Creates a un-shared specific occurence of the geometry for the mesh.
  105470. * @returns the current mesh
  105471. */
  105472. makeGeometryUnique(): Mesh;
  105473. /**
  105474. * Set the index buffer of this mesh
  105475. * @param indices defines the source data
  105476. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105477. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105478. * @returns the current mesh
  105479. */
  105480. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105481. /**
  105482. * Update the current index buffer
  105483. * @param indices defines the source data
  105484. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105485. * @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)
  105486. * @returns the current mesh
  105487. */
  105488. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105489. /**
  105490. * Invert the geometry to move from a right handed system to a left handed one.
  105491. * @returns the current mesh
  105492. */
  105493. toLeftHanded(): Mesh;
  105494. /** @hidden */
  105495. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105496. /** @hidden */
  105497. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105498. /**
  105499. * Registers for this mesh a javascript function called just before the rendering process
  105500. * @param func defines the function to call before rendering this mesh
  105501. * @returns the current mesh
  105502. */
  105503. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105504. /**
  105505. * Disposes a previously registered javascript function called before the rendering
  105506. * @param func defines the function to remove
  105507. * @returns the current mesh
  105508. */
  105509. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105510. /**
  105511. * Registers for this mesh a javascript function called just after the rendering is complete
  105512. * @param func defines the function to call after rendering this mesh
  105513. * @returns the current mesh
  105514. */
  105515. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105516. /**
  105517. * Disposes a previously registered javascript function called after the rendering.
  105518. * @param func defines the function to remove
  105519. * @returns the current mesh
  105520. */
  105521. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105522. /** @hidden */
  105523. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105524. /** @hidden */
  105525. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105526. /** @hidden */
  105527. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105528. /** @hidden */
  105529. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105530. /** @hidden */
  105531. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105532. /** @hidden */
  105533. _rebuild(): void;
  105534. /** @hidden */
  105535. _freeze(): void;
  105536. /** @hidden */
  105537. _unFreeze(): void;
  105538. /**
  105539. * 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
  105540. * @param subMesh defines the subMesh to render
  105541. * @param enableAlphaMode defines if alpha mode can be changed
  105542. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105543. * @returns the current mesh
  105544. */
  105545. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105546. private _onBeforeDraw;
  105547. /**
  105548. * Renormalize the mesh and patch it up if there are no weights
  105549. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105550. * However in the case of zero weights then we set just a single influence to 1.
  105551. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105552. */
  105553. cleanMatrixWeights(): void;
  105554. private normalizeSkinFourWeights;
  105555. private normalizeSkinWeightsAndExtra;
  105556. /**
  105557. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105558. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105559. * the user know there was an issue with importing the mesh
  105560. * @returns a validation object with skinned, valid and report string
  105561. */
  105562. validateSkinning(): {
  105563. skinned: boolean;
  105564. valid: boolean;
  105565. report: string;
  105566. };
  105567. /** @hidden */
  105568. _checkDelayState(): Mesh;
  105569. private _queueLoad;
  105570. /**
  105571. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105572. * A mesh is in the frustum if its bounding box intersects the frustum
  105573. * @param frustumPlanes defines the frustum to test
  105574. * @returns true if the mesh is in the frustum planes
  105575. */
  105576. isInFrustum(frustumPlanes: Plane[]): boolean;
  105577. /**
  105578. * Sets the mesh material by the material or multiMaterial `id` property
  105579. * @param id is a string identifying the material or the multiMaterial
  105580. * @returns the current mesh
  105581. */
  105582. setMaterialByID(id: string): Mesh;
  105583. /**
  105584. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105585. * @returns an array of IAnimatable
  105586. */
  105587. getAnimatables(): IAnimatable[];
  105588. /**
  105589. * Modifies the mesh geometry according to the passed transformation matrix.
  105590. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105591. * The mesh normals are modified using the same transformation.
  105592. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105593. * @param transform defines the transform matrix to use
  105594. * @see http://doc.babylonjs.com/resources/baking_transformations
  105595. * @returns the current mesh
  105596. */
  105597. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105598. /**
  105599. * Modifies the mesh geometry according to its own current World Matrix.
  105600. * The mesh World Matrix is then reset.
  105601. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105602. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105603. * @see http://doc.babylonjs.com/resources/baking_transformations
  105604. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105605. * @returns the current mesh
  105606. */
  105607. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105608. /** @hidden */
  105609. get _positions(): Nullable<Vector3[]>;
  105610. /** @hidden */
  105611. _resetPointsArrayCache(): Mesh;
  105612. /** @hidden */
  105613. _generatePointsArray(): boolean;
  105614. /**
  105615. * Returns a new Mesh object generated from the current mesh properties.
  105616. * This method must not get confused with createInstance()
  105617. * @param name is a string, the name given to the new mesh
  105618. * @param newParent can be any Node object (default `null`)
  105619. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105620. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105621. * @returns a new mesh
  105622. */
  105623. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105624. /**
  105625. * Releases resources associated with this mesh.
  105626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105628. */
  105629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105630. /** @hidden */
  105631. _disposeInstanceSpecificData(): void;
  105632. /** @hidden */
  105633. _disposeThinInstanceSpecificData(): void;
  105634. /**
  105635. * Modifies the mesh geometry according to a displacement map.
  105636. * 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.
  105637. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105638. * @param url is a string, the URL from the image file is to be downloaded.
  105639. * @param minHeight is the lower limit of the displacement.
  105640. * @param maxHeight is the upper limit of the displacement.
  105641. * @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.
  105642. * @param uvOffset is an optional vector2 used to offset UV.
  105643. * @param uvScale is an optional vector2 used to scale UV.
  105644. * @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.
  105645. * @returns the Mesh.
  105646. */
  105647. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105648. /**
  105649. * Modifies the mesh geometry according to a displacementMap buffer.
  105650. * 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.
  105651. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105652. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105653. * @param heightMapWidth is the width of the buffer image.
  105654. * @param heightMapHeight is the height of the buffer image.
  105655. * @param minHeight is the lower limit of the displacement.
  105656. * @param maxHeight is the upper limit of the displacement.
  105657. * @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.
  105658. * @param uvOffset is an optional vector2 used to offset UV.
  105659. * @param uvScale is an optional vector2 used to scale UV.
  105660. * @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.
  105661. * @returns the Mesh.
  105662. */
  105663. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105664. /**
  105665. * Modify the mesh to get a flat shading rendering.
  105666. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105667. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105668. * @returns current mesh
  105669. */
  105670. convertToFlatShadedMesh(): Mesh;
  105671. /**
  105672. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105673. * In other words, more vertices, no more indices and a single bigger VBO.
  105674. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105675. * @returns current mesh
  105676. */
  105677. convertToUnIndexedMesh(): Mesh;
  105678. /**
  105679. * Inverses facet orientations.
  105680. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105681. * @param flipNormals will also inverts the normals
  105682. * @returns current mesh
  105683. */
  105684. flipFaces(flipNormals?: boolean): Mesh;
  105685. /**
  105686. * Increase the number of facets and hence vertices in a mesh
  105687. * Vertex normals are interpolated from existing vertex normals
  105688. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105689. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105690. */
  105691. increaseVertices(numberPerEdge: number): void;
  105692. /**
  105693. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105694. * This will undo any application of covertToFlatShadedMesh
  105695. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105696. */
  105697. forceSharedVertices(): void;
  105698. /** @hidden */
  105699. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105700. /** @hidden */
  105701. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105702. /**
  105703. * Creates a new InstancedMesh object from the mesh model.
  105704. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105705. * @param name defines the name of the new instance
  105706. * @returns a new InstancedMesh
  105707. */
  105708. createInstance(name: string): InstancedMesh;
  105709. /**
  105710. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105711. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105712. * @returns the current mesh
  105713. */
  105714. synchronizeInstances(): Mesh;
  105715. /**
  105716. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105717. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105718. * This should be used together with the simplification to avoid disappearing triangles.
  105719. * @param successCallback an optional success callback to be called after the optimization finished.
  105720. * @returns the current mesh
  105721. */
  105722. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105723. /**
  105724. * Serialize current mesh
  105725. * @param serializationObject defines the object which will receive the serialization data
  105726. */
  105727. serialize(serializationObject: any): void;
  105728. /** @hidden */
  105729. _syncGeometryWithMorphTargetManager(): void;
  105730. /** @hidden */
  105731. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105732. /**
  105733. * Returns a new Mesh object parsed from the source provided.
  105734. * @param parsedMesh is the source
  105735. * @param scene defines the hosting scene
  105736. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105737. * @returns a new Mesh
  105738. */
  105739. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105740. /**
  105741. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105742. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105743. * @param name defines the name of the mesh to create
  105744. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105745. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105746. * @param closePath creates a seam between the first and the last points of each path of the path array
  105747. * @param offset is taken in account only if the `pathArray` is containing a single path
  105748. * @param scene defines the hosting scene
  105749. * @param updatable defines if the mesh must be flagged as updatable
  105750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105751. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  105752. * @returns a new Mesh
  105753. */
  105754. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105755. /**
  105756. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105757. * @param name defines the name of the mesh to create
  105758. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105759. * @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
  105760. * @param scene defines the hosting scene
  105761. * @param updatable defines if the mesh must be flagged as updatable
  105762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105763. * @returns a new Mesh
  105764. */
  105765. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105766. /**
  105767. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105768. * @param name defines the name of the mesh to create
  105769. * @param size sets the size (float) of each box side (default 1)
  105770. * @param scene defines the hosting scene
  105771. * @param updatable defines if the mesh must be flagged as updatable
  105772. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105773. * @returns a new Mesh
  105774. */
  105775. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105776. /**
  105777. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105778. * @param name defines the name of the mesh to create
  105779. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105780. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105781. * @param scene defines the hosting scene
  105782. * @param updatable defines if the mesh must be flagged as updatable
  105783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105784. * @returns a new Mesh
  105785. */
  105786. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105787. /**
  105788. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105789. * @param name defines the name of the mesh to create
  105790. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105791. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105792. * @param scene defines the hosting scene
  105793. * @returns a new Mesh
  105794. */
  105795. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105796. /**
  105797. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105798. * @param name defines the name of the mesh to create
  105799. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105800. * @param diameterTop set the top cap diameter (floats, default 1)
  105801. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105802. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105803. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105804. * @param scene defines the hosting scene
  105805. * @param updatable defines if the mesh must be flagged as updatable
  105806. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105807. * @returns a new Mesh
  105808. */
  105809. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105810. /**
  105811. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105812. * @param name defines the name of the mesh to create
  105813. * @param diameter sets the diameter size (float) of the torus (default 1)
  105814. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105815. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105816. * @param scene defines the hosting scene
  105817. * @param updatable defines if the mesh must be flagged as updatable
  105818. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105819. * @returns a new Mesh
  105820. */
  105821. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105822. /**
  105823. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105824. * @param name defines the name of the mesh to create
  105825. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105826. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105827. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105828. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105829. * @param p the number of windings on X axis (positive integers, default 2)
  105830. * @param q the number of windings on Y axis (positive integers, default 3)
  105831. * @param scene defines the hosting scene
  105832. * @param updatable defines if the mesh must be flagged as updatable
  105833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105834. * @returns a new Mesh
  105835. */
  105836. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105837. /**
  105838. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105839. * @param name defines the name of the mesh to create
  105840. * @param points is an array successive Vector3
  105841. * @param scene defines the hosting scene
  105842. * @param updatable defines if the mesh must be flagged as updatable
  105843. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  105844. * @returns a new Mesh
  105845. */
  105846. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105847. /**
  105848. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105849. * @param name defines the name of the mesh to create
  105850. * @param points is an array successive Vector3
  105851. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105852. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105853. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105854. * @param scene defines the hosting scene
  105855. * @param updatable defines if the mesh must be flagged as updatable
  105856. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  105857. * @returns a new Mesh
  105858. */
  105859. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105860. /**
  105861. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105862. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105863. * 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.
  105864. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105865. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105866. * Remember you can only change the shape positions, not their number when updating a polygon.
  105867. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105868. * @param name defines the name of the mesh to create
  105869. * @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
  105870. * @param scene defines the hosting scene
  105871. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105872. * @param updatable defines if the mesh must be flagged as updatable
  105873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105874. * @param earcutInjection can be used to inject your own earcut reference
  105875. * @returns a new Mesh
  105876. */
  105877. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105878. /**
  105879. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105880. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105881. * @param name defines the name of the mesh to create
  105882. * @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
  105883. * @param depth defines the height of extrusion
  105884. * @param scene defines the hosting scene
  105885. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105886. * @param updatable defines if the mesh must be flagged as updatable
  105887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105888. * @param earcutInjection can be used to inject your own earcut reference
  105889. * @returns a new Mesh
  105890. */
  105891. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105892. /**
  105893. * Creates an extruded shape mesh.
  105894. * 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
  105895. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105896. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105897. * @param name defines the name of the mesh to create
  105898. * @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
  105899. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105900. * @param scale is the value to scale the shape
  105901. * @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
  105902. * @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
  105903. * @param scene defines the hosting scene
  105904. * @param updatable defines if the mesh must be flagged as updatable
  105905. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105906. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  105907. * @returns a new Mesh
  105908. */
  105909. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105910. /**
  105911. * Creates an custom extruded shape mesh.
  105912. * The custom extrusion is a parametric shape.
  105913. * It has no predefined shape. Its final shape will depend on the input parameters.
  105914. * Please consider using the same method from the MeshBuilder class instead
  105915. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105916. * @param name defines the name of the mesh to create
  105917. * @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
  105918. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105919. * @param scaleFunction is a custom Javascript function called on each path point
  105920. * @param rotationFunction is a custom Javascript function called on each path point
  105921. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105922. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105923. * @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
  105924. * @param scene defines the hosting scene
  105925. * @param updatable defines if the mesh must be flagged as updatable
  105926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105927. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  105928. * @returns a new Mesh
  105929. */
  105930. 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;
  105931. /**
  105932. * Creates lathe mesh.
  105933. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105934. * Please consider using the same method from the MeshBuilder class instead
  105935. * @param name defines the name of the mesh to create
  105936. * @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
  105937. * @param radius is the radius value of the lathe
  105938. * @param tessellation is the side number of the lathe.
  105939. * @param scene defines the hosting scene
  105940. * @param updatable defines if the mesh must be flagged as updatable
  105941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105942. * @returns a new Mesh
  105943. */
  105944. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105945. /**
  105946. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105947. * @param name defines the name of the mesh to create
  105948. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105949. * @param scene defines the hosting scene
  105950. * @param updatable defines if the mesh must be flagged as updatable
  105951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105952. * @returns a new Mesh
  105953. */
  105954. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105955. /**
  105956. * Creates a ground mesh.
  105957. * Please consider using the same method from the MeshBuilder class instead
  105958. * @param name defines the name of the mesh to create
  105959. * @param width set the width of the ground
  105960. * @param height set the height of the ground
  105961. * @param subdivisions sets the number of subdivisions per side
  105962. * @param scene defines the hosting scene
  105963. * @param updatable defines if the mesh must be flagged as updatable
  105964. * @returns a new Mesh
  105965. */
  105966. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105967. /**
  105968. * Creates a tiled ground mesh.
  105969. * Please consider using the same method from the MeshBuilder class instead
  105970. * @param name defines the name of the mesh to create
  105971. * @param xmin set the ground minimum X coordinate
  105972. * @param zmin set the ground minimum Y coordinate
  105973. * @param xmax set the ground maximum X coordinate
  105974. * @param zmax set the ground maximum Z coordinate
  105975. * @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
  105976. * @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
  105977. * @param scene defines the hosting scene
  105978. * @param updatable defines if the mesh must be flagged as updatable
  105979. * @returns a new Mesh
  105980. */
  105981. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105982. w: number;
  105983. h: number;
  105984. }, precision: {
  105985. w: number;
  105986. h: number;
  105987. }, scene: Scene, updatable?: boolean): Mesh;
  105988. /**
  105989. * Creates a ground mesh from a height map.
  105990. * Please consider using the same method from the MeshBuilder class instead
  105991. * @see http://doc.babylonjs.com/babylon101/height_map
  105992. * @param name defines the name of the mesh to create
  105993. * @param url sets the URL of the height map image resource
  105994. * @param width set the ground width size
  105995. * @param height set the ground height size
  105996. * @param subdivisions sets the number of subdivision per side
  105997. * @param minHeight is the minimum altitude on the ground
  105998. * @param maxHeight is the maximum altitude on the ground
  105999. * @param scene defines the hosting scene
  106000. * @param updatable defines if the mesh must be flagged as updatable
  106001. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106002. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106003. * @returns a new Mesh
  106004. */
  106005. 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;
  106006. /**
  106007. * Creates a tube mesh.
  106008. * The tube is a parametric shape.
  106009. * It has no predefined shape. Its final shape will depend on the input parameters.
  106010. * Please consider using the same method from the MeshBuilder class instead
  106011. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  106012. * @param name defines the name of the mesh to create
  106013. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106014. * @param radius sets the tube radius size
  106015. * @param tessellation is the number of sides on the tubular surface
  106016. * @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
  106017. * @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
  106018. * @param scene defines the hosting scene
  106019. * @param updatable defines if the mesh must be flagged as updatable
  106020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106021. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  106022. * @returns a new Mesh
  106023. */
  106024. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106025. (i: number, distance: number): number;
  106026. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106027. /**
  106028. * Creates a polyhedron mesh.
  106029. * Please consider using the same method from the MeshBuilder class instead.
  106030. * * 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
  106031. * * The parameter `size` (positive float, default 1) sets the polygon size
  106032. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106033. * * 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`
  106034. * * 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
  106035. * * 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)`)
  106036. * * 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
  106037. * * 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
  106038. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106041. * @param name defines the name of the mesh to create
  106042. * @param options defines the options used to create the mesh
  106043. * @param scene defines the hosting scene
  106044. * @returns a new Mesh
  106045. */
  106046. static CreatePolyhedron(name: string, options: {
  106047. type?: number;
  106048. size?: number;
  106049. sizeX?: number;
  106050. sizeY?: number;
  106051. sizeZ?: number;
  106052. custom?: any;
  106053. faceUV?: Vector4[];
  106054. faceColors?: Color4[];
  106055. updatable?: boolean;
  106056. sideOrientation?: number;
  106057. }, scene: Scene): Mesh;
  106058. /**
  106059. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106060. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106061. * * 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`)
  106062. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106063. * * 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
  106064. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106067. * @param name defines the name of the mesh
  106068. * @param options defines the options used to create the mesh
  106069. * @param scene defines the hosting scene
  106070. * @returns a new Mesh
  106071. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106072. */
  106073. static CreateIcoSphere(name: string, options: {
  106074. radius?: number;
  106075. flat?: boolean;
  106076. subdivisions?: number;
  106077. sideOrientation?: number;
  106078. updatable?: boolean;
  106079. }, scene: Scene): Mesh;
  106080. /**
  106081. * Creates a decal mesh.
  106082. * Please consider using the same method from the MeshBuilder class instead.
  106083. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106084. * @param name defines the name of the mesh
  106085. * @param sourceMesh defines the mesh receiving the decal
  106086. * @param position sets the position of the decal in world coordinates
  106087. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106088. * @param size sets the decal scaling
  106089. * @param angle sets the angle to rotate the decal
  106090. * @returns a new Mesh
  106091. */
  106092. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106093. /**
  106094. * Prepare internal position array for software CPU skinning
  106095. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106096. */
  106097. setPositionsForCPUSkinning(): Float32Array;
  106098. /**
  106099. * Prepare internal normal array for software CPU skinning
  106100. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106101. */
  106102. setNormalsForCPUSkinning(): Float32Array;
  106103. /**
  106104. * Updates the vertex buffer by applying transformation from the bones
  106105. * @param skeleton defines the skeleton to apply to current mesh
  106106. * @returns the current mesh
  106107. */
  106108. applySkeleton(skeleton: Skeleton): Mesh;
  106109. /**
  106110. * 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
  106111. * @param meshes defines the list of meshes to scan
  106112. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106113. */
  106114. static MinMax(meshes: AbstractMesh[]): {
  106115. min: Vector3;
  106116. max: Vector3;
  106117. };
  106118. /**
  106119. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106120. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106121. * @returns a vector3
  106122. */
  106123. static Center(meshesOrMinMaxVector: {
  106124. min: Vector3;
  106125. max: Vector3;
  106126. } | AbstractMesh[]): Vector3;
  106127. /**
  106128. * Merge the array of meshes into a single mesh for performance reasons.
  106129. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106130. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106131. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106132. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106133. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106134. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106135. * @returns a new mesh
  106136. */
  106137. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106138. /** @hidden */
  106139. addInstance(instance: InstancedMesh): void;
  106140. /** @hidden */
  106141. removeInstance(instance: InstancedMesh): void;
  106142. }
  106143. }
  106144. declare module BABYLON {
  106145. /**
  106146. * This is the base class of all the camera used in the application.
  106147. * @see http://doc.babylonjs.com/features/cameras
  106148. */
  106149. export class Camera extends Node {
  106150. /** @hidden */
  106151. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106152. /**
  106153. * This is the default projection mode used by the cameras.
  106154. * It helps recreating a feeling of perspective and better appreciate depth.
  106155. * This is the best way to simulate real life cameras.
  106156. */
  106157. static readonly PERSPECTIVE_CAMERA: number;
  106158. /**
  106159. * This helps creating camera with an orthographic mode.
  106160. * 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.
  106161. */
  106162. static readonly ORTHOGRAPHIC_CAMERA: number;
  106163. /**
  106164. * This is the default FOV mode for perspective cameras.
  106165. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106166. */
  106167. static readonly FOVMODE_VERTICAL_FIXED: number;
  106168. /**
  106169. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106170. */
  106171. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106172. /**
  106173. * This specifies ther is no need for a camera rig.
  106174. * Basically only one eye is rendered corresponding to the camera.
  106175. */
  106176. static readonly RIG_MODE_NONE: number;
  106177. /**
  106178. * Simulates a camera Rig with one blue eye and one red eye.
  106179. * This can be use with 3d blue and red glasses.
  106180. */
  106181. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106182. /**
  106183. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106184. */
  106185. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106186. /**
  106187. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106188. */
  106189. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106190. /**
  106191. * Defines that both eyes of the camera will be rendered over under each other.
  106192. */
  106193. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106194. /**
  106195. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106196. */
  106197. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106198. /**
  106199. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106200. */
  106201. static readonly RIG_MODE_VR: number;
  106202. /**
  106203. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106204. */
  106205. static readonly RIG_MODE_WEBVR: number;
  106206. /**
  106207. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106208. */
  106209. static readonly RIG_MODE_CUSTOM: number;
  106210. /**
  106211. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106212. */
  106213. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106214. /**
  106215. * Define the input manager associated with the camera.
  106216. */
  106217. inputs: CameraInputsManager<Camera>;
  106218. /** @hidden */
  106219. _position: Vector3;
  106220. /**
  106221. * Define the current local position of the camera in the scene
  106222. */
  106223. get position(): Vector3;
  106224. set position(newPosition: Vector3);
  106225. /**
  106226. * The vector the camera should consider as up.
  106227. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106228. */
  106229. upVector: Vector3;
  106230. /**
  106231. * Define the current limit on the left side for an orthographic camera
  106232. * In scene unit
  106233. */
  106234. orthoLeft: Nullable<number>;
  106235. /**
  106236. * Define the current limit on the right side for an orthographic camera
  106237. * In scene unit
  106238. */
  106239. orthoRight: Nullable<number>;
  106240. /**
  106241. * Define the current limit on the bottom side for an orthographic camera
  106242. * In scene unit
  106243. */
  106244. orthoBottom: Nullable<number>;
  106245. /**
  106246. * Define the current limit on the top side for an orthographic camera
  106247. * In scene unit
  106248. */
  106249. orthoTop: Nullable<number>;
  106250. /**
  106251. * Field Of View is set in Radians. (default is 0.8)
  106252. */
  106253. fov: number;
  106254. /**
  106255. * Define the minimum distance the camera can see from.
  106256. * This is important to note that the depth buffer are not infinite and the closer it starts
  106257. * the more your scene might encounter depth fighting issue.
  106258. */
  106259. minZ: number;
  106260. /**
  106261. * Define the maximum distance the camera can see to.
  106262. * This is important to note that the depth buffer are not infinite and the further it end
  106263. * the more your scene might encounter depth fighting issue.
  106264. */
  106265. maxZ: number;
  106266. /**
  106267. * Define the default inertia of the camera.
  106268. * This helps giving a smooth feeling to the camera movement.
  106269. */
  106270. inertia: number;
  106271. /**
  106272. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106273. */
  106274. mode: number;
  106275. /**
  106276. * Define whether the camera is intermediate.
  106277. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106278. */
  106279. isIntermediate: boolean;
  106280. /**
  106281. * Define the viewport of the camera.
  106282. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106283. */
  106284. viewport: Viewport;
  106285. /**
  106286. * Restricts the camera to viewing objects with the same layerMask.
  106287. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106288. */
  106289. layerMask: number;
  106290. /**
  106291. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106292. */
  106293. fovMode: number;
  106294. /**
  106295. * Rig mode of the camera.
  106296. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106297. * This is normally controlled byt the camera themselves as internal use.
  106298. */
  106299. cameraRigMode: number;
  106300. /**
  106301. * Defines the distance between both "eyes" in case of a RIG
  106302. */
  106303. interaxialDistance: number;
  106304. /**
  106305. * Defines if stereoscopic rendering is done side by side or over under.
  106306. */
  106307. isStereoscopicSideBySide: boolean;
  106308. /**
  106309. * 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
  106310. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106311. * else in the scene. (Eg. security camera)
  106312. *
  106313. * 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)
  106314. */
  106315. customRenderTargets: RenderTargetTexture[];
  106316. /**
  106317. * When set, the camera will render to this render target instead of the default canvas
  106318. *
  106319. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106320. */
  106321. outputRenderTarget: Nullable<RenderTargetTexture>;
  106322. /**
  106323. * Observable triggered when the camera view matrix has changed.
  106324. */
  106325. onViewMatrixChangedObservable: Observable<Camera>;
  106326. /**
  106327. * Observable triggered when the camera Projection matrix has changed.
  106328. */
  106329. onProjectionMatrixChangedObservable: Observable<Camera>;
  106330. /**
  106331. * Observable triggered when the inputs have been processed.
  106332. */
  106333. onAfterCheckInputsObservable: Observable<Camera>;
  106334. /**
  106335. * Observable triggered when reset has been called and applied to the camera.
  106336. */
  106337. onRestoreStateObservable: Observable<Camera>;
  106338. /**
  106339. * Is this camera a part of a rig system?
  106340. */
  106341. isRigCamera: boolean;
  106342. /**
  106343. * If isRigCamera set to true this will be set with the parent camera.
  106344. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106345. */
  106346. rigParent?: Camera;
  106347. /** @hidden */
  106348. _cameraRigParams: any;
  106349. /** @hidden */
  106350. _rigCameras: Camera[];
  106351. /** @hidden */
  106352. _rigPostProcess: Nullable<PostProcess>;
  106353. protected _webvrViewMatrix: Matrix;
  106354. /** @hidden */
  106355. _skipRendering: boolean;
  106356. /** @hidden */
  106357. _projectionMatrix: Matrix;
  106358. /** @hidden */
  106359. _postProcesses: Nullable<PostProcess>[];
  106360. /** @hidden */
  106361. _activeMeshes: SmartArray<AbstractMesh>;
  106362. protected _globalPosition: Vector3;
  106363. /** @hidden */
  106364. _computedViewMatrix: Matrix;
  106365. private _doNotComputeProjectionMatrix;
  106366. private _transformMatrix;
  106367. private _frustumPlanes;
  106368. private _refreshFrustumPlanes;
  106369. private _storedFov;
  106370. private _stateStored;
  106371. /**
  106372. * Instantiates a new camera object.
  106373. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106374. * @see http://doc.babylonjs.com/features/cameras
  106375. * @param name Defines the name of the camera in the scene
  106376. * @param position Defines the position of the camera
  106377. * @param scene Defines the scene the camera belongs too
  106378. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106379. */
  106380. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106381. /**
  106382. * Store current camera state (fov, position, etc..)
  106383. * @returns the camera
  106384. */
  106385. storeState(): Camera;
  106386. /**
  106387. * Restores the camera state values if it has been stored. You must call storeState() first
  106388. */
  106389. protected _restoreStateValues(): boolean;
  106390. /**
  106391. * Restored camera state. You must call storeState() first.
  106392. * @returns true if restored and false otherwise
  106393. */
  106394. restoreState(): boolean;
  106395. /**
  106396. * Gets the class name of the camera.
  106397. * @returns the class name
  106398. */
  106399. getClassName(): string;
  106400. /** @hidden */
  106401. readonly _isCamera: boolean;
  106402. /**
  106403. * Gets a string representation of the camera useful for debug purpose.
  106404. * @param fullDetails Defines that a more verboe level of logging is required
  106405. * @returns the string representation
  106406. */
  106407. toString(fullDetails?: boolean): string;
  106408. /**
  106409. * Gets the current world space position of the camera.
  106410. */
  106411. get globalPosition(): Vector3;
  106412. /**
  106413. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106414. * @returns the active meshe list
  106415. */
  106416. getActiveMeshes(): SmartArray<AbstractMesh>;
  106417. /**
  106418. * Check whether a mesh is part of the current active mesh list of the camera
  106419. * @param mesh Defines the mesh to check
  106420. * @returns true if active, false otherwise
  106421. */
  106422. isActiveMesh(mesh: Mesh): boolean;
  106423. /**
  106424. * Is this camera ready to be used/rendered
  106425. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106426. * @return true if the camera is ready
  106427. */
  106428. isReady(completeCheck?: boolean): boolean;
  106429. /** @hidden */
  106430. _initCache(): void;
  106431. /** @hidden */
  106432. _updateCache(ignoreParentClass?: boolean): void;
  106433. /** @hidden */
  106434. _isSynchronized(): boolean;
  106435. /** @hidden */
  106436. _isSynchronizedViewMatrix(): boolean;
  106437. /** @hidden */
  106438. _isSynchronizedProjectionMatrix(): boolean;
  106439. /**
  106440. * Attach the input controls to a specific dom element to get the input from.
  106441. * @param element Defines the element the controls should be listened from
  106442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106443. */
  106444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106445. /**
  106446. * Detach the current controls from the specified dom element.
  106447. * @param element Defines the element to stop listening the inputs from
  106448. */
  106449. detachControl(element: HTMLElement): void;
  106450. /**
  106451. * Update the camera state according to the different inputs gathered during the frame.
  106452. */
  106453. update(): void;
  106454. /** @hidden */
  106455. _checkInputs(): void;
  106456. /** @hidden */
  106457. get rigCameras(): Camera[];
  106458. /**
  106459. * Gets the post process used by the rig cameras
  106460. */
  106461. get rigPostProcess(): Nullable<PostProcess>;
  106462. /**
  106463. * Internal, gets the first post proces.
  106464. * @returns the first post process to be run on this camera.
  106465. */
  106466. _getFirstPostProcess(): Nullable<PostProcess>;
  106467. private _cascadePostProcessesToRigCams;
  106468. /**
  106469. * Attach a post process to the camera.
  106470. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106471. * @param postProcess The post process to attach to the camera
  106472. * @param insertAt The position of the post process in case several of them are in use in the scene
  106473. * @returns the position the post process has been inserted at
  106474. */
  106475. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106476. /**
  106477. * Detach a post process to the camera.
  106478. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106479. * @param postProcess The post process to detach from the camera
  106480. */
  106481. detachPostProcess(postProcess: PostProcess): void;
  106482. /**
  106483. * Gets the current world matrix of the camera
  106484. */
  106485. getWorldMatrix(): Matrix;
  106486. /** @hidden */
  106487. _getViewMatrix(): Matrix;
  106488. /**
  106489. * Gets the current view matrix of the camera.
  106490. * @param force forces the camera to recompute the matrix without looking at the cached state
  106491. * @returns the view matrix
  106492. */
  106493. getViewMatrix(force?: boolean): Matrix;
  106494. /**
  106495. * Freeze the projection matrix.
  106496. * It will prevent the cache check of the camera projection compute and can speed up perf
  106497. * if no parameter of the camera are meant to change
  106498. * @param projection Defines manually a projection if necessary
  106499. */
  106500. freezeProjectionMatrix(projection?: Matrix): void;
  106501. /**
  106502. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106503. */
  106504. unfreezeProjectionMatrix(): void;
  106505. /**
  106506. * Gets the current projection matrix of the camera.
  106507. * @param force forces the camera to recompute the matrix without looking at the cached state
  106508. * @returns the projection matrix
  106509. */
  106510. getProjectionMatrix(force?: boolean): Matrix;
  106511. /**
  106512. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106513. * @returns a Matrix
  106514. */
  106515. getTransformationMatrix(): Matrix;
  106516. private _updateFrustumPlanes;
  106517. /**
  106518. * Checks if a cullable object (mesh...) is in the camera frustum
  106519. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106520. * @param target The object to check
  106521. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106522. * @returns true if the object is in frustum otherwise false
  106523. */
  106524. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106525. /**
  106526. * Checks if a cullable object (mesh...) is in the camera frustum
  106527. * Unlike isInFrustum this cheks the full bounding box
  106528. * @param target The object to check
  106529. * @returns true if the object is in frustum otherwise false
  106530. */
  106531. isCompletelyInFrustum(target: ICullable): boolean;
  106532. /**
  106533. * Gets a ray in the forward direction from the camera.
  106534. * @param length Defines the length of the ray to create
  106535. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106536. * @param origin Defines the start point of the ray which defaults to the camera position
  106537. * @returns the forward ray
  106538. */
  106539. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106540. /**
  106541. * Releases resources associated with this node.
  106542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106544. */
  106545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106546. /** @hidden */
  106547. _isLeftCamera: boolean;
  106548. /**
  106549. * Gets the left camera of a rig setup in case of Rigged Camera
  106550. */
  106551. get isLeftCamera(): boolean;
  106552. /** @hidden */
  106553. _isRightCamera: boolean;
  106554. /**
  106555. * Gets the right camera of a rig setup in case of Rigged Camera
  106556. */
  106557. get isRightCamera(): boolean;
  106558. /**
  106559. * Gets the left camera of a rig setup in case of Rigged Camera
  106560. */
  106561. get leftCamera(): Nullable<FreeCamera>;
  106562. /**
  106563. * Gets the right camera of a rig setup in case of Rigged Camera
  106564. */
  106565. get rightCamera(): Nullable<FreeCamera>;
  106566. /**
  106567. * Gets the left camera target of a rig setup in case of Rigged Camera
  106568. * @returns the target position
  106569. */
  106570. getLeftTarget(): Nullable<Vector3>;
  106571. /**
  106572. * Gets the right camera target of a rig setup in case of Rigged Camera
  106573. * @returns the target position
  106574. */
  106575. getRightTarget(): Nullable<Vector3>;
  106576. /**
  106577. * @hidden
  106578. */
  106579. setCameraRigMode(mode: number, rigParams: any): void;
  106580. /** @hidden */
  106581. static _setStereoscopicRigMode(camera: Camera): void;
  106582. /** @hidden */
  106583. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106584. /** @hidden */
  106585. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106586. /** @hidden */
  106587. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106588. /** @hidden */
  106589. _getVRProjectionMatrix(): Matrix;
  106590. protected _updateCameraRotationMatrix(): void;
  106591. protected _updateWebVRCameraRotationMatrix(): void;
  106592. /**
  106593. * This function MUST be overwritten by the different WebVR cameras available.
  106594. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106595. * @hidden
  106596. */
  106597. _getWebVRProjectionMatrix(): Matrix;
  106598. /**
  106599. * This function MUST be overwritten by the different WebVR cameras available.
  106600. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106601. * @hidden
  106602. */
  106603. _getWebVRViewMatrix(): Matrix;
  106604. /** @hidden */
  106605. setCameraRigParameter(name: string, value: any): void;
  106606. /**
  106607. * needs to be overridden by children so sub has required properties to be copied
  106608. * @hidden
  106609. */
  106610. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106611. /**
  106612. * May need to be overridden by children
  106613. * @hidden
  106614. */
  106615. _updateRigCameras(): void;
  106616. /** @hidden */
  106617. _setupInputs(): void;
  106618. /**
  106619. * Serialiaze the camera setup to a json represention
  106620. * @returns the JSON representation
  106621. */
  106622. serialize(): any;
  106623. /**
  106624. * Clones the current camera.
  106625. * @param name The cloned camera name
  106626. * @returns the cloned camera
  106627. */
  106628. clone(name: string): Camera;
  106629. /**
  106630. * Gets the direction of the camera relative to a given local axis.
  106631. * @param localAxis Defines the reference axis to provide a relative direction.
  106632. * @return the direction
  106633. */
  106634. getDirection(localAxis: Vector3): Vector3;
  106635. /**
  106636. * Returns the current camera absolute rotation
  106637. */
  106638. get absoluteRotation(): Quaternion;
  106639. /**
  106640. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106641. * @param localAxis Defines the reference axis to provide a relative direction.
  106642. * @param result Defines the vector to store the result in
  106643. */
  106644. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106645. /**
  106646. * Gets a camera constructor for a given camera type
  106647. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106648. * @param name The name of the camera the result will be able to instantiate
  106649. * @param scene The scene the result will construct the camera in
  106650. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106651. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106652. * @returns a factory method to construc the camera
  106653. */
  106654. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106655. /**
  106656. * Compute the world matrix of the camera.
  106657. * @returns the camera world matrix
  106658. */
  106659. computeWorldMatrix(): Matrix;
  106660. /**
  106661. * Parse a JSON and creates the camera from the parsed information
  106662. * @param parsedCamera The JSON to parse
  106663. * @param scene The scene to instantiate the camera in
  106664. * @returns the newly constructed camera
  106665. */
  106666. static Parse(parsedCamera: any, scene: Scene): Camera;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. /**
  106671. * Class containing static functions to help procedurally build meshes
  106672. */
  106673. export class DiscBuilder {
  106674. /**
  106675. * Creates a plane polygonal mesh. By default, this is a disc
  106676. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106677. * * 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
  106678. * * 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
  106679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106682. * @param name defines the name of the mesh
  106683. * @param options defines the options used to create the mesh
  106684. * @param scene defines the hosting scene
  106685. * @returns the plane polygonal mesh
  106686. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106687. */
  106688. static CreateDisc(name: string, options: {
  106689. radius?: number;
  106690. tessellation?: number;
  106691. arc?: number;
  106692. updatable?: boolean;
  106693. sideOrientation?: number;
  106694. frontUVs?: Vector4;
  106695. backUVs?: Vector4;
  106696. }, scene?: Nullable<Scene>): Mesh;
  106697. }
  106698. }
  106699. declare module BABYLON {
  106700. /**
  106701. * Options to be used when creating a FresnelParameters.
  106702. */
  106703. export type IFresnelParametersCreationOptions = {
  106704. /**
  106705. * Define the color used on edges (grazing angle)
  106706. */
  106707. leftColor?: Color3;
  106708. /**
  106709. * Define the color used on center
  106710. */
  106711. rightColor?: Color3;
  106712. /**
  106713. * Define bias applied to computed fresnel term
  106714. */
  106715. bias?: number;
  106716. /**
  106717. * Defined the power exponent applied to fresnel term
  106718. */
  106719. power?: number;
  106720. /**
  106721. * Define if the fresnel effect is enable or not.
  106722. */
  106723. isEnabled?: boolean;
  106724. };
  106725. /**
  106726. * Serialized format for FresnelParameters.
  106727. */
  106728. export type IFresnelParametersSerialized = {
  106729. /**
  106730. * Define the color used on edges (grazing angle) [as an array]
  106731. */
  106732. leftColor: number[];
  106733. /**
  106734. * Define the color used on center [as an array]
  106735. */
  106736. rightColor: number[];
  106737. /**
  106738. * Define bias applied to computed fresnel term
  106739. */
  106740. bias: number;
  106741. /**
  106742. * Defined the power exponent applied to fresnel term
  106743. */
  106744. power?: number;
  106745. /**
  106746. * Define if the fresnel effect is enable or not.
  106747. */
  106748. isEnabled: boolean;
  106749. };
  106750. /**
  106751. * This represents all the required information to add a fresnel effect on a material:
  106752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106753. */
  106754. export class FresnelParameters {
  106755. private _isEnabled;
  106756. /**
  106757. * Define if the fresnel effect is enable or not.
  106758. */
  106759. get isEnabled(): boolean;
  106760. set isEnabled(value: boolean);
  106761. /**
  106762. * Define the color used on edges (grazing angle)
  106763. */
  106764. leftColor: Color3;
  106765. /**
  106766. * Define the color used on center
  106767. */
  106768. rightColor: Color3;
  106769. /**
  106770. * Define bias applied to computed fresnel term
  106771. */
  106772. bias: number;
  106773. /**
  106774. * Defined the power exponent applied to fresnel term
  106775. */
  106776. power: number;
  106777. /**
  106778. * Creates a new FresnelParameters object.
  106779. *
  106780. * @param options provide your own settings to optionally to override defaults
  106781. */
  106782. constructor(options?: IFresnelParametersCreationOptions);
  106783. /**
  106784. * Clones the current fresnel and its valuues
  106785. * @returns a clone fresnel configuration
  106786. */
  106787. clone(): FresnelParameters;
  106788. /**
  106789. * Determines equality between FresnelParameters objects
  106790. * @param otherFresnelParameters defines the second operand
  106791. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106792. */
  106793. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106794. /**
  106795. * Serializes the current fresnel parameters to a JSON representation.
  106796. * @return the JSON serialization
  106797. */
  106798. serialize(): IFresnelParametersSerialized;
  106799. /**
  106800. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106801. * @param parsedFresnelParameters Define the JSON representation
  106802. * @returns the parsed parameters
  106803. */
  106804. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106805. }
  106806. }
  106807. declare module BABYLON {
  106808. /**
  106809. * This groups all the flags used to control the materials channel.
  106810. */
  106811. export class MaterialFlags {
  106812. private static _DiffuseTextureEnabled;
  106813. /**
  106814. * Are diffuse textures enabled in the application.
  106815. */
  106816. static get DiffuseTextureEnabled(): boolean;
  106817. static set DiffuseTextureEnabled(value: boolean);
  106818. private static _DetailTextureEnabled;
  106819. /**
  106820. * Are detail textures enabled in the application.
  106821. */
  106822. static get DetailTextureEnabled(): boolean;
  106823. static set DetailTextureEnabled(value: boolean);
  106824. private static _AmbientTextureEnabled;
  106825. /**
  106826. * Are ambient textures enabled in the application.
  106827. */
  106828. static get AmbientTextureEnabled(): boolean;
  106829. static set AmbientTextureEnabled(value: boolean);
  106830. private static _OpacityTextureEnabled;
  106831. /**
  106832. * Are opacity textures enabled in the application.
  106833. */
  106834. static get OpacityTextureEnabled(): boolean;
  106835. static set OpacityTextureEnabled(value: boolean);
  106836. private static _ReflectionTextureEnabled;
  106837. /**
  106838. * Are reflection textures enabled in the application.
  106839. */
  106840. static get ReflectionTextureEnabled(): boolean;
  106841. static set ReflectionTextureEnabled(value: boolean);
  106842. private static _EmissiveTextureEnabled;
  106843. /**
  106844. * Are emissive textures enabled in the application.
  106845. */
  106846. static get EmissiveTextureEnabled(): boolean;
  106847. static set EmissiveTextureEnabled(value: boolean);
  106848. private static _SpecularTextureEnabled;
  106849. /**
  106850. * Are specular textures enabled in the application.
  106851. */
  106852. static get SpecularTextureEnabled(): boolean;
  106853. static set SpecularTextureEnabled(value: boolean);
  106854. private static _BumpTextureEnabled;
  106855. /**
  106856. * Are bump textures enabled in the application.
  106857. */
  106858. static get BumpTextureEnabled(): boolean;
  106859. static set BumpTextureEnabled(value: boolean);
  106860. private static _LightmapTextureEnabled;
  106861. /**
  106862. * Are lightmap textures enabled in the application.
  106863. */
  106864. static get LightmapTextureEnabled(): boolean;
  106865. static set LightmapTextureEnabled(value: boolean);
  106866. private static _RefractionTextureEnabled;
  106867. /**
  106868. * Are refraction textures enabled in the application.
  106869. */
  106870. static get RefractionTextureEnabled(): boolean;
  106871. static set RefractionTextureEnabled(value: boolean);
  106872. private static _ColorGradingTextureEnabled;
  106873. /**
  106874. * Are color grading textures enabled in the application.
  106875. */
  106876. static get ColorGradingTextureEnabled(): boolean;
  106877. static set ColorGradingTextureEnabled(value: boolean);
  106878. private static _FresnelEnabled;
  106879. /**
  106880. * Are fresnels enabled in the application.
  106881. */
  106882. static get FresnelEnabled(): boolean;
  106883. static set FresnelEnabled(value: boolean);
  106884. private static _ClearCoatTextureEnabled;
  106885. /**
  106886. * Are clear coat textures enabled in the application.
  106887. */
  106888. static get ClearCoatTextureEnabled(): boolean;
  106889. static set ClearCoatTextureEnabled(value: boolean);
  106890. private static _ClearCoatBumpTextureEnabled;
  106891. /**
  106892. * Are clear coat bump textures enabled in the application.
  106893. */
  106894. static get ClearCoatBumpTextureEnabled(): boolean;
  106895. static set ClearCoatBumpTextureEnabled(value: boolean);
  106896. private static _ClearCoatTintTextureEnabled;
  106897. /**
  106898. * Are clear coat tint textures enabled in the application.
  106899. */
  106900. static get ClearCoatTintTextureEnabled(): boolean;
  106901. static set ClearCoatTintTextureEnabled(value: boolean);
  106902. private static _SheenTextureEnabled;
  106903. /**
  106904. * Are sheen textures enabled in the application.
  106905. */
  106906. static get SheenTextureEnabled(): boolean;
  106907. static set SheenTextureEnabled(value: boolean);
  106908. private static _AnisotropicTextureEnabled;
  106909. /**
  106910. * Are anisotropic textures enabled in the application.
  106911. */
  106912. static get AnisotropicTextureEnabled(): boolean;
  106913. static set AnisotropicTextureEnabled(value: boolean);
  106914. private static _ThicknessTextureEnabled;
  106915. /**
  106916. * Are thickness textures enabled in the application.
  106917. */
  106918. static get ThicknessTextureEnabled(): boolean;
  106919. static set ThicknessTextureEnabled(value: boolean);
  106920. }
  106921. }
  106922. declare module BABYLON {
  106923. /** @hidden */
  106924. export var defaultFragmentDeclaration: {
  106925. name: string;
  106926. shader: string;
  106927. };
  106928. }
  106929. declare module BABYLON {
  106930. /** @hidden */
  106931. export var defaultUboDeclaration: {
  106932. name: string;
  106933. shader: string;
  106934. };
  106935. }
  106936. declare module BABYLON {
  106937. /** @hidden */
  106938. export var lightFragmentDeclaration: {
  106939. name: string;
  106940. shader: string;
  106941. };
  106942. }
  106943. declare module BABYLON {
  106944. /** @hidden */
  106945. export var lightUboDeclaration: {
  106946. name: string;
  106947. shader: string;
  106948. };
  106949. }
  106950. declare module BABYLON {
  106951. /** @hidden */
  106952. export var lightsFragmentFunctions: {
  106953. name: string;
  106954. shader: string;
  106955. };
  106956. }
  106957. declare module BABYLON {
  106958. /** @hidden */
  106959. export var shadowsFragmentFunctions: {
  106960. name: string;
  106961. shader: string;
  106962. };
  106963. }
  106964. declare module BABYLON {
  106965. /** @hidden */
  106966. export var fresnelFunction: {
  106967. name: string;
  106968. shader: string;
  106969. };
  106970. }
  106971. declare module BABYLON {
  106972. /** @hidden */
  106973. export var bumpFragmentMainFunctions: {
  106974. name: string;
  106975. shader: string;
  106976. };
  106977. }
  106978. declare module BABYLON {
  106979. /** @hidden */
  106980. export var bumpFragmentFunctions: {
  106981. name: string;
  106982. shader: string;
  106983. };
  106984. }
  106985. declare module BABYLON {
  106986. /** @hidden */
  106987. export var logDepthDeclaration: {
  106988. name: string;
  106989. shader: string;
  106990. };
  106991. }
  106992. declare module BABYLON {
  106993. /** @hidden */
  106994. export var bumpFragment: {
  106995. name: string;
  106996. shader: string;
  106997. };
  106998. }
  106999. declare module BABYLON {
  107000. /** @hidden */
  107001. export var depthPrePass: {
  107002. name: string;
  107003. shader: string;
  107004. };
  107005. }
  107006. declare module BABYLON {
  107007. /** @hidden */
  107008. export var lightFragment: {
  107009. name: string;
  107010. shader: string;
  107011. };
  107012. }
  107013. declare module BABYLON {
  107014. /** @hidden */
  107015. export var logDepthFragment: {
  107016. name: string;
  107017. shader: string;
  107018. };
  107019. }
  107020. declare module BABYLON {
  107021. /** @hidden */
  107022. export var defaultPixelShader: {
  107023. name: string;
  107024. shader: string;
  107025. };
  107026. }
  107027. declare module BABYLON {
  107028. /** @hidden */
  107029. export var defaultVertexDeclaration: {
  107030. name: string;
  107031. shader: string;
  107032. };
  107033. }
  107034. declare module BABYLON {
  107035. /** @hidden */
  107036. export var bumpVertexDeclaration: {
  107037. name: string;
  107038. shader: string;
  107039. };
  107040. }
  107041. declare module BABYLON {
  107042. /** @hidden */
  107043. export var bumpVertex: {
  107044. name: string;
  107045. shader: string;
  107046. };
  107047. }
  107048. declare module BABYLON {
  107049. /** @hidden */
  107050. export var fogVertex: {
  107051. name: string;
  107052. shader: string;
  107053. };
  107054. }
  107055. declare module BABYLON {
  107056. /** @hidden */
  107057. export var shadowsVertex: {
  107058. name: string;
  107059. shader: string;
  107060. };
  107061. }
  107062. declare module BABYLON {
  107063. /** @hidden */
  107064. export var pointCloudVertex: {
  107065. name: string;
  107066. shader: string;
  107067. };
  107068. }
  107069. declare module BABYLON {
  107070. /** @hidden */
  107071. export var logDepthVertex: {
  107072. name: string;
  107073. shader: string;
  107074. };
  107075. }
  107076. declare module BABYLON {
  107077. /** @hidden */
  107078. export var defaultVertexShader: {
  107079. name: string;
  107080. shader: string;
  107081. };
  107082. }
  107083. declare module BABYLON {
  107084. /**
  107085. * @hidden
  107086. */
  107087. export interface IMaterialDetailMapDefines {
  107088. DETAIL: boolean;
  107089. DETAILDIRECTUV: number;
  107090. DETAIL_NORMALBLENDMETHOD: number;
  107091. /** @hidden */
  107092. _areTexturesDirty: boolean;
  107093. }
  107094. /**
  107095. * Define the code related to the detail map parameters of a material
  107096. *
  107097. * Inspired from:
  107098. * 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
  107099. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107100. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107101. */
  107102. export class DetailMapConfiguration {
  107103. private _texture;
  107104. /**
  107105. * The detail texture of the material.
  107106. */
  107107. texture: Nullable<BaseTexture>;
  107108. /**
  107109. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107110. * Bigger values mean stronger blending
  107111. */
  107112. diffuseBlendLevel: number;
  107113. /**
  107114. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107115. * Bigger values mean stronger blending. Only used with PBR materials
  107116. */
  107117. roughnessBlendLevel: number;
  107118. /**
  107119. * Defines how strong the bump effect from the detail map is
  107120. * Bigger values mean stronger effect
  107121. */
  107122. bumpLevel: number;
  107123. private _normalBlendMethod;
  107124. /**
  107125. * The method used to blend the bump and detail normals together
  107126. */
  107127. normalBlendMethod: number;
  107128. private _isEnabled;
  107129. /**
  107130. * Enable or disable the detail map on this material
  107131. */
  107132. isEnabled: boolean;
  107133. /** @hidden */
  107134. private _internalMarkAllSubMeshesAsTexturesDirty;
  107135. /** @hidden */
  107136. _markAllSubMeshesAsTexturesDirty(): void;
  107137. /**
  107138. * Instantiate a new detail map
  107139. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107140. */
  107141. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107142. /**
  107143. * Gets whether the submesh is ready to be used or not.
  107144. * @param defines the list of "defines" to update.
  107145. * @param scene defines the scene the material belongs to.
  107146. * @returns - boolean indicating that the submesh is ready or not.
  107147. */
  107148. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107149. /**
  107150. * Update the defines for detail map usage
  107151. * @param defines the list of "defines" to update.
  107152. * @param scene defines the scene the material belongs to.
  107153. */
  107154. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107155. /**
  107156. * Binds the material data.
  107157. * @param uniformBuffer defines the Uniform buffer to fill in.
  107158. * @param scene defines the scene the material belongs to.
  107159. * @param isFrozen defines whether the material is frozen or not.
  107160. */
  107161. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107162. /**
  107163. * Checks to see if a texture is used in the material.
  107164. * @param texture - Base texture to use.
  107165. * @returns - Boolean specifying if a texture is used in the material.
  107166. */
  107167. hasTexture(texture: BaseTexture): boolean;
  107168. /**
  107169. * Returns an array of the actively used textures.
  107170. * @param activeTextures Array of BaseTextures
  107171. */
  107172. getActiveTextures(activeTextures: BaseTexture[]): void;
  107173. /**
  107174. * Returns the animatable textures.
  107175. * @param animatables Array of animatable textures.
  107176. */
  107177. getAnimatables(animatables: IAnimatable[]): void;
  107178. /**
  107179. * Disposes the resources of the material.
  107180. * @param forceDisposeTextures - Forces the disposal of all textures.
  107181. */
  107182. dispose(forceDisposeTextures?: boolean): void;
  107183. /**
  107184. * Get the current class name useful for serialization or dynamic coding.
  107185. * @returns "DetailMap"
  107186. */
  107187. getClassName(): string;
  107188. /**
  107189. * Add the required uniforms to the current list.
  107190. * @param uniforms defines the current uniform list.
  107191. */
  107192. static AddUniforms(uniforms: string[]): void;
  107193. /**
  107194. * Add the required samplers to the current list.
  107195. * @param samplers defines the current sampler list.
  107196. */
  107197. static AddSamplers(samplers: string[]): void;
  107198. /**
  107199. * Add the required uniforms to the current buffer.
  107200. * @param uniformBuffer defines the current uniform buffer.
  107201. */
  107202. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107203. /**
  107204. * Makes a duplicate of the current instance into another one.
  107205. * @param detailMap define the instance where to copy the info
  107206. */
  107207. copyTo(detailMap: DetailMapConfiguration): void;
  107208. /**
  107209. * Serializes this detail map instance
  107210. * @returns - An object with the serialized instance.
  107211. */
  107212. serialize(): any;
  107213. /**
  107214. * Parses a detail map setting from a serialized object.
  107215. * @param source - Serialized object.
  107216. * @param scene Defines the scene we are parsing for
  107217. * @param rootUrl Defines the rootUrl to load from
  107218. */
  107219. parse(source: any, scene: Scene, rootUrl: string): void;
  107220. }
  107221. }
  107222. declare module BABYLON {
  107223. /** @hidden */
  107224. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107225. MAINUV1: boolean;
  107226. MAINUV2: boolean;
  107227. DIFFUSE: boolean;
  107228. DIFFUSEDIRECTUV: number;
  107229. DETAIL: boolean;
  107230. DETAILDIRECTUV: number;
  107231. DETAIL_NORMALBLENDMETHOD: number;
  107232. AMBIENT: boolean;
  107233. AMBIENTDIRECTUV: number;
  107234. OPACITY: boolean;
  107235. OPACITYDIRECTUV: number;
  107236. OPACITYRGB: boolean;
  107237. REFLECTION: boolean;
  107238. EMISSIVE: boolean;
  107239. EMISSIVEDIRECTUV: number;
  107240. SPECULAR: boolean;
  107241. SPECULARDIRECTUV: number;
  107242. BUMP: boolean;
  107243. BUMPDIRECTUV: number;
  107244. PARALLAX: boolean;
  107245. PARALLAXOCCLUSION: boolean;
  107246. SPECULAROVERALPHA: boolean;
  107247. CLIPPLANE: boolean;
  107248. CLIPPLANE2: boolean;
  107249. CLIPPLANE3: boolean;
  107250. CLIPPLANE4: boolean;
  107251. CLIPPLANE5: boolean;
  107252. CLIPPLANE6: boolean;
  107253. ALPHATEST: boolean;
  107254. DEPTHPREPASS: boolean;
  107255. ALPHAFROMDIFFUSE: boolean;
  107256. POINTSIZE: boolean;
  107257. FOG: boolean;
  107258. SPECULARTERM: boolean;
  107259. DIFFUSEFRESNEL: boolean;
  107260. OPACITYFRESNEL: boolean;
  107261. REFLECTIONFRESNEL: boolean;
  107262. REFRACTIONFRESNEL: boolean;
  107263. EMISSIVEFRESNEL: boolean;
  107264. FRESNEL: boolean;
  107265. NORMAL: boolean;
  107266. UV1: boolean;
  107267. UV2: boolean;
  107268. VERTEXCOLOR: boolean;
  107269. VERTEXALPHA: boolean;
  107270. NUM_BONE_INFLUENCERS: number;
  107271. BonesPerMesh: number;
  107272. BONETEXTURE: boolean;
  107273. INSTANCES: boolean;
  107274. THIN_INSTANCES: boolean;
  107275. GLOSSINESS: boolean;
  107276. ROUGHNESS: boolean;
  107277. EMISSIVEASILLUMINATION: boolean;
  107278. LINKEMISSIVEWITHDIFFUSE: boolean;
  107279. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107280. LIGHTMAP: boolean;
  107281. LIGHTMAPDIRECTUV: number;
  107282. OBJECTSPACE_NORMALMAP: boolean;
  107283. USELIGHTMAPASSHADOWMAP: boolean;
  107284. REFLECTIONMAP_3D: boolean;
  107285. REFLECTIONMAP_SPHERICAL: boolean;
  107286. REFLECTIONMAP_PLANAR: boolean;
  107287. REFLECTIONMAP_CUBIC: boolean;
  107288. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107289. REFLECTIONMAP_PROJECTION: boolean;
  107290. REFLECTIONMAP_SKYBOX: boolean;
  107291. REFLECTIONMAP_EXPLICIT: boolean;
  107292. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107293. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107294. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107295. INVERTCUBICMAP: boolean;
  107296. LOGARITHMICDEPTH: boolean;
  107297. REFRACTION: boolean;
  107298. REFRACTIONMAP_3D: boolean;
  107299. REFLECTIONOVERALPHA: boolean;
  107300. TWOSIDEDLIGHTING: boolean;
  107301. SHADOWFLOAT: boolean;
  107302. MORPHTARGETS: boolean;
  107303. MORPHTARGETS_NORMAL: boolean;
  107304. MORPHTARGETS_TANGENT: boolean;
  107305. MORPHTARGETS_UV: boolean;
  107306. NUM_MORPH_INFLUENCERS: number;
  107307. NONUNIFORMSCALING: boolean;
  107308. PREMULTIPLYALPHA: boolean;
  107309. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107310. ALPHABLEND: boolean;
  107311. RGBDLIGHTMAP: boolean;
  107312. RGBDREFLECTION: boolean;
  107313. RGBDREFRACTION: boolean;
  107314. IMAGEPROCESSING: boolean;
  107315. VIGNETTE: boolean;
  107316. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107317. VIGNETTEBLENDMODEOPAQUE: boolean;
  107318. TONEMAPPING: boolean;
  107319. TONEMAPPING_ACES: boolean;
  107320. CONTRAST: boolean;
  107321. COLORCURVES: boolean;
  107322. COLORGRADING: boolean;
  107323. COLORGRADING3D: boolean;
  107324. SAMPLER3DGREENDEPTH: boolean;
  107325. SAMPLER3DBGRMAP: boolean;
  107326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107327. MULTIVIEW: boolean;
  107328. /**
  107329. * If the reflection texture on this material is in linear color space
  107330. * @hidden
  107331. */
  107332. IS_REFLECTION_LINEAR: boolean;
  107333. /**
  107334. * If the refraction texture on this material is in linear color space
  107335. * @hidden
  107336. */
  107337. IS_REFRACTION_LINEAR: boolean;
  107338. EXPOSURE: boolean;
  107339. constructor();
  107340. setReflectionMode(modeToEnable: string): void;
  107341. }
  107342. /**
  107343. * This is the default material used in Babylon. It is the best trade off between quality
  107344. * and performances.
  107345. * @see http://doc.babylonjs.com/babylon101/materials
  107346. */
  107347. export class StandardMaterial extends PushMaterial {
  107348. private _diffuseTexture;
  107349. /**
  107350. * The basic texture of the material as viewed under a light.
  107351. */
  107352. diffuseTexture: Nullable<BaseTexture>;
  107353. private _ambientTexture;
  107354. /**
  107355. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107356. */
  107357. ambientTexture: Nullable<BaseTexture>;
  107358. private _opacityTexture;
  107359. /**
  107360. * Define the transparency of the material from a texture.
  107361. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107362. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107363. */
  107364. opacityTexture: Nullable<BaseTexture>;
  107365. private _reflectionTexture;
  107366. /**
  107367. * Define the texture used to display the reflection.
  107368. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107369. */
  107370. reflectionTexture: Nullable<BaseTexture>;
  107371. private _emissiveTexture;
  107372. /**
  107373. * Define texture of the material as if self lit.
  107374. * This will be mixed in the final result even in the absence of light.
  107375. */
  107376. emissiveTexture: Nullable<BaseTexture>;
  107377. private _specularTexture;
  107378. /**
  107379. * Define how the color and intensity of the highlight given by the light in the material.
  107380. */
  107381. specularTexture: Nullable<BaseTexture>;
  107382. private _bumpTexture;
  107383. /**
  107384. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107385. * 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.
  107386. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107387. */
  107388. bumpTexture: Nullable<BaseTexture>;
  107389. private _lightmapTexture;
  107390. /**
  107391. * Complex lighting can be computationally expensive to compute at runtime.
  107392. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107393. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107394. */
  107395. lightmapTexture: Nullable<BaseTexture>;
  107396. private _refractionTexture;
  107397. /**
  107398. * Define the texture used to display the refraction.
  107399. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107400. */
  107401. refractionTexture: Nullable<BaseTexture>;
  107402. /**
  107403. * The color of the material lit by the environmental background lighting.
  107404. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107405. */
  107406. ambientColor: Color3;
  107407. /**
  107408. * The basic color of the material as viewed under a light.
  107409. */
  107410. diffuseColor: Color3;
  107411. /**
  107412. * Define how the color and intensity of the highlight given by the light in the material.
  107413. */
  107414. specularColor: Color3;
  107415. /**
  107416. * Define the color of the material as if self lit.
  107417. * This will be mixed in the final result even in the absence of light.
  107418. */
  107419. emissiveColor: Color3;
  107420. /**
  107421. * Defines how sharp are the highlights in the material.
  107422. * The bigger the value the sharper giving a more glossy feeling to the result.
  107423. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107424. */
  107425. specularPower: number;
  107426. private _useAlphaFromDiffuseTexture;
  107427. /**
  107428. * Does the transparency come from the diffuse texture alpha channel.
  107429. */
  107430. useAlphaFromDiffuseTexture: boolean;
  107431. private _useEmissiveAsIllumination;
  107432. /**
  107433. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107434. */
  107435. useEmissiveAsIllumination: boolean;
  107436. private _linkEmissiveWithDiffuse;
  107437. /**
  107438. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107439. * the emissive level when the final color is close to one.
  107440. */
  107441. linkEmissiveWithDiffuse: boolean;
  107442. private _useSpecularOverAlpha;
  107443. /**
  107444. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107445. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107446. */
  107447. useSpecularOverAlpha: boolean;
  107448. private _useReflectionOverAlpha;
  107449. /**
  107450. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107451. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107452. */
  107453. useReflectionOverAlpha: boolean;
  107454. private _disableLighting;
  107455. /**
  107456. * Does lights from the scene impacts this material.
  107457. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107458. */
  107459. disableLighting: boolean;
  107460. private _useObjectSpaceNormalMap;
  107461. /**
  107462. * Allows using an object space normal map (instead of tangent space).
  107463. */
  107464. useObjectSpaceNormalMap: boolean;
  107465. private _useParallax;
  107466. /**
  107467. * Is parallax enabled or not.
  107468. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107469. */
  107470. useParallax: boolean;
  107471. private _useParallaxOcclusion;
  107472. /**
  107473. * Is parallax occlusion enabled or not.
  107474. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107475. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107476. */
  107477. useParallaxOcclusion: boolean;
  107478. /**
  107479. * 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.
  107480. */
  107481. parallaxScaleBias: number;
  107482. private _roughness;
  107483. /**
  107484. * Helps to define how blurry the reflections should appears in the material.
  107485. */
  107486. roughness: number;
  107487. /**
  107488. * In case of refraction, define the value of the index of refraction.
  107489. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107490. */
  107491. indexOfRefraction: number;
  107492. /**
  107493. * Invert the refraction texture alongside the y axis.
  107494. * It can be useful with procedural textures or probe for instance.
  107495. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107496. */
  107497. invertRefractionY: boolean;
  107498. /**
  107499. * Defines the alpha limits in alpha test mode.
  107500. */
  107501. alphaCutOff: number;
  107502. private _useLightmapAsShadowmap;
  107503. /**
  107504. * In case of light mapping, define whether the map contains light or shadow informations.
  107505. */
  107506. useLightmapAsShadowmap: boolean;
  107507. private _diffuseFresnelParameters;
  107508. /**
  107509. * Define the diffuse fresnel parameters of the material.
  107510. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107511. */
  107512. diffuseFresnelParameters: FresnelParameters;
  107513. private _opacityFresnelParameters;
  107514. /**
  107515. * Define the opacity fresnel parameters of the material.
  107516. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107517. */
  107518. opacityFresnelParameters: FresnelParameters;
  107519. private _reflectionFresnelParameters;
  107520. /**
  107521. * Define the reflection fresnel parameters of the material.
  107522. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107523. */
  107524. reflectionFresnelParameters: FresnelParameters;
  107525. private _refractionFresnelParameters;
  107526. /**
  107527. * Define the refraction fresnel parameters of the material.
  107528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107529. */
  107530. refractionFresnelParameters: FresnelParameters;
  107531. private _emissiveFresnelParameters;
  107532. /**
  107533. * Define the emissive fresnel parameters of the material.
  107534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107535. */
  107536. emissiveFresnelParameters: FresnelParameters;
  107537. private _useReflectionFresnelFromSpecular;
  107538. /**
  107539. * If true automatically deducts the fresnels values from the material specularity.
  107540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107541. */
  107542. useReflectionFresnelFromSpecular: boolean;
  107543. private _useGlossinessFromSpecularMapAlpha;
  107544. /**
  107545. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107546. */
  107547. useGlossinessFromSpecularMapAlpha: boolean;
  107548. private _maxSimultaneousLights;
  107549. /**
  107550. * Defines the maximum number of lights that can be used in the material
  107551. */
  107552. maxSimultaneousLights: number;
  107553. private _invertNormalMapX;
  107554. /**
  107555. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107556. */
  107557. invertNormalMapX: boolean;
  107558. private _invertNormalMapY;
  107559. /**
  107560. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107561. */
  107562. invertNormalMapY: boolean;
  107563. private _twoSidedLighting;
  107564. /**
  107565. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107566. */
  107567. twoSidedLighting: boolean;
  107568. /**
  107569. * Default configuration related to image processing available in the standard Material.
  107570. */
  107571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107572. /**
  107573. * Gets the image processing configuration used either in this material.
  107574. */
  107575. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107576. /**
  107577. * Sets the Default image processing configuration used either in the this material.
  107578. *
  107579. * If sets to null, the scene one is in use.
  107580. */
  107581. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107582. /**
  107583. * Keep track of the image processing observer to allow dispose and replace.
  107584. */
  107585. private _imageProcessingObserver;
  107586. /**
  107587. * Attaches a new image processing configuration to the Standard Material.
  107588. * @param configuration
  107589. */
  107590. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107591. /**
  107592. * Gets wether the color curves effect is enabled.
  107593. */
  107594. get cameraColorCurvesEnabled(): boolean;
  107595. /**
  107596. * Sets wether the color curves effect is enabled.
  107597. */
  107598. set cameraColorCurvesEnabled(value: boolean);
  107599. /**
  107600. * Gets wether the color grading effect is enabled.
  107601. */
  107602. get cameraColorGradingEnabled(): boolean;
  107603. /**
  107604. * Gets wether the color grading effect is enabled.
  107605. */
  107606. set cameraColorGradingEnabled(value: boolean);
  107607. /**
  107608. * Gets wether tonemapping is enabled or not.
  107609. */
  107610. get cameraToneMappingEnabled(): boolean;
  107611. /**
  107612. * Sets wether tonemapping is enabled or not
  107613. */
  107614. set cameraToneMappingEnabled(value: boolean);
  107615. /**
  107616. * The camera exposure used on this material.
  107617. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107618. * This corresponds to a photographic exposure.
  107619. */
  107620. get cameraExposure(): number;
  107621. /**
  107622. * The camera exposure used on this material.
  107623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107624. * This corresponds to a photographic exposure.
  107625. */
  107626. set cameraExposure(value: number);
  107627. /**
  107628. * Gets The camera contrast used on this material.
  107629. */
  107630. get cameraContrast(): number;
  107631. /**
  107632. * Sets The camera contrast used on this material.
  107633. */
  107634. set cameraContrast(value: number);
  107635. /**
  107636. * Gets the Color Grading 2D Lookup Texture.
  107637. */
  107638. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107639. /**
  107640. * Sets the Color Grading 2D Lookup Texture.
  107641. */
  107642. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107643. /**
  107644. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107645. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107646. * 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;
  107647. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107648. */
  107649. get cameraColorCurves(): Nullable<ColorCurves>;
  107650. /**
  107651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107653. * 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;
  107654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107655. */
  107656. set cameraColorCurves(value: Nullable<ColorCurves>);
  107657. /**
  107658. * Defines the detail map parameters for the material.
  107659. */
  107660. readonly detailMap: DetailMapConfiguration;
  107661. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107662. protected _worldViewProjectionMatrix: Matrix;
  107663. protected _globalAmbientColor: Color3;
  107664. protected _useLogarithmicDepth: boolean;
  107665. protected _rebuildInParallel: boolean;
  107666. /**
  107667. * Instantiates a new standard material.
  107668. * This is the default material used in Babylon. It is the best trade off between quality
  107669. * and performances.
  107670. * @see http://doc.babylonjs.com/babylon101/materials
  107671. * @param name Define the name of the material in the scene
  107672. * @param scene Define the scene the material belong to
  107673. */
  107674. constructor(name: string, scene: Scene);
  107675. /**
  107676. * Gets a boolean indicating that current material needs to register RTT
  107677. */
  107678. get hasRenderTargetTextures(): boolean;
  107679. /**
  107680. * Gets the current class name of the material e.g. "StandardMaterial"
  107681. * Mainly use in serialization.
  107682. * @returns the class name
  107683. */
  107684. getClassName(): string;
  107685. /**
  107686. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107687. * You can try switching to logarithmic depth.
  107688. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107689. */
  107690. get useLogarithmicDepth(): boolean;
  107691. set useLogarithmicDepth(value: boolean);
  107692. /**
  107693. * Specifies if the material will require alpha blending
  107694. * @returns a boolean specifying if alpha blending is needed
  107695. */
  107696. needAlphaBlending(): boolean;
  107697. /**
  107698. * Specifies if this material should be rendered in alpha test mode
  107699. * @returns a boolean specifying if an alpha test is needed.
  107700. */
  107701. needAlphaTesting(): boolean;
  107702. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107703. /**
  107704. * Get the texture used for alpha test purpose.
  107705. * @returns the diffuse texture in case of the standard material.
  107706. */
  107707. getAlphaTestTexture(): Nullable<BaseTexture>;
  107708. /**
  107709. * Get if the submesh is ready to be used and all its information available.
  107710. * Child classes can use it to update shaders
  107711. * @param mesh defines the mesh to check
  107712. * @param subMesh defines which submesh to check
  107713. * @param useInstances specifies that instances should be used
  107714. * @returns a boolean indicating that the submesh is ready or not
  107715. */
  107716. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107717. /**
  107718. * Builds the material UBO layouts.
  107719. * Used internally during the effect preparation.
  107720. */
  107721. buildUniformLayout(): void;
  107722. /**
  107723. * Unbinds the material from the mesh
  107724. */
  107725. unbind(): void;
  107726. /**
  107727. * Binds the submesh to this material by preparing the effect and shader to draw
  107728. * @param world defines the world transformation matrix
  107729. * @param mesh defines the mesh containing the submesh
  107730. * @param subMesh defines the submesh to bind the material to
  107731. */
  107732. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107733. /**
  107734. * Get the list of animatables in the material.
  107735. * @returns the list of animatables object used in the material
  107736. */
  107737. getAnimatables(): IAnimatable[];
  107738. /**
  107739. * Gets the active textures from the material
  107740. * @returns an array of textures
  107741. */
  107742. getActiveTextures(): BaseTexture[];
  107743. /**
  107744. * Specifies if the material uses a texture
  107745. * @param texture defines the texture to check against the material
  107746. * @returns a boolean specifying if the material uses the texture
  107747. */
  107748. hasTexture(texture: BaseTexture): boolean;
  107749. /**
  107750. * Disposes the material
  107751. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107752. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107753. */
  107754. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107755. /**
  107756. * Makes a duplicate of the material, and gives it a new name
  107757. * @param name defines the new name for the duplicated material
  107758. * @returns the cloned material
  107759. */
  107760. clone(name: string): StandardMaterial;
  107761. /**
  107762. * Serializes this material in a JSON representation
  107763. * @returns the serialized material object
  107764. */
  107765. serialize(): any;
  107766. /**
  107767. * Creates a standard material from parsed material data
  107768. * @param source defines the JSON representation of the material
  107769. * @param scene defines the hosting scene
  107770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107771. * @returns a new standard material
  107772. */
  107773. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107774. /**
  107775. * Are diffuse textures enabled in the application.
  107776. */
  107777. static get DiffuseTextureEnabled(): boolean;
  107778. static set DiffuseTextureEnabled(value: boolean);
  107779. /**
  107780. * Are detail textures enabled in the application.
  107781. */
  107782. static get DetailTextureEnabled(): boolean;
  107783. static set DetailTextureEnabled(value: boolean);
  107784. /**
  107785. * Are ambient textures enabled in the application.
  107786. */
  107787. static get AmbientTextureEnabled(): boolean;
  107788. static set AmbientTextureEnabled(value: boolean);
  107789. /**
  107790. * Are opacity textures enabled in the application.
  107791. */
  107792. static get OpacityTextureEnabled(): boolean;
  107793. static set OpacityTextureEnabled(value: boolean);
  107794. /**
  107795. * Are reflection textures enabled in the application.
  107796. */
  107797. static get ReflectionTextureEnabled(): boolean;
  107798. static set ReflectionTextureEnabled(value: boolean);
  107799. /**
  107800. * Are emissive textures enabled in the application.
  107801. */
  107802. static get EmissiveTextureEnabled(): boolean;
  107803. static set EmissiveTextureEnabled(value: boolean);
  107804. /**
  107805. * Are specular textures enabled in the application.
  107806. */
  107807. static get SpecularTextureEnabled(): boolean;
  107808. static set SpecularTextureEnabled(value: boolean);
  107809. /**
  107810. * Are bump textures enabled in the application.
  107811. */
  107812. static get BumpTextureEnabled(): boolean;
  107813. static set BumpTextureEnabled(value: boolean);
  107814. /**
  107815. * Are lightmap textures enabled in the application.
  107816. */
  107817. static get LightmapTextureEnabled(): boolean;
  107818. static set LightmapTextureEnabled(value: boolean);
  107819. /**
  107820. * Are refraction textures enabled in the application.
  107821. */
  107822. static get RefractionTextureEnabled(): boolean;
  107823. static set RefractionTextureEnabled(value: boolean);
  107824. /**
  107825. * Are color grading textures enabled in the application.
  107826. */
  107827. static get ColorGradingTextureEnabled(): boolean;
  107828. static set ColorGradingTextureEnabled(value: boolean);
  107829. /**
  107830. * Are fresnels enabled in the application.
  107831. */
  107832. static get FresnelEnabled(): boolean;
  107833. static set FresnelEnabled(value: boolean);
  107834. }
  107835. }
  107836. declare module BABYLON {
  107837. /**
  107838. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107839. *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.
  107840. * The SPS is also a particle system. It provides some methods to manage the particles.
  107841. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107842. *
  107843. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107844. */
  107845. export class SolidParticleSystem implements IDisposable {
  107846. /**
  107847. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107848. * Example : var p = SPS.particles[i];
  107849. */
  107850. particles: SolidParticle[];
  107851. /**
  107852. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107853. */
  107854. nbParticles: number;
  107855. /**
  107856. * If the particles must ever face the camera (default false). Useful for planar particles.
  107857. */
  107858. billboard: boolean;
  107859. /**
  107860. * Recompute normals when adding a shape
  107861. */
  107862. recomputeNormals: boolean;
  107863. /**
  107864. * This a counter ofr your own usage. It's not set by any SPS functions.
  107865. */
  107866. counter: number;
  107867. /**
  107868. * The SPS name. This name is also given to the underlying mesh.
  107869. */
  107870. name: string;
  107871. /**
  107872. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107873. */
  107874. mesh: Mesh;
  107875. /**
  107876. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107877. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107878. */
  107879. vars: any;
  107880. /**
  107881. * This array is populated when the SPS is set as 'pickable'.
  107882. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107883. * Each element of this array is an object `{idx: int, faceId: int}`.
  107884. * `idx` is the picked particle index in the `SPS.particles` array
  107885. * `faceId` is the picked face index counted within this particle.
  107886. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107887. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107888. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107889. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107890. */
  107891. pickedParticles: {
  107892. idx: number;
  107893. faceId: number;
  107894. }[];
  107895. /**
  107896. * This array is populated when the SPS is set as 'pickable'
  107897. * Each key of this array is a submesh index.
  107898. * Each element of this array is a second array defined like this :
  107899. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107900. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107901. * `idx` is the picked particle index in the `SPS.particles` array
  107902. * `faceId` is the picked face index counted within this particle.
  107903. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107904. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107905. */
  107906. pickedBySubMesh: {
  107907. idx: number;
  107908. faceId: number;
  107909. }[][];
  107910. /**
  107911. * This array is populated when `enableDepthSort` is set to true.
  107912. * Each element of this array is an instance of the class DepthSortedParticle.
  107913. */
  107914. depthSortedParticles: DepthSortedParticle[];
  107915. /**
  107916. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107917. * @hidden
  107918. */
  107919. _bSphereOnly: boolean;
  107920. /**
  107921. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107922. * @hidden
  107923. */
  107924. _bSphereRadiusFactor: number;
  107925. private _scene;
  107926. private _positions;
  107927. private _indices;
  107928. private _normals;
  107929. private _colors;
  107930. private _uvs;
  107931. private _indices32;
  107932. private _positions32;
  107933. private _normals32;
  107934. private _fixedNormal32;
  107935. private _colors32;
  107936. private _uvs32;
  107937. private _index;
  107938. private _updatable;
  107939. private _pickable;
  107940. private _isVisibilityBoxLocked;
  107941. private _alwaysVisible;
  107942. private _depthSort;
  107943. private _expandable;
  107944. private _shapeCounter;
  107945. private _copy;
  107946. private _color;
  107947. private _computeParticleColor;
  107948. private _computeParticleTexture;
  107949. private _computeParticleRotation;
  107950. private _computeParticleVertex;
  107951. private _computeBoundingBox;
  107952. private _depthSortParticles;
  107953. private _camera;
  107954. private _mustUnrotateFixedNormals;
  107955. private _particlesIntersect;
  107956. private _needs32Bits;
  107957. private _isNotBuilt;
  107958. private _lastParticleId;
  107959. private _idxOfId;
  107960. private _multimaterialEnabled;
  107961. private _useModelMaterial;
  107962. private _indicesByMaterial;
  107963. private _materialIndexes;
  107964. private _depthSortFunction;
  107965. private _materialSortFunction;
  107966. private _materials;
  107967. private _multimaterial;
  107968. private _materialIndexesById;
  107969. private _defaultMaterial;
  107970. private _autoUpdateSubMeshes;
  107971. private _tmpVertex;
  107972. /**
  107973. * Creates a SPS (Solid Particle System) object.
  107974. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107975. * @param scene (Scene) is the scene in which the SPS is added.
  107976. * @param options defines the options of the sps e.g.
  107977. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107978. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107979. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107980. * * 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.
  107981. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107982. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107983. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107984. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107985. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107986. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107987. */
  107988. constructor(name: string, scene: Scene, options?: {
  107989. updatable?: boolean;
  107990. isPickable?: boolean;
  107991. enableDepthSort?: boolean;
  107992. particleIntersection?: boolean;
  107993. boundingSphereOnly?: boolean;
  107994. bSphereRadiusFactor?: number;
  107995. expandable?: boolean;
  107996. useModelMaterial?: boolean;
  107997. enableMultiMaterial?: boolean;
  107998. });
  107999. /**
  108000. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108001. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108002. * @returns the created mesh
  108003. */
  108004. buildMesh(): Mesh;
  108005. /**
  108006. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108007. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108008. * Thus the particles generated from `digest()` have their property `position` set yet.
  108009. * @param mesh ( Mesh ) is the mesh to be digested
  108010. * @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
  108011. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108012. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108013. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108014. * @returns the current SPS
  108015. */
  108016. digest(mesh: Mesh, options?: {
  108017. facetNb?: number;
  108018. number?: number;
  108019. delta?: number;
  108020. storage?: [];
  108021. }): SolidParticleSystem;
  108022. /**
  108023. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108024. * @hidden
  108025. */
  108026. private _unrotateFixedNormals;
  108027. /**
  108028. * Resets the temporary working copy particle
  108029. * @hidden
  108030. */
  108031. private _resetCopy;
  108032. /**
  108033. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108034. * @param p the current index in the positions array to be updated
  108035. * @param ind the current index in the indices array
  108036. * @param shape a Vector3 array, the shape geometry
  108037. * @param positions the positions array to be updated
  108038. * @param meshInd the shape indices array
  108039. * @param indices the indices array to be updated
  108040. * @param meshUV the shape uv array
  108041. * @param uvs the uv array to be updated
  108042. * @param meshCol the shape color array
  108043. * @param colors the color array to be updated
  108044. * @param meshNor the shape normals array
  108045. * @param normals the normals array to be updated
  108046. * @param idx the particle index
  108047. * @param idxInShape the particle index in its shape
  108048. * @param options the addShape() method passed options
  108049. * @model the particle model
  108050. * @hidden
  108051. */
  108052. private _meshBuilder;
  108053. /**
  108054. * Returns a shape Vector3 array from positions float array
  108055. * @param positions float array
  108056. * @returns a vector3 array
  108057. * @hidden
  108058. */
  108059. private _posToShape;
  108060. /**
  108061. * Returns a shapeUV array from a float uvs (array deep copy)
  108062. * @param uvs as a float array
  108063. * @returns a shapeUV array
  108064. * @hidden
  108065. */
  108066. private _uvsToShapeUV;
  108067. /**
  108068. * Adds a new particle object in the particles array
  108069. * @param idx particle index in particles array
  108070. * @param id particle id
  108071. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108072. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108073. * @param model particle ModelShape object
  108074. * @param shapeId model shape identifier
  108075. * @param idxInShape index of the particle in the current model
  108076. * @param bInfo model bounding info object
  108077. * @param storage target storage array, if any
  108078. * @hidden
  108079. */
  108080. private _addParticle;
  108081. /**
  108082. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108083. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108084. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108085. * @param nb (positive integer) the number of particles to be created from this model
  108086. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108087. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108088. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108089. * @returns the number of shapes in the system
  108090. */
  108091. addShape(mesh: Mesh, nb: number, options?: {
  108092. positionFunction?: any;
  108093. vertexFunction?: any;
  108094. storage?: [];
  108095. }): number;
  108096. /**
  108097. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108098. * @hidden
  108099. */
  108100. private _rebuildParticle;
  108101. /**
  108102. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108103. * @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.
  108104. * @returns the SPS.
  108105. */
  108106. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108107. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108108. * Returns an array with the removed particles.
  108109. * 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.
  108110. * The SPS can't be empty so at least one particle needs to remain in place.
  108111. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108112. * @param start index of the first particle to remove
  108113. * @param end index of the last particle to remove (included)
  108114. * @returns an array populated with the removed particles
  108115. */
  108116. removeParticles(start: number, end: number): SolidParticle[];
  108117. /**
  108118. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108119. * @param solidParticleArray an array populated with Solid Particles objects
  108120. * @returns the SPS
  108121. */
  108122. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108123. /**
  108124. * Creates a new particle and modifies the SPS mesh geometry :
  108125. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108126. * - calls _addParticle() to populate the particle array
  108127. * factorized code from addShape() and insertParticlesFromArray()
  108128. * @param idx particle index in the particles array
  108129. * @param i particle index in its shape
  108130. * @param modelShape particle ModelShape object
  108131. * @param shape shape vertex array
  108132. * @param meshInd shape indices array
  108133. * @param meshUV shape uv array
  108134. * @param meshCol shape color array
  108135. * @param meshNor shape normals array
  108136. * @param bbInfo shape bounding info
  108137. * @param storage target particle storage
  108138. * @options addShape() passed options
  108139. * @hidden
  108140. */
  108141. private _insertNewParticle;
  108142. /**
  108143. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108144. * This method calls `updateParticle()` for each particle of the SPS.
  108145. * For an animated SPS, it is usually called within the render loop.
  108146. * 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.
  108147. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108148. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108149. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108150. * @returns the SPS.
  108151. */
  108152. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108153. /**
  108154. * Disposes the SPS.
  108155. */
  108156. dispose(): void;
  108157. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108158. * idx is the particle index in the SPS
  108159. * faceId is the picked face index counted within this particle.
  108160. * Returns null if the pickInfo can't identify a picked particle.
  108161. * @param pickingInfo (PickingInfo object)
  108162. * @returns {idx: number, faceId: number} or null
  108163. */
  108164. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108165. idx: number;
  108166. faceId: number;
  108167. }>;
  108168. /**
  108169. * Returns a SolidParticle object from its identifier : particle.id
  108170. * @param id (integer) the particle Id
  108171. * @returns the searched particle or null if not found in the SPS.
  108172. */
  108173. getParticleById(id: number): Nullable<SolidParticle>;
  108174. /**
  108175. * Returns a new array populated with the particles having the passed shapeId.
  108176. * @param shapeId (integer) the shape identifier
  108177. * @returns a new solid particle array
  108178. */
  108179. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108180. /**
  108181. * Populates the passed array "ref" with the particles having the passed shapeId.
  108182. * @param shapeId the shape identifier
  108183. * @returns the SPS
  108184. * @param ref
  108185. */
  108186. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108187. /**
  108188. * Computes the required SubMeshes according the materials assigned to the particles.
  108189. * @returns the solid particle system.
  108190. * Does nothing if called before the SPS mesh is built.
  108191. */
  108192. computeSubMeshes(): SolidParticleSystem;
  108193. /**
  108194. * Sorts the solid particles by material when MultiMaterial is enabled.
  108195. * Updates the indices32 array.
  108196. * Updates the indicesByMaterial array.
  108197. * Updates the mesh indices array.
  108198. * @returns the SPS
  108199. * @hidden
  108200. */
  108201. private _sortParticlesByMaterial;
  108202. /**
  108203. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108204. * @hidden
  108205. */
  108206. private _setMaterialIndexesById;
  108207. /**
  108208. * Returns an array with unique values of Materials from the passed array
  108209. * @param array the material array to be checked and filtered
  108210. * @hidden
  108211. */
  108212. private _filterUniqueMaterialId;
  108213. /**
  108214. * Sets a new Standard Material as _defaultMaterial if not already set.
  108215. * @hidden
  108216. */
  108217. private _setDefaultMaterial;
  108218. /**
  108219. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108221. * @returns the SPS.
  108222. */
  108223. refreshVisibleSize(): SolidParticleSystem;
  108224. /**
  108225. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108226. * @param size the size (float) of the visibility box
  108227. * note : this doesn't lock the SPS mesh bounding box.
  108228. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108229. */
  108230. setVisibilityBox(size: number): void;
  108231. /**
  108232. * Gets whether the SPS as always visible or not
  108233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108234. */
  108235. get isAlwaysVisible(): boolean;
  108236. /**
  108237. * Sets the SPS as always visible or not
  108238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108239. */
  108240. set isAlwaysVisible(val: boolean);
  108241. /**
  108242. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108244. */
  108245. set isVisibilityBoxLocked(val: boolean);
  108246. /**
  108247. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108249. */
  108250. get isVisibilityBoxLocked(): boolean;
  108251. /**
  108252. * Tells to `setParticles()` to compute the particle rotations or not.
  108253. * Default value : true. The SPS is faster when it's set to false.
  108254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108255. */
  108256. set computeParticleRotation(val: boolean);
  108257. /**
  108258. * Tells to `setParticles()` to compute the particle colors or not.
  108259. * Default value : true. The SPS is faster when it's set to false.
  108260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108261. */
  108262. set computeParticleColor(val: boolean);
  108263. set computeParticleTexture(val: boolean);
  108264. /**
  108265. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108266. * Default value : false. The SPS is faster when it's set to false.
  108267. * Note : the particle custom vertex positions aren't stored values.
  108268. */
  108269. set computeParticleVertex(val: boolean);
  108270. /**
  108271. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108272. */
  108273. set computeBoundingBox(val: boolean);
  108274. /**
  108275. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108276. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108277. * Default : `true`
  108278. */
  108279. set depthSortParticles(val: boolean);
  108280. /**
  108281. * Gets if `setParticles()` computes the particle rotations or not.
  108282. * Default value : true. The SPS is faster when it's set to false.
  108283. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108284. */
  108285. get computeParticleRotation(): boolean;
  108286. /**
  108287. * Gets if `setParticles()` computes the particle colors or not.
  108288. * Default value : true. The SPS is faster when it's set to false.
  108289. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108290. */
  108291. get computeParticleColor(): boolean;
  108292. /**
  108293. * Gets if `setParticles()` computes the particle textures or not.
  108294. * Default value : true. The SPS is faster when it's set to false.
  108295. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108296. */
  108297. get computeParticleTexture(): boolean;
  108298. /**
  108299. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108300. * Default value : false. The SPS is faster when it's set to false.
  108301. * Note : the particle custom vertex positions aren't stored values.
  108302. */
  108303. get computeParticleVertex(): boolean;
  108304. /**
  108305. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108306. */
  108307. get computeBoundingBox(): boolean;
  108308. /**
  108309. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108310. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108311. * Default : `true`
  108312. */
  108313. get depthSortParticles(): boolean;
  108314. /**
  108315. * Gets if the SPS is created as expandable at construction time.
  108316. * Default : `false`
  108317. */
  108318. get expandable(): boolean;
  108319. /**
  108320. * Gets if the SPS supports the Multi Materials
  108321. */
  108322. get multimaterialEnabled(): boolean;
  108323. /**
  108324. * Gets if the SPS uses the model materials for its own multimaterial.
  108325. */
  108326. get useModelMaterial(): boolean;
  108327. /**
  108328. * The SPS used material array.
  108329. */
  108330. get materials(): Material[];
  108331. /**
  108332. * Sets the SPS MultiMaterial from the passed materials.
  108333. * Note : the passed array is internally copied and not used then by reference.
  108334. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108335. */
  108336. setMultiMaterial(materials: Material[]): void;
  108337. /**
  108338. * The SPS computed multimaterial object
  108339. */
  108340. get multimaterial(): MultiMaterial;
  108341. set multimaterial(mm: MultiMaterial);
  108342. /**
  108343. * If the subMeshes must be updated on the next call to setParticles()
  108344. */
  108345. get autoUpdateSubMeshes(): boolean;
  108346. set autoUpdateSubMeshes(val: boolean);
  108347. /**
  108348. * This function does nothing. It may be overwritten to set all the particle first values.
  108349. * The SPS doesn't call this function, you may have to call it by your own.
  108350. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108351. */
  108352. initParticles(): void;
  108353. /**
  108354. * This function does nothing. It may be overwritten to recycle a particle.
  108355. * The SPS doesn't call this function, you may have to call it by your own.
  108356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108357. * @param particle The particle to recycle
  108358. * @returns the recycled particle
  108359. */
  108360. recycleParticle(particle: SolidParticle): SolidParticle;
  108361. /**
  108362. * Updates a particle : this function should be overwritten by the user.
  108363. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108364. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108365. * @example : just set a particle position or velocity and recycle conditions
  108366. * @param particle The particle to update
  108367. * @returns the updated particle
  108368. */
  108369. updateParticle(particle: SolidParticle): SolidParticle;
  108370. /**
  108371. * Updates a vertex of a particle : it can be overwritten by the user.
  108372. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108373. * @param particle the current particle
  108374. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108375. * @param pt the index of the current vertex in the particle shape
  108376. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108377. * @example : just set a vertex particle position or color
  108378. * @returns the sps
  108379. */
  108380. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108381. /**
  108382. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108383. * This does nothing and may be overwritten by the user.
  108384. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108385. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108386. * @param update the boolean update value actually passed to setParticles()
  108387. */
  108388. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108389. /**
  108390. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108391. * This will be passed three parameters.
  108392. * This does nothing and may be overwritten by the user.
  108393. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108394. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108395. * @param update the boolean update value actually passed to setParticles()
  108396. */
  108397. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108398. }
  108399. }
  108400. declare module BABYLON {
  108401. /**
  108402. * Represents one particle of a solid particle system.
  108403. */
  108404. export class SolidParticle {
  108405. /**
  108406. * particle global index
  108407. */
  108408. idx: number;
  108409. /**
  108410. * particle identifier
  108411. */
  108412. id: number;
  108413. /**
  108414. * The color of the particle
  108415. */
  108416. color: Nullable<Color4>;
  108417. /**
  108418. * The world space position of the particle.
  108419. */
  108420. position: Vector3;
  108421. /**
  108422. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108423. */
  108424. rotation: Vector3;
  108425. /**
  108426. * The world space rotation quaternion of the particle.
  108427. */
  108428. rotationQuaternion: Nullable<Quaternion>;
  108429. /**
  108430. * The scaling of the particle.
  108431. */
  108432. scaling: Vector3;
  108433. /**
  108434. * The uvs of the particle.
  108435. */
  108436. uvs: Vector4;
  108437. /**
  108438. * The current speed of the particle.
  108439. */
  108440. velocity: Vector3;
  108441. /**
  108442. * The pivot point in the particle local space.
  108443. */
  108444. pivot: Vector3;
  108445. /**
  108446. * Must the particle be translated from its pivot point in its local space ?
  108447. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108448. * Default : false
  108449. */
  108450. translateFromPivot: boolean;
  108451. /**
  108452. * Is the particle active or not ?
  108453. */
  108454. alive: boolean;
  108455. /**
  108456. * Is the particle visible or not ?
  108457. */
  108458. isVisible: boolean;
  108459. /**
  108460. * Index of this particle in the global "positions" array (Internal use)
  108461. * @hidden
  108462. */
  108463. _pos: number;
  108464. /**
  108465. * @hidden Index of this particle in the global "indices" array (Internal use)
  108466. */
  108467. _ind: number;
  108468. /**
  108469. * @hidden ModelShape of this particle (Internal use)
  108470. */
  108471. _model: ModelShape;
  108472. /**
  108473. * ModelShape id of this particle
  108474. */
  108475. shapeId: number;
  108476. /**
  108477. * Index of the particle in its shape id
  108478. */
  108479. idxInShape: number;
  108480. /**
  108481. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108482. */
  108483. _modelBoundingInfo: BoundingInfo;
  108484. /**
  108485. * @hidden Particle BoundingInfo object (Internal use)
  108486. */
  108487. _boundingInfo: BoundingInfo;
  108488. /**
  108489. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108490. */
  108491. _sps: SolidParticleSystem;
  108492. /**
  108493. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108494. */
  108495. _stillInvisible: boolean;
  108496. /**
  108497. * @hidden Last computed particle rotation matrix
  108498. */
  108499. _rotationMatrix: number[];
  108500. /**
  108501. * Parent particle Id, if any.
  108502. * Default null.
  108503. */
  108504. parentId: Nullable<number>;
  108505. /**
  108506. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108507. */
  108508. materialIndex: Nullable<number>;
  108509. /**
  108510. * Custom object or properties.
  108511. */
  108512. props: Nullable<any>;
  108513. /**
  108514. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108515. * The possible values are :
  108516. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108517. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108518. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108519. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108520. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108521. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108522. * */
  108523. cullingStrategy: number;
  108524. /**
  108525. * @hidden Internal global position in the SPS.
  108526. */
  108527. _globalPosition: Vector3;
  108528. /**
  108529. * Creates a Solid Particle object.
  108530. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108531. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108532. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108533. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108534. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108535. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108536. * @param shapeId (integer) is the model shape identifier in the SPS.
  108537. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108538. * @param sps defines the sps it is associated to
  108539. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108540. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108541. */
  108542. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108543. /**
  108544. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108545. * @param target the particle target
  108546. * @returns the current particle
  108547. */
  108548. copyToRef(target: SolidParticle): SolidParticle;
  108549. /**
  108550. * Legacy support, changed scale to scaling
  108551. */
  108552. get scale(): Vector3;
  108553. /**
  108554. * Legacy support, changed scale to scaling
  108555. */
  108556. set scale(scale: Vector3);
  108557. /**
  108558. * Legacy support, changed quaternion to rotationQuaternion
  108559. */
  108560. get quaternion(): Nullable<Quaternion>;
  108561. /**
  108562. * Legacy support, changed quaternion to rotationQuaternion
  108563. */
  108564. set quaternion(q: Nullable<Quaternion>);
  108565. /**
  108566. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108567. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108568. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108569. * @returns true if it intersects
  108570. */
  108571. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108572. /**
  108573. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108574. * A particle is in the frustum if its bounding box intersects the frustum
  108575. * @param frustumPlanes defines the frustum to test
  108576. * @returns true if the particle is in the frustum planes
  108577. */
  108578. isInFrustum(frustumPlanes: Plane[]): boolean;
  108579. /**
  108580. * get the rotation matrix of the particle
  108581. * @hidden
  108582. */
  108583. getRotationMatrix(m: Matrix): void;
  108584. }
  108585. /**
  108586. * Represents the shape of the model used by one particle of a solid particle system.
  108587. * SPS internal tool, don't use it manually.
  108588. */
  108589. export class ModelShape {
  108590. /**
  108591. * The shape id
  108592. * @hidden
  108593. */
  108594. shapeID: number;
  108595. /**
  108596. * flat array of model positions (internal use)
  108597. * @hidden
  108598. */
  108599. _shape: Vector3[];
  108600. /**
  108601. * flat array of model UVs (internal use)
  108602. * @hidden
  108603. */
  108604. _shapeUV: number[];
  108605. /**
  108606. * color array of the model
  108607. * @hidden
  108608. */
  108609. _shapeColors: number[];
  108610. /**
  108611. * indices array of the model
  108612. * @hidden
  108613. */
  108614. _indices: number[];
  108615. /**
  108616. * normals array of the model
  108617. * @hidden
  108618. */
  108619. _normals: number[];
  108620. /**
  108621. * length of the shape in the model indices array (internal use)
  108622. * @hidden
  108623. */
  108624. _indicesLength: number;
  108625. /**
  108626. * Custom position function (internal use)
  108627. * @hidden
  108628. */
  108629. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108630. /**
  108631. * Custom vertex function (internal use)
  108632. * @hidden
  108633. */
  108634. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108635. /**
  108636. * Model material (internal use)
  108637. * @hidden
  108638. */
  108639. _material: Nullable<Material>;
  108640. /**
  108641. * 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.
  108642. * SPS internal tool, don't use it manually.
  108643. * @hidden
  108644. */
  108645. 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>);
  108646. }
  108647. /**
  108648. * Represents a Depth Sorted Particle in the solid particle system.
  108649. * @hidden
  108650. */
  108651. export class DepthSortedParticle {
  108652. /**
  108653. * Particle index
  108654. */
  108655. idx: number;
  108656. /**
  108657. * Index of the particle in the "indices" array
  108658. */
  108659. ind: number;
  108660. /**
  108661. * Length of the particle shape in the "indices" array
  108662. */
  108663. indicesLength: number;
  108664. /**
  108665. * Squared distance from the particle to the camera
  108666. */
  108667. sqDistance: number;
  108668. /**
  108669. * Material index when used with MultiMaterials
  108670. */
  108671. materialIndex: number;
  108672. /**
  108673. * Creates a new sorted particle
  108674. * @param materialIndex
  108675. */
  108676. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108677. }
  108678. /**
  108679. * Represents a solid particle vertex
  108680. */
  108681. export class SolidParticleVertex {
  108682. /**
  108683. * Vertex position
  108684. */
  108685. position: Vector3;
  108686. /**
  108687. * Vertex color
  108688. */
  108689. color: Color4;
  108690. /**
  108691. * Vertex UV
  108692. */
  108693. uv: Vector2;
  108694. /**
  108695. * Creates a new solid particle vertex
  108696. */
  108697. constructor();
  108698. /** Vertex x coordinate */
  108699. get x(): number;
  108700. set x(val: number);
  108701. /** Vertex y coordinate */
  108702. get y(): number;
  108703. set y(val: number);
  108704. /** Vertex z coordinate */
  108705. get z(): number;
  108706. set z(val: number);
  108707. }
  108708. }
  108709. declare module BABYLON {
  108710. /**
  108711. * @hidden
  108712. */
  108713. export class _MeshCollisionData {
  108714. _checkCollisions: boolean;
  108715. _collisionMask: number;
  108716. _collisionGroup: number;
  108717. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108718. _collider: Nullable<Collider>;
  108719. _oldPositionForCollisions: Vector3;
  108720. _diffPositionForCollisions: Vector3;
  108721. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108722. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108723. }
  108724. }
  108725. declare module BABYLON {
  108726. /** @hidden */
  108727. class _FacetDataStorage {
  108728. facetPositions: Vector3[];
  108729. facetNormals: Vector3[];
  108730. facetPartitioning: number[][];
  108731. facetNb: number;
  108732. partitioningSubdivisions: number;
  108733. partitioningBBoxRatio: number;
  108734. facetDataEnabled: boolean;
  108735. facetParameters: any;
  108736. bbSize: Vector3;
  108737. subDiv: {
  108738. max: number;
  108739. X: number;
  108740. Y: number;
  108741. Z: number;
  108742. };
  108743. facetDepthSort: boolean;
  108744. facetDepthSortEnabled: boolean;
  108745. depthSortedIndices: IndicesArray;
  108746. depthSortedFacets: {
  108747. ind: number;
  108748. sqDistance: number;
  108749. }[];
  108750. facetDepthSortFunction: (f1: {
  108751. ind: number;
  108752. sqDistance: number;
  108753. }, f2: {
  108754. ind: number;
  108755. sqDistance: number;
  108756. }) => number;
  108757. facetDepthSortFrom: Vector3;
  108758. facetDepthSortOrigin: Vector3;
  108759. invertedMatrix: Matrix;
  108760. }
  108761. /**
  108762. * @hidden
  108763. **/
  108764. class _InternalAbstractMeshDataInfo {
  108765. _hasVertexAlpha: boolean;
  108766. _useVertexColors: boolean;
  108767. _numBoneInfluencers: number;
  108768. _applyFog: boolean;
  108769. _receiveShadows: boolean;
  108770. _facetData: _FacetDataStorage;
  108771. _visibility: number;
  108772. _skeleton: Nullable<Skeleton>;
  108773. _layerMask: number;
  108774. _computeBonesUsingShaders: boolean;
  108775. _isActive: boolean;
  108776. _onlyForInstances: boolean;
  108777. _isActiveIntermediate: boolean;
  108778. _onlyForInstancesIntermediate: boolean;
  108779. _actAsRegularMesh: boolean;
  108780. }
  108781. /**
  108782. * Class used to store all common mesh properties
  108783. */
  108784. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108785. /** No occlusion */
  108786. static OCCLUSION_TYPE_NONE: number;
  108787. /** Occlusion set to optimisitic */
  108788. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108789. /** Occlusion set to strict */
  108790. static OCCLUSION_TYPE_STRICT: number;
  108791. /** Use an accurante occlusion algorithm */
  108792. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108793. /** Use a conservative occlusion algorithm */
  108794. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108795. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108796. * Test order :
  108797. * Is the bounding sphere outside the frustum ?
  108798. * If not, are the bounding box vertices outside the frustum ?
  108799. * It not, then the cullable object is in the frustum.
  108800. */
  108801. static readonly CULLINGSTRATEGY_STANDARD: number;
  108802. /** Culling strategy : Bounding Sphere Only.
  108803. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108804. * It's also less accurate than the standard because some not visible objects can still be selected.
  108805. * Test : is the bounding sphere outside the frustum ?
  108806. * If not, then the cullable object is in the frustum.
  108807. */
  108808. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108809. /** Culling strategy : Optimistic Inclusion.
  108810. * This in an inclusion test first, then the standard exclusion test.
  108811. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108812. * 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.
  108813. * Anyway, it's as accurate as the standard strategy.
  108814. * Test :
  108815. * Is the cullable object bounding sphere center in the frustum ?
  108816. * If not, apply the default culling strategy.
  108817. */
  108818. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108819. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108820. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108821. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108822. * 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.
  108823. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108824. * Test :
  108825. * Is the cullable object bounding sphere center in the frustum ?
  108826. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108827. */
  108828. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108829. /**
  108830. * No billboard
  108831. */
  108832. static get BILLBOARDMODE_NONE(): number;
  108833. /** Billboard on X axis */
  108834. static get BILLBOARDMODE_X(): number;
  108835. /** Billboard on Y axis */
  108836. static get BILLBOARDMODE_Y(): number;
  108837. /** Billboard on Z axis */
  108838. static get BILLBOARDMODE_Z(): number;
  108839. /** Billboard on all axes */
  108840. static get BILLBOARDMODE_ALL(): number;
  108841. /** Billboard on using position instead of orientation */
  108842. static get BILLBOARDMODE_USE_POSITION(): number;
  108843. /** @hidden */
  108844. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108845. /**
  108846. * The culling strategy to use to check whether the mesh must be rendered or not.
  108847. * This value can be changed at any time and will be used on the next render mesh selection.
  108848. * The possible values are :
  108849. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108850. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108851. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108852. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108853. * Please read each static variable documentation to get details about the culling process.
  108854. * */
  108855. cullingStrategy: number;
  108856. /**
  108857. * Gets the number of facets in the mesh
  108858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108859. */
  108860. get facetNb(): number;
  108861. /**
  108862. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108864. */
  108865. get partitioningSubdivisions(): number;
  108866. set partitioningSubdivisions(nb: number);
  108867. /**
  108868. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108869. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108871. */
  108872. get partitioningBBoxRatio(): number;
  108873. set partitioningBBoxRatio(ratio: number);
  108874. /**
  108875. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108876. * Works only for updatable meshes.
  108877. * Doesn't work with multi-materials
  108878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108879. */
  108880. get mustDepthSortFacets(): boolean;
  108881. set mustDepthSortFacets(sort: boolean);
  108882. /**
  108883. * The location (Vector3) where the facet depth sort must be computed from.
  108884. * By default, the active camera position.
  108885. * Used only when facet depth sort is enabled
  108886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108887. */
  108888. get facetDepthSortFrom(): Vector3;
  108889. set facetDepthSortFrom(location: Vector3);
  108890. /**
  108891. * gets a boolean indicating if facetData is enabled
  108892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108893. */
  108894. get isFacetDataEnabled(): boolean;
  108895. /** @hidden */
  108896. _updateNonUniformScalingState(value: boolean): boolean;
  108897. /**
  108898. * An event triggered when this mesh collides with another one
  108899. */
  108900. onCollideObservable: Observable<AbstractMesh>;
  108901. /** Set a function to call when this mesh collides with another one */
  108902. set onCollide(callback: () => void);
  108903. /**
  108904. * An event triggered when the collision's position changes
  108905. */
  108906. onCollisionPositionChangeObservable: Observable<Vector3>;
  108907. /** Set a function to call when the collision's position changes */
  108908. set onCollisionPositionChange(callback: () => void);
  108909. /**
  108910. * An event triggered when material is changed
  108911. */
  108912. onMaterialChangedObservable: Observable<AbstractMesh>;
  108913. /**
  108914. * Gets or sets the orientation for POV movement & rotation
  108915. */
  108916. definedFacingForward: boolean;
  108917. /** @hidden */
  108918. _occlusionQuery: Nullable<WebGLQuery>;
  108919. /** @hidden */
  108920. _renderingGroup: Nullable<RenderingGroup>;
  108921. /**
  108922. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108923. */
  108924. get visibility(): number;
  108925. /**
  108926. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108927. */
  108928. set visibility(value: number);
  108929. /** Gets or sets the alpha index used to sort transparent meshes
  108930. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108931. */
  108932. alphaIndex: number;
  108933. /**
  108934. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108935. */
  108936. isVisible: boolean;
  108937. /**
  108938. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108939. */
  108940. isPickable: boolean;
  108941. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108942. showSubMeshesBoundingBox: boolean;
  108943. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108945. */
  108946. isBlocker: boolean;
  108947. /**
  108948. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108949. */
  108950. enablePointerMoveEvents: boolean;
  108951. /**
  108952. * Specifies the rendering group id for this mesh (0 by default)
  108953. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108954. */
  108955. renderingGroupId: number;
  108956. private _material;
  108957. /** Gets or sets current material */
  108958. get material(): Nullable<Material>;
  108959. set material(value: Nullable<Material>);
  108960. /**
  108961. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108962. * @see http://doc.babylonjs.com/babylon101/shadows
  108963. */
  108964. get receiveShadows(): boolean;
  108965. set receiveShadows(value: boolean);
  108966. /** Defines color to use when rendering outline */
  108967. outlineColor: Color3;
  108968. /** Define width to use when rendering outline */
  108969. outlineWidth: number;
  108970. /** Defines color to use when rendering overlay */
  108971. overlayColor: Color3;
  108972. /** Defines alpha to use when rendering overlay */
  108973. overlayAlpha: number;
  108974. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108975. get hasVertexAlpha(): boolean;
  108976. set hasVertexAlpha(value: boolean);
  108977. /** 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) */
  108978. get useVertexColors(): boolean;
  108979. set useVertexColors(value: boolean);
  108980. /**
  108981. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108982. */
  108983. get computeBonesUsingShaders(): boolean;
  108984. set computeBonesUsingShaders(value: boolean);
  108985. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108986. get numBoneInfluencers(): number;
  108987. set numBoneInfluencers(value: number);
  108988. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108989. get applyFog(): boolean;
  108990. set applyFog(value: boolean);
  108991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108992. useOctreeForRenderingSelection: boolean;
  108993. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108994. useOctreeForPicking: boolean;
  108995. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108996. useOctreeForCollisions: boolean;
  108997. /**
  108998. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108999. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109000. */
  109001. get layerMask(): number;
  109002. set layerMask(value: number);
  109003. /**
  109004. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109005. */
  109006. alwaysSelectAsActiveMesh: boolean;
  109007. /**
  109008. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109009. */
  109010. doNotSyncBoundingInfo: boolean;
  109011. /**
  109012. * Gets or sets the current action manager
  109013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109014. */
  109015. actionManager: Nullable<AbstractActionManager>;
  109016. private _meshCollisionData;
  109017. /**
  109018. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109020. */
  109021. ellipsoid: Vector3;
  109022. /**
  109023. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109025. */
  109026. ellipsoidOffset: Vector3;
  109027. /**
  109028. * Gets or sets a collision mask used to mask collisions (default is -1).
  109029. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109030. */
  109031. get collisionMask(): number;
  109032. set collisionMask(mask: number);
  109033. /**
  109034. * Gets or sets the current collision group mask (-1 by default).
  109035. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109036. */
  109037. get collisionGroup(): number;
  109038. set collisionGroup(mask: number);
  109039. /**
  109040. * Gets or sets current surrounding meshes (null by default).
  109041. *
  109042. * By default collision detection is tested against every mesh in the scene.
  109043. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109044. * meshes will be tested for the collision.
  109045. *
  109046. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109047. */
  109048. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109049. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109050. /**
  109051. * Defines edge width used when edgesRenderer is enabled
  109052. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109053. */
  109054. edgesWidth: number;
  109055. /**
  109056. * Defines edge color used when edgesRenderer is enabled
  109057. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109058. */
  109059. edgesColor: Color4;
  109060. /** @hidden */
  109061. _edgesRenderer: Nullable<IEdgesRenderer>;
  109062. /** @hidden */
  109063. _masterMesh: Nullable<AbstractMesh>;
  109064. /** @hidden */
  109065. _boundingInfo: Nullable<BoundingInfo>;
  109066. /** @hidden */
  109067. _renderId: number;
  109068. /**
  109069. * Gets or sets the list of subMeshes
  109070. * @see http://doc.babylonjs.com/how_to/multi_materials
  109071. */
  109072. subMeshes: SubMesh[];
  109073. /** @hidden */
  109074. _intersectionsInProgress: AbstractMesh[];
  109075. /** @hidden */
  109076. _unIndexed: boolean;
  109077. /** @hidden */
  109078. _lightSources: Light[];
  109079. /** Gets the list of lights affecting that mesh */
  109080. get lightSources(): Light[];
  109081. /** @hidden */
  109082. get _positions(): Nullable<Vector3[]>;
  109083. /** @hidden */
  109084. _waitingData: {
  109085. lods: Nullable<any>;
  109086. actions: Nullable<any>;
  109087. freezeWorldMatrix: Nullable<boolean>;
  109088. };
  109089. /** @hidden */
  109090. _bonesTransformMatrices: Nullable<Float32Array>;
  109091. /** @hidden */
  109092. _transformMatrixTexture: Nullable<RawTexture>;
  109093. /**
  109094. * Gets or sets a skeleton to apply skining transformations
  109095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109096. */
  109097. set skeleton(value: Nullable<Skeleton>);
  109098. get skeleton(): Nullable<Skeleton>;
  109099. /**
  109100. * An event triggered when the mesh is rebuilt.
  109101. */
  109102. onRebuildObservable: Observable<AbstractMesh>;
  109103. /**
  109104. * Creates a new AbstractMesh
  109105. * @param name defines the name of the mesh
  109106. * @param scene defines the hosting scene
  109107. */
  109108. constructor(name: string, scene?: Nullable<Scene>);
  109109. /**
  109110. * Returns the string "AbstractMesh"
  109111. * @returns "AbstractMesh"
  109112. */
  109113. getClassName(): string;
  109114. /**
  109115. * Gets a string representation of the current mesh
  109116. * @param fullDetails defines a boolean indicating if full details must be included
  109117. * @returns a string representation of the current mesh
  109118. */
  109119. toString(fullDetails?: boolean): string;
  109120. /**
  109121. * @hidden
  109122. */
  109123. protected _getEffectiveParent(): Nullable<Node>;
  109124. /** @hidden */
  109125. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109126. /** @hidden */
  109127. _rebuild(): void;
  109128. /** @hidden */
  109129. _resyncLightSources(): void;
  109130. /** @hidden */
  109131. _resyncLightSource(light: Light): void;
  109132. /** @hidden */
  109133. _unBindEffect(): void;
  109134. /** @hidden */
  109135. _removeLightSource(light: Light, dispose: boolean): void;
  109136. private _markSubMeshesAsDirty;
  109137. /** @hidden */
  109138. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109139. /** @hidden */
  109140. _markSubMeshesAsAttributesDirty(): void;
  109141. /** @hidden */
  109142. _markSubMeshesAsMiscDirty(): void;
  109143. /**
  109144. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109145. */
  109146. get scaling(): Vector3;
  109147. set scaling(newScaling: Vector3);
  109148. /**
  109149. * Returns true if the mesh is blocked. Implemented by child classes
  109150. */
  109151. get isBlocked(): boolean;
  109152. /**
  109153. * Returns the mesh itself by default. Implemented by child classes
  109154. * @param camera defines the camera to use to pick the right LOD level
  109155. * @returns the currentAbstractMesh
  109156. */
  109157. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109158. /**
  109159. * Returns 0 by default. Implemented by child classes
  109160. * @returns an integer
  109161. */
  109162. getTotalVertices(): number;
  109163. /**
  109164. * Returns a positive integer : the total number of indices in this mesh geometry.
  109165. * @returns the numner of indices or zero if the mesh has no geometry.
  109166. */
  109167. getTotalIndices(): number;
  109168. /**
  109169. * Returns null by default. Implemented by child classes
  109170. * @returns null
  109171. */
  109172. getIndices(): Nullable<IndicesArray>;
  109173. /**
  109174. * Returns the array of the requested vertex data kind. Implemented by child classes
  109175. * @param kind defines the vertex data kind to use
  109176. * @returns null
  109177. */
  109178. getVerticesData(kind: string): Nullable<FloatArray>;
  109179. /**
  109180. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109181. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109182. * Note that a new underlying VertexBuffer object is created each call.
  109183. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109184. * @param kind defines vertex data kind:
  109185. * * VertexBuffer.PositionKind
  109186. * * VertexBuffer.UVKind
  109187. * * VertexBuffer.UV2Kind
  109188. * * VertexBuffer.UV3Kind
  109189. * * VertexBuffer.UV4Kind
  109190. * * VertexBuffer.UV5Kind
  109191. * * VertexBuffer.UV6Kind
  109192. * * VertexBuffer.ColorKind
  109193. * * VertexBuffer.MatricesIndicesKind
  109194. * * VertexBuffer.MatricesIndicesExtraKind
  109195. * * VertexBuffer.MatricesWeightsKind
  109196. * * VertexBuffer.MatricesWeightsExtraKind
  109197. * @param data defines the data source
  109198. * @param updatable defines if the data must be flagged as updatable (or static)
  109199. * @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
  109200. * @returns the current mesh
  109201. */
  109202. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109203. /**
  109204. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109205. * If the mesh has no geometry, it is simply returned as it is.
  109206. * @param kind defines vertex data kind:
  109207. * * VertexBuffer.PositionKind
  109208. * * VertexBuffer.UVKind
  109209. * * VertexBuffer.UV2Kind
  109210. * * VertexBuffer.UV3Kind
  109211. * * VertexBuffer.UV4Kind
  109212. * * VertexBuffer.UV5Kind
  109213. * * VertexBuffer.UV6Kind
  109214. * * VertexBuffer.ColorKind
  109215. * * VertexBuffer.MatricesIndicesKind
  109216. * * VertexBuffer.MatricesIndicesExtraKind
  109217. * * VertexBuffer.MatricesWeightsKind
  109218. * * VertexBuffer.MatricesWeightsExtraKind
  109219. * @param data defines the data source
  109220. * @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
  109221. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109222. * @returns the current mesh
  109223. */
  109224. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109225. /**
  109226. * Sets the mesh indices,
  109227. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109228. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109229. * @param totalVertices Defines the total number of vertices
  109230. * @returns the current mesh
  109231. */
  109232. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109233. /**
  109234. * Gets a boolean indicating if specific vertex data is present
  109235. * @param kind defines the vertex data kind to use
  109236. * @returns true is data kind is present
  109237. */
  109238. isVerticesDataPresent(kind: string): boolean;
  109239. /**
  109240. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109241. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109242. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109243. * @returns a BoundingInfo
  109244. */
  109245. getBoundingInfo(): BoundingInfo;
  109246. /**
  109247. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109248. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109249. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109250. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109251. * @returns the current mesh
  109252. */
  109253. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109254. /**
  109255. * Overwrite the current bounding info
  109256. * @param boundingInfo defines the new bounding info
  109257. * @returns the current mesh
  109258. */
  109259. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109260. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109261. get useBones(): boolean;
  109262. /** @hidden */
  109263. _preActivate(): void;
  109264. /** @hidden */
  109265. _preActivateForIntermediateRendering(renderId: number): void;
  109266. /** @hidden */
  109267. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109268. /** @hidden */
  109269. _postActivate(): void;
  109270. /** @hidden */
  109271. _freeze(): void;
  109272. /** @hidden */
  109273. _unFreeze(): void;
  109274. /**
  109275. * Gets the current world matrix
  109276. * @returns a Matrix
  109277. */
  109278. getWorldMatrix(): Matrix;
  109279. /** @hidden */
  109280. _getWorldMatrixDeterminant(): number;
  109281. /**
  109282. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109283. */
  109284. get isAnInstance(): boolean;
  109285. /**
  109286. * Gets a boolean indicating if this mesh has instances
  109287. */
  109288. get hasInstances(): boolean;
  109289. /**
  109290. * Gets a boolean indicating if this mesh has thin instances
  109291. */
  109292. get hasThinInstances(): boolean;
  109293. /**
  109294. * Perform relative position change from the point of view of behind the front of the mesh.
  109295. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109296. * Supports definition of mesh facing forward or backward
  109297. * @param amountRight defines the distance on the right axis
  109298. * @param amountUp defines the distance on the up axis
  109299. * @param amountForward defines the distance on the forward axis
  109300. * @returns the current mesh
  109301. */
  109302. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109303. /**
  109304. * Calculate relative position change from the point of view of behind the front of the mesh.
  109305. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109306. * Supports definition of mesh facing forward or backward
  109307. * @param amountRight defines the distance on the right axis
  109308. * @param amountUp defines the distance on the up axis
  109309. * @param amountForward defines the distance on the forward axis
  109310. * @returns the new displacement vector
  109311. */
  109312. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109313. /**
  109314. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109315. * Supports definition of mesh facing forward or backward
  109316. * @param flipBack defines the flip
  109317. * @param twirlClockwise defines the twirl
  109318. * @param tiltRight defines the tilt
  109319. * @returns the current mesh
  109320. */
  109321. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109322. /**
  109323. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109324. * Supports definition of mesh facing forward or backward.
  109325. * @param flipBack defines the flip
  109326. * @param twirlClockwise defines the twirl
  109327. * @param tiltRight defines the tilt
  109328. * @returns the new rotation vector
  109329. */
  109330. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109331. /**
  109332. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109333. * This means the mesh underlying bounding box and sphere are recomputed.
  109334. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109335. * @returns the current mesh
  109336. */
  109337. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109338. /** @hidden */
  109339. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109340. /** @hidden */
  109341. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109342. /** @hidden */
  109343. _updateBoundingInfo(): AbstractMesh;
  109344. /** @hidden */
  109345. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109346. /** @hidden */
  109347. protected _afterComputeWorldMatrix(): void;
  109348. /** @hidden */
  109349. get _effectiveMesh(): AbstractMesh;
  109350. /**
  109351. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109352. * A mesh is in the frustum if its bounding box intersects the frustum
  109353. * @param frustumPlanes defines the frustum to test
  109354. * @returns true if the mesh is in the frustum planes
  109355. */
  109356. isInFrustum(frustumPlanes: Plane[]): boolean;
  109357. /**
  109358. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109359. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109360. * @param frustumPlanes defines the frustum to test
  109361. * @returns true if the mesh is completely in the frustum planes
  109362. */
  109363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109364. /**
  109365. * True if the mesh intersects another mesh or a SolidParticle object
  109366. * @param mesh defines a target mesh or SolidParticle to test
  109367. * @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)
  109368. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109369. * @returns true if there is an intersection
  109370. */
  109371. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109372. /**
  109373. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109374. * @param point defines the point to test
  109375. * @returns true if there is an intersection
  109376. */
  109377. intersectsPoint(point: Vector3): boolean;
  109378. /**
  109379. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109381. */
  109382. get checkCollisions(): boolean;
  109383. set checkCollisions(collisionEnabled: boolean);
  109384. /**
  109385. * Gets Collider object used to compute collisions (not physics)
  109386. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109387. */
  109388. get collider(): Nullable<Collider>;
  109389. /**
  109390. * Move the mesh using collision engine
  109391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109392. * @param displacement defines the requested displacement vector
  109393. * @returns the current mesh
  109394. */
  109395. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109396. private _onCollisionPositionChange;
  109397. /** @hidden */
  109398. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109399. /** @hidden */
  109400. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109401. /** @hidden */
  109402. _checkCollision(collider: Collider): AbstractMesh;
  109403. /** @hidden */
  109404. _generatePointsArray(): boolean;
  109405. /**
  109406. * Checks if the passed Ray intersects with the mesh
  109407. * @param ray defines the ray to use
  109408. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109410. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109411. * @returns the picking info
  109412. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109413. */
  109414. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109415. /**
  109416. * Clones the current mesh
  109417. * @param name defines the mesh name
  109418. * @param newParent defines the new mesh parent
  109419. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109420. * @returns the new mesh
  109421. */
  109422. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109423. /**
  109424. * Disposes all the submeshes of the current meshnp
  109425. * @returns the current mesh
  109426. */
  109427. releaseSubMeshes(): AbstractMesh;
  109428. /**
  109429. * Releases resources associated with this abstract mesh.
  109430. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109431. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109432. */
  109433. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109434. /**
  109435. * Adds the passed mesh as a child to the current mesh
  109436. * @param mesh defines the child mesh
  109437. * @returns the current mesh
  109438. */
  109439. addChild(mesh: AbstractMesh): AbstractMesh;
  109440. /**
  109441. * Removes the passed mesh from the current mesh children list
  109442. * @param mesh defines the child mesh
  109443. * @returns the current mesh
  109444. */
  109445. removeChild(mesh: AbstractMesh): AbstractMesh;
  109446. /** @hidden */
  109447. private _initFacetData;
  109448. /**
  109449. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109450. * This method can be called within the render loop.
  109451. * 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
  109452. * @returns the current mesh
  109453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109454. */
  109455. updateFacetData(): AbstractMesh;
  109456. /**
  109457. * Returns the facetLocalNormals array.
  109458. * The normals are expressed in the mesh local spac
  109459. * @returns an array of Vector3
  109460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109461. */
  109462. getFacetLocalNormals(): Vector3[];
  109463. /**
  109464. * Returns the facetLocalPositions array.
  109465. * The facet positions are expressed in the mesh local space
  109466. * @returns an array of Vector3
  109467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109468. */
  109469. getFacetLocalPositions(): Vector3[];
  109470. /**
  109471. * Returns the facetLocalPartioning array
  109472. * @returns an array of array of numbers
  109473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109474. */
  109475. getFacetLocalPartitioning(): number[][];
  109476. /**
  109477. * Returns the i-th facet position in the world system.
  109478. * This method allocates a new Vector3 per call
  109479. * @param i defines the facet index
  109480. * @returns a new Vector3
  109481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109482. */
  109483. getFacetPosition(i: number): Vector3;
  109484. /**
  109485. * Sets the reference Vector3 with the i-th facet position in the world system
  109486. * @param i defines the facet index
  109487. * @param ref defines the target vector
  109488. * @returns the current mesh
  109489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109490. */
  109491. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109492. /**
  109493. * Returns the i-th facet normal in the world system.
  109494. * This method allocates a new Vector3 per call
  109495. * @param i defines the facet index
  109496. * @returns a new Vector3
  109497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109498. */
  109499. getFacetNormal(i: number): Vector3;
  109500. /**
  109501. * Sets the reference Vector3 with the i-th facet normal in the world system
  109502. * @param i defines the facet index
  109503. * @param ref defines the target vector
  109504. * @returns the current mesh
  109505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109506. */
  109507. getFacetNormalToRef(i: number, ref: Vector3): this;
  109508. /**
  109509. * 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)
  109510. * @param x defines x coordinate
  109511. * @param y defines y coordinate
  109512. * @param z defines z coordinate
  109513. * @returns the array of facet indexes
  109514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109515. */
  109516. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109517. /**
  109518. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109519. * @param projected sets as the (x,y,z) world projection on the facet
  109520. * @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
  109521. * @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
  109522. * @param x defines x coordinate
  109523. * @param y defines y coordinate
  109524. * @param z defines z coordinate
  109525. * @returns the face index if found (or null instead)
  109526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109527. */
  109528. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109529. /**
  109530. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109531. * @param projected sets as the (x,y,z) local projection on the facet
  109532. * @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
  109533. * @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
  109534. * @param x defines x coordinate
  109535. * @param y defines y coordinate
  109536. * @param z defines z coordinate
  109537. * @returns the face index if found (or null instead)
  109538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109539. */
  109540. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109541. /**
  109542. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109543. * @returns the parameters
  109544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109545. */
  109546. getFacetDataParameters(): any;
  109547. /**
  109548. * Disables the feature FacetData and frees the related memory
  109549. * @returns the current mesh
  109550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109551. */
  109552. disableFacetData(): AbstractMesh;
  109553. /**
  109554. * Updates the AbstractMesh indices array
  109555. * @param indices defines the data source
  109556. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109557. * @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)
  109558. * @returns the current mesh
  109559. */
  109560. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109561. /**
  109562. * Creates new normals data for the mesh
  109563. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109564. * @returns the current mesh
  109565. */
  109566. createNormals(updatable: boolean): AbstractMesh;
  109567. /**
  109568. * Align the mesh with a normal
  109569. * @param normal defines the normal to use
  109570. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109571. * @returns the current mesh
  109572. */
  109573. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109574. /** @hidden */
  109575. _checkOcclusionQuery(): boolean;
  109576. /**
  109577. * Disables the mesh edge rendering mode
  109578. * @returns the currentAbstractMesh
  109579. */
  109580. disableEdgesRendering(): AbstractMesh;
  109581. /**
  109582. * Enables the edge rendering mode on the mesh.
  109583. * This mode makes the mesh edges visible
  109584. * @param epsilon defines the maximal distance between two angles to detect a face
  109585. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109586. * @returns the currentAbstractMesh
  109587. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109588. */
  109589. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109590. }
  109591. }
  109592. declare module BABYLON {
  109593. /**
  109594. * Interface used to define ActionEvent
  109595. */
  109596. export interface IActionEvent {
  109597. /** The mesh or sprite that triggered the action */
  109598. source: any;
  109599. /** The X mouse cursor position at the time of the event */
  109600. pointerX: number;
  109601. /** The Y mouse cursor position at the time of the event */
  109602. pointerY: number;
  109603. /** The mesh that is currently pointed at (can be null) */
  109604. meshUnderPointer: Nullable<AbstractMesh>;
  109605. /** the original (browser) event that triggered the ActionEvent */
  109606. sourceEvent?: any;
  109607. /** additional data for the event */
  109608. additionalData?: any;
  109609. }
  109610. /**
  109611. * ActionEvent is the event being sent when an action is triggered.
  109612. */
  109613. export class ActionEvent implements IActionEvent {
  109614. /** The mesh or sprite that triggered the action */
  109615. source: any;
  109616. /** The X mouse cursor position at the time of the event */
  109617. pointerX: number;
  109618. /** The Y mouse cursor position at the time of the event */
  109619. pointerY: number;
  109620. /** The mesh that is currently pointed at (can be null) */
  109621. meshUnderPointer: Nullable<AbstractMesh>;
  109622. /** the original (browser) event that triggered the ActionEvent */
  109623. sourceEvent?: any;
  109624. /** additional data for the event */
  109625. additionalData?: any;
  109626. /**
  109627. * Creates a new ActionEvent
  109628. * @param source The mesh or sprite that triggered the action
  109629. * @param pointerX The X mouse cursor position at the time of the event
  109630. * @param pointerY The Y mouse cursor position at the time of the event
  109631. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109632. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109633. * @param additionalData additional data for the event
  109634. */
  109635. constructor(
  109636. /** The mesh or sprite that triggered the action */
  109637. source: any,
  109638. /** The X mouse cursor position at the time of the event */
  109639. pointerX: number,
  109640. /** The Y mouse cursor position at the time of the event */
  109641. pointerY: number,
  109642. /** The mesh that is currently pointed at (can be null) */
  109643. meshUnderPointer: Nullable<AbstractMesh>,
  109644. /** the original (browser) event that triggered the ActionEvent */
  109645. sourceEvent?: any,
  109646. /** additional data for the event */
  109647. additionalData?: any);
  109648. /**
  109649. * Helper function to auto-create an ActionEvent from a source mesh.
  109650. * @param source The source mesh that triggered the event
  109651. * @param evt The original (browser) event
  109652. * @param additionalData additional data for the event
  109653. * @returns the new ActionEvent
  109654. */
  109655. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109656. /**
  109657. * Helper function to auto-create an ActionEvent from a source sprite
  109658. * @param source The source sprite that triggered the event
  109659. * @param scene Scene associated with the sprite
  109660. * @param evt The original (browser) event
  109661. * @param additionalData additional data for the event
  109662. * @returns the new ActionEvent
  109663. */
  109664. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109665. /**
  109666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109667. * @param scene the scene where the event occurred
  109668. * @param evt The original (browser) event
  109669. * @returns the new ActionEvent
  109670. */
  109671. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109672. /**
  109673. * Helper function to auto-create an ActionEvent from a primitive
  109674. * @param prim defines the target primitive
  109675. * @param pointerPos defines the pointer position
  109676. * @param evt The original (browser) event
  109677. * @param additionalData additional data for the event
  109678. * @returns the new ActionEvent
  109679. */
  109680. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109681. }
  109682. }
  109683. declare module BABYLON {
  109684. /**
  109685. * Abstract class used to decouple action Manager from scene and meshes.
  109686. * Do not instantiate.
  109687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109688. */
  109689. export abstract class AbstractActionManager implements IDisposable {
  109690. /** Gets the list of active triggers */
  109691. static Triggers: {
  109692. [key: string]: number;
  109693. };
  109694. /** Gets the cursor to use when hovering items */
  109695. hoverCursor: string;
  109696. /** Gets the list of actions */
  109697. actions: IAction[];
  109698. /**
  109699. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109700. */
  109701. isRecursive: boolean;
  109702. /**
  109703. * Releases all associated resources
  109704. */
  109705. abstract dispose(): void;
  109706. /**
  109707. * Does this action manager has pointer triggers
  109708. */
  109709. abstract get hasPointerTriggers(): boolean;
  109710. /**
  109711. * Does this action manager has pick triggers
  109712. */
  109713. abstract get hasPickTriggers(): boolean;
  109714. /**
  109715. * Process a specific trigger
  109716. * @param trigger defines the trigger to process
  109717. * @param evt defines the event details to be processed
  109718. */
  109719. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109720. /**
  109721. * Does this action manager handles actions of any of the given triggers
  109722. * @param triggers defines the triggers to be tested
  109723. * @return a boolean indicating whether one (or more) of the triggers is handled
  109724. */
  109725. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109726. /**
  109727. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109728. * speed.
  109729. * @param triggerA defines the trigger to be tested
  109730. * @param triggerB defines the trigger to be tested
  109731. * @return a boolean indicating whether one (or more) of the triggers is handled
  109732. */
  109733. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109734. /**
  109735. * Does this action manager handles actions of a given trigger
  109736. * @param trigger defines the trigger to be tested
  109737. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109738. * @return whether the trigger is handled
  109739. */
  109740. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109741. /**
  109742. * Serialize this manager to a JSON object
  109743. * @param name defines the property name to store this manager
  109744. * @returns a JSON representation of this manager
  109745. */
  109746. abstract serialize(name: string): any;
  109747. /**
  109748. * Registers an action to this action manager
  109749. * @param action defines the action to be registered
  109750. * @return the action amended (prepared) after registration
  109751. */
  109752. abstract registerAction(action: IAction): Nullable<IAction>;
  109753. /**
  109754. * Unregisters an action to this action manager
  109755. * @param action defines the action to be unregistered
  109756. * @return a boolean indicating whether the action has been unregistered
  109757. */
  109758. abstract unregisterAction(action: IAction): Boolean;
  109759. /**
  109760. * Does exist one action manager with at least one trigger
  109761. **/
  109762. static get HasTriggers(): boolean;
  109763. /**
  109764. * Does exist one action manager with at least one pick trigger
  109765. **/
  109766. static get HasPickTriggers(): boolean;
  109767. /**
  109768. * Does exist one action manager that handles actions of a given trigger
  109769. * @param trigger defines the trigger to be tested
  109770. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109771. **/
  109772. static HasSpecificTrigger(trigger: number): boolean;
  109773. }
  109774. }
  109775. declare module BABYLON {
  109776. /**
  109777. * Defines how a node can be built from a string name.
  109778. */
  109779. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109780. /**
  109781. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109782. */
  109783. export class Node implements IBehaviorAware<Node> {
  109784. /** @hidden */
  109785. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109786. private static _NodeConstructors;
  109787. /**
  109788. * Add a new node constructor
  109789. * @param type defines the type name of the node to construct
  109790. * @param constructorFunc defines the constructor function
  109791. */
  109792. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109793. /**
  109794. * Returns a node constructor based on type name
  109795. * @param type defines the type name
  109796. * @param name defines the new node name
  109797. * @param scene defines the hosting scene
  109798. * @param options defines optional options to transmit to constructors
  109799. * @returns the new constructor or null
  109800. */
  109801. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109802. /**
  109803. * Gets or sets the name of the node
  109804. */
  109805. name: string;
  109806. /**
  109807. * Gets or sets the id of the node
  109808. */
  109809. id: string;
  109810. /**
  109811. * Gets or sets the unique id of the node
  109812. */
  109813. uniqueId: number;
  109814. /**
  109815. * Gets or sets a string used to store user defined state for the node
  109816. */
  109817. state: string;
  109818. /**
  109819. * Gets or sets an object used to store user defined information for the node
  109820. */
  109821. metadata: any;
  109822. /**
  109823. * For internal use only. Please do not use.
  109824. */
  109825. reservedDataStore: any;
  109826. /**
  109827. * List of inspectable custom properties (used by the Inspector)
  109828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109829. */
  109830. inspectableCustomProperties: IInspectable[];
  109831. private _doNotSerialize;
  109832. /**
  109833. * Gets or sets a boolean used to define if the node must be serialized
  109834. */
  109835. get doNotSerialize(): boolean;
  109836. set doNotSerialize(value: boolean);
  109837. /** @hidden */
  109838. _isDisposed: boolean;
  109839. /**
  109840. * Gets a list of Animations associated with the node
  109841. */
  109842. animations: Animation[];
  109843. protected _ranges: {
  109844. [name: string]: Nullable<AnimationRange>;
  109845. };
  109846. /**
  109847. * Callback raised when the node is ready to be used
  109848. */
  109849. onReady: Nullable<(node: Node) => void>;
  109850. private _isEnabled;
  109851. private _isParentEnabled;
  109852. private _isReady;
  109853. /** @hidden */
  109854. _currentRenderId: number;
  109855. private _parentUpdateId;
  109856. /** @hidden */
  109857. _childUpdateId: number;
  109858. /** @hidden */
  109859. _waitingParentId: Nullable<string>;
  109860. /** @hidden */
  109861. _scene: Scene;
  109862. /** @hidden */
  109863. _cache: any;
  109864. private _parentNode;
  109865. private _children;
  109866. /** @hidden */
  109867. _worldMatrix: Matrix;
  109868. /** @hidden */
  109869. _worldMatrixDeterminant: number;
  109870. /** @hidden */
  109871. _worldMatrixDeterminantIsDirty: boolean;
  109872. /** @hidden */
  109873. private _sceneRootNodesIndex;
  109874. /**
  109875. * Gets a boolean indicating if the node has been disposed
  109876. * @returns true if the node was disposed
  109877. */
  109878. isDisposed(): boolean;
  109879. /**
  109880. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109881. * @see https://doc.babylonjs.com/how_to/parenting
  109882. */
  109883. set parent(parent: Nullable<Node>);
  109884. get parent(): Nullable<Node>;
  109885. /** @hidden */
  109886. _addToSceneRootNodes(): void;
  109887. /** @hidden */
  109888. _removeFromSceneRootNodes(): void;
  109889. private _animationPropertiesOverride;
  109890. /**
  109891. * Gets or sets the animation properties override
  109892. */
  109893. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109894. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109895. /**
  109896. * Gets a string idenfifying the name of the class
  109897. * @returns "Node" string
  109898. */
  109899. getClassName(): string;
  109900. /** @hidden */
  109901. readonly _isNode: boolean;
  109902. /**
  109903. * An event triggered when the mesh is disposed
  109904. */
  109905. onDisposeObservable: Observable<Node>;
  109906. private _onDisposeObserver;
  109907. /**
  109908. * Sets a callback that will be raised when the node will be disposed
  109909. */
  109910. set onDispose(callback: () => void);
  109911. /**
  109912. * Creates a new Node
  109913. * @param name the name and id to be given to this node
  109914. * @param scene the scene this node will be added to
  109915. */
  109916. constructor(name: string, scene?: Nullable<Scene>);
  109917. /**
  109918. * Gets the scene of the node
  109919. * @returns a scene
  109920. */
  109921. getScene(): Scene;
  109922. /**
  109923. * Gets the engine of the node
  109924. * @returns a Engine
  109925. */
  109926. getEngine(): Engine;
  109927. private _behaviors;
  109928. /**
  109929. * Attach a behavior to the node
  109930. * @see http://doc.babylonjs.com/features/behaviour
  109931. * @param behavior defines the behavior to attach
  109932. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109933. * @returns the current Node
  109934. */
  109935. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109936. /**
  109937. * Remove an attached behavior
  109938. * @see http://doc.babylonjs.com/features/behaviour
  109939. * @param behavior defines the behavior to attach
  109940. * @returns the current Node
  109941. */
  109942. removeBehavior(behavior: Behavior<Node>): Node;
  109943. /**
  109944. * Gets the list of attached behaviors
  109945. * @see http://doc.babylonjs.com/features/behaviour
  109946. */
  109947. get behaviors(): Behavior<Node>[];
  109948. /**
  109949. * Gets an attached behavior by name
  109950. * @param name defines the name of the behavior to look for
  109951. * @see http://doc.babylonjs.com/features/behaviour
  109952. * @returns null if behavior was not found else the requested behavior
  109953. */
  109954. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109955. /**
  109956. * Returns the latest update of the World matrix
  109957. * @returns a Matrix
  109958. */
  109959. getWorldMatrix(): Matrix;
  109960. /** @hidden */
  109961. _getWorldMatrixDeterminant(): number;
  109962. /**
  109963. * Returns directly the latest state of the mesh World matrix.
  109964. * A Matrix is returned.
  109965. */
  109966. get worldMatrixFromCache(): Matrix;
  109967. /** @hidden */
  109968. _initCache(): void;
  109969. /** @hidden */
  109970. updateCache(force?: boolean): void;
  109971. /** @hidden */
  109972. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109973. /** @hidden */
  109974. _updateCache(ignoreParentClass?: boolean): void;
  109975. /** @hidden */
  109976. _isSynchronized(): boolean;
  109977. /** @hidden */
  109978. _markSyncedWithParent(): void;
  109979. /** @hidden */
  109980. isSynchronizedWithParent(): boolean;
  109981. /** @hidden */
  109982. isSynchronized(): boolean;
  109983. /**
  109984. * Is this node ready to be used/rendered
  109985. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109986. * @return true if the node is ready
  109987. */
  109988. isReady(completeCheck?: boolean): boolean;
  109989. /**
  109990. * Is this node enabled?
  109991. * 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
  109992. * @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
  109993. * @return whether this node (and its parent) is enabled
  109994. */
  109995. isEnabled(checkAncestors?: boolean): boolean;
  109996. /** @hidden */
  109997. protected _syncParentEnabledState(): void;
  109998. /**
  109999. * Set the enabled state of this node
  110000. * @param value defines the new enabled state
  110001. */
  110002. setEnabled(value: boolean): void;
  110003. /**
  110004. * Is this node a descendant of the given node?
  110005. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110006. * @param ancestor defines the parent node to inspect
  110007. * @returns a boolean indicating if this node is a descendant of the given node
  110008. */
  110009. isDescendantOf(ancestor: Node): boolean;
  110010. /** @hidden */
  110011. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110012. /**
  110013. * Will return all nodes that have this node as ascendant
  110014. * @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
  110015. * @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
  110016. * @return all children nodes of all types
  110017. */
  110018. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110019. /**
  110020. * Get all child-meshes of this node
  110021. * @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)
  110022. * @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
  110023. * @returns an array of AbstractMesh
  110024. */
  110025. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110026. /**
  110027. * Get all direct children of this node
  110028. * @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
  110029. * @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)
  110030. * @returns an array of Node
  110031. */
  110032. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110033. /** @hidden */
  110034. _setReady(state: boolean): void;
  110035. /**
  110036. * Get an animation by name
  110037. * @param name defines the name of the animation to look for
  110038. * @returns null if not found else the requested animation
  110039. */
  110040. getAnimationByName(name: string): Nullable<Animation>;
  110041. /**
  110042. * Creates an animation range for this node
  110043. * @param name defines the name of the range
  110044. * @param from defines the starting key
  110045. * @param to defines the end key
  110046. */
  110047. createAnimationRange(name: string, from: number, to: number): void;
  110048. /**
  110049. * Delete a specific animation range
  110050. * @param name defines the name of the range to delete
  110051. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110052. */
  110053. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110054. /**
  110055. * Get an animation range by name
  110056. * @param name defines the name of the animation range to look for
  110057. * @returns null if not found else the requested animation range
  110058. */
  110059. getAnimationRange(name: string): Nullable<AnimationRange>;
  110060. /**
  110061. * Gets the list of all animation ranges defined on this node
  110062. * @returns an array
  110063. */
  110064. getAnimationRanges(): Nullable<AnimationRange>[];
  110065. /**
  110066. * Will start the animation sequence
  110067. * @param name defines the range frames for animation sequence
  110068. * @param loop defines if the animation should loop (false by default)
  110069. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110070. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110071. * @returns the object created for this animation. If range does not exist, it will return null
  110072. */
  110073. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110074. /**
  110075. * Serialize animation ranges into a JSON compatible object
  110076. * @returns serialization object
  110077. */
  110078. serializeAnimationRanges(): any;
  110079. /**
  110080. * Computes the world matrix of the node
  110081. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110082. * @returns the world matrix
  110083. */
  110084. computeWorldMatrix(force?: boolean): Matrix;
  110085. /**
  110086. * Releases resources associated with this node.
  110087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110089. */
  110090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110091. /**
  110092. * Parse animation range data from a serialization object and store them into a given node
  110093. * @param node defines where to store the animation ranges
  110094. * @param parsedNode defines the serialization object to read data from
  110095. * @param scene defines the hosting scene
  110096. */
  110097. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110098. /**
  110099. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110100. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110101. * @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
  110102. * @returns the new bounding vectors
  110103. */
  110104. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110105. min: Vector3;
  110106. max: Vector3;
  110107. };
  110108. }
  110109. }
  110110. declare module BABYLON {
  110111. /**
  110112. * @hidden
  110113. */
  110114. export class _IAnimationState {
  110115. key: number;
  110116. repeatCount: number;
  110117. workValue?: any;
  110118. loopMode?: number;
  110119. offsetValue?: any;
  110120. highLimitValue?: any;
  110121. }
  110122. /**
  110123. * Class used to store any kind of animation
  110124. */
  110125. export class Animation {
  110126. /**Name of the animation */
  110127. name: string;
  110128. /**Property to animate */
  110129. targetProperty: string;
  110130. /**The frames per second of the animation */
  110131. framePerSecond: number;
  110132. /**The data type of the animation */
  110133. dataType: number;
  110134. /**The loop mode of the animation */
  110135. loopMode?: number | undefined;
  110136. /**Specifies if blending should be enabled */
  110137. enableBlending?: boolean | undefined;
  110138. /**
  110139. * Use matrix interpolation instead of using direct key value when animating matrices
  110140. */
  110141. static AllowMatricesInterpolation: boolean;
  110142. /**
  110143. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110144. */
  110145. static AllowMatrixDecomposeForInterpolation: boolean;
  110146. /** Define the Url to load snippets */
  110147. static SnippetUrl: string;
  110148. /** Snippet ID if the animation was created from the snippet server */
  110149. snippetId: string;
  110150. /**
  110151. * Stores the key frames of the animation
  110152. */
  110153. private _keys;
  110154. /**
  110155. * Stores the easing function of the animation
  110156. */
  110157. private _easingFunction;
  110158. /**
  110159. * @hidden Internal use only
  110160. */
  110161. _runtimeAnimations: RuntimeAnimation[];
  110162. /**
  110163. * The set of event that will be linked to this animation
  110164. */
  110165. private _events;
  110166. /**
  110167. * Stores an array of target property paths
  110168. */
  110169. targetPropertyPath: string[];
  110170. /**
  110171. * Stores the blending speed of the animation
  110172. */
  110173. blendingSpeed: number;
  110174. /**
  110175. * Stores the animation ranges for the animation
  110176. */
  110177. private _ranges;
  110178. /**
  110179. * @hidden Internal use
  110180. */
  110181. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110182. /**
  110183. * Sets up an animation
  110184. * @param property The property to animate
  110185. * @param animationType The animation type to apply
  110186. * @param framePerSecond The frames per second of the animation
  110187. * @param easingFunction The easing function used in the animation
  110188. * @returns The created animation
  110189. */
  110190. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110191. /**
  110192. * Create and start an animation on a node
  110193. * @param name defines the name of the global animation that will be run on all nodes
  110194. * @param node defines the root node where the animation will take place
  110195. * @param targetProperty defines property to animate
  110196. * @param framePerSecond defines the number of frame per second yo use
  110197. * @param totalFrame defines the number of frames in total
  110198. * @param from defines the initial value
  110199. * @param to defines the final value
  110200. * @param loopMode defines which loop mode you want to use (off by default)
  110201. * @param easingFunction defines the easing function to use (linear by default)
  110202. * @param onAnimationEnd defines the callback to call when animation end
  110203. * @returns the animatable created for this animation
  110204. */
  110205. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110206. /**
  110207. * Create and start an animation on a node and its descendants
  110208. * @param name defines the name of the global animation that will be run on all nodes
  110209. * @param node defines the root node where the animation will take place
  110210. * @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
  110211. * @param targetProperty defines property to animate
  110212. * @param framePerSecond defines the number of frame per second to use
  110213. * @param totalFrame defines the number of frames in total
  110214. * @param from defines the initial value
  110215. * @param to defines the final value
  110216. * @param loopMode defines which loop mode you want to use (off by default)
  110217. * @param easingFunction defines the easing function to use (linear by default)
  110218. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110219. * @returns the list of animatables created for all nodes
  110220. * @example https://www.babylonjs-playground.com/#MH0VLI
  110221. */
  110222. 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[]>;
  110223. /**
  110224. * Creates a new animation, merges it with the existing animations and starts it
  110225. * @param name Name of the animation
  110226. * @param node Node which contains the scene that begins the animations
  110227. * @param targetProperty Specifies which property to animate
  110228. * @param framePerSecond The frames per second of the animation
  110229. * @param totalFrame The total number of frames
  110230. * @param from The frame at the beginning of the animation
  110231. * @param to The frame at the end of the animation
  110232. * @param loopMode Specifies the loop mode of the animation
  110233. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110234. * @param onAnimationEnd Callback to run once the animation is complete
  110235. * @returns Nullable animation
  110236. */
  110237. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110238. /**
  110239. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110240. * @param sourceAnimation defines the Animation containing keyframes to convert
  110241. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110242. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110243. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110244. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110245. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110246. */
  110247. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110248. /**
  110249. * Transition property of an host to the target Value
  110250. * @param property The property to transition
  110251. * @param targetValue The target Value of the property
  110252. * @param host The object where the property to animate belongs
  110253. * @param scene Scene used to run the animation
  110254. * @param frameRate Framerate (in frame/s) to use
  110255. * @param transition The transition type we want to use
  110256. * @param duration The duration of the animation, in milliseconds
  110257. * @param onAnimationEnd Callback trigger at the end of the animation
  110258. * @returns Nullable animation
  110259. */
  110260. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110261. /**
  110262. * Return the array of runtime animations currently using this animation
  110263. */
  110264. get runtimeAnimations(): RuntimeAnimation[];
  110265. /**
  110266. * Specifies if any of the runtime animations are currently running
  110267. */
  110268. get hasRunningRuntimeAnimations(): boolean;
  110269. /**
  110270. * Initializes the animation
  110271. * @param name Name of the animation
  110272. * @param targetProperty Property to animate
  110273. * @param framePerSecond The frames per second of the animation
  110274. * @param dataType The data type of the animation
  110275. * @param loopMode The loop mode of the animation
  110276. * @param enableBlending Specifies if blending should be enabled
  110277. */
  110278. constructor(
  110279. /**Name of the animation */
  110280. name: string,
  110281. /**Property to animate */
  110282. targetProperty: string,
  110283. /**The frames per second of the animation */
  110284. framePerSecond: number,
  110285. /**The data type of the animation */
  110286. dataType: number,
  110287. /**The loop mode of the animation */
  110288. loopMode?: number | undefined,
  110289. /**Specifies if blending should be enabled */
  110290. enableBlending?: boolean | undefined);
  110291. /**
  110292. * Converts the animation to a string
  110293. * @param fullDetails support for multiple levels of logging within scene loading
  110294. * @returns String form of the animation
  110295. */
  110296. toString(fullDetails?: boolean): string;
  110297. /**
  110298. * Add an event to this animation
  110299. * @param event Event to add
  110300. */
  110301. addEvent(event: AnimationEvent): void;
  110302. /**
  110303. * Remove all events found at the given frame
  110304. * @param frame The frame to remove events from
  110305. */
  110306. removeEvents(frame: number): void;
  110307. /**
  110308. * Retrieves all the events from the animation
  110309. * @returns Events from the animation
  110310. */
  110311. getEvents(): AnimationEvent[];
  110312. /**
  110313. * Creates an animation range
  110314. * @param name Name of the animation range
  110315. * @param from Starting frame of the animation range
  110316. * @param to Ending frame of the animation
  110317. */
  110318. createRange(name: string, from: number, to: number): void;
  110319. /**
  110320. * Deletes an animation range by name
  110321. * @param name Name of the animation range to delete
  110322. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110323. */
  110324. deleteRange(name: string, deleteFrames?: boolean): void;
  110325. /**
  110326. * Gets the animation range by name, or null if not defined
  110327. * @param name Name of the animation range
  110328. * @returns Nullable animation range
  110329. */
  110330. getRange(name: string): Nullable<AnimationRange>;
  110331. /**
  110332. * Gets the key frames from the animation
  110333. * @returns The key frames of the animation
  110334. */
  110335. getKeys(): Array<IAnimationKey>;
  110336. /**
  110337. * Gets the highest frame rate of the animation
  110338. * @returns Highest frame rate of the animation
  110339. */
  110340. getHighestFrame(): number;
  110341. /**
  110342. * Gets the easing function of the animation
  110343. * @returns Easing function of the animation
  110344. */
  110345. getEasingFunction(): IEasingFunction;
  110346. /**
  110347. * Sets the easing function of the animation
  110348. * @param easingFunction A custom mathematical formula for animation
  110349. */
  110350. setEasingFunction(easingFunction: EasingFunction): void;
  110351. /**
  110352. * Interpolates a scalar linearly
  110353. * @param startValue Start value of the animation curve
  110354. * @param endValue End value of the animation curve
  110355. * @param gradient Scalar amount to interpolate
  110356. * @returns Interpolated scalar value
  110357. */
  110358. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110359. /**
  110360. * Interpolates a scalar cubically
  110361. * @param startValue Start value of the animation curve
  110362. * @param outTangent End tangent of the animation
  110363. * @param endValue End value of the animation curve
  110364. * @param inTangent Start tangent of the animation curve
  110365. * @param gradient Scalar amount to interpolate
  110366. * @returns Interpolated scalar value
  110367. */
  110368. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110369. /**
  110370. * Interpolates a quaternion using a spherical linear interpolation
  110371. * @param startValue Start value of the animation curve
  110372. * @param endValue End value of the animation curve
  110373. * @param gradient Scalar amount to interpolate
  110374. * @returns Interpolated quaternion value
  110375. */
  110376. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110377. /**
  110378. * Interpolates a quaternion cubically
  110379. * @param startValue Start value of the animation curve
  110380. * @param outTangent End tangent of the animation curve
  110381. * @param endValue End value of the animation curve
  110382. * @param inTangent Start tangent of the animation curve
  110383. * @param gradient Scalar amount to interpolate
  110384. * @returns Interpolated quaternion value
  110385. */
  110386. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110387. /**
  110388. * Interpolates a Vector3 linearl
  110389. * @param startValue Start value of the animation curve
  110390. * @param endValue End value of the animation curve
  110391. * @param gradient Scalar amount to interpolate
  110392. * @returns Interpolated scalar value
  110393. */
  110394. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110395. /**
  110396. * Interpolates a Vector3 cubically
  110397. * @param startValue Start value of the animation curve
  110398. * @param outTangent End tangent of the animation
  110399. * @param endValue End value of the animation curve
  110400. * @param inTangent Start tangent of the animation curve
  110401. * @param gradient Scalar amount to interpolate
  110402. * @returns InterpolatedVector3 value
  110403. */
  110404. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110405. /**
  110406. * Interpolates a Vector2 linearly
  110407. * @param startValue Start value of the animation curve
  110408. * @param endValue End value of the animation curve
  110409. * @param gradient Scalar amount to interpolate
  110410. * @returns Interpolated Vector2 value
  110411. */
  110412. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110413. /**
  110414. * Interpolates a Vector2 cubically
  110415. * @param startValue Start value of the animation curve
  110416. * @param outTangent End tangent of the animation
  110417. * @param endValue End value of the animation curve
  110418. * @param inTangent Start tangent of the animation curve
  110419. * @param gradient Scalar amount to interpolate
  110420. * @returns Interpolated Vector2 value
  110421. */
  110422. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110423. /**
  110424. * Interpolates a size linearly
  110425. * @param startValue Start value of the animation curve
  110426. * @param endValue End value of the animation curve
  110427. * @param gradient Scalar amount to interpolate
  110428. * @returns Interpolated Size value
  110429. */
  110430. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110431. /**
  110432. * Interpolates a Color3 linearly
  110433. * @param startValue Start value of the animation curve
  110434. * @param endValue End value of the animation curve
  110435. * @param gradient Scalar amount to interpolate
  110436. * @returns Interpolated Color3 value
  110437. */
  110438. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110439. /**
  110440. * Interpolates a Color4 linearly
  110441. * @param startValue Start value of the animation curve
  110442. * @param endValue End value of the animation curve
  110443. * @param gradient Scalar amount to interpolate
  110444. * @returns Interpolated Color3 value
  110445. */
  110446. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110447. /**
  110448. * @hidden Internal use only
  110449. */
  110450. _getKeyValue(value: any): any;
  110451. /**
  110452. * @hidden Internal use only
  110453. */
  110454. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110455. /**
  110456. * Defines the function to use to interpolate matrices
  110457. * @param startValue defines the start matrix
  110458. * @param endValue defines the end matrix
  110459. * @param gradient defines the gradient between both matrices
  110460. * @param result defines an optional target matrix where to store the interpolation
  110461. * @returns the interpolated matrix
  110462. */
  110463. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110464. /**
  110465. * Makes a copy of the animation
  110466. * @returns Cloned animation
  110467. */
  110468. clone(): Animation;
  110469. /**
  110470. * Sets the key frames of the animation
  110471. * @param values The animation key frames to set
  110472. */
  110473. setKeys(values: Array<IAnimationKey>): void;
  110474. /**
  110475. * Serializes the animation to an object
  110476. * @returns Serialized object
  110477. */
  110478. serialize(): any;
  110479. /**
  110480. * Float animation type
  110481. */
  110482. static readonly ANIMATIONTYPE_FLOAT: number;
  110483. /**
  110484. * Vector3 animation type
  110485. */
  110486. static readonly ANIMATIONTYPE_VECTOR3: number;
  110487. /**
  110488. * Quaternion animation type
  110489. */
  110490. static readonly ANIMATIONTYPE_QUATERNION: number;
  110491. /**
  110492. * Matrix animation type
  110493. */
  110494. static readonly ANIMATIONTYPE_MATRIX: number;
  110495. /**
  110496. * Color3 animation type
  110497. */
  110498. static readonly ANIMATIONTYPE_COLOR3: number;
  110499. /**
  110500. * Color3 animation type
  110501. */
  110502. static readonly ANIMATIONTYPE_COLOR4: number;
  110503. /**
  110504. * Vector2 animation type
  110505. */
  110506. static readonly ANIMATIONTYPE_VECTOR2: number;
  110507. /**
  110508. * Size animation type
  110509. */
  110510. static readonly ANIMATIONTYPE_SIZE: number;
  110511. /**
  110512. * Relative Loop Mode
  110513. */
  110514. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110515. /**
  110516. * Cycle Loop Mode
  110517. */
  110518. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110519. /**
  110520. * Constant Loop Mode
  110521. */
  110522. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110523. /** @hidden */
  110524. static _UniversalLerp(left: any, right: any, amount: number): any;
  110525. /**
  110526. * Parses an animation object and creates an animation
  110527. * @param parsedAnimation Parsed animation object
  110528. * @returns Animation object
  110529. */
  110530. static Parse(parsedAnimation: any): Animation;
  110531. /**
  110532. * Appends the serialized animations from the source animations
  110533. * @param source Source containing the animations
  110534. * @param destination Target to store the animations
  110535. */
  110536. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110537. /**
  110538. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110539. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110540. * @param url defines the url to load from
  110541. * @returns a promise that will resolve to the new animation or an array of animations
  110542. */
  110543. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110544. /**
  110545. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110546. * @param snippetId defines the snippet to load
  110547. * @returns a promise that will resolve to the new animation or a new array of animations
  110548. */
  110549. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110550. }
  110551. }
  110552. declare module BABYLON {
  110553. /**
  110554. * Interface containing an array of animations
  110555. */
  110556. export interface IAnimatable {
  110557. /**
  110558. * Array of animations
  110559. */
  110560. animations: Nullable<Array<Animation>>;
  110561. }
  110562. }
  110563. declare module BABYLON {
  110564. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110565. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110566. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110567. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110568. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110569. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110570. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110571. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110572. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110573. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110574. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110575. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110576. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110577. /**
  110578. * Decorator used to define property that can be serialized as reference to a camera
  110579. * @param sourceName defines the name of the property to decorate
  110580. */
  110581. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110582. /**
  110583. * Class used to help serialization objects
  110584. */
  110585. export class SerializationHelper {
  110586. /** @hidden */
  110587. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110588. /** @hidden */
  110589. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110590. /** @hidden */
  110591. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110592. /** @hidden */
  110593. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110594. /**
  110595. * Appends the serialized animations from the source animations
  110596. * @param source Source containing the animations
  110597. * @param destination Target to store the animations
  110598. */
  110599. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110600. /**
  110601. * Static function used to serialized a specific entity
  110602. * @param entity defines the entity to serialize
  110603. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110604. * @returns a JSON compatible object representing the serialization of the entity
  110605. */
  110606. static Serialize<T>(entity: T, serializationObject?: any): any;
  110607. /**
  110608. * Creates a new entity from a serialization data object
  110609. * @param creationFunction defines a function used to instanciated the new entity
  110610. * @param source defines the source serialization data
  110611. * @param scene defines the hosting scene
  110612. * @param rootUrl defines the root url for resources
  110613. * @returns a new entity
  110614. */
  110615. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110616. /**
  110617. * Clones an object
  110618. * @param creationFunction defines the function used to instanciate the new object
  110619. * @param source defines the source object
  110620. * @returns the cloned object
  110621. */
  110622. static Clone<T>(creationFunction: () => T, source: T): T;
  110623. /**
  110624. * Instanciates a new object based on a source one (some data will be shared between both object)
  110625. * @param creationFunction defines the function used to instanciate the new object
  110626. * @param source defines the source object
  110627. * @returns the new object
  110628. */
  110629. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /**
  110634. * Base class of all the textures in babylon.
  110635. * It groups all the common properties the materials, post process, lights... might need
  110636. * in order to make a correct use of the texture.
  110637. */
  110638. export class BaseTexture implements IAnimatable {
  110639. /**
  110640. * Default anisotropic filtering level for the application.
  110641. * It is set to 4 as a good tradeoff between perf and quality.
  110642. */
  110643. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110644. /**
  110645. * Gets or sets the unique id of the texture
  110646. */
  110647. uniqueId: number;
  110648. /**
  110649. * Define the name of the texture.
  110650. */
  110651. name: string;
  110652. /**
  110653. * Gets or sets an object used to store user defined information.
  110654. */
  110655. metadata: any;
  110656. /**
  110657. * For internal use only. Please do not use.
  110658. */
  110659. reservedDataStore: any;
  110660. private _hasAlpha;
  110661. /**
  110662. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110663. */
  110664. set hasAlpha(value: boolean);
  110665. get hasAlpha(): boolean;
  110666. /**
  110667. * Defines if the alpha value should be determined via the rgb values.
  110668. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110669. */
  110670. getAlphaFromRGB: boolean;
  110671. /**
  110672. * Intensity or strength of the texture.
  110673. * It is commonly used by materials to fine tune the intensity of the texture
  110674. */
  110675. level: number;
  110676. /**
  110677. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110678. * This is part of the texture as textures usually maps to one uv set.
  110679. */
  110680. coordinatesIndex: number;
  110681. private _coordinatesMode;
  110682. /**
  110683. * How a texture is mapped.
  110684. *
  110685. * | Value | Type | Description |
  110686. * | ----- | ----------------------------------- | ----------- |
  110687. * | 0 | EXPLICIT_MODE | |
  110688. * | 1 | SPHERICAL_MODE | |
  110689. * | 2 | PLANAR_MODE | |
  110690. * | 3 | CUBIC_MODE | |
  110691. * | 4 | PROJECTION_MODE | |
  110692. * | 5 | SKYBOX_MODE | |
  110693. * | 6 | INVCUBIC_MODE | |
  110694. * | 7 | EQUIRECTANGULAR_MODE | |
  110695. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110696. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110697. */
  110698. set coordinatesMode(value: number);
  110699. get coordinatesMode(): number;
  110700. /**
  110701. * | Value | Type | Description |
  110702. * | ----- | ------------------ | ----------- |
  110703. * | 0 | CLAMP_ADDRESSMODE | |
  110704. * | 1 | WRAP_ADDRESSMODE | |
  110705. * | 2 | MIRROR_ADDRESSMODE | |
  110706. */
  110707. wrapU: number;
  110708. /**
  110709. * | Value | Type | Description |
  110710. * | ----- | ------------------ | ----------- |
  110711. * | 0 | CLAMP_ADDRESSMODE | |
  110712. * | 1 | WRAP_ADDRESSMODE | |
  110713. * | 2 | MIRROR_ADDRESSMODE | |
  110714. */
  110715. wrapV: number;
  110716. /**
  110717. * | Value | Type | Description |
  110718. * | ----- | ------------------ | ----------- |
  110719. * | 0 | CLAMP_ADDRESSMODE | |
  110720. * | 1 | WRAP_ADDRESSMODE | |
  110721. * | 2 | MIRROR_ADDRESSMODE | |
  110722. */
  110723. wrapR: number;
  110724. /**
  110725. * With compliant hardware and browser (supporting anisotropic filtering)
  110726. * this defines the level of anisotropic filtering in the texture.
  110727. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110728. */
  110729. anisotropicFilteringLevel: number;
  110730. /**
  110731. * Define if the texture is a cube texture or if false a 2d texture.
  110732. */
  110733. get isCube(): boolean;
  110734. set isCube(value: boolean);
  110735. /**
  110736. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110737. */
  110738. get is3D(): boolean;
  110739. set is3D(value: boolean);
  110740. /**
  110741. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110742. */
  110743. get is2DArray(): boolean;
  110744. set is2DArray(value: boolean);
  110745. /**
  110746. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110747. * HDR texture are usually stored in linear space.
  110748. * This only impacts the PBR and Background materials
  110749. */
  110750. gammaSpace: boolean;
  110751. /**
  110752. * Gets or sets whether or not the texture contains RGBD data.
  110753. */
  110754. get isRGBD(): boolean;
  110755. set isRGBD(value: boolean);
  110756. /**
  110757. * Is Z inverted in the texture (useful in a cube texture).
  110758. */
  110759. invertZ: boolean;
  110760. /**
  110761. * Are mip maps generated for this texture or not.
  110762. */
  110763. get noMipmap(): boolean;
  110764. /**
  110765. * @hidden
  110766. */
  110767. lodLevelInAlpha: boolean;
  110768. /**
  110769. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110770. */
  110771. get lodGenerationOffset(): number;
  110772. set lodGenerationOffset(value: number);
  110773. /**
  110774. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110775. */
  110776. get lodGenerationScale(): number;
  110777. set lodGenerationScale(value: number);
  110778. /**
  110779. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110780. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110781. * average roughness values.
  110782. */
  110783. get linearSpecularLOD(): boolean;
  110784. set linearSpecularLOD(value: boolean);
  110785. /**
  110786. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110787. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110788. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110789. */
  110790. get irradianceTexture(): Nullable<BaseTexture>;
  110791. set irradianceTexture(value: Nullable<BaseTexture>);
  110792. /**
  110793. * Define if the texture is a render target.
  110794. */
  110795. isRenderTarget: boolean;
  110796. /**
  110797. * Define the unique id of the texture in the scene.
  110798. */
  110799. get uid(): string;
  110800. /** @hidden */
  110801. _prefiltered: boolean;
  110802. /**
  110803. * Return a string representation of the texture.
  110804. * @returns the texture as a string
  110805. */
  110806. toString(): string;
  110807. /**
  110808. * Get the class name of the texture.
  110809. * @returns "BaseTexture"
  110810. */
  110811. getClassName(): string;
  110812. /**
  110813. * Define the list of animation attached to the texture.
  110814. */
  110815. animations: Animation[];
  110816. /**
  110817. * An event triggered when the texture is disposed.
  110818. */
  110819. onDisposeObservable: Observable<BaseTexture>;
  110820. private _onDisposeObserver;
  110821. /**
  110822. * Callback triggered when the texture has been disposed.
  110823. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110824. */
  110825. set onDispose(callback: () => void);
  110826. /**
  110827. * Define the current state of the loading sequence when in delayed load mode.
  110828. */
  110829. delayLoadState: number;
  110830. private _scene;
  110831. private _engine;
  110832. /** @hidden */
  110833. _texture: Nullable<InternalTexture>;
  110834. private _uid;
  110835. /**
  110836. * Define if the texture is preventinga material to render or not.
  110837. * If not and the texture is not ready, the engine will use a default black texture instead.
  110838. */
  110839. get isBlocking(): boolean;
  110840. /**
  110841. * Instantiates a new BaseTexture.
  110842. * Base class of all the textures in babylon.
  110843. * It groups all the common properties the materials, post process, lights... might need
  110844. * in order to make a correct use of the texture.
  110845. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110846. */
  110847. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110848. /**
  110849. * Get the scene the texture belongs to.
  110850. * @returns the scene or null if undefined
  110851. */
  110852. getScene(): Nullable<Scene>;
  110853. /** @hidden */
  110854. protected _getEngine(): Nullable<ThinEngine>;
  110855. /**
  110856. * Get the texture transform matrix used to offset tile the texture for istance.
  110857. * @returns the transformation matrix
  110858. */
  110859. getTextureMatrix(): Matrix;
  110860. /**
  110861. * Get the texture reflection matrix used to rotate/transform the reflection.
  110862. * @returns the reflection matrix
  110863. */
  110864. getReflectionTextureMatrix(): Matrix;
  110865. /**
  110866. * Get the underlying lower level texture from Babylon.
  110867. * @returns the insternal texture
  110868. */
  110869. getInternalTexture(): Nullable<InternalTexture>;
  110870. /**
  110871. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110872. * @returns true if ready or not blocking
  110873. */
  110874. isReadyOrNotBlocking(): boolean;
  110875. /**
  110876. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110877. * @returns true if fully ready
  110878. */
  110879. isReady(): boolean;
  110880. private _cachedSize;
  110881. /**
  110882. * Get the size of the texture.
  110883. * @returns the texture size.
  110884. */
  110885. getSize(): ISize;
  110886. /**
  110887. * Get the base size of the texture.
  110888. * It can be different from the size if the texture has been resized for POT for instance
  110889. * @returns the base size
  110890. */
  110891. getBaseSize(): ISize;
  110892. /**
  110893. * Update the sampling mode of the texture.
  110894. * Default is Trilinear mode.
  110895. *
  110896. * | Value | Type | Description |
  110897. * | ----- | ------------------ | ----------- |
  110898. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110899. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110900. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110901. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110902. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110903. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110904. * | 7 | NEAREST_LINEAR | |
  110905. * | 8 | NEAREST_NEAREST | |
  110906. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110907. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110908. * | 11 | LINEAR_LINEAR | |
  110909. * | 12 | LINEAR_NEAREST | |
  110910. *
  110911. * > _mag_: magnification filter (close to the viewer)
  110912. * > _min_: minification filter (far from the viewer)
  110913. * > _mip_: filter used between mip map levels
  110914. *@param samplingMode Define the new sampling mode of the texture
  110915. */
  110916. updateSamplingMode(samplingMode: number): void;
  110917. /**
  110918. * Scales the texture if is `canRescale()`
  110919. * @param ratio the resize factor we want to use to rescale
  110920. */
  110921. scale(ratio: number): void;
  110922. /**
  110923. * Get if the texture can rescale.
  110924. */
  110925. get canRescale(): boolean;
  110926. /** @hidden */
  110927. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110928. /** @hidden */
  110929. _rebuild(): void;
  110930. /**
  110931. * Triggers the load sequence in delayed load mode.
  110932. */
  110933. delayLoad(): void;
  110934. /**
  110935. * Clones the texture.
  110936. * @returns the cloned texture
  110937. */
  110938. clone(): Nullable<BaseTexture>;
  110939. /**
  110940. * Get the texture underlying type (INT, FLOAT...)
  110941. */
  110942. get textureType(): number;
  110943. /**
  110944. * Get the texture underlying format (RGB, RGBA...)
  110945. */
  110946. get textureFormat(): number;
  110947. /**
  110948. * Indicates that textures need to be re-calculated for all materials
  110949. */
  110950. protected _markAllSubMeshesAsTexturesDirty(): void;
  110951. /**
  110952. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110953. * This will returns an RGBA array buffer containing either in values (0-255) or
  110954. * float values (0-1) depending of the underlying buffer type.
  110955. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110956. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110957. * @param buffer defines a user defined buffer to fill with data (can be null)
  110958. * @returns The Array buffer containing the pixels data.
  110959. */
  110960. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110961. /**
  110962. * Release and destroy the underlying lower level texture aka internalTexture.
  110963. */
  110964. releaseInternalTexture(): void;
  110965. /** @hidden */
  110966. get _lodTextureHigh(): Nullable<BaseTexture>;
  110967. /** @hidden */
  110968. get _lodTextureMid(): Nullable<BaseTexture>;
  110969. /** @hidden */
  110970. get _lodTextureLow(): Nullable<BaseTexture>;
  110971. /**
  110972. * Dispose the texture and release its associated resources.
  110973. */
  110974. dispose(): void;
  110975. /**
  110976. * Serialize the texture into a JSON representation that can be parsed later on.
  110977. * @returns the JSON representation of the texture
  110978. */
  110979. serialize(): any;
  110980. /**
  110981. * Helper function to be called back once a list of texture contains only ready textures.
  110982. * @param textures Define the list of textures to wait for
  110983. * @param callback Define the callback triggered once the entire list will be ready
  110984. */
  110985. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110986. private static _isScene;
  110987. }
  110988. }
  110989. declare module BABYLON {
  110990. /**
  110991. * Options to be used when creating an effect.
  110992. */
  110993. export interface IEffectCreationOptions {
  110994. /**
  110995. * Atrributes that will be used in the shader.
  110996. */
  110997. attributes: string[];
  110998. /**
  110999. * Uniform varible names that will be set in the shader.
  111000. */
  111001. uniformsNames: string[];
  111002. /**
  111003. * Uniform buffer variable names that will be set in the shader.
  111004. */
  111005. uniformBuffersNames: string[];
  111006. /**
  111007. * Sampler texture variable names that will be set in the shader.
  111008. */
  111009. samplers: string[];
  111010. /**
  111011. * Define statements that will be set in the shader.
  111012. */
  111013. defines: any;
  111014. /**
  111015. * Possible fallbacks for this effect to improve performance when needed.
  111016. */
  111017. fallbacks: Nullable<IEffectFallbacks>;
  111018. /**
  111019. * Callback that will be called when the shader is compiled.
  111020. */
  111021. onCompiled: Nullable<(effect: Effect) => void>;
  111022. /**
  111023. * Callback that will be called if an error occurs during shader compilation.
  111024. */
  111025. onError: Nullable<(effect: Effect, errors: string) => void>;
  111026. /**
  111027. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111028. */
  111029. indexParameters?: any;
  111030. /**
  111031. * Max number of lights that can be used in the shader.
  111032. */
  111033. maxSimultaneousLights?: number;
  111034. /**
  111035. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111036. */
  111037. transformFeedbackVaryings?: Nullable<string[]>;
  111038. /**
  111039. * 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
  111040. */
  111041. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111042. }
  111043. /**
  111044. * Effect containing vertex and fragment shader that can be executed on an object.
  111045. */
  111046. export class Effect implements IDisposable {
  111047. /**
  111048. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111049. */
  111050. static ShadersRepository: string;
  111051. /**
  111052. * Enable logging of the shader code when a compilation error occurs
  111053. */
  111054. static LogShaderCodeOnCompilationError: boolean;
  111055. /**
  111056. * Name of the effect.
  111057. */
  111058. name: any;
  111059. /**
  111060. * String container all the define statements that should be set on the shader.
  111061. */
  111062. defines: string;
  111063. /**
  111064. * Callback that will be called when the shader is compiled.
  111065. */
  111066. onCompiled: Nullable<(effect: Effect) => void>;
  111067. /**
  111068. * Callback that will be called if an error occurs during shader compilation.
  111069. */
  111070. onError: Nullable<(effect: Effect, errors: string) => void>;
  111071. /**
  111072. * Callback that will be called when effect is bound.
  111073. */
  111074. onBind: Nullable<(effect: Effect) => void>;
  111075. /**
  111076. * Unique ID of the effect.
  111077. */
  111078. uniqueId: number;
  111079. /**
  111080. * Observable that will be called when the shader is compiled.
  111081. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111082. */
  111083. onCompileObservable: Observable<Effect>;
  111084. /**
  111085. * Observable that will be called if an error occurs during shader compilation.
  111086. */
  111087. onErrorObservable: Observable<Effect>;
  111088. /** @hidden */
  111089. _onBindObservable: Nullable<Observable<Effect>>;
  111090. /**
  111091. * @hidden
  111092. * Specifies if the effect was previously ready
  111093. */
  111094. _wasPreviouslyReady: boolean;
  111095. /**
  111096. * Observable that will be called when effect is bound.
  111097. */
  111098. get onBindObservable(): Observable<Effect>;
  111099. /** @hidden */
  111100. _bonesComputationForcedToCPU: boolean;
  111101. private static _uniqueIdSeed;
  111102. private _engine;
  111103. private _uniformBuffersNames;
  111104. private _uniformBuffersNamesList;
  111105. private _uniformsNames;
  111106. private _samplerList;
  111107. private _samplers;
  111108. private _isReady;
  111109. private _compilationError;
  111110. private _allFallbacksProcessed;
  111111. private _attributesNames;
  111112. private _attributes;
  111113. private _attributeLocationByName;
  111114. private _uniforms;
  111115. /**
  111116. * Key for the effect.
  111117. * @hidden
  111118. */
  111119. _key: string;
  111120. private _indexParameters;
  111121. private _fallbacks;
  111122. private _vertexSourceCode;
  111123. private _fragmentSourceCode;
  111124. private _vertexSourceCodeOverride;
  111125. private _fragmentSourceCodeOverride;
  111126. private _transformFeedbackVaryings;
  111127. /**
  111128. * Compiled shader to webGL program.
  111129. * @hidden
  111130. */
  111131. _pipelineContext: Nullable<IPipelineContext>;
  111132. private _valueCache;
  111133. private static _baseCache;
  111134. /**
  111135. * Instantiates an effect.
  111136. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111137. * @param baseName Name of the effect.
  111138. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111139. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111140. * @param samplers List of sampler variables that will be passed to the shader.
  111141. * @param engine Engine to be used to render the effect
  111142. * @param defines Define statements to be added to the shader.
  111143. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111144. * @param onCompiled Callback that will be called when the shader is compiled.
  111145. * @param onError Callback that will be called if an error occurs during shader compilation.
  111146. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111147. */
  111148. 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);
  111149. private _useFinalCode;
  111150. /**
  111151. * Unique key for this effect
  111152. */
  111153. get key(): string;
  111154. /**
  111155. * If the effect has been compiled and prepared.
  111156. * @returns if the effect is compiled and prepared.
  111157. */
  111158. isReady(): boolean;
  111159. private _isReadyInternal;
  111160. /**
  111161. * The engine the effect was initialized with.
  111162. * @returns the engine.
  111163. */
  111164. getEngine(): Engine;
  111165. /**
  111166. * The pipeline context for this effect
  111167. * @returns the associated pipeline context
  111168. */
  111169. getPipelineContext(): Nullable<IPipelineContext>;
  111170. /**
  111171. * The set of names of attribute variables for the shader.
  111172. * @returns An array of attribute names.
  111173. */
  111174. getAttributesNames(): string[];
  111175. /**
  111176. * Returns the attribute at the given index.
  111177. * @param index The index of the attribute.
  111178. * @returns The location of the attribute.
  111179. */
  111180. getAttributeLocation(index: number): number;
  111181. /**
  111182. * Returns the attribute based on the name of the variable.
  111183. * @param name of the attribute to look up.
  111184. * @returns the attribute location.
  111185. */
  111186. getAttributeLocationByName(name: string): number;
  111187. /**
  111188. * The number of attributes.
  111189. * @returns the numnber of attributes.
  111190. */
  111191. getAttributesCount(): number;
  111192. /**
  111193. * Gets the index of a uniform variable.
  111194. * @param uniformName of the uniform to look up.
  111195. * @returns the index.
  111196. */
  111197. getUniformIndex(uniformName: string): number;
  111198. /**
  111199. * Returns the attribute based on the name of the variable.
  111200. * @param uniformName of the uniform to look up.
  111201. * @returns the location of the uniform.
  111202. */
  111203. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111204. /**
  111205. * Returns an array of sampler variable names
  111206. * @returns The array of sampler variable names.
  111207. */
  111208. getSamplers(): string[];
  111209. /**
  111210. * Returns an array of uniform variable names
  111211. * @returns The array of uniform variable names.
  111212. */
  111213. getUniformNames(): string[];
  111214. /**
  111215. * Returns an array of uniform buffer variable names
  111216. * @returns The array of uniform buffer variable names.
  111217. */
  111218. getUniformBuffersNames(): string[];
  111219. /**
  111220. * Returns the index parameters used to create the effect
  111221. * @returns The index parameters object
  111222. */
  111223. getIndexParameters(): any;
  111224. /**
  111225. * The error from the last compilation.
  111226. * @returns the error string.
  111227. */
  111228. getCompilationError(): string;
  111229. /**
  111230. * Gets a boolean indicating that all fallbacks were used during compilation
  111231. * @returns true if all fallbacks were used
  111232. */
  111233. allFallbacksProcessed(): boolean;
  111234. /**
  111235. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111236. * @param func The callback to be used.
  111237. */
  111238. executeWhenCompiled(func: (effect: Effect) => void): void;
  111239. private _checkIsReady;
  111240. private _loadShader;
  111241. /**
  111242. * Gets the vertex shader source code of this effect
  111243. */
  111244. get vertexSourceCode(): string;
  111245. /**
  111246. * Gets the fragment shader source code of this effect
  111247. */
  111248. get fragmentSourceCode(): string;
  111249. /**
  111250. * Recompiles the webGL program
  111251. * @param vertexSourceCode The source code for the vertex shader.
  111252. * @param fragmentSourceCode The source code for the fragment shader.
  111253. * @param onCompiled Callback called when completed.
  111254. * @param onError Callback called on error.
  111255. * @hidden
  111256. */
  111257. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111258. /**
  111259. * Prepares the effect
  111260. * @hidden
  111261. */
  111262. _prepareEffect(): void;
  111263. private _getShaderCodeAndErrorLine;
  111264. private _processCompilationErrors;
  111265. /**
  111266. * Checks if the effect is supported. (Must be called after compilation)
  111267. */
  111268. get isSupported(): boolean;
  111269. /**
  111270. * Binds a texture to the engine to be used as output of the shader.
  111271. * @param channel Name of the output variable.
  111272. * @param texture Texture to bind.
  111273. * @hidden
  111274. */
  111275. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111276. /**
  111277. * Sets a texture on the engine to be used in the shader.
  111278. * @param channel Name of the sampler variable.
  111279. * @param texture Texture to set.
  111280. */
  111281. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111282. /**
  111283. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111284. * @param channel Name of the sampler variable.
  111285. * @param texture Texture to set.
  111286. */
  111287. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111288. /**
  111289. * Sets an array of textures on the engine to be used in the shader.
  111290. * @param channel Name of the variable.
  111291. * @param textures Textures to set.
  111292. */
  111293. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111294. /**
  111295. * 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)
  111296. * @param channel Name of the sampler variable.
  111297. * @param postProcess Post process to get the input texture from.
  111298. */
  111299. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111300. /**
  111301. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111302. * 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)
  111303. * @param channel Name of the sampler variable.
  111304. * @param postProcess Post process to get the output texture from.
  111305. */
  111306. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111307. /** @hidden */
  111308. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111309. /** @hidden */
  111310. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111311. /** @hidden */
  111312. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111313. /** @hidden */
  111314. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111315. /**
  111316. * Binds a buffer to a uniform.
  111317. * @param buffer Buffer to bind.
  111318. * @param name Name of the uniform variable to bind to.
  111319. */
  111320. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111321. /**
  111322. * Binds block to a uniform.
  111323. * @param blockName Name of the block to bind.
  111324. * @param index Index to bind.
  111325. */
  111326. bindUniformBlock(blockName: string, index: number): void;
  111327. /**
  111328. * Sets an interger value on a uniform variable.
  111329. * @param uniformName Name of the variable.
  111330. * @param value Value to be set.
  111331. * @returns this effect.
  111332. */
  111333. setInt(uniformName: string, value: number): Effect;
  111334. /**
  111335. * Sets an int array on a uniform variable.
  111336. * @param uniformName Name of the variable.
  111337. * @param array array to be set.
  111338. * @returns this effect.
  111339. */
  111340. setIntArray(uniformName: string, array: Int32Array): Effect;
  111341. /**
  111342. * 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)
  111343. * @param uniformName Name of the variable.
  111344. * @param array array to be set.
  111345. * @returns this effect.
  111346. */
  111347. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111348. /**
  111349. * 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)
  111350. * @param uniformName Name of the variable.
  111351. * @param array array to be set.
  111352. * @returns this effect.
  111353. */
  111354. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111355. /**
  111356. * 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)
  111357. * @param uniformName Name of the variable.
  111358. * @param array array to be set.
  111359. * @returns this effect.
  111360. */
  111361. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111362. /**
  111363. * Sets an float array on a uniform variable.
  111364. * @param uniformName Name of the variable.
  111365. * @param array array to be set.
  111366. * @returns this effect.
  111367. */
  111368. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111369. /**
  111370. * 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)
  111371. * @param uniformName Name of the variable.
  111372. * @param array array to be set.
  111373. * @returns this effect.
  111374. */
  111375. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111376. /**
  111377. * 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)
  111378. * @param uniformName Name of the variable.
  111379. * @param array array to be set.
  111380. * @returns this effect.
  111381. */
  111382. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111383. /**
  111384. * 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)
  111385. * @param uniformName Name of the variable.
  111386. * @param array array to be set.
  111387. * @returns this effect.
  111388. */
  111389. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111390. /**
  111391. * Sets an array on a uniform variable.
  111392. * @param uniformName Name of the variable.
  111393. * @param array array to be set.
  111394. * @returns this effect.
  111395. */
  111396. setArray(uniformName: string, array: number[]): Effect;
  111397. /**
  111398. * 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)
  111399. * @param uniformName Name of the variable.
  111400. * @param array array to be set.
  111401. * @returns this effect.
  111402. */
  111403. setArray2(uniformName: string, array: number[]): Effect;
  111404. /**
  111405. * 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)
  111406. * @param uniformName Name of the variable.
  111407. * @param array array to be set.
  111408. * @returns this effect.
  111409. */
  111410. setArray3(uniformName: string, array: number[]): Effect;
  111411. /**
  111412. * 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)
  111413. * @param uniformName Name of the variable.
  111414. * @param array array to be set.
  111415. * @returns this effect.
  111416. */
  111417. setArray4(uniformName: string, array: number[]): Effect;
  111418. /**
  111419. * Sets matrices on a uniform variable.
  111420. * @param uniformName Name of the variable.
  111421. * @param matrices matrices to be set.
  111422. * @returns this effect.
  111423. */
  111424. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111425. /**
  111426. * Sets matrix on a uniform variable.
  111427. * @param uniformName Name of the variable.
  111428. * @param matrix matrix to be set.
  111429. * @returns this effect.
  111430. */
  111431. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111432. /**
  111433. * 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)
  111434. * @param uniformName Name of the variable.
  111435. * @param matrix matrix to be set.
  111436. * @returns this effect.
  111437. */
  111438. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111439. /**
  111440. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111441. * @param uniformName Name of the variable.
  111442. * @param matrix matrix to be set.
  111443. * @returns this effect.
  111444. */
  111445. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111446. /**
  111447. * Sets a float on a uniform variable.
  111448. * @param uniformName Name of the variable.
  111449. * @param value value to be set.
  111450. * @returns this effect.
  111451. */
  111452. setFloat(uniformName: string, value: number): Effect;
  111453. /**
  111454. * Sets a boolean on a uniform variable.
  111455. * @param uniformName Name of the variable.
  111456. * @param bool value to be set.
  111457. * @returns this effect.
  111458. */
  111459. setBool(uniformName: string, bool: boolean): Effect;
  111460. /**
  111461. * Sets a Vector2 on a uniform variable.
  111462. * @param uniformName Name of the variable.
  111463. * @param vector2 vector2 to be set.
  111464. * @returns this effect.
  111465. */
  111466. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111467. /**
  111468. * Sets a float2 on a uniform variable.
  111469. * @param uniformName Name of the variable.
  111470. * @param x First float in float2.
  111471. * @param y Second float in float2.
  111472. * @returns this effect.
  111473. */
  111474. setFloat2(uniformName: string, x: number, y: number): Effect;
  111475. /**
  111476. * Sets a Vector3 on a uniform variable.
  111477. * @param uniformName Name of the variable.
  111478. * @param vector3 Value to be set.
  111479. * @returns this effect.
  111480. */
  111481. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111482. /**
  111483. * Sets a float3 on a uniform variable.
  111484. * @param uniformName Name of the variable.
  111485. * @param x First float in float3.
  111486. * @param y Second float in float3.
  111487. * @param z Third float in float3.
  111488. * @returns this effect.
  111489. */
  111490. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111491. /**
  111492. * Sets a Vector4 on a uniform variable.
  111493. * @param uniformName Name of the variable.
  111494. * @param vector4 Value to be set.
  111495. * @returns this effect.
  111496. */
  111497. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111498. /**
  111499. * Sets a float4 on a uniform variable.
  111500. * @param uniformName Name of the variable.
  111501. * @param x First float in float4.
  111502. * @param y Second float in float4.
  111503. * @param z Third float in float4.
  111504. * @param w Fourth float in float4.
  111505. * @returns this effect.
  111506. */
  111507. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111508. /**
  111509. * Sets a Color3 on a uniform variable.
  111510. * @param uniformName Name of the variable.
  111511. * @param color3 Value to be set.
  111512. * @returns this effect.
  111513. */
  111514. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111515. /**
  111516. * Sets a Color4 on a uniform variable.
  111517. * @param uniformName Name of the variable.
  111518. * @param color3 Value to be set.
  111519. * @param alpha Alpha value to be set.
  111520. * @returns this effect.
  111521. */
  111522. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111523. /**
  111524. * Sets a Color4 on a uniform variable
  111525. * @param uniformName defines the name of the variable
  111526. * @param color4 defines the value to be set
  111527. * @returns this effect.
  111528. */
  111529. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111530. /** Release all associated resources */
  111531. dispose(): void;
  111532. /**
  111533. * This function will add a new shader to the shader store
  111534. * @param name the name of the shader
  111535. * @param pixelShader optional pixel shader content
  111536. * @param vertexShader optional vertex shader content
  111537. */
  111538. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111539. /**
  111540. * Store of each shader (The can be looked up using effect.key)
  111541. */
  111542. static ShadersStore: {
  111543. [key: string]: string;
  111544. };
  111545. /**
  111546. * Store of each included file for a shader (The can be looked up using effect.key)
  111547. */
  111548. static IncludesShadersStore: {
  111549. [key: string]: string;
  111550. };
  111551. /**
  111552. * Resets the cache of effects.
  111553. */
  111554. static ResetCache(): void;
  111555. }
  111556. }
  111557. declare module BABYLON {
  111558. /**
  111559. * Interface used to describe the capabilities of the engine relatively to the current browser
  111560. */
  111561. export interface EngineCapabilities {
  111562. /** Maximum textures units per fragment shader */
  111563. maxTexturesImageUnits: number;
  111564. /** Maximum texture units per vertex shader */
  111565. maxVertexTextureImageUnits: number;
  111566. /** Maximum textures units in the entire pipeline */
  111567. maxCombinedTexturesImageUnits: number;
  111568. /** Maximum texture size */
  111569. maxTextureSize: number;
  111570. /** Maximum texture samples */
  111571. maxSamples?: number;
  111572. /** Maximum cube texture size */
  111573. maxCubemapTextureSize: number;
  111574. /** Maximum render texture size */
  111575. maxRenderTextureSize: number;
  111576. /** Maximum number of vertex attributes */
  111577. maxVertexAttribs: number;
  111578. /** Maximum number of varyings */
  111579. maxVaryingVectors: number;
  111580. /** Maximum number of uniforms per vertex shader */
  111581. maxVertexUniformVectors: number;
  111582. /** Maximum number of uniforms per fragment shader */
  111583. maxFragmentUniformVectors: number;
  111584. /** Defines if standard derivates (dx/dy) are supported */
  111585. standardDerivatives: boolean;
  111586. /** Defines if s3tc texture compression is supported */
  111587. s3tc?: WEBGL_compressed_texture_s3tc;
  111588. /** Defines if pvrtc texture compression is supported */
  111589. pvrtc: any;
  111590. /** Defines if etc1 texture compression is supported */
  111591. etc1: any;
  111592. /** Defines if etc2 texture compression is supported */
  111593. etc2: any;
  111594. /** Defines if astc texture compression is supported */
  111595. astc: any;
  111596. /** Defines if float textures are supported */
  111597. textureFloat: boolean;
  111598. /** Defines if vertex array objects are supported */
  111599. vertexArrayObject: boolean;
  111600. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111601. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111602. /** Gets the maximum level of anisotropy supported */
  111603. maxAnisotropy: number;
  111604. /** Defines if instancing is supported */
  111605. instancedArrays: boolean;
  111606. /** Defines if 32 bits indices are supported */
  111607. uintIndices: boolean;
  111608. /** Defines if high precision shaders are supported */
  111609. highPrecisionShaderSupported: boolean;
  111610. /** Defines if depth reading in the fragment shader is supported */
  111611. fragmentDepthSupported: boolean;
  111612. /** Defines if float texture linear filtering is supported*/
  111613. textureFloatLinearFiltering: boolean;
  111614. /** Defines if rendering to float textures is supported */
  111615. textureFloatRender: boolean;
  111616. /** Defines if half float textures are supported*/
  111617. textureHalfFloat: boolean;
  111618. /** Defines if half float texture linear filtering is supported*/
  111619. textureHalfFloatLinearFiltering: boolean;
  111620. /** Defines if rendering to half float textures is supported */
  111621. textureHalfFloatRender: boolean;
  111622. /** Defines if textureLOD shader command is supported */
  111623. textureLOD: boolean;
  111624. /** Defines if draw buffers extension is supported */
  111625. drawBuffersExtension: boolean;
  111626. /** Defines if depth textures are supported */
  111627. depthTextureExtension: boolean;
  111628. /** Defines if float color buffer are supported */
  111629. colorBufferFloat: boolean;
  111630. /** Gets disjoint timer query extension (null if not supported) */
  111631. timerQuery?: EXT_disjoint_timer_query;
  111632. /** Defines if timestamp can be used with timer query */
  111633. canUseTimestampForTimerQuery: boolean;
  111634. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111635. multiview?: any;
  111636. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111637. oculusMultiview?: any;
  111638. /** Function used to let the system compiles shaders in background */
  111639. parallelShaderCompile?: {
  111640. COMPLETION_STATUS_KHR: number;
  111641. };
  111642. /** Max number of texture samples for MSAA */
  111643. maxMSAASamples: number;
  111644. /** Defines if the blend min max extension is supported */
  111645. blendMinMax: boolean;
  111646. }
  111647. }
  111648. declare module BABYLON {
  111649. /**
  111650. * @hidden
  111651. **/
  111652. export class DepthCullingState {
  111653. private _isDepthTestDirty;
  111654. private _isDepthMaskDirty;
  111655. private _isDepthFuncDirty;
  111656. private _isCullFaceDirty;
  111657. private _isCullDirty;
  111658. private _isZOffsetDirty;
  111659. private _isFrontFaceDirty;
  111660. private _depthTest;
  111661. private _depthMask;
  111662. private _depthFunc;
  111663. private _cull;
  111664. private _cullFace;
  111665. private _zOffset;
  111666. private _frontFace;
  111667. /**
  111668. * Initializes the state.
  111669. */
  111670. constructor();
  111671. get isDirty(): boolean;
  111672. get zOffset(): number;
  111673. set zOffset(value: number);
  111674. get cullFace(): Nullable<number>;
  111675. set cullFace(value: Nullable<number>);
  111676. get cull(): Nullable<boolean>;
  111677. set cull(value: Nullable<boolean>);
  111678. get depthFunc(): Nullable<number>;
  111679. set depthFunc(value: Nullable<number>);
  111680. get depthMask(): boolean;
  111681. set depthMask(value: boolean);
  111682. get depthTest(): boolean;
  111683. set depthTest(value: boolean);
  111684. get frontFace(): Nullable<number>;
  111685. set frontFace(value: Nullable<number>);
  111686. reset(): void;
  111687. apply(gl: WebGLRenderingContext): void;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * @hidden
  111693. **/
  111694. export class StencilState {
  111695. /** 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 */
  111696. static readonly ALWAYS: number;
  111697. /** Passed to stencilOperation to specify that stencil value must be kept */
  111698. static readonly KEEP: number;
  111699. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111700. static readonly REPLACE: number;
  111701. private _isStencilTestDirty;
  111702. private _isStencilMaskDirty;
  111703. private _isStencilFuncDirty;
  111704. private _isStencilOpDirty;
  111705. private _stencilTest;
  111706. private _stencilMask;
  111707. private _stencilFunc;
  111708. private _stencilFuncRef;
  111709. private _stencilFuncMask;
  111710. private _stencilOpStencilFail;
  111711. private _stencilOpDepthFail;
  111712. private _stencilOpStencilDepthPass;
  111713. get isDirty(): boolean;
  111714. get stencilFunc(): number;
  111715. set stencilFunc(value: number);
  111716. get stencilFuncRef(): number;
  111717. set stencilFuncRef(value: number);
  111718. get stencilFuncMask(): number;
  111719. set stencilFuncMask(value: number);
  111720. get stencilOpStencilFail(): number;
  111721. set stencilOpStencilFail(value: number);
  111722. get stencilOpDepthFail(): number;
  111723. set stencilOpDepthFail(value: number);
  111724. get stencilOpStencilDepthPass(): number;
  111725. set stencilOpStencilDepthPass(value: number);
  111726. get stencilMask(): number;
  111727. set stencilMask(value: number);
  111728. get stencilTest(): boolean;
  111729. set stencilTest(value: boolean);
  111730. constructor();
  111731. reset(): void;
  111732. apply(gl: WebGLRenderingContext): void;
  111733. }
  111734. }
  111735. declare module BABYLON {
  111736. /**
  111737. * @hidden
  111738. **/
  111739. export class AlphaState {
  111740. private _isAlphaBlendDirty;
  111741. private _isBlendFunctionParametersDirty;
  111742. private _isBlendEquationParametersDirty;
  111743. private _isBlendConstantsDirty;
  111744. private _alphaBlend;
  111745. private _blendFunctionParameters;
  111746. private _blendEquationParameters;
  111747. private _blendConstants;
  111748. /**
  111749. * Initializes the state.
  111750. */
  111751. constructor();
  111752. get isDirty(): boolean;
  111753. get alphaBlend(): boolean;
  111754. set alphaBlend(value: boolean);
  111755. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111756. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111757. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111758. reset(): void;
  111759. apply(gl: WebGLRenderingContext): void;
  111760. }
  111761. }
  111762. declare module BABYLON {
  111763. /** @hidden */
  111764. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111765. attributeProcessor(attribute: string): string;
  111766. varyingProcessor(varying: string, isFragment: boolean): string;
  111767. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111768. }
  111769. }
  111770. declare module BABYLON {
  111771. /**
  111772. * Interface for attribute information associated with buffer instanciation
  111773. */
  111774. export interface InstancingAttributeInfo {
  111775. /**
  111776. * Name of the GLSL attribute
  111777. * if attribute index is not specified, this is used to retrieve the index from the effect
  111778. */
  111779. attributeName: string;
  111780. /**
  111781. * Index/offset of the attribute in the vertex shader
  111782. * if not specified, this will be computes from the name.
  111783. */
  111784. index?: number;
  111785. /**
  111786. * size of the attribute, 1, 2, 3 or 4
  111787. */
  111788. attributeSize: number;
  111789. /**
  111790. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111791. */
  111792. offset: number;
  111793. /**
  111794. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111795. * default to 1
  111796. */
  111797. divisor?: number;
  111798. /**
  111799. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111800. * default is FLOAT
  111801. */
  111802. attributeType?: number;
  111803. /**
  111804. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111805. */
  111806. normalized?: boolean;
  111807. }
  111808. }
  111809. declare module BABYLON {
  111810. interface ThinEngine {
  111811. /**
  111812. * Update a video texture
  111813. * @param texture defines the texture to update
  111814. * @param video defines the video element to use
  111815. * @param invertY defines if data must be stored with Y axis inverted
  111816. */
  111817. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111818. }
  111819. }
  111820. declare module BABYLON {
  111821. /**
  111822. * Settings for finer control over video usage
  111823. */
  111824. export interface VideoTextureSettings {
  111825. /**
  111826. * Applies `autoplay` to video, if specified
  111827. */
  111828. autoPlay?: boolean;
  111829. /**
  111830. * Applies `loop` to video, if specified
  111831. */
  111832. loop?: boolean;
  111833. /**
  111834. * Automatically updates internal texture from video at every frame in the render loop
  111835. */
  111836. autoUpdateTexture: boolean;
  111837. /**
  111838. * Image src displayed during the video loading or until the user interacts with the video.
  111839. */
  111840. poster?: string;
  111841. }
  111842. /**
  111843. * If you want to display a video in your scene, this is the special texture for that.
  111844. * This special texture works similar to other textures, with the exception of a few parameters.
  111845. * @see https://doc.babylonjs.com/how_to/video_texture
  111846. */
  111847. export class VideoTexture extends Texture {
  111848. /**
  111849. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111850. */
  111851. readonly autoUpdateTexture: boolean;
  111852. /**
  111853. * The video instance used by the texture internally
  111854. */
  111855. readonly video: HTMLVideoElement;
  111856. private _onUserActionRequestedObservable;
  111857. /**
  111858. * Event triggerd when a dom action is required by the user to play the video.
  111859. * This happens due to recent changes in browser policies preventing video to auto start.
  111860. */
  111861. get onUserActionRequestedObservable(): Observable<Texture>;
  111862. private _generateMipMaps;
  111863. private _stillImageCaptured;
  111864. private _displayingPosterTexture;
  111865. private _settings;
  111866. private _createInternalTextureOnEvent;
  111867. private _frameId;
  111868. private _currentSrc;
  111869. /**
  111870. * Creates a video texture.
  111871. * If you want to display a video in your scene, this is the special texture for that.
  111872. * This special texture works similar to other textures, with the exception of a few parameters.
  111873. * @see https://doc.babylonjs.com/how_to/video_texture
  111874. * @param name optional name, will detect from video source, if not defined
  111875. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111876. * @param scene is obviously the current scene.
  111877. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111878. * @param invertY is false by default but can be used to invert video on Y axis
  111879. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111880. * @param settings allows finer control over video usage
  111881. */
  111882. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111883. private _getName;
  111884. private _getVideo;
  111885. private _createInternalTexture;
  111886. private reset;
  111887. /**
  111888. * @hidden Internal method to initiate `update`.
  111889. */
  111890. _rebuild(): void;
  111891. /**
  111892. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111893. */
  111894. update(): void;
  111895. /**
  111896. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111897. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111898. */
  111899. updateTexture(isVisible: boolean): void;
  111900. protected _updateInternalTexture: () => void;
  111901. /**
  111902. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111903. * @param url New url.
  111904. */
  111905. updateURL(url: string): void;
  111906. /**
  111907. * Clones the texture.
  111908. * @returns the cloned texture
  111909. */
  111910. clone(): VideoTexture;
  111911. /**
  111912. * Dispose the texture and release its associated resources.
  111913. */
  111914. dispose(): void;
  111915. /**
  111916. * Creates a video texture straight from a stream.
  111917. * @param scene Define the scene the texture should be created in
  111918. * @param stream Define the stream the texture should be created from
  111919. * @returns The created video texture as a promise
  111920. */
  111921. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111922. /**
  111923. * Creates a video texture straight from your WebCam video feed.
  111924. * @param scene Define the scene the texture should be created in
  111925. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111926. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111927. * @returns The created video texture as a promise
  111928. */
  111929. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111930. minWidth: number;
  111931. maxWidth: number;
  111932. minHeight: number;
  111933. maxHeight: number;
  111934. deviceId: string;
  111935. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111936. /**
  111937. * Creates a video texture straight from your WebCam video feed.
  111938. * @param scene Define the scene the texture should be created in
  111939. * @param onReady Define a callback to triggered once the texture will be ready
  111940. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111941. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111942. */
  111943. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111944. minWidth: number;
  111945. maxWidth: number;
  111946. minHeight: number;
  111947. maxHeight: number;
  111948. deviceId: string;
  111949. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111950. }
  111951. }
  111952. declare module BABYLON {
  111953. /**
  111954. * Defines the interface used by objects working like Scene
  111955. * @hidden
  111956. */
  111957. export interface ISceneLike {
  111958. _addPendingData(data: any): void;
  111959. _removePendingData(data: any): void;
  111960. offlineProvider: IOfflineProvider;
  111961. }
  111962. /** Interface defining initialization parameters for Engine class */
  111963. export interface EngineOptions extends WebGLContextAttributes {
  111964. /**
  111965. * Defines if the engine should no exceed a specified device ratio
  111966. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111967. */
  111968. limitDeviceRatio?: number;
  111969. /**
  111970. * Defines if webvr should be enabled automatically
  111971. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111972. */
  111973. autoEnableWebVR?: boolean;
  111974. /**
  111975. * Defines if webgl2 should be turned off even if supported
  111976. * @see http://doc.babylonjs.com/features/webgl2
  111977. */
  111978. disableWebGL2Support?: boolean;
  111979. /**
  111980. * Defines if webaudio should be initialized as well
  111981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111982. */
  111983. audioEngine?: boolean;
  111984. /**
  111985. * Defines if animations should run using a deterministic lock step
  111986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111987. */
  111988. deterministicLockstep?: boolean;
  111989. /** Defines the maximum steps to use with deterministic lock step mode */
  111990. lockstepMaxSteps?: number;
  111991. /** Defines the seconds between each deterministic lock step */
  111992. timeStep?: number;
  111993. /**
  111994. * Defines that engine should ignore context lost events
  111995. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111996. */
  111997. doNotHandleContextLost?: boolean;
  111998. /**
  111999. * Defines that engine should ignore modifying touch action attribute and style
  112000. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112001. */
  112002. doNotHandleTouchAction?: boolean;
  112003. /**
  112004. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112005. */
  112006. useHighPrecisionFloats?: boolean;
  112007. /**
  112008. * Make the canvas XR Compatible for XR sessions
  112009. */
  112010. xrCompatible?: boolean;
  112011. }
  112012. /**
  112013. * The base engine class (root of all engines)
  112014. */
  112015. export class ThinEngine {
  112016. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112017. static ExceptionList: ({
  112018. key: string;
  112019. capture: string;
  112020. captureConstraint: number;
  112021. targets: string[];
  112022. } | {
  112023. key: string;
  112024. capture: null;
  112025. captureConstraint: null;
  112026. targets: string[];
  112027. })[];
  112028. /** @hidden */
  112029. static _TextureLoaders: IInternalTextureLoader[];
  112030. /**
  112031. * Returns the current npm package of the sdk
  112032. */
  112033. static get NpmPackage(): string;
  112034. /**
  112035. * Returns the current version of the framework
  112036. */
  112037. static get Version(): string;
  112038. /**
  112039. * Returns a string describing the current engine
  112040. */
  112041. get description(): string;
  112042. /**
  112043. * Gets or sets the epsilon value used by collision engine
  112044. */
  112045. static CollisionsEpsilon: number;
  112046. /**
  112047. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112048. */
  112049. static get ShadersRepository(): string;
  112050. static set ShadersRepository(value: string);
  112051. /** @hidden */
  112052. _shaderProcessor: IShaderProcessor;
  112053. /**
  112054. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112055. */
  112056. forcePOTTextures: boolean;
  112057. /**
  112058. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112059. */
  112060. isFullscreen: boolean;
  112061. /**
  112062. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112063. */
  112064. cullBackFaces: boolean;
  112065. /**
  112066. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112067. */
  112068. renderEvenInBackground: boolean;
  112069. /**
  112070. * Gets or sets a boolean indicating that cache can be kept between frames
  112071. */
  112072. preventCacheWipeBetweenFrames: boolean;
  112073. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112074. validateShaderPrograms: boolean;
  112075. /**
  112076. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112077. * This can provide greater z depth for distant objects.
  112078. */
  112079. useReverseDepthBuffer: boolean;
  112080. /**
  112081. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112082. */
  112083. disableUniformBuffers: boolean;
  112084. /** @hidden */
  112085. _uniformBuffers: UniformBuffer[];
  112086. /**
  112087. * Gets a boolean indicating that the engine supports uniform buffers
  112088. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112089. */
  112090. get supportsUniformBuffers(): boolean;
  112091. /** @hidden */
  112092. _gl: WebGLRenderingContext;
  112093. /** @hidden */
  112094. _webGLVersion: number;
  112095. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112096. protected _windowIsBackground: boolean;
  112097. protected _creationOptions: EngineOptions;
  112098. protected _highPrecisionShadersAllowed: boolean;
  112099. /** @hidden */
  112100. get _shouldUseHighPrecisionShader(): boolean;
  112101. /**
  112102. * Gets a boolean indicating that only power of 2 textures are supported
  112103. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112104. */
  112105. get needPOTTextures(): boolean;
  112106. /** @hidden */
  112107. _badOS: boolean;
  112108. /** @hidden */
  112109. _badDesktopOS: boolean;
  112110. private _hardwareScalingLevel;
  112111. /** @hidden */
  112112. _caps: EngineCapabilities;
  112113. private _isStencilEnable;
  112114. private _glVersion;
  112115. private _glRenderer;
  112116. private _glVendor;
  112117. /** @hidden */
  112118. _videoTextureSupported: boolean;
  112119. protected _renderingQueueLaunched: boolean;
  112120. protected _activeRenderLoops: (() => void)[];
  112121. /**
  112122. * Observable signaled when a context lost event is raised
  112123. */
  112124. onContextLostObservable: Observable<ThinEngine>;
  112125. /**
  112126. * Observable signaled when a context restored event is raised
  112127. */
  112128. onContextRestoredObservable: Observable<ThinEngine>;
  112129. private _onContextLost;
  112130. private _onContextRestored;
  112131. protected _contextWasLost: boolean;
  112132. /** @hidden */
  112133. _doNotHandleContextLost: boolean;
  112134. /**
  112135. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112137. */
  112138. get doNotHandleContextLost(): boolean;
  112139. set doNotHandleContextLost(value: boolean);
  112140. /**
  112141. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112142. */
  112143. disableVertexArrayObjects: boolean;
  112144. /** @hidden */
  112145. protected _colorWrite: boolean;
  112146. /** @hidden */
  112147. protected _colorWriteChanged: boolean;
  112148. /** @hidden */
  112149. protected _depthCullingState: DepthCullingState;
  112150. /** @hidden */
  112151. protected _stencilState: StencilState;
  112152. /** @hidden */
  112153. _alphaState: AlphaState;
  112154. /** @hidden */
  112155. _alphaMode: number;
  112156. /** @hidden */
  112157. _alphaEquation: number;
  112158. /** @hidden */
  112159. _internalTexturesCache: InternalTexture[];
  112160. /** @hidden */
  112161. protected _activeChannel: number;
  112162. private _currentTextureChannel;
  112163. /** @hidden */
  112164. protected _boundTexturesCache: {
  112165. [key: string]: Nullable<InternalTexture>;
  112166. };
  112167. /** @hidden */
  112168. protected _currentEffect: Nullable<Effect>;
  112169. /** @hidden */
  112170. protected _currentProgram: Nullable<WebGLProgram>;
  112171. private _compiledEffects;
  112172. private _vertexAttribArraysEnabled;
  112173. /** @hidden */
  112174. protected _cachedViewport: Nullable<IViewportLike>;
  112175. private _cachedVertexArrayObject;
  112176. /** @hidden */
  112177. protected _cachedVertexBuffers: any;
  112178. /** @hidden */
  112179. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112180. /** @hidden */
  112181. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112182. /** @hidden */
  112183. _currentRenderTarget: Nullable<InternalTexture>;
  112184. private _uintIndicesCurrentlySet;
  112185. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112186. /** @hidden */
  112187. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112188. /** @hidden */
  112189. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112190. private _currentBufferPointers;
  112191. private _currentInstanceLocations;
  112192. private _currentInstanceBuffers;
  112193. private _textureUnits;
  112194. /** @hidden */
  112195. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112196. /** @hidden */
  112197. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112198. /** @hidden */
  112199. _boundRenderFunction: any;
  112200. private _vaoRecordInProgress;
  112201. private _mustWipeVertexAttributes;
  112202. private _emptyTexture;
  112203. private _emptyCubeTexture;
  112204. private _emptyTexture3D;
  112205. private _emptyTexture2DArray;
  112206. /** @hidden */
  112207. _frameHandler: number;
  112208. private _nextFreeTextureSlots;
  112209. private _maxSimultaneousTextures;
  112210. private _activeRequests;
  112211. /** @hidden */
  112212. _transformTextureUrl: Nullable<(url: string) => string>;
  112213. protected get _supportsHardwareTextureRescaling(): boolean;
  112214. private _framebufferDimensionsObject;
  112215. /**
  112216. * sets the object from which width and height will be taken from when getting render width and height
  112217. * Will fallback to the gl object
  112218. * @param dimensions the framebuffer width and height that will be used.
  112219. */
  112220. set framebufferDimensionsObject(dimensions: Nullable<{
  112221. framebufferWidth: number;
  112222. framebufferHeight: number;
  112223. }>);
  112224. /**
  112225. * Gets the current viewport
  112226. */
  112227. get currentViewport(): Nullable<IViewportLike>;
  112228. /**
  112229. * Gets the default empty texture
  112230. */
  112231. get emptyTexture(): InternalTexture;
  112232. /**
  112233. * Gets the default empty 3D texture
  112234. */
  112235. get emptyTexture3D(): InternalTexture;
  112236. /**
  112237. * Gets the default empty 2D array texture
  112238. */
  112239. get emptyTexture2DArray(): InternalTexture;
  112240. /**
  112241. * Gets the default empty cube texture
  112242. */
  112243. get emptyCubeTexture(): InternalTexture;
  112244. /**
  112245. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112246. */
  112247. readonly premultipliedAlpha: boolean;
  112248. /**
  112249. * Observable event triggered before each texture is initialized
  112250. */
  112251. onBeforeTextureInitObservable: Observable<Texture>;
  112252. /**
  112253. * Creates a new engine
  112254. * @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
  112255. * @param antialias defines enable antialiasing (default: false)
  112256. * @param options defines further options to be sent to the getContext() function
  112257. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112258. */
  112259. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112260. private _rebuildInternalTextures;
  112261. private _rebuildEffects;
  112262. /**
  112263. * Gets a boolean indicating if all created effects are ready
  112264. * @returns true if all effects are ready
  112265. */
  112266. areAllEffectsReady(): boolean;
  112267. protected _rebuildBuffers(): void;
  112268. protected _initGLContext(): void;
  112269. /**
  112270. * Gets version of the current webGL context
  112271. */
  112272. get webGLVersion(): number;
  112273. /**
  112274. * Gets a string idenfifying the name of the class
  112275. * @returns "Engine" string
  112276. */
  112277. getClassName(): string;
  112278. /**
  112279. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112280. */
  112281. get isStencilEnable(): boolean;
  112282. /** @hidden */
  112283. _prepareWorkingCanvas(): void;
  112284. /**
  112285. * Reset the texture cache to empty state
  112286. */
  112287. resetTextureCache(): void;
  112288. /**
  112289. * Gets an object containing information about the current webGL context
  112290. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112291. */
  112292. getGlInfo(): {
  112293. vendor: string;
  112294. renderer: string;
  112295. version: string;
  112296. };
  112297. /**
  112298. * Defines the hardware scaling level.
  112299. * By default the hardware scaling level is computed from the window device ratio.
  112300. * 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.
  112301. * @param level defines the level to use
  112302. */
  112303. setHardwareScalingLevel(level: number): void;
  112304. /**
  112305. * Gets the current hardware scaling level.
  112306. * By default the hardware scaling level is computed from the window device ratio.
  112307. * 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.
  112308. * @returns a number indicating the current hardware scaling level
  112309. */
  112310. getHardwareScalingLevel(): number;
  112311. /**
  112312. * Gets the list of loaded textures
  112313. * @returns an array containing all loaded textures
  112314. */
  112315. getLoadedTexturesCache(): InternalTexture[];
  112316. /**
  112317. * Gets the object containing all engine capabilities
  112318. * @returns the EngineCapabilities object
  112319. */
  112320. getCaps(): EngineCapabilities;
  112321. /**
  112322. * stop executing a render loop function and remove it from the execution array
  112323. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112324. */
  112325. stopRenderLoop(renderFunction?: () => void): void;
  112326. /** @hidden */
  112327. _renderLoop(): void;
  112328. /**
  112329. * Gets the HTML canvas attached with the current webGL context
  112330. * @returns a HTML canvas
  112331. */
  112332. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112333. /**
  112334. * Gets host window
  112335. * @returns the host window object
  112336. */
  112337. getHostWindow(): Nullable<Window>;
  112338. /**
  112339. * Gets the current render width
  112340. * @param useScreen defines if screen size must be used (or the current render target if any)
  112341. * @returns a number defining the current render width
  112342. */
  112343. getRenderWidth(useScreen?: boolean): number;
  112344. /**
  112345. * Gets the current render height
  112346. * @param useScreen defines if screen size must be used (or the current render target if any)
  112347. * @returns a number defining the current render height
  112348. */
  112349. getRenderHeight(useScreen?: boolean): number;
  112350. /**
  112351. * Can be used to override the current requestAnimationFrame requester.
  112352. * @hidden
  112353. */
  112354. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112355. /**
  112356. * Register and execute a render loop. The engine can have more than one render function
  112357. * @param renderFunction defines the function to continuously execute
  112358. */
  112359. runRenderLoop(renderFunction: () => void): void;
  112360. /**
  112361. * Clear the current render buffer or the current render target (if any is set up)
  112362. * @param color defines the color to use
  112363. * @param backBuffer defines if the back buffer must be cleared
  112364. * @param depth defines if the depth buffer must be cleared
  112365. * @param stencil defines if the stencil buffer must be cleared
  112366. */
  112367. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112368. private _viewportCached;
  112369. /** @hidden */
  112370. _viewport(x: number, y: number, width: number, height: number): void;
  112371. /**
  112372. * Set the WebGL's viewport
  112373. * @param viewport defines the viewport element to be used
  112374. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112375. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112376. */
  112377. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112378. /**
  112379. * Begin a new frame
  112380. */
  112381. beginFrame(): void;
  112382. /**
  112383. * Enf the current frame
  112384. */
  112385. endFrame(): void;
  112386. /**
  112387. * Resize the view according to the canvas' size
  112388. */
  112389. resize(): void;
  112390. /**
  112391. * Force a specific size of the canvas
  112392. * @param width defines the new canvas' width
  112393. * @param height defines the new canvas' height
  112394. */
  112395. setSize(width: number, height: number): void;
  112396. /**
  112397. * Binds the frame buffer to the specified texture.
  112398. * @param texture The texture to render to or null for the default canvas
  112399. * @param faceIndex The face of the texture to render to in case of cube texture
  112400. * @param requiredWidth The width of the target to render to
  112401. * @param requiredHeight The height of the target to render to
  112402. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112403. * @param lodLevel defines the lod level to bind to the frame buffer
  112404. * @param layer defines the 2d array index to bind to frame buffer to
  112405. */
  112406. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112407. /** @hidden */
  112408. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112409. /**
  112410. * Unbind the current render target texture from the webGL context
  112411. * @param texture defines the render target texture to unbind
  112412. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112413. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112414. */
  112415. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112416. /**
  112417. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112418. */
  112419. flushFramebuffer(): void;
  112420. /**
  112421. * Unbind the current render target and bind the default framebuffer
  112422. */
  112423. restoreDefaultFramebuffer(): void;
  112424. /** @hidden */
  112425. protected _resetVertexBufferBinding(): void;
  112426. /**
  112427. * Creates a vertex buffer
  112428. * @param data the data for the vertex buffer
  112429. * @returns the new WebGL static buffer
  112430. */
  112431. createVertexBuffer(data: DataArray): DataBuffer;
  112432. private _createVertexBuffer;
  112433. /**
  112434. * Creates a dynamic vertex buffer
  112435. * @param data the data for the dynamic vertex buffer
  112436. * @returns the new WebGL dynamic buffer
  112437. */
  112438. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112439. protected _resetIndexBufferBinding(): void;
  112440. /**
  112441. * Creates a new index buffer
  112442. * @param indices defines the content of the index buffer
  112443. * @param updatable defines if the index buffer must be updatable
  112444. * @returns a new webGL buffer
  112445. */
  112446. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112447. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112448. /**
  112449. * Bind a webGL buffer to the webGL context
  112450. * @param buffer defines the buffer to bind
  112451. */
  112452. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112453. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112454. private bindBuffer;
  112455. /**
  112456. * update the bound buffer with the given data
  112457. * @param data defines the data to update
  112458. */
  112459. updateArrayBuffer(data: Float32Array): void;
  112460. private _vertexAttribPointer;
  112461. /** @hidden */
  112462. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112463. private _bindVertexBuffersAttributes;
  112464. /**
  112465. * Records a vertex array object
  112466. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112467. * @param vertexBuffers defines the list of vertex buffers to store
  112468. * @param indexBuffer defines the index buffer to store
  112469. * @param effect defines the effect to store
  112470. * @returns the new vertex array object
  112471. */
  112472. recordVertexArrayObject(vertexBuffers: {
  112473. [key: string]: VertexBuffer;
  112474. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112475. /**
  112476. * Bind a specific vertex array object
  112477. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112478. * @param vertexArrayObject defines the vertex array object to bind
  112479. * @param indexBuffer defines the index buffer to bind
  112480. */
  112481. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112482. /**
  112483. * Bind webGl buffers directly to the webGL context
  112484. * @param vertexBuffer defines the vertex buffer to bind
  112485. * @param indexBuffer defines the index buffer to bind
  112486. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112487. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112488. * @param effect defines the effect associated with the vertex buffer
  112489. */
  112490. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112491. private _unbindVertexArrayObject;
  112492. /**
  112493. * Bind a list of vertex buffers to the webGL context
  112494. * @param vertexBuffers defines the list of vertex buffers to bind
  112495. * @param indexBuffer defines the index buffer to bind
  112496. * @param effect defines the effect associated with the vertex buffers
  112497. */
  112498. bindBuffers(vertexBuffers: {
  112499. [key: string]: Nullable<VertexBuffer>;
  112500. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112501. /**
  112502. * Unbind all instance attributes
  112503. */
  112504. unbindInstanceAttributes(): void;
  112505. /**
  112506. * Release and free the memory of a vertex array object
  112507. * @param vao defines the vertex array object to delete
  112508. */
  112509. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112510. /** @hidden */
  112511. _releaseBuffer(buffer: DataBuffer): boolean;
  112512. protected _deleteBuffer(buffer: DataBuffer): void;
  112513. /**
  112514. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112515. * @param instancesBuffer defines the webGL buffer to update and bind
  112516. * @param data defines the data to store in the buffer
  112517. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112518. */
  112519. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112520. /**
  112521. * Bind the content of a webGL buffer used with instantiation
  112522. * @param instancesBuffer defines the webGL buffer to bind
  112523. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112524. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112525. */
  112526. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112527. /**
  112528. * Disable the instance attribute corresponding to the name in parameter
  112529. * @param name defines the name of the attribute to disable
  112530. */
  112531. disableInstanceAttributeByName(name: string): void;
  112532. /**
  112533. * Disable the instance attribute corresponding to the location in parameter
  112534. * @param attributeLocation defines the attribute location of the attribute to disable
  112535. */
  112536. disableInstanceAttribute(attributeLocation: number): void;
  112537. /**
  112538. * Disable the attribute corresponding to the location in parameter
  112539. * @param attributeLocation defines the attribute location of the attribute to disable
  112540. */
  112541. disableAttributeByIndex(attributeLocation: number): void;
  112542. /**
  112543. * Send a draw order
  112544. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112545. * @param indexStart defines the starting index
  112546. * @param indexCount defines the number of index to draw
  112547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112548. */
  112549. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112550. /**
  112551. * Draw a list of points
  112552. * @param verticesStart defines the index of first vertex to draw
  112553. * @param verticesCount defines the count of vertices to draw
  112554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112555. */
  112556. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112557. /**
  112558. * Draw a list of unindexed primitives
  112559. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112560. * @param verticesStart defines the index of first vertex to draw
  112561. * @param verticesCount defines the count of vertices to draw
  112562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112563. */
  112564. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112565. /**
  112566. * Draw a list of indexed primitives
  112567. * @param fillMode defines the primitive to use
  112568. * @param indexStart defines the starting index
  112569. * @param indexCount defines the number of index to draw
  112570. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112571. */
  112572. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112573. /**
  112574. * Draw a list of unindexed primitives
  112575. * @param fillMode defines the primitive to use
  112576. * @param verticesStart defines the index of first vertex to draw
  112577. * @param verticesCount defines the count of vertices to draw
  112578. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112579. */
  112580. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112581. private _drawMode;
  112582. /** @hidden */
  112583. protected _reportDrawCall(): void;
  112584. /** @hidden */
  112585. _releaseEffect(effect: Effect): void;
  112586. /** @hidden */
  112587. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112588. /**
  112589. * Create a new effect (used to store vertex/fragment shaders)
  112590. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112591. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112592. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112593. * @param samplers defines an array of string used to represent textures
  112594. * @param defines defines the string containing the defines to use to compile the shaders
  112595. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112596. * @param onCompiled defines a function to call when the effect creation is successful
  112597. * @param onError defines a function to call when the effect creation has failed
  112598. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112599. * @returns the new Effect
  112600. */
  112601. 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;
  112602. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112603. private _compileShader;
  112604. private _compileRawShader;
  112605. /** @hidden */
  112606. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112607. /**
  112608. * Directly creates a webGL program
  112609. * @param pipelineContext defines the pipeline context to attach to
  112610. * @param vertexCode defines the vertex shader code to use
  112611. * @param fragmentCode defines the fragment shader code to use
  112612. * @param context defines the webGL context to use (if not set, the current one will be used)
  112613. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112614. * @returns the new webGL program
  112615. */
  112616. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112617. /**
  112618. * Creates a webGL program
  112619. * @param pipelineContext defines the pipeline context to attach to
  112620. * @param vertexCode defines the vertex shader code to use
  112621. * @param fragmentCode defines the fragment shader code to use
  112622. * @param defines defines the string containing the defines to use to compile the shaders
  112623. * @param context defines the webGL context to use (if not set, the current one will be used)
  112624. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112625. * @returns the new webGL program
  112626. */
  112627. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112628. /**
  112629. * Creates a new pipeline context
  112630. * @returns the new pipeline
  112631. */
  112632. createPipelineContext(): IPipelineContext;
  112633. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112634. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112635. /** @hidden */
  112636. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112637. /** @hidden */
  112638. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112639. /** @hidden */
  112640. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112641. /**
  112642. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112643. * @param pipelineContext defines the pipeline context to use
  112644. * @param uniformsNames defines the list of uniform names
  112645. * @returns an array of webGL uniform locations
  112646. */
  112647. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112648. /**
  112649. * Gets the lsit of active attributes for a given webGL program
  112650. * @param pipelineContext defines the pipeline context to use
  112651. * @param attributesNames defines the list of attribute names to get
  112652. * @returns an array of indices indicating the offset of each attribute
  112653. */
  112654. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112655. /**
  112656. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112657. * @param effect defines the effect to activate
  112658. */
  112659. enableEffect(effect: Nullable<Effect>): void;
  112660. /**
  112661. * Set the value of an uniform to a number (int)
  112662. * @param uniform defines the webGL uniform location where to store the value
  112663. * @param value defines the int number to store
  112664. */
  112665. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112666. /**
  112667. * Set the value of an uniform to an array of int32
  112668. * @param uniform defines the webGL uniform location where to store the value
  112669. * @param array defines the array of int32 to store
  112670. */
  112671. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112672. /**
  112673. * Set the value of an uniform to an array of int32 (stored as vec2)
  112674. * @param uniform defines the webGL uniform location where to store the value
  112675. * @param array defines the array of int32 to store
  112676. */
  112677. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112678. /**
  112679. * Set the value of an uniform to an array of int32 (stored as vec3)
  112680. * @param uniform defines the webGL uniform location where to store the value
  112681. * @param array defines the array of int32 to store
  112682. */
  112683. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112684. /**
  112685. * Set the value of an uniform to an array of int32 (stored as vec4)
  112686. * @param uniform defines the webGL uniform location where to store the value
  112687. * @param array defines the array of int32 to store
  112688. */
  112689. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112690. /**
  112691. * Set the value of an uniform to an array of number
  112692. * @param uniform defines the webGL uniform location where to store the value
  112693. * @param array defines the array of number to store
  112694. */
  112695. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112696. /**
  112697. * Set the value of an uniform to an array of number (stored as vec2)
  112698. * @param uniform defines the webGL uniform location where to store the value
  112699. * @param array defines the array of number to store
  112700. */
  112701. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112702. /**
  112703. * Set the value of an uniform to an array of number (stored as vec3)
  112704. * @param uniform defines the webGL uniform location where to store the value
  112705. * @param array defines the array of number to store
  112706. */
  112707. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112708. /**
  112709. * Set the value of an uniform to an array of number (stored as vec4)
  112710. * @param uniform defines the webGL uniform location where to store the value
  112711. * @param array defines the array of number to store
  112712. */
  112713. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112714. /**
  112715. * Set the value of an uniform to an array of float32 (stored as matrices)
  112716. * @param uniform defines the webGL uniform location where to store the value
  112717. * @param matrices defines the array of float32 to store
  112718. */
  112719. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112720. /**
  112721. * Set the value of an uniform to a matrix (3x3)
  112722. * @param uniform defines the webGL uniform location where to store the value
  112723. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112724. */
  112725. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112726. /**
  112727. * Set the value of an uniform to a matrix (2x2)
  112728. * @param uniform defines the webGL uniform location where to store the value
  112729. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112730. */
  112731. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112732. /**
  112733. * Set the value of an uniform to a number (float)
  112734. * @param uniform defines the webGL uniform location where to store the value
  112735. * @param value defines the float number to store
  112736. */
  112737. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112738. /**
  112739. * Set the value of an uniform to a vec2
  112740. * @param uniform defines the webGL uniform location where to store the value
  112741. * @param x defines the 1st component of the value
  112742. * @param y defines the 2nd component of the value
  112743. */
  112744. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112745. /**
  112746. * Set the value of an uniform to a vec3
  112747. * @param uniform defines the webGL uniform location where to store the value
  112748. * @param x defines the 1st component of the value
  112749. * @param y defines the 2nd component of the value
  112750. * @param z defines the 3rd component of the value
  112751. */
  112752. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112753. /**
  112754. * Set the value of an uniform to a vec4
  112755. * @param uniform defines the webGL uniform location where to store the value
  112756. * @param x defines the 1st component of the value
  112757. * @param y defines the 2nd component of the value
  112758. * @param z defines the 3rd component of the value
  112759. * @param w defines the 4th component of the value
  112760. */
  112761. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112762. /**
  112763. * Apply all cached states (depth, culling, stencil and alpha)
  112764. */
  112765. applyStates(): void;
  112766. /**
  112767. * Enable or disable color writing
  112768. * @param enable defines the state to set
  112769. */
  112770. setColorWrite(enable: boolean): void;
  112771. /**
  112772. * Gets a boolean indicating if color writing is enabled
  112773. * @returns the current color writing state
  112774. */
  112775. getColorWrite(): boolean;
  112776. /**
  112777. * Gets the depth culling state manager
  112778. */
  112779. get depthCullingState(): DepthCullingState;
  112780. /**
  112781. * Gets the alpha state manager
  112782. */
  112783. get alphaState(): AlphaState;
  112784. /**
  112785. * Gets the stencil state manager
  112786. */
  112787. get stencilState(): StencilState;
  112788. /**
  112789. * Clears the list of texture accessible through engine.
  112790. * This can help preventing texture load conflict due to name collision.
  112791. */
  112792. clearInternalTexturesCache(): void;
  112793. /**
  112794. * Force the entire cache to be cleared
  112795. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112796. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112797. */
  112798. wipeCaches(bruteForce?: boolean): void;
  112799. /** @hidden */
  112800. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112801. min: number;
  112802. mag: number;
  112803. };
  112804. /** @hidden */
  112805. _createTexture(): WebGLTexture;
  112806. /**
  112807. * Usually called from Texture.ts.
  112808. * Passed information to create a WebGLTexture
  112809. * @param url defines a value which contains one of the following:
  112810. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112811. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112812. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112814. * @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)
  112815. * @param scene needed for loading to the correct scene
  112816. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112817. * @param onLoad optional callback to be called upon successful completion
  112818. * @param onError optional callback to be called upon failure
  112819. * @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
  112820. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112821. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112822. * @param forcedExtension defines the extension to use to pick the right loader
  112823. * @param mimeType defines an optional mime type
  112824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112825. */
  112826. 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;
  112827. /**
  112828. * Loads an image as an HTMLImageElement.
  112829. * @param input url string, ArrayBuffer, or Blob to load
  112830. * @param onLoad callback called when the image successfully loads
  112831. * @param onError callback called when the image fails to load
  112832. * @param offlineProvider offline provider for caching
  112833. * @param mimeType optional mime type
  112834. * @returns the HTMLImageElement of the loaded image
  112835. * @hidden
  112836. */
  112837. 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>;
  112838. /**
  112839. * @hidden
  112840. */
  112841. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112842. private _unpackFlipYCached;
  112843. /**
  112844. * In case you are sharing the context with other applications, it might
  112845. * be interested to not cache the unpack flip y state to ensure a consistent
  112846. * value would be set.
  112847. */
  112848. enableUnpackFlipYCached: boolean;
  112849. /** @hidden */
  112850. _unpackFlipY(value: boolean): void;
  112851. /** @hidden */
  112852. _getUnpackAlignement(): number;
  112853. private _getTextureTarget;
  112854. /**
  112855. * Update the sampling mode of a given texture
  112856. * @param samplingMode defines the required sampling mode
  112857. * @param texture defines the texture to update
  112858. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112859. */
  112860. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112861. /**
  112862. * Update the sampling mode of a given texture
  112863. * @param texture defines the texture to update
  112864. * @param wrapU defines the texture wrap mode of the u coordinates
  112865. * @param wrapV defines the texture wrap mode of the v coordinates
  112866. * @param wrapR defines the texture wrap mode of the r coordinates
  112867. */
  112868. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112869. /** @hidden */
  112870. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112871. width: number;
  112872. height: number;
  112873. layers?: number;
  112874. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112875. /** @hidden */
  112876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112877. /** @hidden */
  112878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112879. /**
  112880. * Update a portion of an internal texture
  112881. * @param texture defines the texture to update
  112882. * @param imageData defines the data to store into the texture
  112883. * @param xOffset defines the x coordinates of the update rectangle
  112884. * @param yOffset defines the y coordinates of the update rectangle
  112885. * @param width defines the width of the update rectangle
  112886. * @param height defines the height of the update rectangle
  112887. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112888. * @param lod defines the lod level to update (0 by default)
  112889. */
  112890. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112891. /** @hidden */
  112892. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112893. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112894. private _prepareWebGLTexture;
  112895. /** @hidden */
  112896. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112897. private _getDepthStencilBuffer;
  112898. /** @hidden */
  112899. _releaseFramebufferObjects(texture: InternalTexture): void;
  112900. /** @hidden */
  112901. _releaseTexture(texture: InternalTexture): void;
  112902. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112903. protected _setProgram(program: WebGLProgram): void;
  112904. protected _boundUniforms: {
  112905. [key: number]: WebGLUniformLocation;
  112906. };
  112907. /**
  112908. * Binds an effect to the webGL context
  112909. * @param effect defines the effect to bind
  112910. */
  112911. bindSamplers(effect: Effect): void;
  112912. private _activateCurrentTexture;
  112913. /** @hidden */
  112914. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112915. /** @hidden */
  112916. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112917. /**
  112918. * Unbind all textures from the webGL context
  112919. */
  112920. unbindAllTextures(): void;
  112921. /**
  112922. * Sets a texture to the according uniform.
  112923. * @param channel The texture channel
  112924. * @param uniform The uniform to set
  112925. * @param texture The texture to apply
  112926. */
  112927. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112928. private _bindSamplerUniformToChannel;
  112929. private _getTextureWrapMode;
  112930. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112931. /**
  112932. * Sets an array of texture to the webGL context
  112933. * @param channel defines the channel where the texture array must be set
  112934. * @param uniform defines the associated uniform location
  112935. * @param textures defines the array of textures to bind
  112936. */
  112937. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112938. /** @hidden */
  112939. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112940. private _setTextureParameterFloat;
  112941. private _setTextureParameterInteger;
  112942. /**
  112943. * Unbind all vertex attributes from the webGL context
  112944. */
  112945. unbindAllAttributes(): void;
  112946. /**
  112947. * 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
  112948. */
  112949. releaseEffects(): void;
  112950. /**
  112951. * Dispose and release all associated resources
  112952. */
  112953. dispose(): void;
  112954. /**
  112955. * Attach a new callback raised when context lost event is fired
  112956. * @param callback defines the callback to call
  112957. */
  112958. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112959. /**
  112960. * Attach a new callback raised when context restored event is fired
  112961. * @param callback defines the callback to call
  112962. */
  112963. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112964. /**
  112965. * Get the current error code of the webGL context
  112966. * @returns the error code
  112967. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112968. */
  112969. getError(): number;
  112970. private _canRenderToFloatFramebuffer;
  112971. private _canRenderToHalfFloatFramebuffer;
  112972. private _canRenderToFramebuffer;
  112973. /** @hidden */
  112974. _getWebGLTextureType(type: number): number;
  112975. /** @hidden */
  112976. _getInternalFormat(format: number): number;
  112977. /** @hidden */
  112978. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112979. /** @hidden */
  112980. _getRGBAMultiSampleBufferFormat(type: number): number;
  112981. /** @hidden */
  112982. _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;
  112983. /**
  112984. * Loads a file from a url
  112985. * @param url url to load
  112986. * @param onSuccess callback called when the file successfully loads
  112987. * @param onProgress callback called while file is loading (if the server supports this mode)
  112988. * @param offlineProvider defines the offline provider for caching
  112989. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112990. * @param onError callback called when the file fails to load
  112991. * @returns a file request object
  112992. * @hidden
  112993. */
  112994. 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;
  112995. /**
  112996. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112997. * @param x defines the x coordinate of the rectangle where pixels must be read
  112998. * @param y defines the y coordinate of the rectangle where pixels must be read
  112999. * @param width defines the width of the rectangle where pixels must be read
  113000. * @param height defines the height of the rectangle where pixels must be read
  113001. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113002. * @returns a Uint8Array containing RGBA colors
  113003. */
  113004. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113005. private static _isSupported;
  113006. /**
  113007. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113008. * @returns true if the engine can be created
  113009. * @ignorenaming
  113010. */
  113011. static isSupported(): boolean;
  113012. /**
  113013. * Find the next highest power of two.
  113014. * @param x Number to start search from.
  113015. * @return Next highest power of two.
  113016. */
  113017. static CeilingPOT(x: number): number;
  113018. /**
  113019. * Find the next lowest power of two.
  113020. * @param x Number to start search from.
  113021. * @return Next lowest power of two.
  113022. */
  113023. static FloorPOT(x: number): number;
  113024. /**
  113025. * Find the nearest power of two.
  113026. * @param x Number to start search from.
  113027. * @return Next nearest power of two.
  113028. */
  113029. static NearestPOT(x: number): number;
  113030. /**
  113031. * Get the closest exponent of two
  113032. * @param value defines the value to approximate
  113033. * @param max defines the maximum value to return
  113034. * @param mode defines how to define the closest value
  113035. * @returns closest exponent of two of the given value
  113036. */
  113037. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113038. /**
  113039. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113040. * @param func - the function to be called
  113041. * @param requester - the object that will request the next frame. Falls back to window.
  113042. * @returns frame number
  113043. */
  113044. static QueueNewFrame(func: () => void, requester?: any): number;
  113045. /**
  113046. * Gets host document
  113047. * @returns the host document object
  113048. */
  113049. getHostDocument(): Nullable<Document>;
  113050. }
  113051. }
  113052. declare module BABYLON {
  113053. /**
  113054. * Class representing spherical harmonics coefficients to the 3rd degree
  113055. */
  113056. export class SphericalHarmonics {
  113057. /**
  113058. * Defines whether or not the harmonics have been prescaled for rendering.
  113059. */
  113060. preScaled: boolean;
  113061. /**
  113062. * The l0,0 coefficients of the spherical harmonics
  113063. */
  113064. l00: Vector3;
  113065. /**
  113066. * The l1,-1 coefficients of the spherical harmonics
  113067. */
  113068. l1_1: Vector3;
  113069. /**
  113070. * The l1,0 coefficients of the spherical harmonics
  113071. */
  113072. l10: Vector3;
  113073. /**
  113074. * The l1,1 coefficients of the spherical harmonics
  113075. */
  113076. l11: Vector3;
  113077. /**
  113078. * The l2,-2 coefficients of the spherical harmonics
  113079. */
  113080. l2_2: Vector3;
  113081. /**
  113082. * The l2,-1 coefficients of the spherical harmonics
  113083. */
  113084. l2_1: Vector3;
  113085. /**
  113086. * The l2,0 coefficients of the spherical harmonics
  113087. */
  113088. l20: Vector3;
  113089. /**
  113090. * The l2,1 coefficients of the spherical harmonics
  113091. */
  113092. l21: Vector3;
  113093. /**
  113094. * The l2,2 coefficients of the spherical harmonics
  113095. */
  113096. l22: Vector3;
  113097. /**
  113098. * Adds a light to the spherical harmonics
  113099. * @param direction the direction of the light
  113100. * @param color the color of the light
  113101. * @param deltaSolidAngle the delta solid angle of the light
  113102. */
  113103. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113104. /**
  113105. * Scales the spherical harmonics by the given amount
  113106. * @param scale the amount to scale
  113107. */
  113108. scaleInPlace(scale: number): void;
  113109. /**
  113110. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113111. *
  113112. * ```
  113113. * E_lm = A_l * L_lm
  113114. * ```
  113115. *
  113116. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113117. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113118. * the scaling factors are given in equation 9.
  113119. */
  113120. convertIncidentRadianceToIrradiance(): void;
  113121. /**
  113122. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113123. *
  113124. * ```
  113125. * L = (1/pi) * E * rho
  113126. * ```
  113127. *
  113128. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113129. */
  113130. convertIrradianceToLambertianRadiance(): void;
  113131. /**
  113132. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113133. * required operations at run time.
  113134. *
  113135. * This is simply done by scaling back the SH with Ylm constants parameter.
  113136. * The trigonometric part being applied by the shader at run time.
  113137. */
  113138. preScaleForRendering(): void;
  113139. /**
  113140. * Constructs a spherical harmonics from an array.
  113141. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113142. * @returns the spherical harmonics
  113143. */
  113144. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113145. /**
  113146. * Gets the spherical harmonics from polynomial
  113147. * @param polynomial the spherical polynomial
  113148. * @returns the spherical harmonics
  113149. */
  113150. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113151. }
  113152. /**
  113153. * Class representing spherical polynomial coefficients to the 3rd degree
  113154. */
  113155. export class SphericalPolynomial {
  113156. private _harmonics;
  113157. /**
  113158. * The spherical harmonics used to create the polynomials.
  113159. */
  113160. get preScaledHarmonics(): SphericalHarmonics;
  113161. /**
  113162. * The x coefficients of the spherical polynomial
  113163. */
  113164. x: Vector3;
  113165. /**
  113166. * The y coefficients of the spherical polynomial
  113167. */
  113168. y: Vector3;
  113169. /**
  113170. * The z coefficients of the spherical polynomial
  113171. */
  113172. z: Vector3;
  113173. /**
  113174. * The xx coefficients of the spherical polynomial
  113175. */
  113176. xx: Vector3;
  113177. /**
  113178. * The yy coefficients of the spherical polynomial
  113179. */
  113180. yy: Vector3;
  113181. /**
  113182. * The zz coefficients of the spherical polynomial
  113183. */
  113184. zz: Vector3;
  113185. /**
  113186. * The xy coefficients of the spherical polynomial
  113187. */
  113188. xy: Vector3;
  113189. /**
  113190. * The yz coefficients of the spherical polynomial
  113191. */
  113192. yz: Vector3;
  113193. /**
  113194. * The zx coefficients of the spherical polynomial
  113195. */
  113196. zx: Vector3;
  113197. /**
  113198. * Adds an ambient color to the spherical polynomial
  113199. * @param color the color to add
  113200. */
  113201. addAmbient(color: Color3): void;
  113202. /**
  113203. * Scales the spherical polynomial by the given amount
  113204. * @param scale the amount to scale
  113205. */
  113206. scaleInPlace(scale: number): void;
  113207. /**
  113208. * Gets the spherical polynomial from harmonics
  113209. * @param harmonics the spherical harmonics
  113210. * @returns the spherical polynomial
  113211. */
  113212. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113213. /**
  113214. * Constructs a spherical polynomial from an array.
  113215. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113216. * @returns the spherical polynomial
  113217. */
  113218. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113219. }
  113220. }
  113221. declare module BABYLON {
  113222. /**
  113223. * Defines the source of the internal texture
  113224. */
  113225. export enum InternalTextureSource {
  113226. /**
  113227. * The source of the texture data is unknown
  113228. */
  113229. Unknown = 0,
  113230. /**
  113231. * Texture data comes from an URL
  113232. */
  113233. Url = 1,
  113234. /**
  113235. * Texture data is only used for temporary storage
  113236. */
  113237. Temp = 2,
  113238. /**
  113239. * Texture data comes from raw data (ArrayBuffer)
  113240. */
  113241. Raw = 3,
  113242. /**
  113243. * Texture content is dynamic (video or dynamic texture)
  113244. */
  113245. Dynamic = 4,
  113246. /**
  113247. * Texture content is generated by rendering to it
  113248. */
  113249. RenderTarget = 5,
  113250. /**
  113251. * Texture content is part of a multi render target process
  113252. */
  113253. MultiRenderTarget = 6,
  113254. /**
  113255. * Texture data comes from a cube data file
  113256. */
  113257. Cube = 7,
  113258. /**
  113259. * Texture data comes from a raw cube data
  113260. */
  113261. CubeRaw = 8,
  113262. /**
  113263. * Texture data come from a prefiltered cube data file
  113264. */
  113265. CubePrefiltered = 9,
  113266. /**
  113267. * Texture content is raw 3D data
  113268. */
  113269. Raw3D = 10,
  113270. /**
  113271. * Texture content is raw 2D array data
  113272. */
  113273. Raw2DArray = 11,
  113274. /**
  113275. * Texture content is a depth texture
  113276. */
  113277. Depth = 12,
  113278. /**
  113279. * Texture data comes from a raw cube data encoded with RGBD
  113280. */
  113281. CubeRawRGBD = 13
  113282. }
  113283. /**
  113284. * Class used to store data associated with WebGL texture data for the engine
  113285. * This class should not be used directly
  113286. */
  113287. export class InternalTexture {
  113288. /** @hidden */
  113289. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113290. /**
  113291. * Defines if the texture is ready
  113292. */
  113293. isReady: boolean;
  113294. /**
  113295. * Defines if the texture is a cube texture
  113296. */
  113297. isCube: boolean;
  113298. /**
  113299. * Defines if the texture contains 3D data
  113300. */
  113301. is3D: boolean;
  113302. /**
  113303. * Defines if the texture contains 2D array data
  113304. */
  113305. is2DArray: boolean;
  113306. /**
  113307. * Defines if the texture contains multiview data
  113308. */
  113309. isMultiview: boolean;
  113310. /**
  113311. * Gets the URL used to load this texture
  113312. */
  113313. url: string;
  113314. /**
  113315. * Gets the sampling mode of the texture
  113316. */
  113317. samplingMode: number;
  113318. /**
  113319. * Gets a boolean indicating if the texture needs mipmaps generation
  113320. */
  113321. generateMipMaps: boolean;
  113322. /**
  113323. * Gets the number of samples used by the texture (WebGL2+ only)
  113324. */
  113325. samples: number;
  113326. /**
  113327. * Gets the type of the texture (int, float...)
  113328. */
  113329. type: number;
  113330. /**
  113331. * Gets the format of the texture (RGB, RGBA...)
  113332. */
  113333. format: number;
  113334. /**
  113335. * Observable called when the texture is loaded
  113336. */
  113337. onLoadedObservable: Observable<InternalTexture>;
  113338. /**
  113339. * Gets the width of the texture
  113340. */
  113341. width: number;
  113342. /**
  113343. * Gets the height of the texture
  113344. */
  113345. height: number;
  113346. /**
  113347. * Gets the depth of the texture
  113348. */
  113349. depth: number;
  113350. /**
  113351. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113352. */
  113353. baseWidth: number;
  113354. /**
  113355. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113356. */
  113357. baseHeight: number;
  113358. /**
  113359. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113360. */
  113361. baseDepth: number;
  113362. /**
  113363. * Gets a boolean indicating if the texture is inverted on Y axis
  113364. */
  113365. invertY: boolean;
  113366. /** @hidden */
  113367. _invertVScale: boolean;
  113368. /** @hidden */
  113369. _associatedChannel: number;
  113370. /** @hidden */
  113371. _source: InternalTextureSource;
  113372. /** @hidden */
  113373. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113374. /** @hidden */
  113375. _bufferView: Nullable<ArrayBufferView>;
  113376. /** @hidden */
  113377. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113378. /** @hidden */
  113379. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113380. /** @hidden */
  113381. _size: number;
  113382. /** @hidden */
  113383. _extension: string;
  113384. /** @hidden */
  113385. _files: Nullable<string[]>;
  113386. /** @hidden */
  113387. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113388. /** @hidden */
  113389. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113390. /** @hidden */
  113391. _framebuffer: Nullable<WebGLFramebuffer>;
  113392. /** @hidden */
  113393. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113394. /** @hidden */
  113395. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113396. /** @hidden */
  113397. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113398. /** @hidden */
  113399. _attachments: Nullable<number[]>;
  113400. /** @hidden */
  113401. _cachedCoordinatesMode: Nullable<number>;
  113402. /** @hidden */
  113403. _cachedWrapU: Nullable<number>;
  113404. /** @hidden */
  113405. _cachedWrapV: Nullable<number>;
  113406. /** @hidden */
  113407. _cachedWrapR: Nullable<number>;
  113408. /** @hidden */
  113409. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113410. /** @hidden */
  113411. _isDisabled: boolean;
  113412. /** @hidden */
  113413. _compression: Nullable<string>;
  113414. /** @hidden */
  113415. _generateStencilBuffer: boolean;
  113416. /** @hidden */
  113417. _generateDepthBuffer: boolean;
  113418. /** @hidden */
  113419. _comparisonFunction: number;
  113420. /** @hidden */
  113421. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113422. /** @hidden */
  113423. _lodGenerationScale: number;
  113424. /** @hidden */
  113425. _lodGenerationOffset: number;
  113426. /** @hidden */
  113427. _depthStencilTexture: Nullable<InternalTexture>;
  113428. /** @hidden */
  113429. _colorTextureArray: Nullable<WebGLTexture>;
  113430. /** @hidden */
  113431. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113432. /** @hidden */
  113433. _lodTextureHigh: Nullable<BaseTexture>;
  113434. /** @hidden */
  113435. _lodTextureMid: Nullable<BaseTexture>;
  113436. /** @hidden */
  113437. _lodTextureLow: Nullable<BaseTexture>;
  113438. /** @hidden */
  113439. _isRGBD: boolean;
  113440. /** @hidden */
  113441. _linearSpecularLOD: boolean;
  113442. /** @hidden */
  113443. _irradianceTexture: Nullable<BaseTexture>;
  113444. /** @hidden */
  113445. _webGLTexture: Nullable<WebGLTexture>;
  113446. /** @hidden */
  113447. _references: number;
  113448. private _engine;
  113449. /**
  113450. * Gets the Engine the texture belongs to.
  113451. * @returns The babylon engine
  113452. */
  113453. getEngine(): ThinEngine;
  113454. /**
  113455. * Gets the data source type of the texture
  113456. */
  113457. get source(): InternalTextureSource;
  113458. /**
  113459. * Creates a new InternalTexture
  113460. * @param engine defines the engine to use
  113461. * @param source defines the type of data that will be used
  113462. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113463. */
  113464. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113465. /**
  113466. * Increments the number of references (ie. the number of Texture that point to it)
  113467. */
  113468. incrementReferences(): void;
  113469. /**
  113470. * Change the size of the texture (not the size of the content)
  113471. * @param width defines the new width
  113472. * @param height defines the new height
  113473. * @param depth defines the new depth (1 by default)
  113474. */
  113475. updateSize(width: int, height: int, depth?: int): void;
  113476. /** @hidden */
  113477. _rebuild(): void;
  113478. /** @hidden */
  113479. _swapAndDie(target: InternalTexture): void;
  113480. /**
  113481. * Dispose the current allocated resources
  113482. */
  113483. dispose(): void;
  113484. }
  113485. }
  113486. declare module BABYLON {
  113487. /**
  113488. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113490. */
  113491. export class Analyser {
  113492. /**
  113493. * Gets or sets the smoothing
  113494. * @ignorenaming
  113495. */
  113496. SMOOTHING: number;
  113497. /**
  113498. * Gets or sets the FFT table size
  113499. * @ignorenaming
  113500. */
  113501. FFT_SIZE: number;
  113502. /**
  113503. * Gets or sets the bar graph amplitude
  113504. * @ignorenaming
  113505. */
  113506. BARGRAPHAMPLITUDE: number;
  113507. /**
  113508. * Gets or sets the position of the debug canvas
  113509. * @ignorenaming
  113510. */
  113511. DEBUGCANVASPOS: {
  113512. x: number;
  113513. y: number;
  113514. };
  113515. /**
  113516. * Gets or sets the debug canvas size
  113517. * @ignorenaming
  113518. */
  113519. DEBUGCANVASSIZE: {
  113520. width: number;
  113521. height: number;
  113522. };
  113523. private _byteFreqs;
  113524. private _byteTime;
  113525. private _floatFreqs;
  113526. private _webAudioAnalyser;
  113527. private _debugCanvas;
  113528. private _debugCanvasContext;
  113529. private _scene;
  113530. private _registerFunc;
  113531. private _audioEngine;
  113532. /**
  113533. * Creates a new analyser
  113534. * @param scene defines hosting scene
  113535. */
  113536. constructor(scene: Scene);
  113537. /**
  113538. * Get the number of data values you will have to play with for the visualization
  113539. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113540. * @returns a number
  113541. */
  113542. getFrequencyBinCount(): number;
  113543. /**
  113544. * Gets the current frequency data as a byte array
  113545. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113546. * @returns a Uint8Array
  113547. */
  113548. getByteFrequencyData(): Uint8Array;
  113549. /**
  113550. * Gets the current waveform as a byte array
  113551. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113552. * @returns a Uint8Array
  113553. */
  113554. getByteTimeDomainData(): Uint8Array;
  113555. /**
  113556. * Gets the current frequency data as a float array
  113557. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113558. * @returns a Float32Array
  113559. */
  113560. getFloatFrequencyData(): Float32Array;
  113561. /**
  113562. * Renders the debug canvas
  113563. */
  113564. drawDebugCanvas(): void;
  113565. /**
  113566. * Stops rendering the debug canvas and removes it
  113567. */
  113568. stopDebugCanvas(): void;
  113569. /**
  113570. * Connects two audio nodes
  113571. * @param inputAudioNode defines first node to connect
  113572. * @param outputAudioNode defines second node to connect
  113573. */
  113574. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113575. /**
  113576. * Releases all associated resources
  113577. */
  113578. dispose(): void;
  113579. }
  113580. }
  113581. declare module BABYLON {
  113582. /**
  113583. * This represents an audio engine and it is responsible
  113584. * to play, synchronize and analyse sounds throughout the application.
  113585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113586. */
  113587. export interface IAudioEngine extends IDisposable {
  113588. /**
  113589. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113590. */
  113591. readonly canUseWebAudio: boolean;
  113592. /**
  113593. * Gets the current AudioContext if available.
  113594. */
  113595. readonly audioContext: Nullable<AudioContext>;
  113596. /**
  113597. * The master gain node defines the global audio volume of your audio engine.
  113598. */
  113599. readonly masterGain: GainNode;
  113600. /**
  113601. * Gets whether or not mp3 are supported by your browser.
  113602. */
  113603. readonly isMP3supported: boolean;
  113604. /**
  113605. * Gets whether or not ogg are supported by your browser.
  113606. */
  113607. readonly isOGGsupported: boolean;
  113608. /**
  113609. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113610. * @ignoreNaming
  113611. */
  113612. WarnedWebAudioUnsupported: boolean;
  113613. /**
  113614. * Defines if the audio engine relies on a custom unlocked button.
  113615. * In this case, the embedded button will not be displayed.
  113616. */
  113617. useCustomUnlockedButton: boolean;
  113618. /**
  113619. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113620. */
  113621. readonly unlocked: boolean;
  113622. /**
  113623. * Event raised when audio has been unlocked on the browser.
  113624. */
  113625. onAudioUnlockedObservable: Observable<AudioEngine>;
  113626. /**
  113627. * Event raised when audio has been locked on the browser.
  113628. */
  113629. onAudioLockedObservable: Observable<AudioEngine>;
  113630. /**
  113631. * Flags the audio engine in Locked state.
  113632. * This happens due to new browser policies preventing audio to autoplay.
  113633. */
  113634. lock(): void;
  113635. /**
  113636. * Unlocks the audio engine once a user action has been done on the dom.
  113637. * This is helpful to resume play once browser policies have been satisfied.
  113638. */
  113639. unlock(): void;
  113640. /**
  113641. * Gets the global volume sets on the master gain.
  113642. * @returns the global volume if set or -1 otherwise
  113643. */
  113644. getGlobalVolume(): number;
  113645. /**
  113646. * Sets the global volume of your experience (sets on the master gain).
  113647. * @param newVolume Defines the new global volume of the application
  113648. */
  113649. setGlobalVolume(newVolume: number): void;
  113650. /**
  113651. * Connect the audio engine to an audio analyser allowing some amazing
  113652. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113654. * @param analyser The analyser to connect to the engine
  113655. */
  113656. connectToAnalyser(analyser: Analyser): void;
  113657. }
  113658. /**
  113659. * This represents the default audio engine used in babylon.
  113660. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113662. */
  113663. export class AudioEngine implements IAudioEngine {
  113664. private _audioContext;
  113665. private _audioContextInitialized;
  113666. private _muteButton;
  113667. private _hostElement;
  113668. /**
  113669. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113670. */
  113671. canUseWebAudio: boolean;
  113672. /**
  113673. * The master gain node defines the global audio volume of your audio engine.
  113674. */
  113675. masterGain: GainNode;
  113676. /**
  113677. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113678. * @ignoreNaming
  113679. */
  113680. WarnedWebAudioUnsupported: boolean;
  113681. /**
  113682. * Gets whether or not mp3 are supported by your browser.
  113683. */
  113684. isMP3supported: boolean;
  113685. /**
  113686. * Gets whether or not ogg are supported by your browser.
  113687. */
  113688. isOGGsupported: boolean;
  113689. /**
  113690. * Gets whether audio has been unlocked on the device.
  113691. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113692. * a user interaction has happened.
  113693. */
  113694. unlocked: boolean;
  113695. /**
  113696. * Defines if the audio engine relies on a custom unlocked button.
  113697. * In this case, the embedded button will not be displayed.
  113698. */
  113699. useCustomUnlockedButton: boolean;
  113700. /**
  113701. * Event raised when audio has been unlocked on the browser.
  113702. */
  113703. onAudioUnlockedObservable: Observable<AudioEngine>;
  113704. /**
  113705. * Event raised when audio has been locked on the browser.
  113706. */
  113707. onAudioLockedObservable: Observable<AudioEngine>;
  113708. /**
  113709. * Gets the current AudioContext if available.
  113710. */
  113711. get audioContext(): Nullable<AudioContext>;
  113712. private _connectedAnalyser;
  113713. /**
  113714. * Instantiates a new audio engine.
  113715. *
  113716. * There should be only one per page as some browsers restrict the number
  113717. * of audio contexts you can create.
  113718. * @param hostElement defines the host element where to display the mute icon if necessary
  113719. */
  113720. constructor(hostElement?: Nullable<HTMLElement>);
  113721. /**
  113722. * Flags the audio engine in Locked state.
  113723. * This happens due to new browser policies preventing audio to autoplay.
  113724. */
  113725. lock(): void;
  113726. /**
  113727. * Unlocks the audio engine once a user action has been done on the dom.
  113728. * This is helpful to resume play once browser policies have been satisfied.
  113729. */
  113730. unlock(): void;
  113731. private _resumeAudioContext;
  113732. private _initializeAudioContext;
  113733. private _tryToRun;
  113734. private _triggerRunningState;
  113735. private _triggerSuspendedState;
  113736. private _displayMuteButton;
  113737. private _moveButtonToTopLeft;
  113738. private _onResize;
  113739. private _hideMuteButton;
  113740. /**
  113741. * Destroy and release the resources associated with the audio ccontext.
  113742. */
  113743. dispose(): void;
  113744. /**
  113745. * Gets the global volume sets on the master gain.
  113746. * @returns the global volume if set or -1 otherwise
  113747. */
  113748. getGlobalVolume(): number;
  113749. /**
  113750. * Sets the global volume of your experience (sets on the master gain).
  113751. * @param newVolume Defines the new global volume of the application
  113752. */
  113753. setGlobalVolume(newVolume: number): void;
  113754. /**
  113755. * Connect the audio engine to an audio analyser allowing some amazing
  113756. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113758. * @param analyser The analyser to connect to the engine
  113759. */
  113760. connectToAnalyser(analyser: Analyser): void;
  113761. }
  113762. }
  113763. declare module BABYLON {
  113764. /**
  113765. * Interface used to present a loading screen while loading a scene
  113766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113767. */
  113768. export interface ILoadingScreen {
  113769. /**
  113770. * Function called to display the loading screen
  113771. */
  113772. displayLoadingUI: () => void;
  113773. /**
  113774. * Function called to hide the loading screen
  113775. */
  113776. hideLoadingUI: () => void;
  113777. /**
  113778. * Gets or sets the color to use for the background
  113779. */
  113780. loadingUIBackgroundColor: string;
  113781. /**
  113782. * Gets or sets the text to display while loading
  113783. */
  113784. loadingUIText: string;
  113785. }
  113786. /**
  113787. * Class used for the default loading screen
  113788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113789. */
  113790. export class DefaultLoadingScreen implements ILoadingScreen {
  113791. private _renderingCanvas;
  113792. private _loadingText;
  113793. private _loadingDivBackgroundColor;
  113794. private _loadingDiv;
  113795. private _loadingTextDiv;
  113796. /** Gets or sets the logo url to use for the default loading screen */
  113797. static DefaultLogoUrl: string;
  113798. /** Gets or sets the spinner url to use for the default loading screen */
  113799. static DefaultSpinnerUrl: string;
  113800. /**
  113801. * Creates a new default loading screen
  113802. * @param _renderingCanvas defines the canvas used to render the scene
  113803. * @param _loadingText defines the default text to display
  113804. * @param _loadingDivBackgroundColor defines the default background color
  113805. */
  113806. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113807. /**
  113808. * Function called to display the loading screen
  113809. */
  113810. displayLoadingUI(): void;
  113811. /**
  113812. * Function called to hide the loading screen
  113813. */
  113814. hideLoadingUI(): void;
  113815. /**
  113816. * Gets or sets the text to display while loading
  113817. */
  113818. set loadingUIText(text: string);
  113819. get loadingUIText(): string;
  113820. /**
  113821. * Gets or sets the color to use for the background
  113822. */
  113823. get loadingUIBackgroundColor(): string;
  113824. set loadingUIBackgroundColor(color: string);
  113825. private _resizeLoadingUI;
  113826. }
  113827. }
  113828. declare module BABYLON {
  113829. /**
  113830. * Interface for any object that can request an animation frame
  113831. */
  113832. export interface ICustomAnimationFrameRequester {
  113833. /**
  113834. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113835. */
  113836. renderFunction?: Function;
  113837. /**
  113838. * Called to request the next frame to render to
  113839. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113840. */
  113841. requestAnimationFrame: Function;
  113842. /**
  113843. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113844. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113845. */
  113846. requestID?: number;
  113847. }
  113848. }
  113849. declare module BABYLON {
  113850. /**
  113851. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113852. */
  113853. export class PerformanceMonitor {
  113854. private _enabled;
  113855. private _rollingFrameTime;
  113856. private _lastFrameTimeMs;
  113857. /**
  113858. * constructor
  113859. * @param frameSampleSize The number of samples required to saturate the sliding window
  113860. */
  113861. constructor(frameSampleSize?: number);
  113862. /**
  113863. * Samples current frame
  113864. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113865. */
  113866. sampleFrame(timeMs?: number): void;
  113867. /**
  113868. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113869. */
  113870. get averageFrameTime(): number;
  113871. /**
  113872. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113873. */
  113874. get averageFrameTimeVariance(): number;
  113875. /**
  113876. * Returns the frame time of the most recent frame
  113877. */
  113878. get instantaneousFrameTime(): number;
  113879. /**
  113880. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113881. */
  113882. get averageFPS(): number;
  113883. /**
  113884. * Returns the average framerate in frames per second using the most recent frame time
  113885. */
  113886. get instantaneousFPS(): number;
  113887. /**
  113888. * Returns true if enough samples have been taken to completely fill the sliding window
  113889. */
  113890. get isSaturated(): boolean;
  113891. /**
  113892. * Enables contributions to the sliding window sample set
  113893. */
  113894. enable(): void;
  113895. /**
  113896. * Disables contributions to the sliding window sample set
  113897. * Samples will not be interpolated over the disabled period
  113898. */
  113899. disable(): void;
  113900. /**
  113901. * Returns true if sampling is enabled
  113902. */
  113903. get isEnabled(): boolean;
  113904. /**
  113905. * Resets performance monitor
  113906. */
  113907. reset(): void;
  113908. }
  113909. /**
  113910. * RollingAverage
  113911. *
  113912. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113913. */
  113914. export class RollingAverage {
  113915. /**
  113916. * Current average
  113917. */
  113918. average: number;
  113919. /**
  113920. * Current variance
  113921. */
  113922. variance: number;
  113923. protected _samples: Array<number>;
  113924. protected _sampleCount: number;
  113925. protected _pos: number;
  113926. protected _m2: number;
  113927. /**
  113928. * constructor
  113929. * @param length The number of samples required to saturate the sliding window
  113930. */
  113931. constructor(length: number);
  113932. /**
  113933. * Adds a sample to the sample set
  113934. * @param v The sample value
  113935. */
  113936. add(v: number): void;
  113937. /**
  113938. * Returns previously added values or null if outside of history or outside the sliding window domain
  113939. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113940. * @return Value previously recorded with add() or null if outside of range
  113941. */
  113942. history(i: number): number;
  113943. /**
  113944. * Returns true if enough samples have been taken to completely fill the sliding window
  113945. * @return true if sample-set saturated
  113946. */
  113947. isSaturated(): boolean;
  113948. /**
  113949. * Resets the rolling average (equivalent to 0 samples taken so far)
  113950. */
  113951. reset(): void;
  113952. /**
  113953. * Wraps a value around the sample range boundaries
  113954. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113955. * @return Wrapped position in sample range
  113956. */
  113957. protected _wrapPosition(i: number): number;
  113958. }
  113959. }
  113960. declare module BABYLON {
  113961. /**
  113962. * This class is used to track a performance counter which is number based.
  113963. * The user has access to many properties which give statistics of different nature.
  113964. *
  113965. * The implementer can track two kinds of Performance Counter: time and count.
  113966. * 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.
  113967. * 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.
  113968. */
  113969. export class PerfCounter {
  113970. /**
  113971. * Gets or sets a global boolean to turn on and off all the counters
  113972. */
  113973. static Enabled: boolean;
  113974. /**
  113975. * Returns the smallest value ever
  113976. */
  113977. get min(): number;
  113978. /**
  113979. * Returns the biggest value ever
  113980. */
  113981. get max(): number;
  113982. /**
  113983. * Returns the average value since the performance counter is running
  113984. */
  113985. get average(): number;
  113986. /**
  113987. * Returns the average value of the last second the counter was monitored
  113988. */
  113989. get lastSecAverage(): number;
  113990. /**
  113991. * Returns the current value
  113992. */
  113993. get current(): number;
  113994. /**
  113995. * Gets the accumulated total
  113996. */
  113997. get total(): number;
  113998. /**
  113999. * Gets the total value count
  114000. */
  114001. get count(): number;
  114002. /**
  114003. * Creates a new counter
  114004. */
  114005. constructor();
  114006. /**
  114007. * Call this method to start monitoring a new frame.
  114008. * 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.
  114009. */
  114010. fetchNewFrame(): void;
  114011. /**
  114012. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114013. * @param newCount the count value to add to the monitored count
  114014. * @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.
  114015. */
  114016. addCount(newCount: number, fetchResult: boolean): void;
  114017. /**
  114018. * Start monitoring this performance counter
  114019. */
  114020. beginMonitoring(): void;
  114021. /**
  114022. * Compute the time lapsed since the previous beginMonitoring() call.
  114023. * @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
  114024. */
  114025. endMonitoring(newFrame?: boolean): void;
  114026. private _fetchResult;
  114027. private _startMonitoringTime;
  114028. private _min;
  114029. private _max;
  114030. private _average;
  114031. private _current;
  114032. private _totalValueCount;
  114033. private _totalAccumulated;
  114034. private _lastSecAverage;
  114035. private _lastSecAccumulated;
  114036. private _lastSecTime;
  114037. private _lastSecValueCount;
  114038. }
  114039. }
  114040. declare module BABYLON {
  114041. interface ThinEngine {
  114042. /**
  114043. * Sets alpha constants used by some alpha blending modes
  114044. * @param r defines the red component
  114045. * @param g defines the green component
  114046. * @param b defines the blue component
  114047. * @param a defines the alpha component
  114048. */
  114049. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114050. /**
  114051. * Sets the current alpha mode
  114052. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114053. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114054. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114055. */
  114056. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114057. /**
  114058. * Gets the current alpha mode
  114059. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114060. * @returns the current alpha mode
  114061. */
  114062. getAlphaMode(): number;
  114063. /**
  114064. * Sets the current alpha equation
  114065. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114066. */
  114067. setAlphaEquation(equation: number): void;
  114068. /**
  114069. * Gets the current alpha equation.
  114070. * @returns the current alpha equation
  114071. */
  114072. getAlphaEquation(): number;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. interface ThinEngine {
  114077. /** @hidden */
  114078. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114079. }
  114080. }
  114081. declare module BABYLON {
  114082. /**
  114083. * Defines the interface used by display changed events
  114084. */
  114085. export interface IDisplayChangedEventArgs {
  114086. /** Gets the vrDisplay object (if any) */
  114087. vrDisplay: Nullable<any>;
  114088. /** Gets a boolean indicating if webVR is supported */
  114089. vrSupported: boolean;
  114090. }
  114091. /**
  114092. * Defines the interface used by objects containing a viewport (like a camera)
  114093. */
  114094. interface IViewportOwnerLike {
  114095. /**
  114096. * Gets or sets the viewport
  114097. */
  114098. viewport: IViewportLike;
  114099. }
  114100. /**
  114101. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114102. */
  114103. export class Engine extends ThinEngine {
  114104. /** Defines that alpha blending is disabled */
  114105. static readonly ALPHA_DISABLE: number;
  114106. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114107. static readonly ALPHA_ADD: number;
  114108. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114109. static readonly ALPHA_COMBINE: number;
  114110. /** Defines that alpha blending to DEST - SRC * DEST */
  114111. static readonly ALPHA_SUBTRACT: number;
  114112. /** Defines that alpha blending to SRC * DEST */
  114113. static readonly ALPHA_MULTIPLY: number;
  114114. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114115. static readonly ALPHA_MAXIMIZED: number;
  114116. /** Defines that alpha blending to SRC + DEST */
  114117. static readonly ALPHA_ONEONE: number;
  114118. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114119. static readonly ALPHA_PREMULTIPLIED: number;
  114120. /**
  114121. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114122. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114123. */
  114124. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114125. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114126. static readonly ALPHA_INTERPOLATE: number;
  114127. /**
  114128. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114129. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114130. */
  114131. static readonly ALPHA_SCREENMODE: number;
  114132. /** Defines that the ressource is not delayed*/
  114133. static readonly DELAYLOADSTATE_NONE: number;
  114134. /** Defines that the ressource was successfully delay loaded */
  114135. static readonly DELAYLOADSTATE_LOADED: number;
  114136. /** Defines that the ressource is currently delay loading */
  114137. static readonly DELAYLOADSTATE_LOADING: number;
  114138. /** Defines that the ressource is delayed and has not started loading */
  114139. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114140. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114141. static readonly NEVER: number;
  114142. /** 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 */
  114143. static readonly ALWAYS: number;
  114144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114145. static readonly LESS: number;
  114146. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114147. static readonly EQUAL: number;
  114148. /** 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 */
  114149. static readonly LEQUAL: number;
  114150. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114151. static readonly GREATER: number;
  114152. /** 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 */
  114153. static readonly GEQUAL: number;
  114154. /** 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 */
  114155. static readonly NOTEQUAL: number;
  114156. /** Passed to stencilOperation to specify that stencil value must be kept */
  114157. static readonly KEEP: number;
  114158. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114159. static readonly REPLACE: number;
  114160. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114161. static readonly INCR: number;
  114162. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114163. static readonly DECR: number;
  114164. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114165. static readonly INVERT: number;
  114166. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114167. static readonly INCR_WRAP: number;
  114168. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114169. static readonly DECR_WRAP: number;
  114170. /** Texture is not repeating outside of 0..1 UVs */
  114171. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114172. /** Texture is repeating outside of 0..1 UVs */
  114173. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114174. /** Texture is repeating and mirrored */
  114175. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114176. /** ALPHA */
  114177. static readonly TEXTUREFORMAT_ALPHA: number;
  114178. /** LUMINANCE */
  114179. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114180. /** LUMINANCE_ALPHA */
  114181. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114182. /** RGB */
  114183. static readonly TEXTUREFORMAT_RGB: number;
  114184. /** RGBA */
  114185. static readonly TEXTUREFORMAT_RGBA: number;
  114186. /** RED */
  114187. static readonly TEXTUREFORMAT_RED: number;
  114188. /** RED (2nd reference) */
  114189. static readonly TEXTUREFORMAT_R: number;
  114190. /** RG */
  114191. static readonly TEXTUREFORMAT_RG: number;
  114192. /** RED_INTEGER */
  114193. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114194. /** RED_INTEGER (2nd reference) */
  114195. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114196. /** RG_INTEGER */
  114197. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114198. /** RGB_INTEGER */
  114199. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114200. /** RGBA_INTEGER */
  114201. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114202. /** UNSIGNED_BYTE */
  114203. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114204. /** UNSIGNED_BYTE (2nd reference) */
  114205. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114206. /** FLOAT */
  114207. static readonly TEXTURETYPE_FLOAT: number;
  114208. /** HALF_FLOAT */
  114209. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114210. /** BYTE */
  114211. static readonly TEXTURETYPE_BYTE: number;
  114212. /** SHORT */
  114213. static readonly TEXTURETYPE_SHORT: number;
  114214. /** UNSIGNED_SHORT */
  114215. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114216. /** INT */
  114217. static readonly TEXTURETYPE_INT: number;
  114218. /** UNSIGNED_INT */
  114219. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114220. /** UNSIGNED_SHORT_4_4_4_4 */
  114221. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114222. /** UNSIGNED_SHORT_5_5_5_1 */
  114223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114224. /** UNSIGNED_SHORT_5_6_5 */
  114225. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114226. /** UNSIGNED_INT_2_10_10_10_REV */
  114227. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114228. /** UNSIGNED_INT_24_8 */
  114229. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114230. /** UNSIGNED_INT_10F_11F_11F_REV */
  114231. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114232. /** UNSIGNED_INT_5_9_9_9_REV */
  114233. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114234. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114235. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114236. /** nearest is mag = nearest and min = nearest and mip = linear */
  114237. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114238. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114239. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114240. /** Trilinear is mag = linear and min = linear and mip = linear */
  114241. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114242. /** nearest is mag = nearest and min = nearest and mip = linear */
  114243. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114244. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114245. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114246. /** Trilinear is mag = linear and min = linear and mip = linear */
  114247. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114248. /** mag = nearest and min = nearest and mip = nearest */
  114249. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114250. /** mag = nearest and min = linear and mip = nearest */
  114251. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114252. /** mag = nearest and min = linear and mip = linear */
  114253. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114254. /** mag = nearest and min = linear and mip = none */
  114255. static readonly TEXTURE_NEAREST_LINEAR: number;
  114256. /** mag = nearest and min = nearest and mip = none */
  114257. static readonly TEXTURE_NEAREST_NEAREST: number;
  114258. /** mag = linear and min = nearest and mip = nearest */
  114259. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114260. /** mag = linear and min = nearest and mip = linear */
  114261. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114262. /** mag = linear and min = linear and mip = none */
  114263. static readonly TEXTURE_LINEAR_LINEAR: number;
  114264. /** mag = linear and min = nearest and mip = none */
  114265. static readonly TEXTURE_LINEAR_NEAREST: number;
  114266. /** Explicit coordinates mode */
  114267. static readonly TEXTURE_EXPLICIT_MODE: number;
  114268. /** Spherical coordinates mode */
  114269. static readonly TEXTURE_SPHERICAL_MODE: number;
  114270. /** Planar coordinates mode */
  114271. static readonly TEXTURE_PLANAR_MODE: number;
  114272. /** Cubic coordinates mode */
  114273. static readonly TEXTURE_CUBIC_MODE: number;
  114274. /** Projection coordinates mode */
  114275. static readonly TEXTURE_PROJECTION_MODE: number;
  114276. /** Skybox coordinates mode */
  114277. static readonly TEXTURE_SKYBOX_MODE: number;
  114278. /** Inverse Cubic coordinates mode */
  114279. static readonly TEXTURE_INVCUBIC_MODE: number;
  114280. /** Equirectangular coordinates mode */
  114281. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114282. /** Equirectangular Fixed coordinates mode */
  114283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114284. /** Equirectangular Fixed Mirrored coordinates mode */
  114285. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114286. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114287. static readonly SCALEMODE_FLOOR: number;
  114288. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114289. static readonly SCALEMODE_NEAREST: number;
  114290. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114291. static readonly SCALEMODE_CEILING: number;
  114292. /**
  114293. * Returns the current npm package of the sdk
  114294. */
  114295. static get NpmPackage(): string;
  114296. /**
  114297. * Returns the current version of the framework
  114298. */
  114299. static get Version(): string;
  114300. /** Gets the list of created engines */
  114301. static get Instances(): Engine[];
  114302. /**
  114303. * Gets the latest created engine
  114304. */
  114305. static get LastCreatedEngine(): Nullable<Engine>;
  114306. /**
  114307. * Gets the latest created scene
  114308. */
  114309. static get LastCreatedScene(): Nullable<Scene>;
  114310. /**
  114311. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114312. * @param flag defines which part of the materials must be marked as dirty
  114313. * @param predicate defines a predicate used to filter which materials should be affected
  114314. */
  114315. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114316. /**
  114317. * Method called to create the default loading screen.
  114318. * This can be overriden in your own app.
  114319. * @param canvas The rendering canvas element
  114320. * @returns The loading screen
  114321. */
  114322. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114323. /**
  114324. * Method called to create the default rescale post process on each engine.
  114325. */
  114326. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114327. /**
  114328. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114329. **/
  114330. enableOfflineSupport: boolean;
  114331. /**
  114332. * 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)
  114333. **/
  114334. disableManifestCheck: boolean;
  114335. /**
  114336. * Gets the list of created scenes
  114337. */
  114338. scenes: Scene[];
  114339. /**
  114340. * Event raised when a new scene is created
  114341. */
  114342. onNewSceneAddedObservable: Observable<Scene>;
  114343. /**
  114344. * Gets the list of created postprocesses
  114345. */
  114346. postProcesses: PostProcess[];
  114347. /**
  114348. * Gets a boolean indicating if the pointer is currently locked
  114349. */
  114350. isPointerLock: boolean;
  114351. /**
  114352. * Observable event triggered each time the rendering canvas is resized
  114353. */
  114354. onResizeObservable: Observable<Engine>;
  114355. /**
  114356. * Observable event triggered each time the canvas loses focus
  114357. */
  114358. onCanvasBlurObservable: Observable<Engine>;
  114359. /**
  114360. * Observable event triggered each time the canvas gains focus
  114361. */
  114362. onCanvasFocusObservable: Observable<Engine>;
  114363. /**
  114364. * Observable event triggered each time the canvas receives pointerout event
  114365. */
  114366. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114367. /**
  114368. * Observable raised when the engine begins a new frame
  114369. */
  114370. onBeginFrameObservable: Observable<Engine>;
  114371. /**
  114372. * If set, will be used to request the next animation frame for the render loop
  114373. */
  114374. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114375. /**
  114376. * Observable raised when the engine ends the current frame
  114377. */
  114378. onEndFrameObservable: Observable<Engine>;
  114379. /**
  114380. * Observable raised when the engine is about to compile a shader
  114381. */
  114382. onBeforeShaderCompilationObservable: Observable<Engine>;
  114383. /**
  114384. * Observable raised when the engine has jsut compiled a shader
  114385. */
  114386. onAfterShaderCompilationObservable: Observable<Engine>;
  114387. /**
  114388. * Gets the audio engine
  114389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114390. * @ignorenaming
  114391. */
  114392. static audioEngine: IAudioEngine;
  114393. /**
  114394. * Default AudioEngine factory responsible of creating the Audio Engine.
  114395. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114396. */
  114397. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114398. /**
  114399. * Default offline support factory responsible of creating a tool used to store data locally.
  114400. * By default, this will create a Database object if the workload has been embedded.
  114401. */
  114402. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114403. private _loadingScreen;
  114404. private _pointerLockRequested;
  114405. private _rescalePostProcess;
  114406. private _deterministicLockstep;
  114407. private _lockstepMaxSteps;
  114408. private _timeStep;
  114409. protected get _supportsHardwareTextureRescaling(): boolean;
  114410. private _fps;
  114411. private _deltaTime;
  114412. /** @hidden */
  114413. _drawCalls: PerfCounter;
  114414. /** 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 */
  114415. canvasTabIndex: number;
  114416. /**
  114417. * Turn this value on if you want to pause FPS computation when in background
  114418. */
  114419. disablePerformanceMonitorInBackground: boolean;
  114420. private _performanceMonitor;
  114421. /**
  114422. * Gets the performance monitor attached to this engine
  114423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114424. */
  114425. get performanceMonitor(): PerformanceMonitor;
  114426. private _onFocus;
  114427. private _onBlur;
  114428. private _onCanvasPointerOut;
  114429. private _onCanvasBlur;
  114430. private _onCanvasFocus;
  114431. private _onFullscreenChange;
  114432. private _onPointerLockChange;
  114433. /**
  114434. * Gets the HTML element used to attach event listeners
  114435. * @returns a HTML element
  114436. */
  114437. getInputElement(): Nullable<HTMLElement>;
  114438. /**
  114439. * Creates a new engine
  114440. * @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
  114441. * @param antialias defines enable antialiasing (default: false)
  114442. * @param options defines further options to be sent to the getContext() function
  114443. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114444. */
  114445. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114446. /**
  114447. * Gets current aspect ratio
  114448. * @param viewportOwner defines the camera to use to get the aspect ratio
  114449. * @param useScreen defines if screen size must be used (or the current render target if any)
  114450. * @returns a number defining the aspect ratio
  114451. */
  114452. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114453. /**
  114454. * Gets current screen aspect ratio
  114455. * @returns a number defining the aspect ratio
  114456. */
  114457. getScreenAspectRatio(): number;
  114458. /**
  114459. * Gets the client rect of the HTML canvas attached with the current webGL context
  114460. * @returns a client rectanglee
  114461. */
  114462. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114463. /**
  114464. * Gets the client rect of the HTML element used for events
  114465. * @returns a client rectanglee
  114466. */
  114467. getInputElementClientRect(): Nullable<ClientRect>;
  114468. /**
  114469. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114470. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114471. * @returns true if engine is in deterministic lock step mode
  114472. */
  114473. isDeterministicLockStep(): boolean;
  114474. /**
  114475. * Gets the max steps when engine is running in deterministic lock step
  114476. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114477. * @returns the max steps
  114478. */
  114479. getLockstepMaxSteps(): number;
  114480. /**
  114481. * Returns the time in ms between steps when using deterministic lock step.
  114482. * @returns time step in (ms)
  114483. */
  114484. getTimeStep(): number;
  114485. /**
  114486. * Force the mipmap generation for the given render target texture
  114487. * @param texture defines the render target texture to use
  114488. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114489. */
  114490. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114491. /** States */
  114492. /**
  114493. * Set various states to the webGL context
  114494. * @param culling defines backface culling state
  114495. * @param zOffset defines the value to apply to zOffset (0 by default)
  114496. * @param force defines if states must be applied even if cache is up to date
  114497. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114498. */
  114499. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114500. /**
  114501. * Set the z offset to apply to current rendering
  114502. * @param value defines the offset to apply
  114503. */
  114504. setZOffset(value: number): void;
  114505. /**
  114506. * Gets the current value of the zOffset
  114507. * @returns the current zOffset state
  114508. */
  114509. getZOffset(): number;
  114510. /**
  114511. * Enable or disable depth buffering
  114512. * @param enable defines the state to set
  114513. */
  114514. setDepthBuffer(enable: boolean): void;
  114515. /**
  114516. * Gets a boolean indicating if depth writing is enabled
  114517. * @returns the current depth writing state
  114518. */
  114519. getDepthWrite(): boolean;
  114520. /**
  114521. * Enable or disable depth writing
  114522. * @param enable defines the state to set
  114523. */
  114524. setDepthWrite(enable: boolean): void;
  114525. /**
  114526. * Gets a boolean indicating if stencil buffer is enabled
  114527. * @returns the current stencil buffer state
  114528. */
  114529. getStencilBuffer(): boolean;
  114530. /**
  114531. * Enable or disable the stencil buffer
  114532. * @param enable defines if the stencil buffer must be enabled or disabled
  114533. */
  114534. setStencilBuffer(enable: boolean): void;
  114535. /**
  114536. * Gets the current stencil mask
  114537. * @returns a number defining the new stencil mask to use
  114538. */
  114539. getStencilMask(): number;
  114540. /**
  114541. * Sets the current stencil mask
  114542. * @param mask defines the new stencil mask to use
  114543. */
  114544. setStencilMask(mask: number): void;
  114545. /**
  114546. * Gets the current stencil function
  114547. * @returns a number defining the stencil function to use
  114548. */
  114549. getStencilFunction(): number;
  114550. /**
  114551. * Gets the current stencil reference value
  114552. * @returns a number defining the stencil reference value to use
  114553. */
  114554. getStencilFunctionReference(): number;
  114555. /**
  114556. * Gets the current stencil mask
  114557. * @returns a number defining the stencil mask to use
  114558. */
  114559. getStencilFunctionMask(): number;
  114560. /**
  114561. * Sets the current stencil function
  114562. * @param stencilFunc defines the new stencil function to use
  114563. */
  114564. setStencilFunction(stencilFunc: number): void;
  114565. /**
  114566. * Sets the current stencil reference
  114567. * @param reference defines the new stencil reference to use
  114568. */
  114569. setStencilFunctionReference(reference: number): void;
  114570. /**
  114571. * Sets the current stencil mask
  114572. * @param mask defines the new stencil mask to use
  114573. */
  114574. setStencilFunctionMask(mask: number): void;
  114575. /**
  114576. * Gets the current stencil operation when stencil fails
  114577. * @returns a number defining stencil operation to use when stencil fails
  114578. */
  114579. getStencilOperationFail(): number;
  114580. /**
  114581. * Gets the current stencil operation when depth fails
  114582. * @returns a number defining stencil operation to use when depth fails
  114583. */
  114584. getStencilOperationDepthFail(): number;
  114585. /**
  114586. * Gets the current stencil operation when stencil passes
  114587. * @returns a number defining stencil operation to use when stencil passes
  114588. */
  114589. getStencilOperationPass(): number;
  114590. /**
  114591. * Sets the stencil operation to use when stencil fails
  114592. * @param operation defines the stencil operation to use when stencil fails
  114593. */
  114594. setStencilOperationFail(operation: number): void;
  114595. /**
  114596. * Sets the stencil operation to use when depth fails
  114597. * @param operation defines the stencil operation to use when depth fails
  114598. */
  114599. setStencilOperationDepthFail(operation: number): void;
  114600. /**
  114601. * Sets the stencil operation to use when stencil passes
  114602. * @param operation defines the stencil operation to use when stencil passes
  114603. */
  114604. setStencilOperationPass(operation: number): void;
  114605. /**
  114606. * Sets a boolean indicating if the dithering state is enabled or disabled
  114607. * @param value defines the dithering state
  114608. */
  114609. setDitheringState(value: boolean): void;
  114610. /**
  114611. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114612. * @param value defines the rasterizer state
  114613. */
  114614. setRasterizerState(value: boolean): void;
  114615. /**
  114616. * Gets the current depth function
  114617. * @returns a number defining the depth function
  114618. */
  114619. getDepthFunction(): Nullable<number>;
  114620. /**
  114621. * Sets the current depth function
  114622. * @param depthFunc defines the function to use
  114623. */
  114624. setDepthFunction(depthFunc: number): void;
  114625. /**
  114626. * Sets the current depth function to GREATER
  114627. */
  114628. setDepthFunctionToGreater(): void;
  114629. /**
  114630. * Sets the current depth function to GEQUAL
  114631. */
  114632. setDepthFunctionToGreaterOrEqual(): void;
  114633. /**
  114634. * Sets the current depth function to LESS
  114635. */
  114636. setDepthFunctionToLess(): void;
  114637. /**
  114638. * Sets the current depth function to LEQUAL
  114639. */
  114640. setDepthFunctionToLessOrEqual(): void;
  114641. private _cachedStencilBuffer;
  114642. private _cachedStencilFunction;
  114643. private _cachedStencilMask;
  114644. private _cachedStencilOperationPass;
  114645. private _cachedStencilOperationFail;
  114646. private _cachedStencilOperationDepthFail;
  114647. private _cachedStencilReference;
  114648. /**
  114649. * Caches the the state of the stencil buffer
  114650. */
  114651. cacheStencilState(): void;
  114652. /**
  114653. * Restores the state of the stencil buffer
  114654. */
  114655. restoreStencilState(): void;
  114656. /**
  114657. * Directly set the WebGL Viewport
  114658. * @param x defines the x coordinate of the viewport (in screen space)
  114659. * @param y defines the y coordinate of the viewport (in screen space)
  114660. * @param width defines the width of the viewport (in screen space)
  114661. * @param height defines the height of the viewport (in screen space)
  114662. * @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
  114663. */
  114664. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114665. /**
  114666. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114667. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114668. * @param y defines the y-coordinate of the corner of the clear rectangle
  114669. * @param width defines the width of the clear rectangle
  114670. * @param height defines the height of the clear rectangle
  114671. * @param clearColor defines the clear color
  114672. */
  114673. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114674. /**
  114675. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114676. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114677. * @param y defines the y-coordinate of the corner of the clear rectangle
  114678. * @param width defines the width of the clear rectangle
  114679. * @param height defines the height of the clear rectangle
  114680. */
  114681. enableScissor(x: number, y: number, width: number, height: number): void;
  114682. /**
  114683. * Disable previously set scissor test rectangle
  114684. */
  114685. disableScissor(): void;
  114686. protected _reportDrawCall(): void;
  114687. /**
  114688. * Initializes a webVR display and starts listening to display change events
  114689. * The onVRDisplayChangedObservable will be notified upon these changes
  114690. * @returns The onVRDisplayChangedObservable
  114691. */
  114692. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114693. /** @hidden */
  114694. _prepareVRComponent(): void;
  114695. /** @hidden */
  114696. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114697. /** @hidden */
  114698. _submitVRFrame(): void;
  114699. /**
  114700. * Call this function to leave webVR mode
  114701. * Will do nothing if webVR is not supported or if there is no webVR device
  114702. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114703. */
  114704. disableVR(): void;
  114705. /**
  114706. * Gets a boolean indicating that the system is in VR mode and is presenting
  114707. * @returns true if VR mode is engaged
  114708. */
  114709. isVRPresenting(): boolean;
  114710. /** @hidden */
  114711. _requestVRFrame(): void;
  114712. /** @hidden */
  114713. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114714. /**
  114715. * Gets the source code of the vertex shader associated with a specific webGL program
  114716. * @param program defines the program to use
  114717. * @returns a string containing the source code of the vertex shader associated with the program
  114718. */
  114719. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114720. /**
  114721. * Gets the source code of the fragment shader associated with a specific webGL program
  114722. * @param program defines the program to use
  114723. * @returns a string containing the source code of the fragment shader associated with the program
  114724. */
  114725. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114726. /**
  114727. * Sets a depth stencil texture from a render target to the according uniform.
  114728. * @param channel The texture channel
  114729. * @param uniform The uniform to set
  114730. * @param texture The render target texture containing the depth stencil texture to apply
  114731. */
  114732. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114733. /**
  114734. * Sets a texture to the webGL context from a postprocess
  114735. * @param channel defines the channel to use
  114736. * @param postProcess defines the source postprocess
  114737. */
  114738. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114739. /**
  114740. * Binds the output of the passed in post process to the texture channel specified
  114741. * @param channel The channel the texture should be bound to
  114742. * @param postProcess The post process which's output should be bound
  114743. */
  114744. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114745. protected _rebuildBuffers(): void;
  114746. /** @hidden */
  114747. _renderFrame(): void;
  114748. _renderLoop(): void;
  114749. /** @hidden */
  114750. _renderViews(): boolean;
  114751. /**
  114752. * Toggle full screen mode
  114753. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114754. */
  114755. switchFullscreen(requestPointerLock: boolean): void;
  114756. /**
  114757. * Enters full screen mode
  114758. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114759. */
  114760. enterFullscreen(requestPointerLock: boolean): void;
  114761. /**
  114762. * Exits full screen mode
  114763. */
  114764. exitFullscreen(): void;
  114765. /**
  114766. * Enters Pointerlock mode
  114767. */
  114768. enterPointerlock(): void;
  114769. /**
  114770. * Exits Pointerlock mode
  114771. */
  114772. exitPointerlock(): void;
  114773. /**
  114774. * Begin a new frame
  114775. */
  114776. beginFrame(): void;
  114777. /**
  114778. * Enf the current frame
  114779. */
  114780. endFrame(): void;
  114781. resize(): void;
  114782. /**
  114783. * Force a specific size of the canvas
  114784. * @param width defines the new canvas' width
  114785. * @param height defines the new canvas' height
  114786. */
  114787. setSize(width: number, height: number): void;
  114788. /**
  114789. * Updates a dynamic vertex buffer.
  114790. * @param vertexBuffer the vertex buffer to update
  114791. * @param data the data used to update the vertex buffer
  114792. * @param byteOffset the byte offset of the data
  114793. * @param byteLength the byte length of the data
  114794. */
  114795. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114796. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114797. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114798. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114799. _releaseTexture(texture: InternalTexture): void;
  114800. /**
  114801. * @hidden
  114802. * Rescales a texture
  114803. * @param source input texutre
  114804. * @param destination destination texture
  114805. * @param scene scene to use to render the resize
  114806. * @param internalFormat format to use when resizing
  114807. * @param onComplete callback to be called when resize has completed
  114808. */
  114809. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114810. /**
  114811. * Gets the current framerate
  114812. * @returns a number representing the framerate
  114813. */
  114814. getFps(): number;
  114815. /**
  114816. * Gets the time spent between current and previous frame
  114817. * @returns a number representing the delta time in ms
  114818. */
  114819. getDeltaTime(): number;
  114820. private _measureFps;
  114821. /** @hidden */
  114822. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114823. /**
  114824. * Update a dynamic index buffer
  114825. * @param indexBuffer defines the target index buffer
  114826. * @param indices defines the data to update
  114827. * @param offset defines the offset in the target index buffer where update should start
  114828. */
  114829. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114830. /**
  114831. * Updates the sample count of a render target texture
  114832. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114833. * @param texture defines the texture to update
  114834. * @param samples defines the sample count to set
  114835. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114836. */
  114837. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114838. /**
  114839. * Updates a depth texture Comparison Mode and Function.
  114840. * If the comparison Function is equal to 0, the mode will be set to none.
  114841. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114842. * @param texture The texture to set the comparison function for
  114843. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114844. */
  114845. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114846. /**
  114847. * Creates a webGL buffer to use with instanciation
  114848. * @param capacity defines the size of the buffer
  114849. * @returns the webGL buffer
  114850. */
  114851. createInstancesBuffer(capacity: number): DataBuffer;
  114852. /**
  114853. * Delete a webGL buffer used with instanciation
  114854. * @param buffer defines the webGL buffer to delete
  114855. */
  114856. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114857. private _clientWaitAsync;
  114858. /** @hidden */
  114859. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114860. dispose(): void;
  114861. private _disableTouchAction;
  114862. /**
  114863. * Display the loading screen
  114864. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114865. */
  114866. displayLoadingUI(): void;
  114867. /**
  114868. * Hide the loading screen
  114869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114870. */
  114871. hideLoadingUI(): void;
  114872. /**
  114873. * Gets the current loading screen object
  114874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114875. */
  114876. get loadingScreen(): ILoadingScreen;
  114877. /**
  114878. * Sets the current loading screen object
  114879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114880. */
  114881. set loadingScreen(loadingScreen: ILoadingScreen);
  114882. /**
  114883. * Sets the current loading screen text
  114884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114885. */
  114886. set loadingUIText(text: string);
  114887. /**
  114888. * Sets the current loading screen background color
  114889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114890. */
  114891. set loadingUIBackgroundColor(color: string);
  114892. /** Pointerlock and fullscreen */
  114893. /**
  114894. * Ask the browser to promote the current element to pointerlock mode
  114895. * @param element defines the DOM element to promote
  114896. */
  114897. static _RequestPointerlock(element: HTMLElement): void;
  114898. /**
  114899. * Asks the browser to exit pointerlock mode
  114900. */
  114901. static _ExitPointerlock(): void;
  114902. /**
  114903. * Ask the browser to promote the current element to fullscreen rendering mode
  114904. * @param element defines the DOM element to promote
  114905. */
  114906. static _RequestFullscreen(element: HTMLElement): void;
  114907. /**
  114908. * Asks the browser to exit fullscreen mode
  114909. */
  114910. static _ExitFullscreen(): void;
  114911. }
  114912. }
  114913. declare module BABYLON {
  114914. /**
  114915. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114916. * during the life time of the application.
  114917. */
  114918. export class EngineStore {
  114919. /** Gets the list of created engines */
  114920. static Instances: Engine[];
  114921. /** @hidden */
  114922. static _LastCreatedScene: Nullable<Scene>;
  114923. /**
  114924. * Gets the latest created engine
  114925. */
  114926. static get LastCreatedEngine(): Nullable<Engine>;
  114927. /**
  114928. * Gets the latest created scene
  114929. */
  114930. static get LastCreatedScene(): Nullable<Scene>;
  114931. /**
  114932. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114933. * @ignorenaming
  114934. */
  114935. static UseFallbackTexture: boolean;
  114936. /**
  114937. * Texture content used if a texture cannot loaded
  114938. * @ignorenaming
  114939. */
  114940. static FallbackTexture: string;
  114941. }
  114942. }
  114943. declare module BABYLON {
  114944. /**
  114945. * Helper class that provides a small promise polyfill
  114946. */
  114947. export class PromisePolyfill {
  114948. /**
  114949. * Static function used to check if the polyfill is required
  114950. * If this is the case then the function will inject the polyfill to window.Promise
  114951. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114952. */
  114953. static Apply(force?: boolean): void;
  114954. }
  114955. }
  114956. declare module BABYLON {
  114957. /**
  114958. * Interface for screenshot methods with describe argument called `size` as object with options
  114959. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114960. */
  114961. export interface IScreenshotSize {
  114962. /**
  114963. * number in pixels for canvas height
  114964. */
  114965. height?: number;
  114966. /**
  114967. * multiplier allowing render at a higher or lower resolution
  114968. * If value is defined then height and width will be ignored and taken from camera
  114969. */
  114970. precision?: number;
  114971. /**
  114972. * number in pixels for canvas width
  114973. */
  114974. width?: number;
  114975. }
  114976. }
  114977. declare module BABYLON {
  114978. interface IColor4Like {
  114979. r: float;
  114980. g: float;
  114981. b: float;
  114982. a: float;
  114983. }
  114984. /**
  114985. * Class containing a set of static utilities functions
  114986. */
  114987. export class Tools {
  114988. /**
  114989. * Gets or sets the base URL to use to load assets
  114990. */
  114991. static get BaseUrl(): string;
  114992. static set BaseUrl(value: string);
  114993. /**
  114994. * Enable/Disable Custom HTTP Request Headers globally.
  114995. * default = false
  114996. * @see CustomRequestHeaders
  114997. */
  114998. static UseCustomRequestHeaders: boolean;
  114999. /**
  115000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115001. * i.e. when loading files, where the server/service expects an Authorization header
  115002. */
  115003. static CustomRequestHeaders: {
  115004. [key: string]: string;
  115005. };
  115006. /**
  115007. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115008. */
  115009. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115010. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115011. /**
  115012. * Default behaviour for cors in the application.
  115013. * It can be a string if the expected behavior is identical in the entire app.
  115014. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115015. */
  115016. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115017. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115018. /**
  115019. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115020. * @ignorenaming
  115021. */
  115022. static get UseFallbackTexture(): boolean;
  115023. static set UseFallbackTexture(value: boolean);
  115024. /**
  115025. * Use this object to register external classes like custom textures or material
  115026. * to allow the laoders to instantiate them
  115027. */
  115028. static get RegisteredExternalClasses(): {
  115029. [key: string]: Object;
  115030. };
  115031. static set RegisteredExternalClasses(classes: {
  115032. [key: string]: Object;
  115033. });
  115034. /**
  115035. * Texture content used if a texture cannot loaded
  115036. * @ignorenaming
  115037. */
  115038. static get fallbackTexture(): string;
  115039. static set fallbackTexture(value: string);
  115040. /**
  115041. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115042. * @param u defines the coordinate on X axis
  115043. * @param v defines the coordinate on Y axis
  115044. * @param width defines the width of the source data
  115045. * @param height defines the height of the source data
  115046. * @param pixels defines the source byte array
  115047. * @param color defines the output color
  115048. */
  115049. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115050. /**
  115051. * Interpolates between a and b via alpha
  115052. * @param a The lower value (returned when alpha = 0)
  115053. * @param b The upper value (returned when alpha = 1)
  115054. * @param alpha The interpolation-factor
  115055. * @return The mixed value
  115056. */
  115057. static Mix(a: number, b: number, alpha: number): number;
  115058. /**
  115059. * Tries to instantiate a new object from a given class name
  115060. * @param className defines the class name to instantiate
  115061. * @returns the new object or null if the system was not able to do the instantiation
  115062. */
  115063. static Instantiate(className: string): any;
  115064. /**
  115065. * Provides a slice function that will work even on IE
  115066. * @param data defines the array to slice
  115067. * @param start defines the start of the data (optional)
  115068. * @param end defines the end of the data (optional)
  115069. * @returns the new sliced array
  115070. */
  115071. static Slice<T>(data: T, start?: number, end?: number): T;
  115072. /**
  115073. * Polyfill for setImmediate
  115074. * @param action defines the action to execute after the current execution block
  115075. */
  115076. static SetImmediate(action: () => void): void;
  115077. /**
  115078. * Function indicating if a number is an exponent of 2
  115079. * @param value defines the value to test
  115080. * @returns true if the value is an exponent of 2
  115081. */
  115082. static IsExponentOfTwo(value: number): boolean;
  115083. private static _tmpFloatArray;
  115084. /**
  115085. * Returns the nearest 32-bit single precision float representation of a Number
  115086. * @param value A Number. If the parameter is of a different type, it will get converted
  115087. * to a number or to NaN if it cannot be converted
  115088. * @returns number
  115089. */
  115090. static FloatRound(value: number): number;
  115091. /**
  115092. * Extracts the filename from a path
  115093. * @param path defines the path to use
  115094. * @returns the filename
  115095. */
  115096. static GetFilename(path: string): string;
  115097. /**
  115098. * Extracts the "folder" part of a path (everything before the filename).
  115099. * @param uri The URI to extract the info from
  115100. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115101. * @returns The "folder" part of the path
  115102. */
  115103. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115104. /**
  115105. * Extracts text content from a DOM element hierarchy
  115106. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115107. */
  115108. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115109. /**
  115110. * Convert an angle in radians to degrees
  115111. * @param angle defines the angle to convert
  115112. * @returns the angle in degrees
  115113. */
  115114. static ToDegrees(angle: number): number;
  115115. /**
  115116. * Convert an angle in degrees to radians
  115117. * @param angle defines the angle to convert
  115118. * @returns the angle in radians
  115119. */
  115120. static ToRadians(angle: number): number;
  115121. /**
  115122. * Returns an array if obj is not an array
  115123. * @param obj defines the object to evaluate as an array
  115124. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115125. * @returns either obj directly if obj is an array or a new array containing obj
  115126. */
  115127. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115128. /**
  115129. * Gets the pointer prefix to use
  115130. * @param engine defines the engine we are finding the prefix for
  115131. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115132. */
  115133. static GetPointerPrefix(engine: Engine): string;
  115134. /**
  115135. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115136. * @param url define the url we are trying
  115137. * @param element define the dom element where to configure the cors policy
  115138. */
  115139. static SetCorsBehavior(url: string | string[], element: {
  115140. crossOrigin: string | null;
  115141. }): void;
  115142. /**
  115143. * Removes unwanted characters from an url
  115144. * @param url defines the url to clean
  115145. * @returns the cleaned url
  115146. */
  115147. static CleanUrl(url: string): string;
  115148. /**
  115149. * Gets or sets a function used to pre-process url before using them to load assets
  115150. */
  115151. static get PreprocessUrl(): (url: string) => string;
  115152. static set PreprocessUrl(processor: (url: string) => string);
  115153. /**
  115154. * Loads an image as an HTMLImageElement.
  115155. * @param input url string, ArrayBuffer, or Blob to load
  115156. * @param onLoad callback called when the image successfully loads
  115157. * @param onError callback called when the image fails to load
  115158. * @param offlineProvider offline provider for caching
  115159. * @param mimeType optional mime type
  115160. * @returns the HTMLImageElement of the loaded image
  115161. */
  115162. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115163. /**
  115164. * Loads a file from a url
  115165. * @param url url string, ArrayBuffer, or Blob to load
  115166. * @param onSuccess callback called when the file successfully loads
  115167. * @param onProgress callback called while file is loading (if the server supports this mode)
  115168. * @param offlineProvider defines the offline provider for caching
  115169. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115170. * @param onError callback called when the file fails to load
  115171. * @returns a file request object
  115172. */
  115173. 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;
  115174. /**
  115175. * Loads a file from a url
  115176. * @param url the file url to load
  115177. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115178. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115179. */
  115180. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115181. /**
  115182. * Load a script (identified by an url). When the url returns, the
  115183. * content of this file is added into a new script element, attached to the DOM (body element)
  115184. * @param scriptUrl defines the url of the script to laod
  115185. * @param onSuccess defines the callback called when the script is loaded
  115186. * @param onError defines the callback to call if an error occurs
  115187. * @param scriptId defines the id of the script element
  115188. */
  115189. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115190. /**
  115191. * Load an asynchronous script (identified by an url). When the url returns, the
  115192. * content of this file is added into a new script element, attached to the DOM (body element)
  115193. * @param scriptUrl defines the url of the script to laod
  115194. * @param scriptId defines the id of the script element
  115195. * @returns a promise request object
  115196. */
  115197. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115198. /**
  115199. * Loads a file from a blob
  115200. * @param fileToLoad defines the blob to use
  115201. * @param callback defines the callback to call when data is loaded
  115202. * @param progressCallback defines the callback to call during loading process
  115203. * @returns a file request object
  115204. */
  115205. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115206. /**
  115207. * Reads a file from a File object
  115208. * @param file defines the file to load
  115209. * @param onSuccess defines the callback to call when data is loaded
  115210. * @param onProgress defines the callback to call during loading process
  115211. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115212. * @param onError defines the callback to call when an error occurs
  115213. * @returns a file request object
  115214. */
  115215. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115216. /**
  115217. * Creates a data url from a given string content
  115218. * @param content defines the content to convert
  115219. * @returns the new data url link
  115220. */
  115221. static FileAsURL(content: string): string;
  115222. /**
  115223. * Format the given number to a specific decimal format
  115224. * @param value defines the number to format
  115225. * @param decimals defines the number of decimals to use
  115226. * @returns the formatted string
  115227. */
  115228. static Format(value: number, decimals?: number): string;
  115229. /**
  115230. * Tries to copy an object by duplicating every property
  115231. * @param source defines the source object
  115232. * @param destination defines the target object
  115233. * @param doNotCopyList defines a list of properties to avoid
  115234. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115235. */
  115236. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115237. /**
  115238. * Gets a boolean indicating if the given object has no own property
  115239. * @param obj defines the object to test
  115240. * @returns true if object has no own property
  115241. */
  115242. static IsEmpty(obj: any): boolean;
  115243. /**
  115244. * Function used to register events at window level
  115245. * @param windowElement defines the Window object to use
  115246. * @param events defines the events to register
  115247. */
  115248. static RegisterTopRootEvents(windowElement: Window, events: {
  115249. name: string;
  115250. handler: Nullable<(e: FocusEvent) => any>;
  115251. }[]): void;
  115252. /**
  115253. * Function used to unregister events from window level
  115254. * @param windowElement defines the Window object to use
  115255. * @param events defines the events to unregister
  115256. */
  115257. static UnregisterTopRootEvents(windowElement: Window, events: {
  115258. name: string;
  115259. handler: Nullable<(e: FocusEvent) => any>;
  115260. }[]): void;
  115261. /**
  115262. * @ignore
  115263. */
  115264. static _ScreenshotCanvas: HTMLCanvasElement;
  115265. /**
  115266. * Dumps the current bound framebuffer
  115267. * @param width defines the rendering width
  115268. * @param height defines the rendering height
  115269. * @param engine defines the hosting engine
  115270. * @param successCallback defines the callback triggered once the data are available
  115271. * @param mimeType defines the mime type of the result
  115272. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115273. */
  115274. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115275. /**
  115276. * Converts the canvas data to blob.
  115277. * This acts as a polyfill for browsers not supporting the to blob function.
  115278. * @param canvas Defines the canvas to extract the data from
  115279. * @param successCallback Defines the callback triggered once the data are available
  115280. * @param mimeType Defines the mime type of the result
  115281. */
  115282. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115283. /**
  115284. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115285. * @param successCallback defines the callback triggered once the data are available
  115286. * @param mimeType defines the mime type of the result
  115287. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115288. */
  115289. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115290. /**
  115291. * Downloads a blob in the browser
  115292. * @param blob defines the blob to download
  115293. * @param fileName defines the name of the downloaded file
  115294. */
  115295. static Download(blob: Blob, fileName: string): void;
  115296. /**
  115297. * Captures a screenshot of the current rendering
  115298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115299. * @param engine defines the rendering engine
  115300. * @param camera defines the source camera
  115301. * @param size This parameter can be set to a single number or to an object with the
  115302. * following (optional) properties: precision, width, height. If a single number is passed,
  115303. * it will be used for both width and height. If an object is passed, the screenshot size
  115304. * will be derived from the parameters. The precision property is a multiplier allowing
  115305. * rendering at a higher or lower resolution
  115306. * @param successCallback defines the callback receives a single parameter which contains the
  115307. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115308. * src parameter of an <img> to display it
  115309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115310. * Check your browser for supported MIME types
  115311. */
  115312. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115313. /**
  115314. * Captures a screenshot of the current rendering
  115315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115316. * @param engine defines the rendering engine
  115317. * @param camera defines the source camera
  115318. * @param size This parameter can be set to a single number or to an object with the
  115319. * following (optional) properties: precision, width, height. If a single number is passed,
  115320. * it will be used for both width and height. If an object is passed, the screenshot size
  115321. * will be derived from the parameters. The precision property is a multiplier allowing
  115322. * rendering at a higher or lower resolution
  115323. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115324. * Check your browser for supported MIME types
  115325. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115326. * to the src parameter of an <img> to display it
  115327. */
  115328. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115329. /**
  115330. * Generates an image screenshot from the specified camera.
  115331. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115332. * @param engine The engine to use for rendering
  115333. * @param camera The camera to use for rendering
  115334. * @param size This parameter can be set to a single number or to an object with the
  115335. * following (optional) properties: precision, width, height. If a single number is passed,
  115336. * it will be used for both width and height. If an object is passed, the screenshot size
  115337. * will be derived from the parameters. The precision property is a multiplier allowing
  115338. * rendering at a higher or lower resolution
  115339. * @param successCallback The callback receives a single parameter which contains the
  115340. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115341. * src parameter of an <img> to display it
  115342. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115343. * Check your browser for supported MIME types
  115344. * @param samples Texture samples (default: 1)
  115345. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115346. * @param fileName A name for for the downloaded file.
  115347. */
  115348. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115349. /**
  115350. * Generates an image screenshot from the specified camera.
  115351. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115352. * @param engine The engine to use for rendering
  115353. * @param camera The camera to use for rendering
  115354. * @param size This parameter can be set to a single number or to an object with the
  115355. * following (optional) properties: precision, width, height. If a single number is passed,
  115356. * it will be used for both width and height. If an object is passed, the screenshot size
  115357. * will be derived from the parameters. The precision property is a multiplier allowing
  115358. * rendering at a higher or lower resolution
  115359. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115360. * Check your browser for supported MIME types
  115361. * @param samples Texture samples (default: 1)
  115362. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115363. * @param fileName A name for for the downloaded file.
  115364. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115365. * to the src parameter of an <img> to display it
  115366. */
  115367. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115368. /**
  115369. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115370. * Be aware Math.random() could cause collisions, but:
  115371. * "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"
  115372. * @returns a pseudo random id
  115373. */
  115374. static RandomId(): string;
  115375. /**
  115376. * Test if the given uri is a base64 string
  115377. * @param uri The uri to test
  115378. * @return True if the uri is a base64 string or false otherwise
  115379. */
  115380. static IsBase64(uri: string): boolean;
  115381. /**
  115382. * Decode the given base64 uri.
  115383. * @param uri The uri to decode
  115384. * @return The decoded base64 data.
  115385. */
  115386. static DecodeBase64(uri: string): ArrayBuffer;
  115387. /**
  115388. * Gets the absolute url.
  115389. * @param url the input url
  115390. * @return the absolute url
  115391. */
  115392. static GetAbsoluteUrl(url: string): string;
  115393. /**
  115394. * No log
  115395. */
  115396. static readonly NoneLogLevel: number;
  115397. /**
  115398. * Only message logs
  115399. */
  115400. static readonly MessageLogLevel: number;
  115401. /**
  115402. * Only warning logs
  115403. */
  115404. static readonly WarningLogLevel: number;
  115405. /**
  115406. * Only error logs
  115407. */
  115408. static readonly ErrorLogLevel: number;
  115409. /**
  115410. * All logs
  115411. */
  115412. static readonly AllLogLevel: number;
  115413. /**
  115414. * Gets a value indicating the number of loading errors
  115415. * @ignorenaming
  115416. */
  115417. static get errorsCount(): number;
  115418. /**
  115419. * Callback called when a new log is added
  115420. */
  115421. static OnNewCacheEntry: (entry: string) => void;
  115422. /**
  115423. * Log a message to the console
  115424. * @param message defines the message to log
  115425. */
  115426. static Log(message: string): void;
  115427. /**
  115428. * Write a warning message to the console
  115429. * @param message defines the message to log
  115430. */
  115431. static Warn(message: string): void;
  115432. /**
  115433. * Write an error message to the console
  115434. * @param message defines the message to log
  115435. */
  115436. static Error(message: string): void;
  115437. /**
  115438. * Gets current log cache (list of logs)
  115439. */
  115440. static get LogCache(): string;
  115441. /**
  115442. * Clears the log cache
  115443. */
  115444. static ClearLogCache(): void;
  115445. /**
  115446. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115447. */
  115448. static set LogLevels(level: number);
  115449. /**
  115450. * Checks if the window object exists
  115451. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115452. */
  115453. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115454. /**
  115455. * No performance log
  115456. */
  115457. static readonly PerformanceNoneLogLevel: number;
  115458. /**
  115459. * Use user marks to log performance
  115460. */
  115461. static readonly PerformanceUserMarkLogLevel: number;
  115462. /**
  115463. * Log performance to the console
  115464. */
  115465. static readonly PerformanceConsoleLogLevel: number;
  115466. private static _performance;
  115467. /**
  115468. * Sets the current performance log level
  115469. */
  115470. static set PerformanceLogLevel(level: number);
  115471. private static _StartPerformanceCounterDisabled;
  115472. private static _EndPerformanceCounterDisabled;
  115473. private static _StartUserMark;
  115474. private static _EndUserMark;
  115475. private static _StartPerformanceConsole;
  115476. private static _EndPerformanceConsole;
  115477. /**
  115478. * Starts a performance counter
  115479. */
  115480. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115481. /**
  115482. * Ends a specific performance coutner
  115483. */
  115484. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115485. /**
  115486. * Gets either window.performance.now() if supported or Date.now() else
  115487. */
  115488. static get Now(): number;
  115489. /**
  115490. * This method will return the name of the class used to create the instance of the given object.
  115491. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115492. * @param object the object to get the class name from
  115493. * @param isType defines if the object is actually a type
  115494. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115495. */
  115496. static GetClassName(object: any, isType?: boolean): string;
  115497. /**
  115498. * Gets the first element of an array satisfying a given predicate
  115499. * @param array defines the array to browse
  115500. * @param predicate defines the predicate to use
  115501. * @returns null if not found or the element
  115502. */
  115503. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115504. /**
  115505. * This method will return the name of the full name of the class, including its owning module (if any).
  115506. * 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).
  115507. * @param object the object to get the class name from
  115508. * @param isType defines if the object is actually a type
  115509. * @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.
  115510. * @ignorenaming
  115511. */
  115512. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115513. /**
  115514. * Returns a promise that resolves after the given amount of time.
  115515. * @param delay Number of milliseconds to delay
  115516. * @returns Promise that resolves after the given amount of time
  115517. */
  115518. static DelayAsync(delay: number): Promise<void>;
  115519. /**
  115520. * Utility function to detect if the current user agent is Safari
  115521. * @returns whether or not the current user agent is safari
  115522. */
  115523. static IsSafari(): boolean;
  115524. }
  115525. /**
  115526. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115527. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115528. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115529. * @param name The name of the class, case should be preserved
  115530. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115531. */
  115532. export function className(name: string, module?: string): (target: Object) => void;
  115533. /**
  115534. * An implementation of a loop for asynchronous functions.
  115535. */
  115536. export class AsyncLoop {
  115537. /**
  115538. * Defines the number of iterations for the loop
  115539. */
  115540. iterations: number;
  115541. /**
  115542. * Defines the current index of the loop.
  115543. */
  115544. index: number;
  115545. private _done;
  115546. private _fn;
  115547. private _successCallback;
  115548. /**
  115549. * Constructor.
  115550. * @param iterations the number of iterations.
  115551. * @param func the function to run each iteration
  115552. * @param successCallback the callback that will be called upon succesful execution
  115553. * @param offset starting offset.
  115554. */
  115555. constructor(
  115556. /**
  115557. * Defines the number of iterations for the loop
  115558. */
  115559. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115560. /**
  115561. * Execute the next iteration. Must be called after the last iteration was finished.
  115562. */
  115563. executeNext(): void;
  115564. /**
  115565. * Break the loop and run the success callback.
  115566. */
  115567. breakLoop(): void;
  115568. /**
  115569. * Create and run an async loop.
  115570. * @param iterations the number of iterations.
  115571. * @param fn the function to run each iteration
  115572. * @param successCallback the callback that will be called upon succesful execution
  115573. * @param offset starting offset.
  115574. * @returns the created async loop object
  115575. */
  115576. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115577. /**
  115578. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115579. * @param iterations total number of iterations
  115580. * @param syncedIterations number of synchronous iterations in each async iteration.
  115581. * @param fn the function to call each iteration.
  115582. * @param callback a success call back that will be called when iterating stops.
  115583. * @param breakFunction a break condition (optional)
  115584. * @param timeout timeout settings for the setTimeout function. default - 0.
  115585. * @returns the created async loop object
  115586. */
  115587. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115593. * The underlying implementation relies on an associative array to ensure the best performances.
  115594. * The value can be anything including 'null' but except 'undefined'
  115595. */
  115596. export class StringDictionary<T> {
  115597. /**
  115598. * This will clear this dictionary and copy the content from the 'source' one.
  115599. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115600. * @param source the dictionary to take the content from and copy to this dictionary
  115601. */
  115602. copyFrom(source: StringDictionary<T>): void;
  115603. /**
  115604. * Get a value based from its key
  115605. * @param key the given key to get the matching value from
  115606. * @return the value if found, otherwise undefined is returned
  115607. */
  115608. get(key: string): T | undefined;
  115609. /**
  115610. * Get a value from its key or add it if it doesn't exist.
  115611. * This method will ensure you that a given key/data will be present in the dictionary.
  115612. * @param key the given key to get the matching value from
  115613. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115614. * The factory will only be invoked if there's no data for the given key.
  115615. * @return the value corresponding to the key.
  115616. */
  115617. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115618. /**
  115619. * Get a value from its key if present in the dictionary otherwise add it
  115620. * @param key the key to get the value from
  115621. * @param val if there's no such key/value pair in the dictionary add it with this value
  115622. * @return the value corresponding to the key
  115623. */
  115624. getOrAdd(key: string, val: T): T;
  115625. /**
  115626. * Check if there's a given key in the dictionary
  115627. * @param key the key to check for
  115628. * @return true if the key is present, false otherwise
  115629. */
  115630. contains(key: string): boolean;
  115631. /**
  115632. * Add a new key and its corresponding value
  115633. * @param key the key to add
  115634. * @param value the value corresponding to the key
  115635. * @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
  115636. */
  115637. add(key: string, value: T): boolean;
  115638. /**
  115639. * Update a specific value associated to a key
  115640. * @param key defines the key to use
  115641. * @param value defines the value to store
  115642. * @returns true if the value was updated (or false if the key was not found)
  115643. */
  115644. set(key: string, value: T): boolean;
  115645. /**
  115646. * Get the element of the given key and remove it from the dictionary
  115647. * @param key defines the key to search
  115648. * @returns the value associated with the key or null if not found
  115649. */
  115650. getAndRemove(key: string): Nullable<T>;
  115651. /**
  115652. * Remove a key/value from the dictionary.
  115653. * @param key the key to remove
  115654. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115655. */
  115656. remove(key: string): boolean;
  115657. /**
  115658. * Clear the whole content of the dictionary
  115659. */
  115660. clear(): void;
  115661. /**
  115662. * Gets the current count
  115663. */
  115664. get count(): number;
  115665. /**
  115666. * Execute a callback on each key/val of the dictionary.
  115667. * Note that you can remove any element in this dictionary in the callback implementation
  115668. * @param callback the callback to execute on a given key/value pair
  115669. */
  115670. forEach(callback: (key: string, val: T) => void): void;
  115671. /**
  115672. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115673. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115674. * Note that you can remove any element in this dictionary in the callback implementation
  115675. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115676. * @returns the first item
  115677. */
  115678. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115679. private _count;
  115680. private _data;
  115681. }
  115682. }
  115683. declare module BABYLON {
  115684. /** @hidden */
  115685. export interface ICollisionCoordinator {
  115686. createCollider(): Collider;
  115687. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115688. init(scene: Scene): void;
  115689. }
  115690. /** @hidden */
  115691. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115692. private _scene;
  115693. private _scaledPosition;
  115694. private _scaledVelocity;
  115695. private _finalPosition;
  115696. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115697. createCollider(): Collider;
  115698. init(scene: Scene): void;
  115699. private _collideWithWorld;
  115700. }
  115701. }
  115702. declare module BABYLON {
  115703. /**
  115704. * Class used to manage all inputs for the scene.
  115705. */
  115706. export class InputManager {
  115707. /** The distance in pixel that you have to move to prevent some events */
  115708. static DragMovementThreshold: number;
  115709. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115710. static LongPressDelay: number;
  115711. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115712. static DoubleClickDelay: number;
  115713. /** If you need to check double click without raising a single click at first click, enable this flag */
  115714. static ExclusiveDoubleClickMode: boolean;
  115715. private _wheelEventName;
  115716. private _onPointerMove;
  115717. private _onPointerDown;
  115718. private _onPointerUp;
  115719. private _initClickEvent;
  115720. private _initActionManager;
  115721. private _delayedSimpleClick;
  115722. private _delayedSimpleClickTimeout;
  115723. private _previousDelayedSimpleClickTimeout;
  115724. private _meshPickProceed;
  115725. private _previousButtonPressed;
  115726. private _currentPickResult;
  115727. private _previousPickResult;
  115728. private _totalPointersPressed;
  115729. private _doubleClickOccured;
  115730. private _pointerOverMesh;
  115731. private _pickedDownMesh;
  115732. private _pickedUpMesh;
  115733. private _pointerX;
  115734. private _pointerY;
  115735. private _unTranslatedPointerX;
  115736. private _unTranslatedPointerY;
  115737. private _startingPointerPosition;
  115738. private _previousStartingPointerPosition;
  115739. private _startingPointerTime;
  115740. private _previousStartingPointerTime;
  115741. private _pointerCaptures;
  115742. private _onKeyDown;
  115743. private _onKeyUp;
  115744. private _onCanvasFocusObserver;
  115745. private _onCanvasBlurObserver;
  115746. private _scene;
  115747. /**
  115748. * Creates a new InputManager
  115749. * @param scene defines the hosting scene
  115750. */
  115751. constructor(scene: Scene);
  115752. /**
  115753. * Gets the mesh that is currently under the pointer
  115754. */
  115755. get meshUnderPointer(): Nullable<AbstractMesh>;
  115756. /**
  115757. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115758. */
  115759. get unTranslatedPointer(): Vector2;
  115760. /**
  115761. * Gets or sets the current on-screen X position of the pointer
  115762. */
  115763. get pointerX(): number;
  115764. set pointerX(value: number);
  115765. /**
  115766. * Gets or sets the current on-screen Y position of the pointer
  115767. */
  115768. get pointerY(): number;
  115769. set pointerY(value: number);
  115770. private _updatePointerPosition;
  115771. private _processPointerMove;
  115772. private _setRayOnPointerInfo;
  115773. private _checkPrePointerObservable;
  115774. /**
  115775. * Use this method to simulate a pointer move on a mesh
  115776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115779. */
  115780. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115781. /**
  115782. * Use this method to simulate a pointer down on a mesh
  115783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115786. */
  115787. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115788. private _processPointerDown;
  115789. /** @hidden */
  115790. _isPointerSwiping(): boolean;
  115791. /**
  115792. * Use this method to simulate a pointer up on a mesh
  115793. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115794. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115795. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115796. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115797. */
  115798. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115799. private _processPointerUp;
  115800. /**
  115801. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115802. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115803. * @returns true if the pointer was captured
  115804. */
  115805. isPointerCaptured(pointerId?: number): boolean;
  115806. /**
  115807. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115808. * @param attachUp defines if you want to attach events to pointerup
  115809. * @param attachDown defines if you want to attach events to pointerdown
  115810. * @param attachMove defines if you want to attach events to pointermove
  115811. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115812. */
  115813. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115814. /**
  115815. * Detaches all event handlers
  115816. */
  115817. detachControl(): void;
  115818. /**
  115819. * Force the value of meshUnderPointer
  115820. * @param mesh defines the mesh to use
  115821. */
  115822. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115823. /**
  115824. * Gets the mesh under the pointer
  115825. * @returns a Mesh or null if no mesh is under the pointer
  115826. */
  115827. getPointerOverMesh(): Nullable<AbstractMesh>;
  115828. }
  115829. }
  115830. declare module BABYLON {
  115831. /**
  115832. * This class defines the direct association between an animation and a target
  115833. */
  115834. export class TargetedAnimation {
  115835. /**
  115836. * Animation to perform
  115837. */
  115838. animation: Animation;
  115839. /**
  115840. * Target to animate
  115841. */
  115842. target: any;
  115843. /**
  115844. * Returns the string "TargetedAnimation"
  115845. * @returns "TargetedAnimation"
  115846. */
  115847. getClassName(): string;
  115848. /**
  115849. * Serialize the object
  115850. * @returns the JSON object representing the current entity
  115851. */
  115852. serialize(): any;
  115853. }
  115854. /**
  115855. * Use this class to create coordinated animations on multiple targets
  115856. */
  115857. export class AnimationGroup implements IDisposable {
  115858. /** The name of the animation group */
  115859. name: string;
  115860. private _scene;
  115861. private _targetedAnimations;
  115862. private _animatables;
  115863. private _from;
  115864. private _to;
  115865. private _isStarted;
  115866. private _isPaused;
  115867. private _speedRatio;
  115868. private _loopAnimation;
  115869. private _isAdditive;
  115870. /**
  115871. * Gets or sets the unique id of the node
  115872. */
  115873. uniqueId: number;
  115874. /**
  115875. * This observable will notify when one animation have ended
  115876. */
  115877. onAnimationEndObservable: Observable<TargetedAnimation>;
  115878. /**
  115879. * Observer raised when one animation loops
  115880. */
  115881. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115882. /**
  115883. * Observer raised when all animations have looped
  115884. */
  115885. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115886. /**
  115887. * This observable will notify when all animations have ended.
  115888. */
  115889. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115890. /**
  115891. * This observable will notify when all animations have paused.
  115892. */
  115893. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115894. /**
  115895. * This observable will notify when all animations are playing.
  115896. */
  115897. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115898. /**
  115899. * Gets the first frame
  115900. */
  115901. get from(): number;
  115902. /**
  115903. * Gets the last frame
  115904. */
  115905. get to(): number;
  115906. /**
  115907. * Define if the animations are started
  115908. */
  115909. get isStarted(): boolean;
  115910. /**
  115911. * Gets a value indicating that the current group is playing
  115912. */
  115913. get isPlaying(): boolean;
  115914. /**
  115915. * Gets or sets the speed ratio to use for all animations
  115916. */
  115917. get speedRatio(): number;
  115918. /**
  115919. * Gets or sets the speed ratio to use for all animations
  115920. */
  115921. set speedRatio(value: number);
  115922. /**
  115923. * Gets or sets if all animations should loop or not
  115924. */
  115925. get loopAnimation(): boolean;
  115926. set loopAnimation(value: boolean);
  115927. /**
  115928. * Gets or sets if all animations should be evaluated additively
  115929. */
  115930. get isAdditive(): boolean;
  115931. set isAdditive(value: boolean);
  115932. /**
  115933. * Gets the targeted animations for this animation group
  115934. */
  115935. get targetedAnimations(): Array<TargetedAnimation>;
  115936. /**
  115937. * returning the list of animatables controlled by this animation group.
  115938. */
  115939. get animatables(): Array<Animatable>;
  115940. /**
  115941. * Gets the list of target animations
  115942. */
  115943. get children(): TargetedAnimation[];
  115944. /**
  115945. * Instantiates a new Animation Group.
  115946. * This helps managing several animations at once.
  115947. * @see http://doc.babylonjs.com/how_to/group
  115948. * @param name Defines the name of the group
  115949. * @param scene Defines the scene the group belongs to
  115950. */
  115951. constructor(
  115952. /** The name of the animation group */
  115953. name: string, scene?: Nullable<Scene>);
  115954. /**
  115955. * Add an animation (with its target) in the group
  115956. * @param animation defines the animation we want to add
  115957. * @param target defines the target of the animation
  115958. * @returns the TargetedAnimation object
  115959. */
  115960. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115961. /**
  115962. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115963. * It can add constant keys at begin or end
  115964. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115965. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115966. * @returns the animation group
  115967. */
  115968. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115969. private _animationLoopCount;
  115970. private _animationLoopFlags;
  115971. private _processLoop;
  115972. /**
  115973. * Start all animations on given targets
  115974. * @param loop defines if animations must loop
  115975. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115976. * @param from defines the from key (optional)
  115977. * @param to defines the to key (optional)
  115978. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115979. * @returns the current animation group
  115980. */
  115981. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115982. /**
  115983. * Pause all animations
  115984. * @returns the animation group
  115985. */
  115986. pause(): AnimationGroup;
  115987. /**
  115988. * Play all animations to initial state
  115989. * This function will start() the animations if they were not started or will restart() them if they were paused
  115990. * @param loop defines if animations must loop
  115991. * @returns the animation group
  115992. */
  115993. play(loop?: boolean): AnimationGroup;
  115994. /**
  115995. * Reset all animations to initial state
  115996. * @returns the animation group
  115997. */
  115998. reset(): AnimationGroup;
  115999. /**
  116000. * Restart animations from key 0
  116001. * @returns the animation group
  116002. */
  116003. restart(): AnimationGroup;
  116004. /**
  116005. * Stop all animations
  116006. * @returns the animation group
  116007. */
  116008. stop(): AnimationGroup;
  116009. /**
  116010. * Set animation weight for all animatables
  116011. * @param weight defines the weight to use
  116012. * @return the animationGroup
  116013. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116014. */
  116015. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116016. /**
  116017. * Synchronize and normalize all animatables with a source animatable
  116018. * @param root defines the root animatable to synchronize with
  116019. * @return the animationGroup
  116020. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116021. */
  116022. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116023. /**
  116024. * Goes to a specific frame in this animation group
  116025. * @param frame the frame number to go to
  116026. * @return the animationGroup
  116027. */
  116028. goToFrame(frame: number): AnimationGroup;
  116029. /**
  116030. * Dispose all associated resources
  116031. */
  116032. dispose(): void;
  116033. private _checkAnimationGroupEnded;
  116034. /**
  116035. * Clone the current animation group and returns a copy
  116036. * @param newName defines the name of the new group
  116037. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116038. * @returns the new aniamtion group
  116039. */
  116040. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116041. /**
  116042. * Serializes the animationGroup to an object
  116043. * @returns Serialized object
  116044. */
  116045. serialize(): any;
  116046. /**
  116047. * Returns a new AnimationGroup object parsed from the source provided.
  116048. * @param parsedAnimationGroup defines the source
  116049. * @param scene defines the scene that will receive the animationGroup
  116050. * @returns a new AnimationGroup
  116051. */
  116052. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116053. /**
  116054. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116055. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116056. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116057. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116058. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116059. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116060. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116061. */
  116062. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116063. /**
  116064. * Returns the string "AnimationGroup"
  116065. * @returns "AnimationGroup"
  116066. */
  116067. getClassName(): string;
  116068. /**
  116069. * Creates a detailled string about the object
  116070. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116071. * @returns a string representing the object
  116072. */
  116073. toString(fullDetails?: boolean): string;
  116074. }
  116075. }
  116076. declare module BABYLON {
  116077. /**
  116078. * Define an interface for all classes that will hold resources
  116079. */
  116080. export interface IDisposable {
  116081. /**
  116082. * Releases all held resources
  116083. */
  116084. dispose(): void;
  116085. }
  116086. /** Interface defining initialization parameters for Scene class */
  116087. export interface SceneOptions {
  116088. /**
  116089. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116090. * It will improve performance when the number of geometries becomes important.
  116091. */
  116092. useGeometryUniqueIdsMap?: boolean;
  116093. /**
  116094. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116095. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116096. */
  116097. useMaterialMeshMap?: boolean;
  116098. /**
  116099. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116100. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116101. */
  116102. useClonedMeshMap?: boolean;
  116103. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116104. virtual?: boolean;
  116105. }
  116106. /**
  116107. * Represents a scene to be rendered by the engine.
  116108. * @see http://doc.babylonjs.com/features/scene
  116109. */
  116110. export class Scene extends AbstractScene implements IAnimatable {
  116111. /** The fog is deactivated */
  116112. static readonly FOGMODE_NONE: number;
  116113. /** The fog density is following an exponential function */
  116114. static readonly FOGMODE_EXP: number;
  116115. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116116. static readonly FOGMODE_EXP2: number;
  116117. /** The fog density is following a linear function. */
  116118. static readonly FOGMODE_LINEAR: number;
  116119. /**
  116120. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116122. */
  116123. static MinDeltaTime: number;
  116124. /**
  116125. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116126. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116127. */
  116128. static MaxDeltaTime: number;
  116129. /**
  116130. * Factory used to create the default material.
  116131. * @param name The name of the material to create
  116132. * @param scene The scene to create the material for
  116133. * @returns The default material
  116134. */
  116135. static DefaultMaterialFactory(scene: Scene): Material;
  116136. /**
  116137. * Factory used to create the a collision coordinator.
  116138. * @returns The collision coordinator
  116139. */
  116140. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116141. /** @hidden */
  116142. _inputManager: InputManager;
  116143. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116144. cameraToUseForPointers: Nullable<Camera>;
  116145. /** @hidden */
  116146. readonly _isScene: boolean;
  116147. /** @hidden */
  116148. _blockEntityCollection: boolean;
  116149. /**
  116150. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116151. */
  116152. autoClear: boolean;
  116153. /**
  116154. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116155. */
  116156. autoClearDepthAndStencil: boolean;
  116157. /**
  116158. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116159. */
  116160. clearColor: Color4;
  116161. /**
  116162. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116163. */
  116164. ambientColor: Color3;
  116165. /**
  116166. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116167. * It should only be one of the following (if not the default embedded one):
  116168. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116169. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116170. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116171. * The material properties need to be setup according to the type of texture in use.
  116172. */
  116173. environmentBRDFTexture: BaseTexture;
  116174. /** @hidden */
  116175. protected _environmentTexture: Nullable<BaseTexture>;
  116176. /**
  116177. * Texture used in all pbr material as the reflection texture.
  116178. * As in the majority of the scene they are the same (exception for multi room and so on),
  116179. * this is easier to reference from here than from all the materials.
  116180. */
  116181. get environmentTexture(): Nullable<BaseTexture>;
  116182. /**
  116183. * Texture used in all pbr material as the reflection texture.
  116184. * As in the majority of the scene they are the same (exception for multi room and so on),
  116185. * this is easier to set here than in all the materials.
  116186. */
  116187. set environmentTexture(value: Nullable<BaseTexture>);
  116188. /** @hidden */
  116189. protected _environmentIntensity: number;
  116190. /**
  116191. * Intensity of the environment in all pbr material.
  116192. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116193. * As in the majority of the scene they are the same (exception for multi room and so on),
  116194. * this is easier to reference from here than from all the materials.
  116195. */
  116196. get environmentIntensity(): number;
  116197. /**
  116198. * Intensity of the environment in all pbr material.
  116199. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116200. * As in the majority of the scene they are the same (exception for multi room and so on),
  116201. * this is easier to set here than in all the materials.
  116202. */
  116203. set environmentIntensity(value: number);
  116204. /** @hidden */
  116205. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116206. /**
  116207. * Default image processing configuration used either in the rendering
  116208. * Forward main pass or through the imageProcessingPostProcess if present.
  116209. * As in the majority of the scene they are the same (exception for multi camera),
  116210. * this is easier to reference from here than from all the materials and post process.
  116211. *
  116212. * No setter as we it is a shared configuration, you can set the values instead.
  116213. */
  116214. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116215. private _forceWireframe;
  116216. /**
  116217. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116218. */
  116219. set forceWireframe(value: boolean);
  116220. get forceWireframe(): boolean;
  116221. private _skipFrustumClipping;
  116222. /**
  116223. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116224. */
  116225. set skipFrustumClipping(value: boolean);
  116226. get skipFrustumClipping(): boolean;
  116227. private _forcePointsCloud;
  116228. /**
  116229. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116230. */
  116231. set forcePointsCloud(value: boolean);
  116232. get forcePointsCloud(): boolean;
  116233. /**
  116234. * Gets or sets the active clipplane 1
  116235. */
  116236. clipPlane: Nullable<Plane>;
  116237. /**
  116238. * Gets or sets the active clipplane 2
  116239. */
  116240. clipPlane2: Nullable<Plane>;
  116241. /**
  116242. * Gets or sets the active clipplane 3
  116243. */
  116244. clipPlane3: Nullable<Plane>;
  116245. /**
  116246. * Gets or sets the active clipplane 4
  116247. */
  116248. clipPlane4: Nullable<Plane>;
  116249. /**
  116250. * Gets or sets the active clipplane 5
  116251. */
  116252. clipPlane5: Nullable<Plane>;
  116253. /**
  116254. * Gets or sets the active clipplane 6
  116255. */
  116256. clipPlane6: Nullable<Plane>;
  116257. /**
  116258. * Gets or sets a boolean indicating if animations are enabled
  116259. */
  116260. animationsEnabled: boolean;
  116261. private _animationPropertiesOverride;
  116262. /**
  116263. * Gets or sets the animation properties override
  116264. */
  116265. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116266. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116267. /**
  116268. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116269. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116270. */
  116271. useConstantAnimationDeltaTime: boolean;
  116272. /**
  116273. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116274. * Please note that it requires to run a ray cast through the scene on every frame
  116275. */
  116276. constantlyUpdateMeshUnderPointer: boolean;
  116277. /**
  116278. * Defines the HTML cursor to use when hovering over interactive elements
  116279. */
  116280. hoverCursor: string;
  116281. /**
  116282. * Defines the HTML default cursor to use (empty by default)
  116283. */
  116284. defaultCursor: string;
  116285. /**
  116286. * Defines whether cursors are handled by the scene.
  116287. */
  116288. doNotHandleCursors: boolean;
  116289. /**
  116290. * This is used to call preventDefault() on pointer down
  116291. * in order to block unwanted artifacts like system double clicks
  116292. */
  116293. preventDefaultOnPointerDown: boolean;
  116294. /**
  116295. * This is used to call preventDefault() on pointer up
  116296. * in order to block unwanted artifacts like system double clicks
  116297. */
  116298. preventDefaultOnPointerUp: boolean;
  116299. /**
  116300. * Gets or sets user defined metadata
  116301. */
  116302. metadata: any;
  116303. /**
  116304. * For internal use only. Please do not use.
  116305. */
  116306. reservedDataStore: any;
  116307. /**
  116308. * Gets the name of the plugin used to load this scene (null by default)
  116309. */
  116310. loadingPluginName: string;
  116311. /**
  116312. * Use this array to add regular expressions used to disable offline support for specific urls
  116313. */
  116314. disableOfflineSupportExceptionRules: RegExp[];
  116315. /**
  116316. * An event triggered when the scene is disposed.
  116317. */
  116318. onDisposeObservable: Observable<Scene>;
  116319. private _onDisposeObserver;
  116320. /** Sets a function to be executed when this scene is disposed. */
  116321. set onDispose(callback: () => void);
  116322. /**
  116323. * An event triggered before rendering the scene (right after animations and physics)
  116324. */
  116325. onBeforeRenderObservable: Observable<Scene>;
  116326. private _onBeforeRenderObserver;
  116327. /** Sets a function to be executed before rendering this scene */
  116328. set beforeRender(callback: Nullable<() => void>);
  116329. /**
  116330. * An event triggered after rendering the scene
  116331. */
  116332. onAfterRenderObservable: Observable<Scene>;
  116333. /**
  116334. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116335. */
  116336. onAfterRenderCameraObservable: Observable<Camera>;
  116337. private _onAfterRenderObserver;
  116338. /** Sets a function to be executed after rendering this scene */
  116339. set afterRender(callback: Nullable<() => void>);
  116340. /**
  116341. * An event triggered before animating the scene
  116342. */
  116343. onBeforeAnimationsObservable: Observable<Scene>;
  116344. /**
  116345. * An event triggered after animations processing
  116346. */
  116347. onAfterAnimationsObservable: Observable<Scene>;
  116348. /**
  116349. * An event triggered before draw calls are ready to be sent
  116350. */
  116351. onBeforeDrawPhaseObservable: Observable<Scene>;
  116352. /**
  116353. * An event triggered after draw calls have been sent
  116354. */
  116355. onAfterDrawPhaseObservable: Observable<Scene>;
  116356. /**
  116357. * An event triggered when the scene is ready
  116358. */
  116359. onReadyObservable: Observable<Scene>;
  116360. /**
  116361. * An event triggered before rendering a camera
  116362. */
  116363. onBeforeCameraRenderObservable: Observable<Camera>;
  116364. private _onBeforeCameraRenderObserver;
  116365. /** Sets a function to be executed before rendering a camera*/
  116366. set beforeCameraRender(callback: () => void);
  116367. /**
  116368. * An event triggered after rendering a camera
  116369. */
  116370. onAfterCameraRenderObservable: Observable<Camera>;
  116371. private _onAfterCameraRenderObserver;
  116372. /** Sets a function to be executed after rendering a camera*/
  116373. set afterCameraRender(callback: () => void);
  116374. /**
  116375. * An event triggered when active meshes evaluation is about to start
  116376. */
  116377. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116378. /**
  116379. * An event triggered when active meshes evaluation is done
  116380. */
  116381. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116382. /**
  116383. * An event triggered when particles rendering is about to start
  116384. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116385. */
  116386. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116387. /**
  116388. * An event triggered when particles rendering is done
  116389. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116390. */
  116391. onAfterParticlesRenderingObservable: Observable<Scene>;
  116392. /**
  116393. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116394. */
  116395. onDataLoadedObservable: Observable<Scene>;
  116396. /**
  116397. * An event triggered when a camera is created
  116398. */
  116399. onNewCameraAddedObservable: Observable<Camera>;
  116400. /**
  116401. * An event triggered when a camera is removed
  116402. */
  116403. onCameraRemovedObservable: Observable<Camera>;
  116404. /**
  116405. * An event triggered when a light is created
  116406. */
  116407. onNewLightAddedObservable: Observable<Light>;
  116408. /**
  116409. * An event triggered when a light is removed
  116410. */
  116411. onLightRemovedObservable: Observable<Light>;
  116412. /**
  116413. * An event triggered when a geometry is created
  116414. */
  116415. onNewGeometryAddedObservable: Observable<Geometry>;
  116416. /**
  116417. * An event triggered when a geometry is removed
  116418. */
  116419. onGeometryRemovedObservable: Observable<Geometry>;
  116420. /**
  116421. * An event triggered when a transform node is created
  116422. */
  116423. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116424. /**
  116425. * An event triggered when a transform node is removed
  116426. */
  116427. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116428. /**
  116429. * An event triggered when a mesh is created
  116430. */
  116431. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116432. /**
  116433. * An event triggered when a mesh is removed
  116434. */
  116435. onMeshRemovedObservable: Observable<AbstractMesh>;
  116436. /**
  116437. * An event triggered when a skeleton is created
  116438. */
  116439. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116440. /**
  116441. * An event triggered when a skeleton is removed
  116442. */
  116443. onSkeletonRemovedObservable: Observable<Skeleton>;
  116444. /**
  116445. * An event triggered when a material is created
  116446. */
  116447. onNewMaterialAddedObservable: Observable<Material>;
  116448. /**
  116449. * An event triggered when a material is removed
  116450. */
  116451. onMaterialRemovedObservable: Observable<Material>;
  116452. /**
  116453. * An event triggered when a texture is created
  116454. */
  116455. onNewTextureAddedObservable: Observable<BaseTexture>;
  116456. /**
  116457. * An event triggered when a texture is removed
  116458. */
  116459. onTextureRemovedObservable: Observable<BaseTexture>;
  116460. /**
  116461. * An event triggered when render targets are about to be rendered
  116462. * Can happen multiple times per frame.
  116463. */
  116464. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116465. /**
  116466. * An event triggered when render targets were rendered.
  116467. * Can happen multiple times per frame.
  116468. */
  116469. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116470. /**
  116471. * An event triggered before calculating deterministic simulation step
  116472. */
  116473. onBeforeStepObservable: Observable<Scene>;
  116474. /**
  116475. * An event triggered after calculating deterministic simulation step
  116476. */
  116477. onAfterStepObservable: Observable<Scene>;
  116478. /**
  116479. * An event triggered when the activeCamera property is updated
  116480. */
  116481. onActiveCameraChanged: Observable<Scene>;
  116482. /**
  116483. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116484. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116485. * 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)
  116486. */
  116487. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116488. /**
  116489. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116490. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116491. * 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)
  116492. */
  116493. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116494. /**
  116495. * This Observable will when a mesh has been imported into the scene.
  116496. */
  116497. onMeshImportedObservable: Observable<AbstractMesh>;
  116498. /**
  116499. * This Observable will when an animation file has been imported into the scene.
  116500. */
  116501. onAnimationFileImportedObservable: Observable<Scene>;
  116502. /**
  116503. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116504. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116505. */
  116506. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116507. /** @hidden */
  116508. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116509. /**
  116510. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116511. */
  116512. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116513. /**
  116514. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116515. */
  116516. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116517. /**
  116518. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116519. */
  116520. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116521. /** Callback called when a pointer move is detected */
  116522. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116523. /** Callback called when a pointer down is detected */
  116524. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116525. /** Callback called when a pointer up is detected */
  116526. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116527. /** Callback called when a pointer pick is detected */
  116528. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116529. /**
  116530. * 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).
  116531. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116532. */
  116533. onPrePointerObservable: Observable<PointerInfoPre>;
  116534. /**
  116535. * Observable event triggered each time an input event is received from the rendering canvas
  116536. */
  116537. onPointerObservable: Observable<PointerInfo>;
  116538. /**
  116539. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116540. */
  116541. get unTranslatedPointer(): Vector2;
  116542. /**
  116543. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116544. */
  116545. static get DragMovementThreshold(): number;
  116546. static set DragMovementThreshold(value: number);
  116547. /**
  116548. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116549. */
  116550. static get LongPressDelay(): number;
  116551. static set LongPressDelay(value: number);
  116552. /**
  116553. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116554. */
  116555. static get DoubleClickDelay(): number;
  116556. static set DoubleClickDelay(value: number);
  116557. /** If you need to check double click without raising a single click at first click, enable this flag */
  116558. static get ExclusiveDoubleClickMode(): boolean;
  116559. static set ExclusiveDoubleClickMode(value: boolean);
  116560. /** @hidden */
  116561. _mirroredCameraPosition: Nullable<Vector3>;
  116562. /**
  116563. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116564. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116565. */
  116566. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116567. /**
  116568. * Observable event triggered each time an keyboard event is received from the hosting window
  116569. */
  116570. onKeyboardObservable: Observable<KeyboardInfo>;
  116571. private _useRightHandedSystem;
  116572. /**
  116573. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116574. */
  116575. set useRightHandedSystem(value: boolean);
  116576. get useRightHandedSystem(): boolean;
  116577. private _timeAccumulator;
  116578. private _currentStepId;
  116579. private _currentInternalStep;
  116580. /**
  116581. * Sets the step Id used by deterministic lock step
  116582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116583. * @param newStepId defines the step Id
  116584. */
  116585. setStepId(newStepId: number): void;
  116586. /**
  116587. * Gets the step Id used by deterministic lock step
  116588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116589. * @returns the step Id
  116590. */
  116591. getStepId(): number;
  116592. /**
  116593. * Gets the internal step used by deterministic lock step
  116594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116595. * @returns the internal step
  116596. */
  116597. getInternalStep(): number;
  116598. private _fogEnabled;
  116599. /**
  116600. * Gets or sets a boolean indicating if fog is enabled on this scene
  116601. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116602. * (Default is true)
  116603. */
  116604. set fogEnabled(value: boolean);
  116605. get fogEnabled(): boolean;
  116606. private _fogMode;
  116607. /**
  116608. * Gets or sets the fog mode to use
  116609. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116610. * | mode | value |
  116611. * | --- | --- |
  116612. * | FOGMODE_NONE | 0 |
  116613. * | FOGMODE_EXP | 1 |
  116614. * | FOGMODE_EXP2 | 2 |
  116615. * | FOGMODE_LINEAR | 3 |
  116616. */
  116617. set fogMode(value: number);
  116618. get fogMode(): number;
  116619. /**
  116620. * Gets or sets the fog color to use
  116621. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116622. * (Default is Color3(0.2, 0.2, 0.3))
  116623. */
  116624. fogColor: Color3;
  116625. /**
  116626. * Gets or sets the fog density to use
  116627. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116628. * (Default is 0.1)
  116629. */
  116630. fogDensity: number;
  116631. /**
  116632. * Gets or sets the fog start distance to use
  116633. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116634. * (Default is 0)
  116635. */
  116636. fogStart: number;
  116637. /**
  116638. * Gets or sets the fog end distance to use
  116639. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116640. * (Default is 1000)
  116641. */
  116642. fogEnd: number;
  116643. private _shadowsEnabled;
  116644. /**
  116645. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116646. */
  116647. set shadowsEnabled(value: boolean);
  116648. get shadowsEnabled(): boolean;
  116649. private _lightsEnabled;
  116650. /**
  116651. * Gets or sets a boolean indicating if lights are enabled on this scene
  116652. */
  116653. set lightsEnabled(value: boolean);
  116654. get lightsEnabled(): boolean;
  116655. /** All of the active cameras added to this scene. */
  116656. activeCameras: Camera[];
  116657. /** @hidden */
  116658. _activeCamera: Nullable<Camera>;
  116659. /** Gets or sets the current active camera */
  116660. get activeCamera(): Nullable<Camera>;
  116661. set activeCamera(value: Nullable<Camera>);
  116662. private _defaultMaterial;
  116663. /** The default material used on meshes when no material is affected */
  116664. get defaultMaterial(): Material;
  116665. /** The default material used on meshes when no material is affected */
  116666. set defaultMaterial(value: Material);
  116667. private _texturesEnabled;
  116668. /**
  116669. * Gets or sets a boolean indicating if textures are enabled on this scene
  116670. */
  116671. set texturesEnabled(value: boolean);
  116672. get texturesEnabled(): boolean;
  116673. /**
  116674. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116675. */
  116676. physicsEnabled: boolean;
  116677. /**
  116678. * Gets or sets a boolean indicating if particles are enabled on this scene
  116679. */
  116680. particlesEnabled: boolean;
  116681. /**
  116682. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116683. */
  116684. spritesEnabled: boolean;
  116685. private _skeletonsEnabled;
  116686. /**
  116687. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116688. */
  116689. set skeletonsEnabled(value: boolean);
  116690. get skeletonsEnabled(): boolean;
  116691. /**
  116692. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116693. */
  116694. lensFlaresEnabled: boolean;
  116695. /**
  116696. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116698. */
  116699. collisionsEnabled: boolean;
  116700. private _collisionCoordinator;
  116701. /** @hidden */
  116702. get collisionCoordinator(): ICollisionCoordinator;
  116703. /**
  116704. * Defines the gravity applied to this scene (used only for collisions)
  116705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116706. */
  116707. gravity: Vector3;
  116708. /**
  116709. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116710. */
  116711. postProcessesEnabled: boolean;
  116712. /**
  116713. * The list of postprocesses added to the scene
  116714. */
  116715. postProcesses: PostProcess[];
  116716. /**
  116717. * Gets the current postprocess manager
  116718. */
  116719. postProcessManager: PostProcessManager;
  116720. /**
  116721. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116722. */
  116723. renderTargetsEnabled: boolean;
  116724. /**
  116725. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116726. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116727. */
  116728. dumpNextRenderTargets: boolean;
  116729. /**
  116730. * The list of user defined render targets added to the scene
  116731. */
  116732. customRenderTargets: RenderTargetTexture[];
  116733. /**
  116734. * Defines if texture loading must be delayed
  116735. * If true, textures will only be loaded when they need to be rendered
  116736. */
  116737. useDelayedTextureLoading: boolean;
  116738. /**
  116739. * Gets the list of meshes imported to the scene through SceneLoader
  116740. */
  116741. importedMeshesFiles: String[];
  116742. /**
  116743. * Gets or sets a boolean indicating if probes are enabled on this scene
  116744. */
  116745. probesEnabled: boolean;
  116746. /**
  116747. * Gets or sets the current offline provider to use to store scene data
  116748. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116749. */
  116750. offlineProvider: IOfflineProvider;
  116751. /**
  116752. * Gets or sets the action manager associated with the scene
  116753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116754. */
  116755. actionManager: AbstractActionManager;
  116756. private _meshesForIntersections;
  116757. /**
  116758. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116759. */
  116760. proceduralTexturesEnabled: boolean;
  116761. private _engine;
  116762. private _totalVertices;
  116763. /** @hidden */
  116764. _activeIndices: PerfCounter;
  116765. /** @hidden */
  116766. _activeParticles: PerfCounter;
  116767. /** @hidden */
  116768. _activeBones: PerfCounter;
  116769. private _animationRatio;
  116770. /** @hidden */
  116771. _animationTimeLast: number;
  116772. /** @hidden */
  116773. _animationTime: number;
  116774. /**
  116775. * Gets or sets a general scale for animation speed
  116776. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116777. */
  116778. animationTimeScale: number;
  116779. /** @hidden */
  116780. _cachedMaterial: Nullable<Material>;
  116781. /** @hidden */
  116782. _cachedEffect: Nullable<Effect>;
  116783. /** @hidden */
  116784. _cachedVisibility: Nullable<number>;
  116785. private _renderId;
  116786. private _frameId;
  116787. private _executeWhenReadyTimeoutId;
  116788. private _intermediateRendering;
  116789. private _viewUpdateFlag;
  116790. private _projectionUpdateFlag;
  116791. /** @hidden */
  116792. _toBeDisposed: Nullable<IDisposable>[];
  116793. private _activeRequests;
  116794. /** @hidden */
  116795. _pendingData: any[];
  116796. private _isDisposed;
  116797. /**
  116798. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116799. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116800. */
  116801. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116802. private _activeMeshes;
  116803. private _processedMaterials;
  116804. private _renderTargets;
  116805. /** @hidden */
  116806. _activeParticleSystems: SmartArray<IParticleSystem>;
  116807. private _activeSkeletons;
  116808. private _softwareSkinnedMeshes;
  116809. private _renderingManager;
  116810. /** @hidden */
  116811. _activeAnimatables: Animatable[];
  116812. private _transformMatrix;
  116813. private _sceneUbo;
  116814. /** @hidden */
  116815. _viewMatrix: Matrix;
  116816. private _projectionMatrix;
  116817. /** @hidden */
  116818. _forcedViewPosition: Nullable<Vector3>;
  116819. /** @hidden */
  116820. _frustumPlanes: Plane[];
  116821. /**
  116822. * Gets the list of frustum planes (built from the active camera)
  116823. */
  116824. get frustumPlanes(): Plane[];
  116825. /**
  116826. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116827. * This is useful if there are more lights that the maximum simulteanous authorized
  116828. */
  116829. requireLightSorting: boolean;
  116830. /** @hidden */
  116831. readonly useMaterialMeshMap: boolean;
  116832. /** @hidden */
  116833. readonly useClonedMeshMap: boolean;
  116834. private _externalData;
  116835. private _uid;
  116836. /**
  116837. * @hidden
  116838. * Backing store of defined scene components.
  116839. */
  116840. _components: ISceneComponent[];
  116841. /**
  116842. * @hidden
  116843. * Backing store of defined scene components.
  116844. */
  116845. _serializableComponents: ISceneSerializableComponent[];
  116846. /**
  116847. * List of components to register on the next registration step.
  116848. */
  116849. private _transientComponents;
  116850. /**
  116851. * Registers the transient components if needed.
  116852. */
  116853. private _registerTransientComponents;
  116854. /**
  116855. * @hidden
  116856. * Add a component to the scene.
  116857. * Note that the ccomponent could be registered on th next frame if this is called after
  116858. * the register component stage.
  116859. * @param component Defines the component to add to the scene
  116860. */
  116861. _addComponent(component: ISceneComponent): void;
  116862. /**
  116863. * @hidden
  116864. * Gets a component from the scene.
  116865. * @param name defines the name of the component to retrieve
  116866. * @returns the component or null if not present
  116867. */
  116868. _getComponent(name: string): Nullable<ISceneComponent>;
  116869. /**
  116870. * @hidden
  116871. * Defines the actions happening before camera updates.
  116872. */
  116873. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116874. /**
  116875. * @hidden
  116876. * Defines the actions happening before clear the canvas.
  116877. */
  116878. _beforeClearStage: Stage<SimpleStageAction>;
  116879. /**
  116880. * @hidden
  116881. * Defines the actions when collecting render targets for the frame.
  116882. */
  116883. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116884. /**
  116885. * @hidden
  116886. * Defines the actions happening for one camera in the frame.
  116887. */
  116888. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116889. /**
  116890. * @hidden
  116891. * Defines the actions happening during the per mesh ready checks.
  116892. */
  116893. _isReadyForMeshStage: Stage<MeshStageAction>;
  116894. /**
  116895. * @hidden
  116896. * Defines the actions happening before evaluate active mesh checks.
  116897. */
  116898. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116899. /**
  116900. * @hidden
  116901. * Defines the actions happening during the evaluate sub mesh checks.
  116902. */
  116903. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116904. /**
  116905. * @hidden
  116906. * Defines the actions happening during the active mesh stage.
  116907. */
  116908. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116909. /**
  116910. * @hidden
  116911. * Defines the actions happening during the per camera render target step.
  116912. */
  116913. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116914. /**
  116915. * @hidden
  116916. * Defines the actions happening just before the active camera is drawing.
  116917. */
  116918. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116919. /**
  116920. * @hidden
  116921. * Defines the actions happening just before a render target is drawing.
  116922. */
  116923. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116924. /**
  116925. * @hidden
  116926. * Defines the actions happening just before a rendering group is drawing.
  116927. */
  116928. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116929. /**
  116930. * @hidden
  116931. * Defines the actions happening just before a mesh is drawing.
  116932. */
  116933. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116934. /**
  116935. * @hidden
  116936. * Defines the actions happening just after a mesh has been drawn.
  116937. */
  116938. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116939. /**
  116940. * @hidden
  116941. * Defines the actions happening just after a rendering group has been drawn.
  116942. */
  116943. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116944. /**
  116945. * @hidden
  116946. * Defines the actions happening just after the active camera has been drawn.
  116947. */
  116948. _afterCameraDrawStage: Stage<CameraStageAction>;
  116949. /**
  116950. * @hidden
  116951. * Defines the actions happening just after a render target has been drawn.
  116952. */
  116953. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116954. /**
  116955. * @hidden
  116956. * Defines the actions happening just after rendering all cameras and computing intersections.
  116957. */
  116958. _afterRenderStage: Stage<SimpleStageAction>;
  116959. /**
  116960. * @hidden
  116961. * Defines the actions happening when a pointer move event happens.
  116962. */
  116963. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116964. /**
  116965. * @hidden
  116966. * Defines the actions happening when a pointer down event happens.
  116967. */
  116968. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116969. /**
  116970. * @hidden
  116971. * Defines the actions happening when a pointer up event happens.
  116972. */
  116973. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116974. /**
  116975. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116976. */
  116977. private geometriesByUniqueId;
  116978. /**
  116979. * Creates a new Scene
  116980. * @param engine defines the engine to use to render this scene
  116981. * @param options defines the scene options
  116982. */
  116983. constructor(engine: Engine, options?: SceneOptions);
  116984. /**
  116985. * Gets a string idenfifying the name of the class
  116986. * @returns "Scene" string
  116987. */
  116988. getClassName(): string;
  116989. private _defaultMeshCandidates;
  116990. /**
  116991. * @hidden
  116992. */
  116993. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116994. private _defaultSubMeshCandidates;
  116995. /**
  116996. * @hidden
  116997. */
  116998. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116999. /**
  117000. * Sets the default candidate providers for the scene.
  117001. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117002. * and getCollidingSubMeshCandidates to their default function
  117003. */
  117004. setDefaultCandidateProviders(): void;
  117005. /**
  117006. * Gets the mesh that is currently under the pointer
  117007. */
  117008. get meshUnderPointer(): Nullable<AbstractMesh>;
  117009. /**
  117010. * Gets or sets the current on-screen X position of the pointer
  117011. */
  117012. get pointerX(): number;
  117013. set pointerX(value: number);
  117014. /**
  117015. * Gets or sets the current on-screen Y position of the pointer
  117016. */
  117017. get pointerY(): number;
  117018. set pointerY(value: number);
  117019. /**
  117020. * Gets the cached material (ie. the latest rendered one)
  117021. * @returns the cached material
  117022. */
  117023. getCachedMaterial(): Nullable<Material>;
  117024. /**
  117025. * Gets the cached effect (ie. the latest rendered one)
  117026. * @returns the cached effect
  117027. */
  117028. getCachedEffect(): Nullable<Effect>;
  117029. /**
  117030. * Gets the cached visibility state (ie. the latest rendered one)
  117031. * @returns the cached visibility state
  117032. */
  117033. getCachedVisibility(): Nullable<number>;
  117034. /**
  117035. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117036. * @param material defines the current material
  117037. * @param effect defines the current effect
  117038. * @param visibility defines the current visibility state
  117039. * @returns true if one parameter is not cached
  117040. */
  117041. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117042. /**
  117043. * Gets the engine associated with the scene
  117044. * @returns an Engine
  117045. */
  117046. getEngine(): Engine;
  117047. /**
  117048. * Gets the total number of vertices rendered per frame
  117049. * @returns the total number of vertices rendered per frame
  117050. */
  117051. getTotalVertices(): number;
  117052. /**
  117053. * Gets the performance counter for total vertices
  117054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117055. */
  117056. get totalVerticesPerfCounter(): PerfCounter;
  117057. /**
  117058. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117059. * @returns the total number of active indices rendered per frame
  117060. */
  117061. getActiveIndices(): number;
  117062. /**
  117063. * Gets the performance counter for active indices
  117064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117065. */
  117066. get totalActiveIndicesPerfCounter(): PerfCounter;
  117067. /**
  117068. * Gets the total number of active particles rendered per frame
  117069. * @returns the total number of active particles rendered per frame
  117070. */
  117071. getActiveParticles(): number;
  117072. /**
  117073. * Gets the performance counter for active particles
  117074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117075. */
  117076. get activeParticlesPerfCounter(): PerfCounter;
  117077. /**
  117078. * Gets the total number of active bones rendered per frame
  117079. * @returns the total number of active bones rendered per frame
  117080. */
  117081. getActiveBones(): number;
  117082. /**
  117083. * Gets the performance counter for active bones
  117084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117085. */
  117086. get activeBonesPerfCounter(): PerfCounter;
  117087. /**
  117088. * Gets the array of active meshes
  117089. * @returns an array of AbstractMesh
  117090. */
  117091. getActiveMeshes(): SmartArray<AbstractMesh>;
  117092. /**
  117093. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117094. * @returns a number
  117095. */
  117096. getAnimationRatio(): number;
  117097. /**
  117098. * Gets an unique Id for the current render phase
  117099. * @returns a number
  117100. */
  117101. getRenderId(): number;
  117102. /**
  117103. * Gets an unique Id for the current frame
  117104. * @returns a number
  117105. */
  117106. getFrameId(): number;
  117107. /** Call this function if you want to manually increment the render Id*/
  117108. incrementRenderId(): void;
  117109. private _createUbo;
  117110. /**
  117111. * Use this method to simulate a pointer move on a mesh
  117112. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117113. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117114. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117115. * @returns the current scene
  117116. */
  117117. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117118. /**
  117119. * Use this method to simulate a pointer down on a mesh
  117120. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117121. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117122. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117123. * @returns the current scene
  117124. */
  117125. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117126. /**
  117127. * Use this method to simulate a pointer up on a mesh
  117128. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117129. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117130. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117131. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117132. * @returns the current scene
  117133. */
  117134. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117135. /**
  117136. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117137. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117138. * @returns true if the pointer was captured
  117139. */
  117140. isPointerCaptured(pointerId?: number): boolean;
  117141. /**
  117142. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117143. * @param attachUp defines if you want to attach events to pointerup
  117144. * @param attachDown defines if you want to attach events to pointerdown
  117145. * @param attachMove defines if you want to attach events to pointermove
  117146. */
  117147. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117148. /** Detaches all event handlers*/
  117149. detachControl(): void;
  117150. /**
  117151. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117152. * Delay loaded resources are not taking in account
  117153. * @return true if all required resources are ready
  117154. */
  117155. isReady(): boolean;
  117156. /** Resets all cached information relative to material (including effect and visibility) */
  117157. resetCachedMaterial(): void;
  117158. /**
  117159. * Registers a function to be called before every frame render
  117160. * @param func defines the function to register
  117161. */
  117162. registerBeforeRender(func: () => void): void;
  117163. /**
  117164. * Unregisters a function called before every frame render
  117165. * @param func defines the function to unregister
  117166. */
  117167. unregisterBeforeRender(func: () => void): void;
  117168. /**
  117169. * Registers a function to be called after every frame render
  117170. * @param func defines the function to register
  117171. */
  117172. registerAfterRender(func: () => void): void;
  117173. /**
  117174. * Unregisters a function called after every frame render
  117175. * @param func defines the function to unregister
  117176. */
  117177. unregisterAfterRender(func: () => void): void;
  117178. private _executeOnceBeforeRender;
  117179. /**
  117180. * The provided function will run before render once and will be disposed afterwards.
  117181. * A timeout delay can be provided so that the function will be executed in N ms.
  117182. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117183. * @param func The function to be executed.
  117184. * @param timeout optional delay in ms
  117185. */
  117186. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117187. /** @hidden */
  117188. _addPendingData(data: any): void;
  117189. /** @hidden */
  117190. _removePendingData(data: any): void;
  117191. /**
  117192. * Returns the number of items waiting to be loaded
  117193. * @returns the number of items waiting to be loaded
  117194. */
  117195. getWaitingItemsCount(): number;
  117196. /**
  117197. * Returns a boolean indicating if the scene is still loading data
  117198. */
  117199. get isLoading(): boolean;
  117200. /**
  117201. * Registers a function to be executed when the scene is ready
  117202. * @param {Function} func - the function to be executed
  117203. */
  117204. executeWhenReady(func: () => void): void;
  117205. /**
  117206. * Returns a promise that resolves when the scene is ready
  117207. * @returns A promise that resolves when the scene is ready
  117208. */
  117209. whenReadyAsync(): Promise<void>;
  117210. /** @hidden */
  117211. _checkIsReady(): void;
  117212. /**
  117213. * Gets all animatable attached to the scene
  117214. */
  117215. get animatables(): Animatable[];
  117216. /**
  117217. * Resets the last animation time frame.
  117218. * Useful to override when animations start running when loading a scene for the first time.
  117219. */
  117220. resetLastAnimationTimeFrame(): void;
  117221. /**
  117222. * Gets the current view matrix
  117223. * @returns a Matrix
  117224. */
  117225. getViewMatrix(): Matrix;
  117226. /**
  117227. * Gets the current projection matrix
  117228. * @returns a Matrix
  117229. */
  117230. getProjectionMatrix(): Matrix;
  117231. /**
  117232. * Gets the current transform matrix
  117233. * @returns a Matrix made of View * Projection
  117234. */
  117235. getTransformMatrix(): Matrix;
  117236. /**
  117237. * Sets the current transform matrix
  117238. * @param viewL defines the View matrix to use
  117239. * @param projectionL defines the Projection matrix to use
  117240. * @param viewR defines the right View matrix to use (if provided)
  117241. * @param projectionR defines the right Projection matrix to use (if provided)
  117242. */
  117243. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117244. /**
  117245. * Gets the uniform buffer used to store scene data
  117246. * @returns a UniformBuffer
  117247. */
  117248. getSceneUniformBuffer(): UniformBuffer;
  117249. /**
  117250. * Gets an unique (relatively to the current scene) Id
  117251. * @returns an unique number for the scene
  117252. */
  117253. getUniqueId(): number;
  117254. /**
  117255. * Add a mesh to the list of scene's meshes
  117256. * @param newMesh defines the mesh to add
  117257. * @param recursive if all child meshes should also be added to the scene
  117258. */
  117259. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117260. /**
  117261. * Remove a mesh for the list of scene's meshes
  117262. * @param toRemove defines the mesh to remove
  117263. * @param recursive if all child meshes should also be removed from the scene
  117264. * @returns the index where the mesh was in the mesh list
  117265. */
  117266. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117267. /**
  117268. * Add a transform node to the list of scene's transform nodes
  117269. * @param newTransformNode defines the transform node to add
  117270. */
  117271. addTransformNode(newTransformNode: TransformNode): void;
  117272. /**
  117273. * Remove a transform node for the list of scene's transform nodes
  117274. * @param toRemove defines the transform node to remove
  117275. * @returns the index where the transform node was in the transform node list
  117276. */
  117277. removeTransformNode(toRemove: TransformNode): number;
  117278. /**
  117279. * Remove a skeleton for the list of scene's skeletons
  117280. * @param toRemove defines the skeleton to remove
  117281. * @returns the index where the skeleton was in the skeleton list
  117282. */
  117283. removeSkeleton(toRemove: Skeleton): number;
  117284. /**
  117285. * Remove a morph target for the list of scene's morph targets
  117286. * @param toRemove defines the morph target to remove
  117287. * @returns the index where the morph target was in the morph target list
  117288. */
  117289. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117290. /**
  117291. * Remove a light for the list of scene's lights
  117292. * @param toRemove defines the light to remove
  117293. * @returns the index where the light was in the light list
  117294. */
  117295. removeLight(toRemove: Light): number;
  117296. /**
  117297. * Remove a camera for the list of scene's cameras
  117298. * @param toRemove defines the camera to remove
  117299. * @returns the index where the camera was in the camera list
  117300. */
  117301. removeCamera(toRemove: Camera): number;
  117302. /**
  117303. * Remove a particle system for the list of scene's particle systems
  117304. * @param toRemove defines the particle system to remove
  117305. * @returns the index where the particle system was in the particle system list
  117306. */
  117307. removeParticleSystem(toRemove: IParticleSystem): number;
  117308. /**
  117309. * Remove a animation for the list of scene's animations
  117310. * @param toRemove defines the animation to remove
  117311. * @returns the index where the animation was in the animation list
  117312. */
  117313. removeAnimation(toRemove: Animation): number;
  117314. /**
  117315. * Will stop the animation of the given target
  117316. * @param target - the target
  117317. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117318. * @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)
  117319. */
  117320. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117321. /**
  117322. * Removes the given animation group from this scene.
  117323. * @param toRemove The animation group to remove
  117324. * @returns The index of the removed animation group
  117325. */
  117326. removeAnimationGroup(toRemove: AnimationGroup): number;
  117327. /**
  117328. * Removes the given multi-material from this scene.
  117329. * @param toRemove The multi-material to remove
  117330. * @returns The index of the removed multi-material
  117331. */
  117332. removeMultiMaterial(toRemove: MultiMaterial): number;
  117333. /**
  117334. * Removes the given material from this scene.
  117335. * @param toRemove The material to remove
  117336. * @returns The index of the removed material
  117337. */
  117338. removeMaterial(toRemove: Material): number;
  117339. /**
  117340. * Removes the given action manager from this scene.
  117341. * @param toRemove The action manager to remove
  117342. * @returns The index of the removed action manager
  117343. */
  117344. removeActionManager(toRemove: AbstractActionManager): number;
  117345. /**
  117346. * Removes the given texture from this scene.
  117347. * @param toRemove The texture to remove
  117348. * @returns The index of the removed texture
  117349. */
  117350. removeTexture(toRemove: BaseTexture): number;
  117351. /**
  117352. * Adds the given light to this scene
  117353. * @param newLight The light to add
  117354. */
  117355. addLight(newLight: Light): void;
  117356. /**
  117357. * Sorts the list list based on light priorities
  117358. */
  117359. sortLightsByPriority(): void;
  117360. /**
  117361. * Adds the given camera to this scene
  117362. * @param newCamera The camera to add
  117363. */
  117364. addCamera(newCamera: Camera): void;
  117365. /**
  117366. * Adds the given skeleton to this scene
  117367. * @param newSkeleton The skeleton to add
  117368. */
  117369. addSkeleton(newSkeleton: Skeleton): void;
  117370. /**
  117371. * Adds the given particle system to this scene
  117372. * @param newParticleSystem The particle system to add
  117373. */
  117374. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117375. /**
  117376. * Adds the given animation to this scene
  117377. * @param newAnimation The animation to add
  117378. */
  117379. addAnimation(newAnimation: Animation): void;
  117380. /**
  117381. * Adds the given animation group to this scene.
  117382. * @param newAnimationGroup The animation group to add
  117383. */
  117384. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117385. /**
  117386. * Adds the given multi-material to this scene
  117387. * @param newMultiMaterial The multi-material to add
  117388. */
  117389. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117390. /**
  117391. * Adds the given material to this scene
  117392. * @param newMaterial The material to add
  117393. */
  117394. addMaterial(newMaterial: Material): void;
  117395. /**
  117396. * Adds the given morph target to this scene
  117397. * @param newMorphTargetManager The morph target to add
  117398. */
  117399. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117400. /**
  117401. * Adds the given geometry to this scene
  117402. * @param newGeometry The geometry to add
  117403. */
  117404. addGeometry(newGeometry: Geometry): void;
  117405. /**
  117406. * Adds the given action manager to this scene
  117407. * @param newActionManager The action manager to add
  117408. */
  117409. addActionManager(newActionManager: AbstractActionManager): void;
  117410. /**
  117411. * Adds the given texture to this scene.
  117412. * @param newTexture The texture to add
  117413. */
  117414. addTexture(newTexture: BaseTexture): void;
  117415. /**
  117416. * Switch active camera
  117417. * @param newCamera defines the new active camera
  117418. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117419. */
  117420. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117421. /**
  117422. * sets the active camera of the scene using its ID
  117423. * @param id defines the camera's ID
  117424. * @return the new active camera or null if none found.
  117425. */
  117426. setActiveCameraByID(id: string): Nullable<Camera>;
  117427. /**
  117428. * sets the active camera of the scene using its name
  117429. * @param name defines the camera's name
  117430. * @returns the new active camera or null if none found.
  117431. */
  117432. setActiveCameraByName(name: string): Nullable<Camera>;
  117433. /**
  117434. * get an animation group using its name
  117435. * @param name defines the material's name
  117436. * @return the animation group or null if none found.
  117437. */
  117438. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117439. /**
  117440. * Get a material using its unique id
  117441. * @param uniqueId defines the material's unique id
  117442. * @return the material or null if none found.
  117443. */
  117444. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117445. /**
  117446. * get a material using its id
  117447. * @param id defines the material's ID
  117448. * @return the material or null if none found.
  117449. */
  117450. getMaterialByID(id: string): Nullable<Material>;
  117451. /**
  117452. * Gets a the last added material using a given id
  117453. * @param id defines the material's ID
  117454. * @return the last material with the given id or null if none found.
  117455. */
  117456. getLastMaterialByID(id: string): Nullable<Material>;
  117457. /**
  117458. * Gets a material using its name
  117459. * @param name defines the material's name
  117460. * @return the material or null if none found.
  117461. */
  117462. getMaterialByName(name: string): Nullable<Material>;
  117463. /**
  117464. * Get a texture using its unique id
  117465. * @param uniqueId defines the texture's unique id
  117466. * @return the texture or null if none found.
  117467. */
  117468. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117469. /**
  117470. * Gets a camera using its id
  117471. * @param id defines the id to look for
  117472. * @returns the camera or null if not found
  117473. */
  117474. getCameraByID(id: string): Nullable<Camera>;
  117475. /**
  117476. * Gets a camera using its unique id
  117477. * @param uniqueId defines the unique id to look for
  117478. * @returns the camera or null if not found
  117479. */
  117480. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117481. /**
  117482. * Gets a camera using its name
  117483. * @param name defines the camera's name
  117484. * @return the camera or null if none found.
  117485. */
  117486. getCameraByName(name: string): Nullable<Camera>;
  117487. /**
  117488. * Gets a bone using its id
  117489. * @param id defines the bone's id
  117490. * @return the bone or null if not found
  117491. */
  117492. getBoneByID(id: string): Nullable<Bone>;
  117493. /**
  117494. * Gets a bone using its id
  117495. * @param name defines the bone's name
  117496. * @return the bone or null if not found
  117497. */
  117498. getBoneByName(name: string): Nullable<Bone>;
  117499. /**
  117500. * Gets a light node using its name
  117501. * @param name defines the the light's name
  117502. * @return the light or null if none found.
  117503. */
  117504. getLightByName(name: string): Nullable<Light>;
  117505. /**
  117506. * Gets a light node using its id
  117507. * @param id defines the light's id
  117508. * @return the light or null if none found.
  117509. */
  117510. getLightByID(id: string): Nullable<Light>;
  117511. /**
  117512. * Gets a light node using its scene-generated unique ID
  117513. * @param uniqueId defines the light's unique id
  117514. * @return the light or null if none found.
  117515. */
  117516. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117517. /**
  117518. * Gets a particle system by id
  117519. * @param id defines the particle system id
  117520. * @return the corresponding system or null if none found
  117521. */
  117522. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117523. /**
  117524. * Gets a geometry using its ID
  117525. * @param id defines the geometry's id
  117526. * @return the geometry or null if none found.
  117527. */
  117528. getGeometryByID(id: string): Nullable<Geometry>;
  117529. private _getGeometryByUniqueID;
  117530. /**
  117531. * Add a new geometry to this scene
  117532. * @param geometry defines the geometry to be added to the scene.
  117533. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117534. * @return a boolean defining if the geometry was added or not
  117535. */
  117536. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117537. /**
  117538. * Removes an existing geometry
  117539. * @param geometry defines the geometry to be removed from the scene
  117540. * @return a boolean defining if the geometry was removed or not
  117541. */
  117542. removeGeometry(geometry: Geometry): boolean;
  117543. /**
  117544. * Gets the list of geometries attached to the scene
  117545. * @returns an array of Geometry
  117546. */
  117547. getGeometries(): Geometry[];
  117548. /**
  117549. * Gets the first added mesh found of a given ID
  117550. * @param id defines the id to search for
  117551. * @return the mesh found or null if not found at all
  117552. */
  117553. getMeshByID(id: string): Nullable<AbstractMesh>;
  117554. /**
  117555. * Gets a list of meshes using their id
  117556. * @param id defines the id to search for
  117557. * @returns a list of meshes
  117558. */
  117559. getMeshesByID(id: string): Array<AbstractMesh>;
  117560. /**
  117561. * Gets the first added transform node found of a given ID
  117562. * @param id defines the id to search for
  117563. * @return the found transform node or null if not found at all.
  117564. */
  117565. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117566. /**
  117567. * Gets a transform node with its auto-generated unique id
  117568. * @param uniqueId efines the unique id to search for
  117569. * @return the found transform node or null if not found at all.
  117570. */
  117571. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117572. /**
  117573. * Gets a list of transform nodes using their id
  117574. * @param id defines the id to search for
  117575. * @returns a list of transform nodes
  117576. */
  117577. getTransformNodesByID(id: string): Array<TransformNode>;
  117578. /**
  117579. * Gets a mesh with its auto-generated unique id
  117580. * @param uniqueId defines the unique id to search for
  117581. * @return the found mesh or null if not found at all.
  117582. */
  117583. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117584. /**
  117585. * Gets a the last added mesh using a given id
  117586. * @param id defines the id to search for
  117587. * @return the found mesh or null if not found at all.
  117588. */
  117589. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117590. /**
  117591. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117592. * @param id defines the id to search for
  117593. * @return the found node or null if not found at all
  117594. */
  117595. getLastEntryByID(id: string): Nullable<Node>;
  117596. /**
  117597. * Gets a node (Mesh, Camera, Light) using a given id
  117598. * @param id defines the id to search for
  117599. * @return the found node or null if not found at all
  117600. */
  117601. getNodeByID(id: string): Nullable<Node>;
  117602. /**
  117603. * Gets a node (Mesh, Camera, Light) using a given name
  117604. * @param name defines the name to search for
  117605. * @return the found node or null if not found at all.
  117606. */
  117607. getNodeByName(name: string): Nullable<Node>;
  117608. /**
  117609. * Gets a mesh using a given name
  117610. * @param name defines the name to search for
  117611. * @return the found mesh or null if not found at all.
  117612. */
  117613. getMeshByName(name: string): Nullable<AbstractMesh>;
  117614. /**
  117615. * Gets a transform node using a given name
  117616. * @param name defines the name to search for
  117617. * @return the found transform node or null if not found at all.
  117618. */
  117619. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117620. /**
  117621. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117622. * @param id defines the id to search for
  117623. * @return the found skeleton or null if not found at all.
  117624. */
  117625. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117626. /**
  117627. * Gets a skeleton using a given auto generated unique id
  117628. * @param uniqueId defines the unique id to search for
  117629. * @return the found skeleton or null if not found at all.
  117630. */
  117631. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117632. /**
  117633. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117634. * @param id defines the id to search for
  117635. * @return the found skeleton or null if not found at all.
  117636. */
  117637. getSkeletonById(id: string): Nullable<Skeleton>;
  117638. /**
  117639. * Gets a skeleton using a given name
  117640. * @param name defines the name to search for
  117641. * @return the found skeleton or null if not found at all.
  117642. */
  117643. getSkeletonByName(name: string): Nullable<Skeleton>;
  117644. /**
  117645. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117646. * @param id defines the id to search for
  117647. * @return the found morph target manager or null if not found at all.
  117648. */
  117649. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117650. /**
  117651. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117652. * @param id defines the id to search for
  117653. * @return the found morph target or null if not found at all.
  117654. */
  117655. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117656. /**
  117657. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117658. * @param name defines the name to search for
  117659. * @return the found morph target or null if not found at all.
  117660. */
  117661. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117662. /**
  117663. * Gets a boolean indicating if the given mesh is active
  117664. * @param mesh defines the mesh to look for
  117665. * @returns true if the mesh is in the active list
  117666. */
  117667. isActiveMesh(mesh: AbstractMesh): boolean;
  117668. /**
  117669. * Return a unique id as a string which can serve as an identifier for the scene
  117670. */
  117671. get uid(): string;
  117672. /**
  117673. * Add an externaly attached data from its key.
  117674. * This method call will fail and return false, if such key already exists.
  117675. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117676. * @param key the unique key that identifies the data
  117677. * @param data the data object to associate to the key for this Engine instance
  117678. * @return true if no such key were already present and the data was added successfully, false otherwise
  117679. */
  117680. addExternalData<T>(key: string, data: T): boolean;
  117681. /**
  117682. * Get an externaly attached data from its key
  117683. * @param key the unique key that identifies the data
  117684. * @return the associated data, if present (can be null), or undefined if not present
  117685. */
  117686. getExternalData<T>(key: string): Nullable<T>;
  117687. /**
  117688. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117689. * @param key the unique key that identifies the data
  117690. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117691. * @return the associated data, can be null if the factory returned null.
  117692. */
  117693. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117694. /**
  117695. * Remove an externaly attached data from the Engine instance
  117696. * @param key the unique key that identifies the data
  117697. * @return true if the data was successfully removed, false if it doesn't exist
  117698. */
  117699. removeExternalData(key: string): boolean;
  117700. private _evaluateSubMesh;
  117701. /**
  117702. * Clear the processed materials smart array preventing retention point in material dispose.
  117703. */
  117704. freeProcessedMaterials(): void;
  117705. private _preventFreeActiveMeshesAndRenderingGroups;
  117706. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117707. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117708. * when disposing several meshes in a row or a hierarchy of meshes.
  117709. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117710. */
  117711. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117712. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117713. /**
  117714. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117715. */
  117716. freeActiveMeshes(): void;
  117717. /**
  117718. * Clear the info related to rendering groups preventing retention points during dispose.
  117719. */
  117720. freeRenderingGroups(): void;
  117721. /** @hidden */
  117722. _isInIntermediateRendering(): boolean;
  117723. /**
  117724. * Lambda returning the list of potentially active meshes.
  117725. */
  117726. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117727. /**
  117728. * Lambda returning the list of potentially active sub meshes.
  117729. */
  117730. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117731. /**
  117732. * Lambda returning the list of potentially intersecting sub meshes.
  117733. */
  117734. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117735. /**
  117736. * Lambda returning the list of potentially colliding sub meshes.
  117737. */
  117738. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117739. private _activeMeshesFrozen;
  117740. private _skipEvaluateActiveMeshesCompletely;
  117741. /**
  117742. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117743. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117744. * @returns the current scene
  117745. */
  117746. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117747. /**
  117748. * Use this function to restart evaluating active meshes on every frame
  117749. * @returns the current scene
  117750. */
  117751. unfreezeActiveMeshes(): Scene;
  117752. private _evaluateActiveMeshes;
  117753. private _activeMesh;
  117754. /**
  117755. * Update the transform matrix to update from the current active camera
  117756. * @param force defines a boolean used to force the update even if cache is up to date
  117757. */
  117758. updateTransformMatrix(force?: boolean): void;
  117759. private _bindFrameBuffer;
  117760. /** @hidden */
  117761. _allowPostProcessClearColor: boolean;
  117762. /** @hidden */
  117763. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117764. private _processSubCameras;
  117765. private _checkIntersections;
  117766. /** @hidden */
  117767. _advancePhysicsEngineStep(step: number): void;
  117768. /**
  117769. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117770. */
  117771. getDeterministicFrameTime: () => number;
  117772. /** @hidden */
  117773. _animate(): void;
  117774. /** Execute all animations (for a frame) */
  117775. animate(): void;
  117776. /**
  117777. * Render the scene
  117778. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117779. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117780. */
  117781. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117782. /**
  117783. * Freeze all materials
  117784. * A frozen material will not be updatable but should be faster to render
  117785. */
  117786. freezeMaterials(): void;
  117787. /**
  117788. * Unfreeze all materials
  117789. * A frozen material will not be updatable but should be faster to render
  117790. */
  117791. unfreezeMaterials(): void;
  117792. /**
  117793. * Releases all held ressources
  117794. */
  117795. dispose(): void;
  117796. /**
  117797. * Gets if the scene is already disposed
  117798. */
  117799. get isDisposed(): boolean;
  117800. /**
  117801. * Call this function to reduce memory footprint of the scene.
  117802. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117803. */
  117804. clearCachedVertexData(): void;
  117805. /**
  117806. * This function will remove the local cached buffer data from texture.
  117807. * It will save memory but will prevent the texture from being rebuilt
  117808. */
  117809. cleanCachedTextureBuffer(): void;
  117810. /**
  117811. * Get the world extend vectors with an optional filter
  117812. *
  117813. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117814. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117815. */
  117816. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117817. min: Vector3;
  117818. max: Vector3;
  117819. };
  117820. /**
  117821. * Creates a ray that can be used to pick in the scene
  117822. * @param x defines the x coordinate of the origin (on-screen)
  117823. * @param y defines the y coordinate of the origin (on-screen)
  117824. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117825. * @param camera defines the camera to use for the picking
  117826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117827. * @returns a Ray
  117828. */
  117829. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117830. /**
  117831. * Creates a ray that can be used to pick in the scene
  117832. * @param x defines the x coordinate of the origin (on-screen)
  117833. * @param y defines the y coordinate of the origin (on-screen)
  117834. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117835. * @param result defines the ray where to store the picking ray
  117836. * @param camera defines the camera to use for the picking
  117837. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117838. * @returns the current scene
  117839. */
  117840. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117841. /**
  117842. * Creates a ray that can be used to pick in the scene
  117843. * @param x defines the x coordinate of the origin (on-screen)
  117844. * @param y defines the y coordinate of the origin (on-screen)
  117845. * @param camera defines the camera to use for the picking
  117846. * @returns a Ray
  117847. */
  117848. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117849. /**
  117850. * Creates a ray that can be used to pick in the scene
  117851. * @param x defines the x coordinate of the origin (on-screen)
  117852. * @param y defines the y coordinate of the origin (on-screen)
  117853. * @param result defines the ray where to store the picking ray
  117854. * @param camera defines the camera to use for the picking
  117855. * @returns the current scene
  117856. */
  117857. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117858. /** Launch a ray to try to pick a mesh in the scene
  117859. * @param x position on screen
  117860. * @param y position on screen
  117861. * @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
  117862. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117863. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117864. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117865. * @returns a PickingInfo
  117866. */
  117867. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117868. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117869. * @param x position on screen
  117870. * @param y position on screen
  117871. * @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
  117872. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117873. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117874. * @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)
  117875. */
  117876. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117877. /** Use the given ray to pick a mesh in the scene
  117878. * @param ray The ray to use to pick meshes
  117879. * @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
  117880. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117882. * @returns a PickingInfo
  117883. */
  117884. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117885. /**
  117886. * Launch a ray to try to pick a mesh in the scene
  117887. * @param x X position on screen
  117888. * @param y Y position on screen
  117889. * @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
  117890. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117891. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117892. * @returns an array of PickingInfo
  117893. */
  117894. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117895. /**
  117896. * Launch a ray to try to pick a mesh in the scene
  117897. * @param ray Ray to use
  117898. * @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
  117899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117900. * @returns an array of PickingInfo
  117901. */
  117902. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117903. /**
  117904. * Force the value of meshUnderPointer
  117905. * @param mesh defines the mesh to use
  117906. */
  117907. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117908. /**
  117909. * Gets the mesh under the pointer
  117910. * @returns a Mesh or null if no mesh is under the pointer
  117911. */
  117912. getPointerOverMesh(): Nullable<AbstractMesh>;
  117913. /** @hidden */
  117914. _rebuildGeometries(): void;
  117915. /** @hidden */
  117916. _rebuildTextures(): void;
  117917. private _getByTags;
  117918. /**
  117919. * Get a list of meshes by tags
  117920. * @param tagsQuery defines the tags query to use
  117921. * @param forEach defines a predicate used to filter results
  117922. * @returns an array of Mesh
  117923. */
  117924. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117925. /**
  117926. * Get a list of cameras by tags
  117927. * @param tagsQuery defines the tags query to use
  117928. * @param forEach defines a predicate used to filter results
  117929. * @returns an array of Camera
  117930. */
  117931. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117932. /**
  117933. * Get a list of lights by tags
  117934. * @param tagsQuery defines the tags query to use
  117935. * @param forEach defines a predicate used to filter results
  117936. * @returns an array of Light
  117937. */
  117938. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117939. /**
  117940. * Get a list of materials by tags
  117941. * @param tagsQuery defines the tags query to use
  117942. * @param forEach defines a predicate used to filter results
  117943. * @returns an array of Material
  117944. */
  117945. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117946. /**
  117947. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117948. * This allowed control for front to back rendering or reversly depending of the special needs.
  117949. *
  117950. * @param renderingGroupId The rendering group id corresponding to its index
  117951. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117952. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117953. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117954. */
  117955. 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;
  117956. /**
  117957. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117958. *
  117959. * @param renderingGroupId The rendering group id corresponding to its index
  117960. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117961. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117962. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117963. */
  117964. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117965. /**
  117966. * Gets the current auto clear configuration for one rendering group of the rendering
  117967. * manager.
  117968. * @param index the rendering group index to get the information for
  117969. * @returns The auto clear setup for the requested rendering group
  117970. */
  117971. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117972. private _blockMaterialDirtyMechanism;
  117973. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117974. get blockMaterialDirtyMechanism(): boolean;
  117975. set blockMaterialDirtyMechanism(value: boolean);
  117976. /**
  117977. * Will flag all materials as dirty to trigger new shader compilation
  117978. * @param flag defines the flag used to specify which material part must be marked as dirty
  117979. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117980. */
  117981. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117982. /** @hidden */
  117983. _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;
  117984. /** @hidden */
  117985. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117986. /** @hidden */
  117987. _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;
  117988. /** @hidden */
  117989. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117990. /** @hidden */
  117991. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117992. /** @hidden */
  117993. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117994. }
  117995. }
  117996. declare module BABYLON {
  117997. /**
  117998. * Set of assets to keep when moving a scene into an asset container.
  117999. */
  118000. export class KeepAssets extends AbstractScene {
  118001. }
  118002. /**
  118003. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118004. */
  118005. export class InstantiatedEntries {
  118006. /**
  118007. * List of new root nodes (eg. nodes with no parent)
  118008. */
  118009. rootNodes: TransformNode[];
  118010. /**
  118011. * List of new skeletons
  118012. */
  118013. skeletons: Skeleton[];
  118014. /**
  118015. * List of new animation groups
  118016. */
  118017. animationGroups: AnimationGroup[];
  118018. }
  118019. /**
  118020. * Container with a set of assets that can be added or removed from a scene.
  118021. */
  118022. export class AssetContainer extends AbstractScene {
  118023. private _wasAddedToScene;
  118024. /**
  118025. * The scene the AssetContainer belongs to.
  118026. */
  118027. scene: Scene;
  118028. /**
  118029. * Instantiates an AssetContainer.
  118030. * @param scene The scene the AssetContainer belongs to.
  118031. */
  118032. constructor(scene: Scene);
  118033. /**
  118034. * Instantiate or clone all meshes and add the new ones to the scene.
  118035. * Skeletons and animation groups will all be cloned
  118036. * @param nameFunction defines an optional function used to get new names for clones
  118037. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118038. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118039. */
  118040. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118041. /**
  118042. * Adds all the assets from the container to the scene.
  118043. */
  118044. addAllToScene(): void;
  118045. /**
  118046. * Removes all the assets in the container from the scene
  118047. */
  118048. removeAllFromScene(): void;
  118049. /**
  118050. * Disposes all the assets in the container
  118051. */
  118052. dispose(): void;
  118053. private _moveAssets;
  118054. /**
  118055. * Removes all the assets contained in the scene and adds them to the container.
  118056. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118057. */
  118058. moveAllFromScene(keepAssets?: KeepAssets): void;
  118059. /**
  118060. * 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.
  118061. * @returns the root mesh
  118062. */
  118063. createRootMesh(): Mesh;
  118064. /**
  118065. * Merge animations (direct and animation groups) from this asset container into a scene
  118066. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118067. * @param animatables set of animatables to retarget to a node from the scene
  118068. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118069. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118070. */
  118071. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118072. }
  118073. }
  118074. declare module BABYLON {
  118075. /**
  118076. * Defines how the parser contract is defined.
  118077. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118078. */
  118079. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118080. /**
  118081. * Defines how the individual parser contract is defined.
  118082. * These parser can parse an individual asset
  118083. */
  118084. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118085. /**
  118086. * Base class of the scene acting as a container for the different elements composing a scene.
  118087. * This class is dynamically extended by the different components of the scene increasing
  118088. * flexibility and reducing coupling
  118089. */
  118090. export abstract class AbstractScene {
  118091. /**
  118092. * Stores the list of available parsers in the application.
  118093. */
  118094. private static _BabylonFileParsers;
  118095. /**
  118096. * Stores the list of available individual parsers in the application.
  118097. */
  118098. private static _IndividualBabylonFileParsers;
  118099. /**
  118100. * Adds a parser in the list of available ones
  118101. * @param name Defines the name of the parser
  118102. * @param parser Defines the parser to add
  118103. */
  118104. static AddParser(name: string, parser: BabylonFileParser): void;
  118105. /**
  118106. * Gets a general parser from the list of avaialble ones
  118107. * @param name Defines the name of the parser
  118108. * @returns the requested parser or null
  118109. */
  118110. static GetParser(name: string): Nullable<BabylonFileParser>;
  118111. /**
  118112. * Adds n individual parser in the list of available ones
  118113. * @param name Defines the name of the parser
  118114. * @param parser Defines the parser to add
  118115. */
  118116. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118117. /**
  118118. * Gets an individual parser from the list of avaialble ones
  118119. * @param name Defines the name of the parser
  118120. * @returns the requested parser or null
  118121. */
  118122. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118123. /**
  118124. * Parser json data and populate both a scene and its associated container object
  118125. * @param jsonData Defines the data to parse
  118126. * @param scene Defines the scene to parse the data for
  118127. * @param container Defines the container attached to the parsing sequence
  118128. * @param rootUrl Defines the root url of the data
  118129. */
  118130. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118131. /**
  118132. * Gets the list of root nodes (ie. nodes with no parent)
  118133. */
  118134. rootNodes: Node[];
  118135. /** All of the cameras added to this scene
  118136. * @see http://doc.babylonjs.com/babylon101/cameras
  118137. */
  118138. cameras: Camera[];
  118139. /**
  118140. * All of the lights added to this scene
  118141. * @see http://doc.babylonjs.com/babylon101/lights
  118142. */
  118143. lights: Light[];
  118144. /**
  118145. * All of the (abstract) meshes added to this scene
  118146. */
  118147. meshes: AbstractMesh[];
  118148. /**
  118149. * The list of skeletons added to the scene
  118150. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118151. */
  118152. skeletons: Skeleton[];
  118153. /**
  118154. * All of the particle systems added to this scene
  118155. * @see http://doc.babylonjs.com/babylon101/particles
  118156. */
  118157. particleSystems: IParticleSystem[];
  118158. /**
  118159. * Gets a list of Animations associated with the scene
  118160. */
  118161. animations: Animation[];
  118162. /**
  118163. * All of the animation groups added to this scene
  118164. * @see http://doc.babylonjs.com/how_to/group
  118165. */
  118166. animationGroups: AnimationGroup[];
  118167. /**
  118168. * All of the multi-materials added to this scene
  118169. * @see http://doc.babylonjs.com/how_to/multi_materials
  118170. */
  118171. multiMaterials: MultiMaterial[];
  118172. /**
  118173. * All of the materials added to this scene
  118174. * In the context of a Scene, it is not supposed to be modified manually.
  118175. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118176. * Note also that the order of the Material within the array is not significant and might change.
  118177. * @see http://doc.babylonjs.com/babylon101/materials
  118178. */
  118179. materials: Material[];
  118180. /**
  118181. * The list of morph target managers added to the scene
  118182. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118183. */
  118184. morphTargetManagers: MorphTargetManager[];
  118185. /**
  118186. * The list of geometries used in the scene.
  118187. */
  118188. geometries: Geometry[];
  118189. /**
  118190. * All of the tranform nodes added to this scene
  118191. * In the context of a Scene, it is not supposed to be modified manually.
  118192. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118193. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118194. * @see http://doc.babylonjs.com/how_to/transformnode
  118195. */
  118196. transformNodes: TransformNode[];
  118197. /**
  118198. * ActionManagers available on the scene.
  118199. */
  118200. actionManagers: AbstractActionManager[];
  118201. /**
  118202. * Textures to keep.
  118203. */
  118204. textures: BaseTexture[];
  118205. /**
  118206. * Environment texture for the scene
  118207. */
  118208. environmentTexture: Nullable<BaseTexture>;
  118209. /**
  118210. * @returns all meshes, lights, cameras, transformNodes and bones
  118211. */
  118212. getNodes(): Array<Node>;
  118213. }
  118214. }
  118215. declare module BABYLON {
  118216. /**
  118217. * Interface used to define options for Sound class
  118218. */
  118219. export interface ISoundOptions {
  118220. /**
  118221. * Does the sound autoplay once loaded.
  118222. */
  118223. autoplay?: boolean;
  118224. /**
  118225. * Does the sound loop after it finishes playing once.
  118226. */
  118227. loop?: boolean;
  118228. /**
  118229. * Sound's volume
  118230. */
  118231. volume?: number;
  118232. /**
  118233. * Is it a spatial sound?
  118234. */
  118235. spatialSound?: boolean;
  118236. /**
  118237. * Maximum distance to hear that sound
  118238. */
  118239. maxDistance?: number;
  118240. /**
  118241. * Uses user defined attenuation function
  118242. */
  118243. useCustomAttenuation?: boolean;
  118244. /**
  118245. * Define the roll off factor of spatial sounds.
  118246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118247. */
  118248. rolloffFactor?: number;
  118249. /**
  118250. * Define the reference distance the sound should be heard perfectly.
  118251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118252. */
  118253. refDistance?: number;
  118254. /**
  118255. * Define the distance attenuation model the sound will follow.
  118256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118257. */
  118258. distanceModel?: string;
  118259. /**
  118260. * Defines the playback speed (1 by default)
  118261. */
  118262. playbackRate?: number;
  118263. /**
  118264. * Defines if the sound is from a streaming source
  118265. */
  118266. streaming?: boolean;
  118267. /**
  118268. * Defines an optional length (in seconds) inside the sound file
  118269. */
  118270. length?: number;
  118271. /**
  118272. * Defines an optional offset (in seconds) inside the sound file
  118273. */
  118274. offset?: number;
  118275. /**
  118276. * If true, URLs will not be required to state the audio file codec to use.
  118277. */
  118278. skipCodecCheck?: boolean;
  118279. }
  118280. /**
  118281. * Defines a sound that can be played in the application.
  118282. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118284. */
  118285. export class Sound {
  118286. /**
  118287. * The name of the sound in the scene.
  118288. */
  118289. name: string;
  118290. /**
  118291. * Does the sound autoplay once loaded.
  118292. */
  118293. autoplay: boolean;
  118294. /**
  118295. * Does the sound loop after it finishes playing once.
  118296. */
  118297. loop: boolean;
  118298. /**
  118299. * Does the sound use a custom attenuation curve to simulate the falloff
  118300. * happening when the source gets further away from the camera.
  118301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118302. */
  118303. useCustomAttenuation: boolean;
  118304. /**
  118305. * The sound track id this sound belongs to.
  118306. */
  118307. soundTrackId: number;
  118308. /**
  118309. * Is this sound currently played.
  118310. */
  118311. isPlaying: boolean;
  118312. /**
  118313. * Is this sound currently paused.
  118314. */
  118315. isPaused: boolean;
  118316. /**
  118317. * Does this sound enables spatial sound.
  118318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118319. */
  118320. spatialSound: boolean;
  118321. /**
  118322. * Define the reference distance the sound should be heard perfectly.
  118323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118324. */
  118325. refDistance: number;
  118326. /**
  118327. * Define the roll off factor of spatial sounds.
  118328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118329. */
  118330. rolloffFactor: number;
  118331. /**
  118332. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118334. */
  118335. maxDistance: number;
  118336. /**
  118337. * Define the distance attenuation model the sound will follow.
  118338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118339. */
  118340. distanceModel: string;
  118341. /**
  118342. * @hidden
  118343. * Back Compat
  118344. **/
  118345. onended: () => any;
  118346. /**
  118347. * Gets or sets an object used to store user defined information for the sound.
  118348. */
  118349. metadata: any;
  118350. /**
  118351. * Observable event when the current playing sound finishes.
  118352. */
  118353. onEndedObservable: Observable<Sound>;
  118354. private _panningModel;
  118355. private _playbackRate;
  118356. private _streaming;
  118357. private _startTime;
  118358. private _startOffset;
  118359. private _position;
  118360. /** @hidden */
  118361. _positionInEmitterSpace: boolean;
  118362. private _localDirection;
  118363. private _volume;
  118364. private _isReadyToPlay;
  118365. private _isDirectional;
  118366. private _readyToPlayCallback;
  118367. private _audioBuffer;
  118368. private _soundSource;
  118369. private _streamingSource;
  118370. private _soundPanner;
  118371. private _soundGain;
  118372. private _inputAudioNode;
  118373. private _outputAudioNode;
  118374. private _coneInnerAngle;
  118375. private _coneOuterAngle;
  118376. private _coneOuterGain;
  118377. private _scene;
  118378. private _connectedTransformNode;
  118379. private _customAttenuationFunction;
  118380. private _registerFunc;
  118381. private _isOutputConnected;
  118382. private _htmlAudioElement;
  118383. private _urlType;
  118384. private _length?;
  118385. private _offset?;
  118386. /** @hidden */
  118387. static _SceneComponentInitialization: (scene: Scene) => void;
  118388. /**
  118389. * Create a sound and attach it to a scene
  118390. * @param name Name of your sound
  118391. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118392. * @param scene defines the scene the sound belongs to
  118393. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118394. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118395. */
  118396. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118397. /**
  118398. * Release the sound and its associated resources
  118399. */
  118400. dispose(): void;
  118401. /**
  118402. * Gets if the sounds is ready to be played or not.
  118403. * @returns true if ready, otherwise false
  118404. */
  118405. isReady(): boolean;
  118406. private _soundLoaded;
  118407. /**
  118408. * Sets the data of the sound from an audiobuffer
  118409. * @param audioBuffer The audioBuffer containing the data
  118410. */
  118411. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118412. /**
  118413. * Updates the current sounds options such as maxdistance, loop...
  118414. * @param options A JSON object containing values named as the object properties
  118415. */
  118416. updateOptions(options: ISoundOptions): void;
  118417. private _createSpatialParameters;
  118418. private _updateSpatialParameters;
  118419. /**
  118420. * Switch the panning model to HRTF:
  118421. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118423. */
  118424. switchPanningModelToHRTF(): void;
  118425. /**
  118426. * Switch the panning model to Equal Power:
  118427. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118429. */
  118430. switchPanningModelToEqualPower(): void;
  118431. private _switchPanningModel;
  118432. /**
  118433. * Connect this sound to a sound track audio node like gain...
  118434. * @param soundTrackAudioNode the sound track audio node to connect to
  118435. */
  118436. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118437. /**
  118438. * Transform this sound into a directional source
  118439. * @param coneInnerAngle Size of the inner cone in degree
  118440. * @param coneOuterAngle Size of the outer cone in degree
  118441. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118442. */
  118443. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118444. /**
  118445. * Gets or sets the inner angle for the directional cone.
  118446. */
  118447. get directionalConeInnerAngle(): number;
  118448. /**
  118449. * Gets or sets the inner angle for the directional cone.
  118450. */
  118451. set directionalConeInnerAngle(value: number);
  118452. /**
  118453. * Gets or sets the outer angle for the directional cone.
  118454. */
  118455. get directionalConeOuterAngle(): number;
  118456. /**
  118457. * Gets or sets the outer angle for the directional cone.
  118458. */
  118459. set directionalConeOuterAngle(value: number);
  118460. /**
  118461. * Sets the position of the emitter if spatial sound is enabled
  118462. * @param newPosition Defines the new posisiton
  118463. */
  118464. setPosition(newPosition: Vector3): void;
  118465. /**
  118466. * Sets the local direction of the emitter if spatial sound is enabled
  118467. * @param newLocalDirection Defines the new local direction
  118468. */
  118469. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118470. private _updateDirection;
  118471. /** @hidden */
  118472. updateDistanceFromListener(): void;
  118473. /**
  118474. * Sets a new custom attenuation function for the sound.
  118475. * @param callback Defines the function used for the attenuation
  118476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118477. */
  118478. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118479. /**
  118480. * Play the sound
  118481. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118482. * @param offset (optional) Start the sound at a specific time in seconds
  118483. * @param length (optional) Sound duration (in seconds)
  118484. */
  118485. play(time?: number, offset?: number, length?: number): void;
  118486. private _onended;
  118487. /**
  118488. * Stop the sound
  118489. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118490. */
  118491. stop(time?: number): void;
  118492. /**
  118493. * Put the sound in pause
  118494. */
  118495. pause(): void;
  118496. /**
  118497. * Sets a dedicated volume for this sounds
  118498. * @param newVolume Define the new volume of the sound
  118499. * @param time Define time for gradual change to new volume
  118500. */
  118501. setVolume(newVolume: number, time?: number): void;
  118502. /**
  118503. * Set the sound play back rate
  118504. * @param newPlaybackRate Define the playback rate the sound should be played at
  118505. */
  118506. setPlaybackRate(newPlaybackRate: number): void;
  118507. /**
  118508. * Gets the volume of the sound.
  118509. * @returns the volume of the sound
  118510. */
  118511. getVolume(): number;
  118512. /**
  118513. * Attach the sound to a dedicated mesh
  118514. * @param transformNode The transform node to connect the sound with
  118515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118516. */
  118517. attachToMesh(transformNode: TransformNode): void;
  118518. /**
  118519. * Detach the sound from the previously attached mesh
  118520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118521. */
  118522. detachFromMesh(): void;
  118523. private _onRegisterAfterWorldMatrixUpdate;
  118524. /**
  118525. * Clone the current sound in the scene.
  118526. * @returns the new sound clone
  118527. */
  118528. clone(): Nullable<Sound>;
  118529. /**
  118530. * Gets the current underlying audio buffer containing the data
  118531. * @returns the audio buffer
  118532. */
  118533. getAudioBuffer(): Nullable<AudioBuffer>;
  118534. /**
  118535. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118536. * @returns the source node
  118537. */
  118538. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118539. /**
  118540. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118541. * @returns the gain node
  118542. */
  118543. getSoundGain(): Nullable<GainNode>;
  118544. /**
  118545. * Serializes the Sound in a JSON representation
  118546. * @returns the JSON representation of the sound
  118547. */
  118548. serialize(): any;
  118549. /**
  118550. * Parse a JSON representation of a sound to innstantiate in a given scene
  118551. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118552. * @param scene Define the scene the new parsed sound should be created in
  118553. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118554. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118555. * @returns the newly parsed sound
  118556. */
  118557. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118558. }
  118559. }
  118560. declare module BABYLON {
  118561. /**
  118562. * This defines an action helpful to play a defined sound on a triggered action.
  118563. */
  118564. export class PlaySoundAction extends Action {
  118565. private _sound;
  118566. /**
  118567. * Instantiate the action
  118568. * @param triggerOptions defines the trigger options
  118569. * @param sound defines the sound to play
  118570. * @param condition defines the trigger related conditions
  118571. */
  118572. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118573. /** @hidden */
  118574. _prepare(): void;
  118575. /**
  118576. * Execute the action and play the sound.
  118577. */
  118578. execute(): void;
  118579. /**
  118580. * Serializes the actions and its related information.
  118581. * @param parent defines the object to serialize in
  118582. * @returns the serialized object
  118583. */
  118584. serialize(parent: any): any;
  118585. }
  118586. /**
  118587. * This defines an action helpful to stop a defined sound on a triggered action.
  118588. */
  118589. export class StopSoundAction extends Action {
  118590. private _sound;
  118591. /**
  118592. * Instantiate the action
  118593. * @param triggerOptions defines the trigger options
  118594. * @param sound defines the sound to stop
  118595. * @param condition defines the trigger related conditions
  118596. */
  118597. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118598. /** @hidden */
  118599. _prepare(): void;
  118600. /**
  118601. * Execute the action and stop the sound.
  118602. */
  118603. execute(): void;
  118604. /**
  118605. * Serializes the actions and its related information.
  118606. * @param parent defines the object to serialize in
  118607. * @returns the serialized object
  118608. */
  118609. serialize(parent: any): any;
  118610. }
  118611. }
  118612. declare module BABYLON {
  118613. /**
  118614. * This defines an action responsible to change the value of a property
  118615. * by interpolating between its current value and the newly set one once triggered.
  118616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118617. */
  118618. export class InterpolateValueAction extends Action {
  118619. /**
  118620. * Defines the path of the property where the value should be interpolated
  118621. */
  118622. propertyPath: string;
  118623. /**
  118624. * Defines the target value at the end of the interpolation.
  118625. */
  118626. value: any;
  118627. /**
  118628. * Defines the time it will take for the property to interpolate to the value.
  118629. */
  118630. duration: number;
  118631. /**
  118632. * Defines if the other scene animations should be stopped when the action has been triggered
  118633. */
  118634. stopOtherAnimations?: boolean;
  118635. /**
  118636. * Defines a callback raised once the interpolation animation has been done.
  118637. */
  118638. onInterpolationDone?: () => void;
  118639. /**
  118640. * Observable triggered once the interpolation animation has been done.
  118641. */
  118642. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118643. private _target;
  118644. private _effectiveTarget;
  118645. private _property;
  118646. /**
  118647. * Instantiate the action
  118648. * @param triggerOptions defines the trigger options
  118649. * @param target defines the object containing the value to interpolate
  118650. * @param propertyPath defines the path to the property in the target object
  118651. * @param value defines the target value at the end of the interpolation
  118652. * @param duration deines the time it will take for the property to interpolate to the value.
  118653. * @param condition defines the trigger related conditions
  118654. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118655. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118656. */
  118657. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118658. /** @hidden */
  118659. _prepare(): void;
  118660. /**
  118661. * Execute the action starts the value interpolation.
  118662. */
  118663. execute(): void;
  118664. /**
  118665. * Serializes the actions and its related information.
  118666. * @param parent defines the object to serialize in
  118667. * @returns the serialized object
  118668. */
  118669. serialize(parent: any): any;
  118670. }
  118671. }
  118672. declare module BABYLON {
  118673. /**
  118674. * Options allowed during the creation of a sound track.
  118675. */
  118676. export interface ISoundTrackOptions {
  118677. /**
  118678. * The volume the sound track should take during creation
  118679. */
  118680. volume?: number;
  118681. /**
  118682. * Define if the sound track is the main sound track of the scene
  118683. */
  118684. mainTrack?: boolean;
  118685. }
  118686. /**
  118687. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118688. * It will be also used in a future release to apply effects on a specific track.
  118689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118690. */
  118691. export class SoundTrack {
  118692. /**
  118693. * The unique identifier of the sound track in the scene.
  118694. */
  118695. id: number;
  118696. /**
  118697. * The list of sounds included in the sound track.
  118698. */
  118699. soundCollection: Array<Sound>;
  118700. private _outputAudioNode;
  118701. private _scene;
  118702. private _connectedAnalyser;
  118703. private _options;
  118704. private _isInitialized;
  118705. /**
  118706. * Creates a new sound track.
  118707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118708. * @param scene Define the scene the sound track belongs to
  118709. * @param options
  118710. */
  118711. constructor(scene: Scene, options?: ISoundTrackOptions);
  118712. private _initializeSoundTrackAudioGraph;
  118713. /**
  118714. * Release the sound track and its associated resources
  118715. */
  118716. dispose(): void;
  118717. /**
  118718. * Adds a sound to this sound track
  118719. * @param sound define the cound to add
  118720. * @ignoreNaming
  118721. */
  118722. AddSound(sound: Sound): void;
  118723. /**
  118724. * Removes a sound to this sound track
  118725. * @param sound define the cound to remove
  118726. * @ignoreNaming
  118727. */
  118728. RemoveSound(sound: Sound): void;
  118729. /**
  118730. * Set a global volume for the full sound track.
  118731. * @param newVolume Define the new volume of the sound track
  118732. */
  118733. setVolume(newVolume: number): void;
  118734. /**
  118735. * Switch the panning model to HRTF:
  118736. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118738. */
  118739. switchPanningModelToHRTF(): void;
  118740. /**
  118741. * Switch the panning model to Equal Power:
  118742. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118744. */
  118745. switchPanningModelToEqualPower(): void;
  118746. /**
  118747. * Connect the sound track to an audio analyser allowing some amazing
  118748. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118750. * @param analyser The analyser to connect to the engine
  118751. */
  118752. connectToAnalyser(analyser: Analyser): void;
  118753. }
  118754. }
  118755. declare module BABYLON {
  118756. interface AbstractScene {
  118757. /**
  118758. * The list of sounds used in the scene.
  118759. */
  118760. sounds: Nullable<Array<Sound>>;
  118761. }
  118762. interface Scene {
  118763. /**
  118764. * @hidden
  118765. * Backing field
  118766. */
  118767. _mainSoundTrack: SoundTrack;
  118768. /**
  118769. * The main sound track played by the scene.
  118770. * It cotains your primary collection of sounds.
  118771. */
  118772. mainSoundTrack: SoundTrack;
  118773. /**
  118774. * The list of sound tracks added to the scene
  118775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118776. */
  118777. soundTracks: Nullable<Array<SoundTrack>>;
  118778. /**
  118779. * Gets a sound using a given name
  118780. * @param name defines the name to search for
  118781. * @return the found sound or null if not found at all.
  118782. */
  118783. getSoundByName(name: string): Nullable<Sound>;
  118784. /**
  118785. * Gets or sets if audio support is enabled
  118786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118787. */
  118788. audioEnabled: boolean;
  118789. /**
  118790. * Gets or sets if audio will be output to headphones
  118791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118792. */
  118793. headphone: boolean;
  118794. /**
  118795. * Gets or sets custom audio listener position provider
  118796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118797. */
  118798. audioListenerPositionProvider: Nullable<() => Vector3>;
  118799. /**
  118800. * Gets or sets a refresh rate when using 3D audio positioning
  118801. */
  118802. audioPositioningRefreshRate: number;
  118803. }
  118804. /**
  118805. * Defines the sound scene component responsible to manage any sounds
  118806. * in a given scene.
  118807. */
  118808. export class AudioSceneComponent implements ISceneSerializableComponent {
  118809. /**
  118810. * The component name helpfull to identify the component in the list of scene components.
  118811. */
  118812. readonly name: string;
  118813. /**
  118814. * The scene the component belongs to.
  118815. */
  118816. scene: Scene;
  118817. private _audioEnabled;
  118818. /**
  118819. * Gets whether audio is enabled or not.
  118820. * Please use related enable/disable method to switch state.
  118821. */
  118822. get audioEnabled(): boolean;
  118823. private _headphone;
  118824. /**
  118825. * Gets whether audio is outputing to headphone or not.
  118826. * Please use the according Switch methods to change output.
  118827. */
  118828. get headphone(): boolean;
  118829. /**
  118830. * Gets or sets a refresh rate when using 3D audio positioning
  118831. */
  118832. audioPositioningRefreshRate: number;
  118833. private _audioListenerPositionProvider;
  118834. /**
  118835. * Gets the current audio listener position provider
  118836. */
  118837. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118838. /**
  118839. * Sets a custom listener position for all sounds in the scene
  118840. * By default, this is the position of the first active camera
  118841. */
  118842. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118843. /**
  118844. * Creates a new instance of the component for the given scene
  118845. * @param scene Defines the scene to register the component in
  118846. */
  118847. constructor(scene: Scene);
  118848. /**
  118849. * Registers the component in a given scene
  118850. */
  118851. register(): void;
  118852. /**
  118853. * Rebuilds the elements related to this component in case of
  118854. * context lost for instance.
  118855. */
  118856. rebuild(): void;
  118857. /**
  118858. * Serializes the component data to the specified json object
  118859. * @param serializationObject The object to serialize to
  118860. */
  118861. serialize(serializationObject: any): void;
  118862. /**
  118863. * Adds all the elements from the container to the scene
  118864. * @param container the container holding the elements
  118865. */
  118866. addFromContainer(container: AbstractScene): void;
  118867. /**
  118868. * Removes all the elements in the container from the scene
  118869. * @param container contains the elements to remove
  118870. * @param dispose if the removed element should be disposed (default: false)
  118871. */
  118872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118873. /**
  118874. * Disposes the component and the associated ressources.
  118875. */
  118876. dispose(): void;
  118877. /**
  118878. * Disables audio in the associated scene.
  118879. */
  118880. disableAudio(): void;
  118881. /**
  118882. * Enables audio in the associated scene.
  118883. */
  118884. enableAudio(): void;
  118885. /**
  118886. * Switch audio to headphone output.
  118887. */
  118888. switchAudioModeForHeadphones(): void;
  118889. /**
  118890. * Switch audio to normal speakers.
  118891. */
  118892. switchAudioModeForNormalSpeakers(): void;
  118893. private _cachedCameraDirection;
  118894. private _cachedCameraPosition;
  118895. private _lastCheck;
  118896. private _afterRender;
  118897. }
  118898. }
  118899. declare module BABYLON {
  118900. /**
  118901. * Wraps one or more Sound objects and selects one with random weight for playback.
  118902. */
  118903. export class WeightedSound {
  118904. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118905. loop: boolean;
  118906. private _coneInnerAngle;
  118907. private _coneOuterAngle;
  118908. private _volume;
  118909. /** A Sound is currently playing. */
  118910. isPlaying: boolean;
  118911. /** A Sound is currently paused. */
  118912. isPaused: boolean;
  118913. private _sounds;
  118914. private _weights;
  118915. private _currentIndex?;
  118916. /**
  118917. * Creates a new WeightedSound from the list of sounds given.
  118918. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118919. * @param sounds Array of Sounds that will be selected from.
  118920. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118921. */
  118922. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118923. /**
  118924. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118925. */
  118926. get directionalConeInnerAngle(): number;
  118927. /**
  118928. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118929. */
  118930. set directionalConeInnerAngle(value: number);
  118931. /**
  118932. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118933. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118934. */
  118935. get directionalConeOuterAngle(): number;
  118936. /**
  118937. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118938. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118939. */
  118940. set directionalConeOuterAngle(value: number);
  118941. /**
  118942. * Playback volume.
  118943. */
  118944. get volume(): number;
  118945. /**
  118946. * Playback volume.
  118947. */
  118948. set volume(value: number);
  118949. private _onended;
  118950. /**
  118951. * Suspend playback
  118952. */
  118953. pause(): void;
  118954. /**
  118955. * Stop playback
  118956. */
  118957. stop(): void;
  118958. /**
  118959. * Start playback.
  118960. * @param startOffset Position the clip head at a specific time in seconds.
  118961. */
  118962. play(startOffset?: number): void;
  118963. }
  118964. }
  118965. declare module BABYLON {
  118966. /**
  118967. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118968. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118969. */
  118970. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118971. /**
  118972. * Gets the name of the behavior.
  118973. */
  118974. get name(): string;
  118975. /**
  118976. * The easing function used by animations
  118977. */
  118978. static EasingFunction: BackEase;
  118979. /**
  118980. * The easing mode used by animations
  118981. */
  118982. static EasingMode: number;
  118983. /**
  118984. * The duration of the animation, in milliseconds
  118985. */
  118986. transitionDuration: number;
  118987. /**
  118988. * Length of the distance animated by the transition when lower radius is reached
  118989. */
  118990. lowerRadiusTransitionRange: number;
  118991. /**
  118992. * Length of the distance animated by the transition when upper radius is reached
  118993. */
  118994. upperRadiusTransitionRange: number;
  118995. private _autoTransitionRange;
  118996. /**
  118997. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118998. */
  118999. get autoTransitionRange(): boolean;
  119000. /**
  119001. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119002. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119003. */
  119004. set autoTransitionRange(value: boolean);
  119005. private _attachedCamera;
  119006. private _onAfterCheckInputsObserver;
  119007. private _onMeshTargetChangedObserver;
  119008. /**
  119009. * Initializes the behavior.
  119010. */
  119011. init(): void;
  119012. /**
  119013. * Attaches the behavior to its arc rotate camera.
  119014. * @param camera Defines the camera to attach the behavior to
  119015. */
  119016. attach(camera: ArcRotateCamera): void;
  119017. /**
  119018. * Detaches the behavior from its current arc rotate camera.
  119019. */
  119020. detach(): void;
  119021. private _radiusIsAnimating;
  119022. private _radiusBounceTransition;
  119023. private _animatables;
  119024. private _cachedWheelPrecision;
  119025. /**
  119026. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119027. * @param radiusLimit The limit to check against.
  119028. * @return Bool to indicate if at limit.
  119029. */
  119030. private _isRadiusAtLimit;
  119031. /**
  119032. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119033. * @param radiusDelta The delta by which to animate to. Can be negative.
  119034. */
  119035. private _applyBoundRadiusAnimation;
  119036. /**
  119037. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119038. */
  119039. protected _clearAnimationLocks(): void;
  119040. /**
  119041. * Stops and removes all animations that have been applied to the camera
  119042. */
  119043. stopAllAnimations(): void;
  119044. }
  119045. }
  119046. declare module BABYLON {
  119047. /**
  119048. * 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.
  119049. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119050. */
  119051. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119052. /**
  119053. * Gets the name of the behavior.
  119054. */
  119055. get name(): string;
  119056. private _mode;
  119057. private _radiusScale;
  119058. private _positionScale;
  119059. private _defaultElevation;
  119060. private _elevationReturnTime;
  119061. private _elevationReturnWaitTime;
  119062. private _zoomStopsAnimation;
  119063. private _framingTime;
  119064. /**
  119065. * The easing function used by animations
  119066. */
  119067. static EasingFunction: ExponentialEase;
  119068. /**
  119069. * The easing mode used by animations
  119070. */
  119071. static EasingMode: number;
  119072. /**
  119073. * Sets the current mode used by the behavior
  119074. */
  119075. set mode(mode: number);
  119076. /**
  119077. * Gets current mode used by the behavior.
  119078. */
  119079. get mode(): number;
  119080. /**
  119081. * Sets the scale applied to the radius (1 by default)
  119082. */
  119083. set radiusScale(radius: number);
  119084. /**
  119085. * Gets the scale applied to the radius
  119086. */
  119087. get radiusScale(): number;
  119088. /**
  119089. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119090. */
  119091. set positionScale(scale: number);
  119092. /**
  119093. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119094. */
  119095. get positionScale(): number;
  119096. /**
  119097. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119098. * behaviour is triggered, in radians.
  119099. */
  119100. set defaultElevation(elevation: number);
  119101. /**
  119102. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119103. * behaviour is triggered, in radians.
  119104. */
  119105. get defaultElevation(): number;
  119106. /**
  119107. * Sets the time (in milliseconds) taken to return to the default beta position.
  119108. * Negative value indicates camera should not return to default.
  119109. */
  119110. set elevationReturnTime(speed: number);
  119111. /**
  119112. * Gets the time (in milliseconds) taken to return to the default beta position.
  119113. * Negative value indicates camera should not return to default.
  119114. */
  119115. get elevationReturnTime(): number;
  119116. /**
  119117. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119118. */
  119119. set elevationReturnWaitTime(time: number);
  119120. /**
  119121. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119122. */
  119123. get elevationReturnWaitTime(): number;
  119124. /**
  119125. * Sets the flag that indicates if user zooming should stop animation.
  119126. */
  119127. set zoomStopsAnimation(flag: boolean);
  119128. /**
  119129. * Gets the flag that indicates if user zooming should stop animation.
  119130. */
  119131. get zoomStopsAnimation(): boolean;
  119132. /**
  119133. * Sets the transition time when framing the mesh, in milliseconds
  119134. */
  119135. set framingTime(time: number);
  119136. /**
  119137. * Gets the transition time when framing the mesh, in milliseconds
  119138. */
  119139. get framingTime(): number;
  119140. /**
  119141. * Define if the behavior should automatically change the configured
  119142. * camera limits and sensibilities.
  119143. */
  119144. autoCorrectCameraLimitsAndSensibility: boolean;
  119145. private _onPrePointerObservableObserver;
  119146. private _onAfterCheckInputsObserver;
  119147. private _onMeshTargetChangedObserver;
  119148. private _attachedCamera;
  119149. private _isPointerDown;
  119150. private _lastInteractionTime;
  119151. /**
  119152. * Initializes the behavior.
  119153. */
  119154. init(): void;
  119155. /**
  119156. * Attaches the behavior to its arc rotate camera.
  119157. * @param camera Defines the camera to attach the behavior to
  119158. */
  119159. attach(camera: ArcRotateCamera): void;
  119160. /**
  119161. * Detaches the behavior from its current arc rotate camera.
  119162. */
  119163. detach(): void;
  119164. private _animatables;
  119165. private _betaIsAnimating;
  119166. private _betaTransition;
  119167. private _radiusTransition;
  119168. private _vectorTransition;
  119169. /**
  119170. * Targets the given mesh and updates zoom level accordingly.
  119171. * @param mesh The mesh to target.
  119172. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119173. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119174. */
  119175. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119176. /**
  119177. * Targets the given mesh with its children and updates zoom level accordingly.
  119178. * @param mesh The mesh to target.
  119179. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119180. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119181. */
  119182. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119183. /**
  119184. * Targets the given meshes with their children and updates zoom level accordingly.
  119185. * @param meshes The mesh to target.
  119186. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119187. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119188. */
  119189. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119190. /**
  119191. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119192. * @param minimumWorld Determines the smaller position of the bounding box extend
  119193. * @param maximumWorld Determines the bigger position of the bounding box extend
  119194. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119195. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119196. */
  119197. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119198. /**
  119199. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119200. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119201. * frustum width.
  119202. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119203. * to fully enclose the mesh in the viewing frustum.
  119204. */
  119205. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119206. /**
  119207. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119208. * is automatically returned to its default position (expected to be above ground plane).
  119209. */
  119210. private _maintainCameraAboveGround;
  119211. /**
  119212. * Returns the frustum slope based on the canvas ratio and camera FOV
  119213. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119214. */
  119215. private _getFrustumSlope;
  119216. /**
  119217. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119218. */
  119219. private _clearAnimationLocks;
  119220. /**
  119221. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119222. */
  119223. private _applyUserInteraction;
  119224. /**
  119225. * Stops and removes all animations that have been applied to the camera
  119226. */
  119227. stopAllAnimations(): void;
  119228. /**
  119229. * Gets a value indicating if the user is moving the camera
  119230. */
  119231. get isUserIsMoving(): boolean;
  119232. /**
  119233. * The camera can move all the way towards the mesh.
  119234. */
  119235. static IgnoreBoundsSizeMode: number;
  119236. /**
  119237. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119238. */
  119239. static FitFrustumSidesMode: number;
  119240. }
  119241. }
  119242. declare module BABYLON {
  119243. /**
  119244. * Base class for Camera Pointer Inputs.
  119245. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119246. * for example usage.
  119247. */
  119248. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119249. /**
  119250. * Defines the camera the input is attached to.
  119251. */
  119252. abstract camera: Camera;
  119253. /**
  119254. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119255. */
  119256. protected _altKey: boolean;
  119257. protected _ctrlKey: boolean;
  119258. protected _metaKey: boolean;
  119259. protected _shiftKey: boolean;
  119260. /**
  119261. * Which mouse buttons were pressed at time of last mouse event.
  119262. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119263. */
  119264. protected _buttonsPressed: number;
  119265. /**
  119266. * Defines the buttons associated with the input to handle camera move.
  119267. */
  119268. buttons: number[];
  119269. /**
  119270. * Attach the input controls to a specific dom element to get the input from.
  119271. * @param element Defines the element the controls should be listened from
  119272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119273. */
  119274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119275. /**
  119276. * Detach the current controls from the specified dom element.
  119277. * @param element Defines the element to stop listening the inputs from
  119278. */
  119279. detachControl(element: Nullable<HTMLElement>): void;
  119280. /**
  119281. * Gets the class name of the current input.
  119282. * @returns the class name
  119283. */
  119284. getClassName(): string;
  119285. /**
  119286. * Get the friendly name associated with the input class.
  119287. * @returns the input friendly name
  119288. */
  119289. getSimpleName(): string;
  119290. /**
  119291. * Called on pointer POINTERDOUBLETAP event.
  119292. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119293. */
  119294. protected onDoubleTap(type: string): void;
  119295. /**
  119296. * Called on pointer POINTERMOVE event if only a single touch is active.
  119297. * Override this method to provide functionality.
  119298. */
  119299. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119300. /**
  119301. * Called on pointer POINTERMOVE event if multiple touches are active.
  119302. * Override this method to provide functionality.
  119303. */
  119304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119305. /**
  119306. * Called on JS contextmenu event.
  119307. * Override this method to provide functionality.
  119308. */
  119309. protected onContextMenu(evt: PointerEvent): void;
  119310. /**
  119311. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119312. * press.
  119313. * Override this method to provide functionality.
  119314. */
  119315. protected onButtonDown(evt: PointerEvent): void;
  119316. /**
  119317. * Called each time a new POINTERUP event occurs. Ie, for each button
  119318. * release.
  119319. * Override this method to provide functionality.
  119320. */
  119321. protected onButtonUp(evt: PointerEvent): void;
  119322. /**
  119323. * Called when window becomes inactive.
  119324. * Override this method to provide functionality.
  119325. */
  119326. protected onLostFocus(): void;
  119327. private _pointerInput;
  119328. private _observer;
  119329. private _onLostFocus;
  119330. private pointA;
  119331. private pointB;
  119332. }
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * Manage the pointers inputs to control an arc rotate camera.
  119337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119338. */
  119339. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119340. /**
  119341. * Defines the camera the input is attached to.
  119342. */
  119343. camera: ArcRotateCamera;
  119344. /**
  119345. * Gets the class name of the current input.
  119346. * @returns the class name
  119347. */
  119348. getClassName(): string;
  119349. /**
  119350. * Defines the buttons associated with the input to handle camera move.
  119351. */
  119352. buttons: number[];
  119353. /**
  119354. * Defines the pointer angular sensibility along the X axis or how fast is
  119355. * the camera rotating.
  119356. */
  119357. angularSensibilityX: number;
  119358. /**
  119359. * Defines the pointer angular sensibility along the Y axis or how fast is
  119360. * the camera rotating.
  119361. */
  119362. angularSensibilityY: number;
  119363. /**
  119364. * Defines the pointer pinch precision or how fast is the camera zooming.
  119365. */
  119366. pinchPrecision: number;
  119367. /**
  119368. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119369. * from 0.
  119370. * It defines the percentage of current camera.radius to use as delta when
  119371. * pinch zoom is used.
  119372. */
  119373. pinchDeltaPercentage: number;
  119374. /**
  119375. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119376. * that any object in the plane at the camera's target point will scale
  119377. * perfectly with finger motion.
  119378. * Overrides pinchDeltaPercentage and pinchPrecision.
  119379. */
  119380. useNaturalPinchZoom: boolean;
  119381. /**
  119382. * Defines the pointer panning sensibility or how fast is the camera moving.
  119383. */
  119384. panningSensibility: number;
  119385. /**
  119386. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119387. */
  119388. multiTouchPanning: boolean;
  119389. /**
  119390. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119391. * zoom (pinch) through multitouch.
  119392. */
  119393. multiTouchPanAndZoom: boolean;
  119394. /**
  119395. * Revers pinch action direction.
  119396. */
  119397. pinchInwards: boolean;
  119398. private _isPanClick;
  119399. private _twoFingerActivityCount;
  119400. private _isPinching;
  119401. /**
  119402. * Called on pointer POINTERMOVE event if only a single touch is active.
  119403. */
  119404. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119405. /**
  119406. * Called on pointer POINTERDOUBLETAP event.
  119407. */
  119408. protected onDoubleTap(type: string): void;
  119409. /**
  119410. * Called on pointer POINTERMOVE event if multiple touches are active.
  119411. */
  119412. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119413. /**
  119414. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119415. * press.
  119416. */
  119417. protected onButtonDown(evt: PointerEvent): void;
  119418. /**
  119419. * Called each time a new POINTERUP event occurs. Ie, for each button
  119420. * release.
  119421. */
  119422. protected onButtonUp(evt: PointerEvent): void;
  119423. /**
  119424. * Called when window becomes inactive.
  119425. */
  119426. protected onLostFocus(): void;
  119427. }
  119428. }
  119429. declare module BABYLON {
  119430. /**
  119431. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119433. */
  119434. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119435. /**
  119436. * Defines the camera the input is attached to.
  119437. */
  119438. camera: ArcRotateCamera;
  119439. /**
  119440. * Defines the list of key codes associated with the up action (increase alpha)
  119441. */
  119442. keysUp: number[];
  119443. /**
  119444. * Defines the list of key codes associated with the down action (decrease alpha)
  119445. */
  119446. keysDown: number[];
  119447. /**
  119448. * Defines the list of key codes associated with the left action (increase beta)
  119449. */
  119450. keysLeft: number[];
  119451. /**
  119452. * Defines the list of key codes associated with the right action (decrease beta)
  119453. */
  119454. keysRight: number[];
  119455. /**
  119456. * Defines the list of key codes associated with the reset action.
  119457. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119458. */
  119459. keysReset: number[];
  119460. /**
  119461. * Defines the panning sensibility of the inputs.
  119462. * (How fast is the camera panning)
  119463. */
  119464. panningSensibility: number;
  119465. /**
  119466. * Defines the zooming sensibility of the inputs.
  119467. * (How fast is the camera zooming)
  119468. */
  119469. zoomingSensibility: number;
  119470. /**
  119471. * Defines whether maintaining the alt key down switch the movement mode from
  119472. * orientation to zoom.
  119473. */
  119474. useAltToZoom: boolean;
  119475. /**
  119476. * Rotation speed of the camera
  119477. */
  119478. angularSpeed: number;
  119479. private _keys;
  119480. private _ctrlPressed;
  119481. private _altPressed;
  119482. private _onCanvasBlurObserver;
  119483. private _onKeyboardObserver;
  119484. private _engine;
  119485. private _scene;
  119486. /**
  119487. * Attach the input controls to a specific dom element to get the input from.
  119488. * @param element Defines the element the controls should be listened from
  119489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119490. */
  119491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119492. /**
  119493. * Detach the current controls from the specified dom element.
  119494. * @param element Defines the element to stop listening the inputs from
  119495. */
  119496. detachControl(element: Nullable<HTMLElement>): void;
  119497. /**
  119498. * Update the current camera state depending on the inputs that have been used this frame.
  119499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119500. */
  119501. checkInputs(): void;
  119502. /**
  119503. * Gets the class name of the current intput.
  119504. * @returns the class name
  119505. */
  119506. getClassName(): string;
  119507. /**
  119508. * Get the friendly name associated with the input class.
  119509. * @returns the input friendly name
  119510. */
  119511. getSimpleName(): string;
  119512. }
  119513. }
  119514. declare module BABYLON {
  119515. /**
  119516. * Manage the mouse wheel inputs to control an arc rotate camera.
  119517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119518. */
  119519. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119520. /**
  119521. * Defines the camera the input is attached to.
  119522. */
  119523. camera: ArcRotateCamera;
  119524. /**
  119525. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119526. */
  119527. wheelPrecision: number;
  119528. /**
  119529. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119530. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119531. */
  119532. wheelDeltaPercentage: number;
  119533. private _wheel;
  119534. private _observer;
  119535. private computeDeltaFromMouseWheelLegacyEvent;
  119536. /**
  119537. * Attach the input controls to a specific dom element to get the input from.
  119538. * @param element Defines the element the controls should be listened from
  119539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119540. */
  119541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119542. /**
  119543. * Detach the current controls from the specified dom element.
  119544. * @param element Defines the element to stop listening the inputs from
  119545. */
  119546. detachControl(element: Nullable<HTMLElement>): void;
  119547. /**
  119548. * Gets the class name of the current intput.
  119549. * @returns the class name
  119550. */
  119551. getClassName(): string;
  119552. /**
  119553. * Get the friendly name associated with the input class.
  119554. * @returns the input friendly name
  119555. */
  119556. getSimpleName(): string;
  119557. }
  119558. }
  119559. declare module BABYLON {
  119560. /**
  119561. * Default Inputs manager for the ArcRotateCamera.
  119562. * It groups all the default supported inputs for ease of use.
  119563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119564. */
  119565. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119566. /**
  119567. * Instantiates a new ArcRotateCameraInputsManager.
  119568. * @param camera Defines the camera the inputs belong to
  119569. */
  119570. constructor(camera: ArcRotateCamera);
  119571. /**
  119572. * Add mouse wheel input support to the input manager.
  119573. * @returns the current input manager
  119574. */
  119575. addMouseWheel(): ArcRotateCameraInputsManager;
  119576. /**
  119577. * Add pointers input support to the input manager.
  119578. * @returns the current input manager
  119579. */
  119580. addPointers(): ArcRotateCameraInputsManager;
  119581. /**
  119582. * Add keyboard input support to the input manager.
  119583. * @returns the current input manager
  119584. */
  119585. addKeyboard(): ArcRotateCameraInputsManager;
  119586. }
  119587. }
  119588. declare module BABYLON {
  119589. /**
  119590. * This represents an orbital type of camera.
  119591. *
  119592. * 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.
  119593. * 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.
  119594. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119595. */
  119596. export class ArcRotateCamera extends TargetCamera {
  119597. /**
  119598. * Defines the rotation angle of the camera along the longitudinal axis.
  119599. */
  119600. alpha: number;
  119601. /**
  119602. * Defines the rotation angle of the camera along the latitudinal axis.
  119603. */
  119604. beta: number;
  119605. /**
  119606. * Defines the radius of the camera from it s target point.
  119607. */
  119608. radius: number;
  119609. protected _target: Vector3;
  119610. protected _targetHost: Nullable<AbstractMesh>;
  119611. /**
  119612. * Defines the target point of the camera.
  119613. * The camera looks towards it form the radius distance.
  119614. */
  119615. get target(): Vector3;
  119616. set target(value: Vector3);
  119617. /**
  119618. * Define the current local position of the camera in the scene
  119619. */
  119620. get position(): Vector3;
  119621. set position(newPosition: Vector3);
  119622. protected _upVector: Vector3;
  119623. protected _upToYMatrix: Matrix;
  119624. protected _YToUpMatrix: Matrix;
  119625. /**
  119626. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119627. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119628. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119629. */
  119630. set upVector(vec: Vector3);
  119631. get upVector(): Vector3;
  119632. /**
  119633. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119634. */
  119635. setMatUp(): void;
  119636. /**
  119637. * Current inertia value on the longitudinal axis.
  119638. * The bigger this number the longer it will take for the camera to stop.
  119639. */
  119640. inertialAlphaOffset: number;
  119641. /**
  119642. * Current inertia value on the latitudinal axis.
  119643. * The bigger this number the longer it will take for the camera to stop.
  119644. */
  119645. inertialBetaOffset: number;
  119646. /**
  119647. * Current inertia value on the radius axis.
  119648. * The bigger this number the longer it will take for the camera to stop.
  119649. */
  119650. inertialRadiusOffset: number;
  119651. /**
  119652. * Minimum allowed angle on the longitudinal axis.
  119653. * This can help limiting how the Camera is able to move in the scene.
  119654. */
  119655. lowerAlphaLimit: Nullable<number>;
  119656. /**
  119657. * Maximum allowed angle on the longitudinal axis.
  119658. * This can help limiting how the Camera is able to move in the scene.
  119659. */
  119660. upperAlphaLimit: Nullable<number>;
  119661. /**
  119662. * Minimum allowed angle on the latitudinal axis.
  119663. * This can help limiting how the Camera is able to move in the scene.
  119664. */
  119665. lowerBetaLimit: number;
  119666. /**
  119667. * Maximum allowed angle on the latitudinal axis.
  119668. * This can help limiting how the Camera is able to move in the scene.
  119669. */
  119670. upperBetaLimit: number;
  119671. /**
  119672. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119673. * This can help limiting how the Camera is able to move in the scene.
  119674. */
  119675. lowerRadiusLimit: Nullable<number>;
  119676. /**
  119677. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119678. * This can help limiting how the Camera is able to move in the scene.
  119679. */
  119680. upperRadiusLimit: Nullable<number>;
  119681. /**
  119682. * Defines the current inertia value used during panning of the camera along the X axis.
  119683. */
  119684. inertialPanningX: number;
  119685. /**
  119686. * Defines the current inertia value used during panning of the camera along the Y axis.
  119687. */
  119688. inertialPanningY: number;
  119689. /**
  119690. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119691. * Basically if your fingers moves away from more than this distance you will be considered
  119692. * in pinch mode.
  119693. */
  119694. pinchToPanMaxDistance: number;
  119695. /**
  119696. * Defines the maximum distance the camera can pan.
  119697. * This could help keeping the cammera always in your scene.
  119698. */
  119699. panningDistanceLimit: Nullable<number>;
  119700. /**
  119701. * Defines the target of the camera before paning.
  119702. */
  119703. panningOriginTarget: Vector3;
  119704. /**
  119705. * Defines the value of the inertia used during panning.
  119706. * 0 would mean stop inertia and one would mean no decelleration at all.
  119707. */
  119708. panningInertia: number;
  119709. /**
  119710. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119711. */
  119712. get angularSensibilityX(): number;
  119713. set angularSensibilityX(value: number);
  119714. /**
  119715. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119716. */
  119717. get angularSensibilityY(): number;
  119718. set angularSensibilityY(value: number);
  119719. /**
  119720. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119721. */
  119722. get pinchPrecision(): number;
  119723. set pinchPrecision(value: number);
  119724. /**
  119725. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119726. * It will be used instead of pinchDeltaPrecision if different from 0.
  119727. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119728. */
  119729. get pinchDeltaPercentage(): number;
  119730. set pinchDeltaPercentage(value: number);
  119731. /**
  119732. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119733. * and pinch delta percentage.
  119734. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119735. * that any object in the plane at the camera's target point will scale
  119736. * perfectly with finger motion.
  119737. */
  119738. get useNaturalPinchZoom(): boolean;
  119739. set useNaturalPinchZoom(value: boolean);
  119740. /**
  119741. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119742. */
  119743. get panningSensibility(): number;
  119744. set panningSensibility(value: number);
  119745. /**
  119746. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119747. */
  119748. get keysUp(): number[];
  119749. set keysUp(value: number[]);
  119750. /**
  119751. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119752. */
  119753. get keysDown(): number[];
  119754. set keysDown(value: number[]);
  119755. /**
  119756. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119757. */
  119758. get keysLeft(): number[];
  119759. set keysLeft(value: number[]);
  119760. /**
  119761. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119762. */
  119763. get keysRight(): number[];
  119764. set keysRight(value: number[]);
  119765. /**
  119766. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119767. */
  119768. get wheelPrecision(): number;
  119769. set wheelPrecision(value: number);
  119770. /**
  119771. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119772. * It will be used instead of pinchDeltaPrecision if different from 0.
  119773. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119774. */
  119775. get wheelDeltaPercentage(): number;
  119776. set wheelDeltaPercentage(value: number);
  119777. /**
  119778. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119779. */
  119780. zoomOnFactor: number;
  119781. /**
  119782. * Defines a screen offset for the camera position.
  119783. */
  119784. targetScreenOffset: Vector2;
  119785. /**
  119786. * Allows the camera to be completely reversed.
  119787. * If false the camera can not arrive upside down.
  119788. */
  119789. allowUpsideDown: boolean;
  119790. /**
  119791. * Define if double tap/click is used to restore the previously saved state of the camera.
  119792. */
  119793. useInputToRestoreState: boolean;
  119794. /** @hidden */
  119795. _viewMatrix: Matrix;
  119796. /** @hidden */
  119797. _useCtrlForPanning: boolean;
  119798. /** @hidden */
  119799. _panningMouseButton: number;
  119800. /**
  119801. * Defines the input associated to the camera.
  119802. */
  119803. inputs: ArcRotateCameraInputsManager;
  119804. /** @hidden */
  119805. _reset: () => void;
  119806. /**
  119807. * Defines the allowed panning axis.
  119808. */
  119809. panningAxis: Vector3;
  119810. protected _localDirection: Vector3;
  119811. protected _transformedDirection: Vector3;
  119812. private _bouncingBehavior;
  119813. /**
  119814. * Gets the bouncing behavior of the camera if it has been enabled.
  119815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119816. */
  119817. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119818. /**
  119819. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119821. */
  119822. get useBouncingBehavior(): boolean;
  119823. set useBouncingBehavior(value: boolean);
  119824. private _framingBehavior;
  119825. /**
  119826. * Gets the framing behavior of the camera if it has been enabled.
  119827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119828. */
  119829. get framingBehavior(): Nullable<FramingBehavior>;
  119830. /**
  119831. * Defines if the framing behavior of the camera is enabled on the camera.
  119832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119833. */
  119834. get useFramingBehavior(): boolean;
  119835. set useFramingBehavior(value: boolean);
  119836. private _autoRotationBehavior;
  119837. /**
  119838. * Gets the auto rotation behavior of the camera if it has been enabled.
  119839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119840. */
  119841. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119842. /**
  119843. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119845. */
  119846. get useAutoRotationBehavior(): boolean;
  119847. set useAutoRotationBehavior(value: boolean);
  119848. /**
  119849. * Observable triggered when the mesh target has been changed on the camera.
  119850. */
  119851. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119852. /**
  119853. * Event raised when the camera is colliding with a mesh.
  119854. */
  119855. onCollide: (collidedMesh: AbstractMesh) => void;
  119856. /**
  119857. * Defines whether the camera should check collision with the objects oh the scene.
  119858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119859. */
  119860. checkCollisions: boolean;
  119861. /**
  119862. * Defines the collision radius of the camera.
  119863. * This simulates a sphere around the camera.
  119864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119865. */
  119866. collisionRadius: Vector3;
  119867. protected _collider: Collider;
  119868. protected _previousPosition: Vector3;
  119869. protected _collisionVelocity: Vector3;
  119870. protected _newPosition: Vector3;
  119871. protected _previousAlpha: number;
  119872. protected _previousBeta: number;
  119873. protected _previousRadius: number;
  119874. protected _collisionTriggered: boolean;
  119875. protected _targetBoundingCenter: Nullable<Vector3>;
  119876. private _computationVector;
  119877. /**
  119878. * Instantiates a new ArcRotateCamera in a given scene
  119879. * @param name Defines the name of the camera
  119880. * @param alpha Defines the camera rotation along the logitudinal axis
  119881. * @param beta Defines the camera rotation along the latitudinal axis
  119882. * @param radius Defines the camera distance from its target
  119883. * @param target Defines the camera target
  119884. * @param scene Defines the scene the camera belongs to
  119885. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119886. */
  119887. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119888. /** @hidden */
  119889. _initCache(): void;
  119890. /** @hidden */
  119891. _updateCache(ignoreParentClass?: boolean): void;
  119892. protected _getTargetPosition(): Vector3;
  119893. private _storedAlpha;
  119894. private _storedBeta;
  119895. private _storedRadius;
  119896. private _storedTarget;
  119897. private _storedTargetScreenOffset;
  119898. /**
  119899. * Stores the current state of the camera (alpha, beta, radius and target)
  119900. * @returns the camera itself
  119901. */
  119902. storeState(): Camera;
  119903. /**
  119904. * @hidden
  119905. * Restored camera state. You must call storeState() first
  119906. */
  119907. _restoreStateValues(): boolean;
  119908. /** @hidden */
  119909. _isSynchronizedViewMatrix(): boolean;
  119910. /**
  119911. * Attached controls to the current camera.
  119912. * @param element Defines the element the controls should be listened from
  119913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119914. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119915. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119916. */
  119917. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119918. /**
  119919. * Detach the current controls from the camera.
  119920. * The camera will stop reacting to inputs.
  119921. * @param element Defines the element to stop listening the inputs from
  119922. */
  119923. detachControl(element: HTMLElement): void;
  119924. /** @hidden */
  119925. _checkInputs(): void;
  119926. protected _checkLimits(): void;
  119927. /**
  119928. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119929. */
  119930. rebuildAnglesAndRadius(): void;
  119931. /**
  119932. * Use a position to define the current camera related information like alpha, beta and radius
  119933. * @param position Defines the position to set the camera at
  119934. */
  119935. setPosition(position: Vector3): void;
  119936. /**
  119937. * Defines the target the camera should look at.
  119938. * This will automatically adapt alpha beta and radius to fit within the new target.
  119939. * @param target Defines the new target as a Vector or a mesh
  119940. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119941. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119942. */
  119943. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119944. /** @hidden */
  119945. _getViewMatrix(): Matrix;
  119946. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119947. /**
  119948. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119949. * @param meshes Defines the mesh to zoom on
  119950. * @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)
  119951. */
  119952. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119953. /**
  119954. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119955. * The target will be changed but the radius
  119956. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119957. * @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)
  119958. */
  119959. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119960. min: Vector3;
  119961. max: Vector3;
  119962. distance: number;
  119963. }, doNotUpdateMaxZ?: boolean): void;
  119964. /**
  119965. * @override
  119966. * Override Camera.createRigCamera
  119967. */
  119968. createRigCamera(name: string, cameraIndex: number): Camera;
  119969. /**
  119970. * @hidden
  119971. * @override
  119972. * Override Camera._updateRigCameras
  119973. */
  119974. _updateRigCameras(): void;
  119975. /**
  119976. * Destroy the camera and release the current resources hold by it.
  119977. */
  119978. dispose(): void;
  119979. /**
  119980. * Gets the current object class name.
  119981. * @return the class name
  119982. */
  119983. getClassName(): string;
  119984. }
  119985. }
  119986. declare module BABYLON {
  119987. /**
  119988. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119989. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119990. */
  119991. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119992. /**
  119993. * Gets the name of the behavior.
  119994. */
  119995. get name(): string;
  119996. private _zoomStopsAnimation;
  119997. private _idleRotationSpeed;
  119998. private _idleRotationWaitTime;
  119999. private _idleRotationSpinupTime;
  120000. /**
  120001. * Sets the flag that indicates if user zooming should stop animation.
  120002. */
  120003. set zoomStopsAnimation(flag: boolean);
  120004. /**
  120005. * Gets the flag that indicates if user zooming should stop animation.
  120006. */
  120007. get zoomStopsAnimation(): boolean;
  120008. /**
  120009. * Sets the default speed at which the camera rotates around the model.
  120010. */
  120011. set idleRotationSpeed(speed: number);
  120012. /**
  120013. * Gets the default speed at which the camera rotates around the model.
  120014. */
  120015. get idleRotationSpeed(): number;
  120016. /**
  120017. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120018. */
  120019. set idleRotationWaitTime(time: number);
  120020. /**
  120021. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120022. */
  120023. get idleRotationWaitTime(): number;
  120024. /**
  120025. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120026. */
  120027. set idleRotationSpinupTime(time: number);
  120028. /**
  120029. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120030. */
  120031. get idleRotationSpinupTime(): number;
  120032. /**
  120033. * Gets a value indicating if the camera is currently rotating because of this behavior
  120034. */
  120035. get rotationInProgress(): boolean;
  120036. private _onPrePointerObservableObserver;
  120037. private _onAfterCheckInputsObserver;
  120038. private _attachedCamera;
  120039. private _isPointerDown;
  120040. private _lastFrameTime;
  120041. private _lastInteractionTime;
  120042. private _cameraRotationSpeed;
  120043. /**
  120044. * Initializes the behavior.
  120045. */
  120046. init(): void;
  120047. /**
  120048. * Attaches the behavior to its arc rotate camera.
  120049. * @param camera Defines the camera to attach the behavior to
  120050. */
  120051. attach(camera: ArcRotateCamera): void;
  120052. /**
  120053. * Detaches the behavior from its current arc rotate camera.
  120054. */
  120055. detach(): void;
  120056. /**
  120057. * Returns true if user is scrolling.
  120058. * @return true if user is scrolling.
  120059. */
  120060. private _userIsZooming;
  120061. private _lastFrameRadius;
  120062. private _shouldAnimationStopForInteraction;
  120063. /**
  120064. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120065. */
  120066. private _applyUserInteraction;
  120067. private _userIsMoving;
  120068. }
  120069. }
  120070. declare module BABYLON {
  120071. /**
  120072. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120073. */
  120074. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120075. private ui;
  120076. /**
  120077. * The name of the behavior
  120078. */
  120079. name: string;
  120080. /**
  120081. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120082. */
  120083. distanceAwayFromFace: number;
  120084. /**
  120085. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120086. */
  120087. distanceAwayFromBottomOfFace: number;
  120088. private _faceVectors;
  120089. private _target;
  120090. private _scene;
  120091. private _onRenderObserver;
  120092. private _tmpMatrix;
  120093. private _tmpVector;
  120094. /**
  120095. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120096. * @param ui The transform node that should be attched to the mesh
  120097. */
  120098. constructor(ui: TransformNode);
  120099. /**
  120100. * Initializes the behavior
  120101. */
  120102. init(): void;
  120103. private _closestFace;
  120104. private _zeroVector;
  120105. private _lookAtTmpMatrix;
  120106. private _lookAtToRef;
  120107. /**
  120108. * Attaches the AttachToBoxBehavior to the passed in mesh
  120109. * @param target The mesh that the specified node will be attached to
  120110. */
  120111. attach(target: Mesh): void;
  120112. /**
  120113. * Detaches the behavior from the mesh
  120114. */
  120115. detach(): void;
  120116. }
  120117. }
  120118. declare module BABYLON {
  120119. /**
  120120. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120121. */
  120122. export class FadeInOutBehavior implements Behavior<Mesh> {
  120123. /**
  120124. * Time in milliseconds to delay before fading in (Default: 0)
  120125. */
  120126. delay: number;
  120127. /**
  120128. * Time in milliseconds for the mesh to fade in (Default: 300)
  120129. */
  120130. fadeInTime: number;
  120131. private _millisecondsPerFrame;
  120132. private _hovered;
  120133. private _hoverValue;
  120134. private _ownerNode;
  120135. /**
  120136. * Instatiates the FadeInOutBehavior
  120137. */
  120138. constructor();
  120139. /**
  120140. * The name of the behavior
  120141. */
  120142. get name(): string;
  120143. /**
  120144. * Initializes the behavior
  120145. */
  120146. init(): void;
  120147. /**
  120148. * Attaches the fade behavior on the passed in mesh
  120149. * @param ownerNode The mesh that will be faded in/out once attached
  120150. */
  120151. attach(ownerNode: Mesh): void;
  120152. /**
  120153. * Detaches the behavior from the mesh
  120154. */
  120155. detach(): void;
  120156. /**
  120157. * Triggers the mesh to begin fading in or out
  120158. * @param value if the object should fade in or out (true to fade in)
  120159. */
  120160. fadeIn(value: boolean): void;
  120161. private _update;
  120162. private _setAllVisibility;
  120163. }
  120164. }
  120165. declare module BABYLON {
  120166. /**
  120167. * Class containing a set of static utilities functions for managing Pivots
  120168. * @hidden
  120169. */
  120170. export class PivotTools {
  120171. private static _PivotCached;
  120172. private static _OldPivotPoint;
  120173. private static _PivotTranslation;
  120174. private static _PivotTmpVector;
  120175. /** @hidden */
  120176. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120177. /** @hidden */
  120178. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120179. }
  120180. }
  120181. declare module BABYLON {
  120182. /**
  120183. * Class containing static functions to help procedurally build meshes
  120184. */
  120185. export class PlaneBuilder {
  120186. /**
  120187. * Creates a plane mesh
  120188. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120189. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120190. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120194. * @param name defines the name of the mesh
  120195. * @param options defines the options used to create the mesh
  120196. * @param scene defines the hosting scene
  120197. * @returns the plane mesh
  120198. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120199. */
  120200. static CreatePlane(name: string, options: {
  120201. size?: number;
  120202. width?: number;
  120203. height?: number;
  120204. sideOrientation?: number;
  120205. frontUVs?: Vector4;
  120206. backUVs?: Vector4;
  120207. updatable?: boolean;
  120208. sourcePlane?: Plane;
  120209. }, scene?: Nullable<Scene>): Mesh;
  120210. }
  120211. }
  120212. declare module BABYLON {
  120213. /**
  120214. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120215. */
  120216. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120217. private static _AnyMouseID;
  120218. /**
  120219. * Abstract mesh the behavior is set on
  120220. */
  120221. attachedNode: AbstractMesh;
  120222. private _dragPlane;
  120223. private _scene;
  120224. private _pointerObserver;
  120225. private _beforeRenderObserver;
  120226. private static _planeScene;
  120227. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120228. /**
  120229. * 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)
  120230. */
  120231. maxDragAngle: number;
  120232. /**
  120233. * @hidden
  120234. */
  120235. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120236. /**
  120237. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120238. */
  120239. currentDraggingPointerID: number;
  120240. /**
  120241. * The last position where the pointer hit the drag plane in world space
  120242. */
  120243. lastDragPosition: Vector3;
  120244. /**
  120245. * If the behavior is currently in a dragging state
  120246. */
  120247. dragging: boolean;
  120248. /**
  120249. * 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)
  120250. */
  120251. dragDeltaRatio: number;
  120252. /**
  120253. * If the drag plane orientation should be updated during the dragging (Default: true)
  120254. */
  120255. updateDragPlane: boolean;
  120256. private _debugMode;
  120257. private _moving;
  120258. /**
  120259. * Fires each time the attached mesh is dragged with the pointer
  120260. * * delta between last drag position and current drag position in world space
  120261. * * dragDistance along the drag axis
  120262. * * dragPlaneNormal normal of the current drag plane used during the drag
  120263. * * dragPlanePoint in world space where the drag intersects the drag plane
  120264. */
  120265. onDragObservable: Observable<{
  120266. delta: Vector3;
  120267. dragPlanePoint: Vector3;
  120268. dragPlaneNormal: Vector3;
  120269. dragDistance: number;
  120270. pointerId: number;
  120271. }>;
  120272. /**
  120273. * Fires each time a drag begins (eg. mouse down on mesh)
  120274. */
  120275. onDragStartObservable: Observable<{
  120276. dragPlanePoint: Vector3;
  120277. pointerId: number;
  120278. }>;
  120279. /**
  120280. * Fires each time a drag ends (eg. mouse release after drag)
  120281. */
  120282. onDragEndObservable: Observable<{
  120283. dragPlanePoint: Vector3;
  120284. pointerId: number;
  120285. }>;
  120286. /**
  120287. * If the attached mesh should be moved when dragged
  120288. */
  120289. moveAttached: boolean;
  120290. /**
  120291. * If the drag behavior will react to drag events (Default: true)
  120292. */
  120293. enabled: boolean;
  120294. /**
  120295. * If pointer events should start and release the drag (Default: true)
  120296. */
  120297. startAndReleaseDragOnPointerEvents: boolean;
  120298. /**
  120299. * If camera controls should be detached during the drag
  120300. */
  120301. detachCameraControls: boolean;
  120302. /**
  120303. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120304. */
  120305. useObjectOrientationForDragging: boolean;
  120306. private _options;
  120307. /**
  120308. * Gets the options used by the behavior
  120309. */
  120310. get options(): {
  120311. dragAxis?: Vector3;
  120312. dragPlaneNormal?: Vector3;
  120313. };
  120314. /**
  120315. * Sets the options used by the behavior
  120316. */
  120317. set options(options: {
  120318. dragAxis?: Vector3;
  120319. dragPlaneNormal?: Vector3;
  120320. });
  120321. /**
  120322. * Creates a pointer drag behavior that can be attached to a mesh
  120323. * @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)
  120324. */
  120325. constructor(options?: {
  120326. dragAxis?: Vector3;
  120327. dragPlaneNormal?: Vector3;
  120328. });
  120329. /**
  120330. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120331. */
  120332. validateDrag: (targetPosition: Vector3) => boolean;
  120333. /**
  120334. * The name of the behavior
  120335. */
  120336. get name(): string;
  120337. /**
  120338. * Initializes the behavior
  120339. */
  120340. init(): void;
  120341. private _tmpVector;
  120342. private _alternatePickedPoint;
  120343. private _worldDragAxis;
  120344. private _targetPosition;
  120345. private _attachedElement;
  120346. /**
  120347. * Attaches the drag behavior the passed in mesh
  120348. * @param ownerNode The mesh that will be dragged around once attached
  120349. * @param predicate Predicate to use for pick filtering
  120350. */
  120351. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120352. /**
  120353. * Force relase the drag action by code.
  120354. */
  120355. releaseDrag(): void;
  120356. private _startDragRay;
  120357. private _lastPointerRay;
  120358. /**
  120359. * Simulates the start of a pointer drag event on the behavior
  120360. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120361. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120362. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120363. */
  120364. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120365. private _startDrag;
  120366. private _dragDelta;
  120367. private _moveDrag;
  120368. private _pickWithRayOnDragPlane;
  120369. private _pointA;
  120370. private _pointB;
  120371. private _pointC;
  120372. private _lineA;
  120373. private _lineB;
  120374. private _localAxis;
  120375. private _lookAt;
  120376. private _updateDragPlanePosition;
  120377. /**
  120378. * Detaches the behavior from the mesh
  120379. */
  120380. detach(): void;
  120381. }
  120382. }
  120383. declare module BABYLON {
  120384. /**
  120385. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120386. */
  120387. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120388. private _dragBehaviorA;
  120389. private _dragBehaviorB;
  120390. private _startDistance;
  120391. private _initialScale;
  120392. private _targetScale;
  120393. private _ownerNode;
  120394. private _sceneRenderObserver;
  120395. /**
  120396. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120397. */
  120398. constructor();
  120399. /**
  120400. * The name of the behavior
  120401. */
  120402. get name(): string;
  120403. /**
  120404. * Initializes the behavior
  120405. */
  120406. init(): void;
  120407. private _getCurrentDistance;
  120408. /**
  120409. * Attaches the scale behavior the passed in mesh
  120410. * @param ownerNode The mesh that will be scaled around once attached
  120411. */
  120412. attach(ownerNode: Mesh): void;
  120413. /**
  120414. * Detaches the behavior from the mesh
  120415. */
  120416. detach(): void;
  120417. }
  120418. }
  120419. declare module BABYLON {
  120420. /**
  120421. * 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
  120422. */
  120423. export class SixDofDragBehavior implements Behavior<Mesh> {
  120424. private static _virtualScene;
  120425. private _ownerNode;
  120426. private _sceneRenderObserver;
  120427. private _scene;
  120428. private _targetPosition;
  120429. private _virtualOriginMesh;
  120430. private _virtualDragMesh;
  120431. private _pointerObserver;
  120432. private _moving;
  120433. private _startingOrientation;
  120434. private _attachedElement;
  120435. /**
  120436. * 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)
  120437. */
  120438. private zDragFactor;
  120439. /**
  120440. * If the object should rotate to face the drag origin
  120441. */
  120442. rotateDraggedObject: boolean;
  120443. /**
  120444. * If the behavior is currently in a dragging state
  120445. */
  120446. dragging: boolean;
  120447. /**
  120448. * 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)
  120449. */
  120450. dragDeltaRatio: number;
  120451. /**
  120452. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120453. */
  120454. currentDraggingPointerID: number;
  120455. /**
  120456. * If camera controls should be detached during the drag
  120457. */
  120458. detachCameraControls: boolean;
  120459. /**
  120460. * Fires each time a drag starts
  120461. */
  120462. onDragStartObservable: Observable<{}>;
  120463. /**
  120464. * Fires each time a drag ends (eg. mouse release after drag)
  120465. */
  120466. onDragEndObservable: Observable<{}>;
  120467. /**
  120468. * 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
  120469. */
  120470. constructor();
  120471. /**
  120472. * The name of the behavior
  120473. */
  120474. get name(): string;
  120475. /**
  120476. * Initializes the behavior
  120477. */
  120478. init(): void;
  120479. /**
  120480. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120481. */
  120482. private get _pointerCamera();
  120483. /**
  120484. * Attaches the scale behavior the passed in mesh
  120485. * @param ownerNode The mesh that will be scaled around once attached
  120486. */
  120487. attach(ownerNode: Mesh): void;
  120488. /**
  120489. * Detaches the behavior from the mesh
  120490. */
  120491. detach(): void;
  120492. }
  120493. }
  120494. declare module BABYLON {
  120495. /**
  120496. * Class used to apply inverse kinematics to bones
  120497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120498. */
  120499. export class BoneIKController {
  120500. private static _tmpVecs;
  120501. private static _tmpQuat;
  120502. private static _tmpMats;
  120503. /**
  120504. * Gets or sets the target mesh
  120505. */
  120506. targetMesh: AbstractMesh;
  120507. /** Gets or sets the mesh used as pole */
  120508. poleTargetMesh: AbstractMesh;
  120509. /**
  120510. * Gets or sets the bone used as pole
  120511. */
  120512. poleTargetBone: Nullable<Bone>;
  120513. /**
  120514. * Gets or sets the target position
  120515. */
  120516. targetPosition: Vector3;
  120517. /**
  120518. * Gets or sets the pole target position
  120519. */
  120520. poleTargetPosition: Vector3;
  120521. /**
  120522. * Gets or sets the pole target local offset
  120523. */
  120524. poleTargetLocalOffset: Vector3;
  120525. /**
  120526. * Gets or sets the pole angle
  120527. */
  120528. poleAngle: number;
  120529. /**
  120530. * Gets or sets the mesh associated with the controller
  120531. */
  120532. mesh: AbstractMesh;
  120533. /**
  120534. * 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)
  120535. */
  120536. slerpAmount: number;
  120537. private _bone1Quat;
  120538. private _bone1Mat;
  120539. private _bone2Ang;
  120540. private _bone1;
  120541. private _bone2;
  120542. private _bone1Length;
  120543. private _bone2Length;
  120544. private _maxAngle;
  120545. private _maxReach;
  120546. private _rightHandedSystem;
  120547. private _bendAxis;
  120548. private _slerping;
  120549. private _adjustRoll;
  120550. /**
  120551. * Gets or sets maximum allowed angle
  120552. */
  120553. get maxAngle(): number;
  120554. set maxAngle(value: number);
  120555. /**
  120556. * Creates a new BoneIKController
  120557. * @param mesh defines the mesh to control
  120558. * @param bone defines the bone to control
  120559. * @param options defines options to set up the controller
  120560. */
  120561. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120562. targetMesh?: AbstractMesh;
  120563. poleTargetMesh?: AbstractMesh;
  120564. poleTargetBone?: Bone;
  120565. poleTargetLocalOffset?: Vector3;
  120566. poleAngle?: number;
  120567. bendAxis?: Vector3;
  120568. maxAngle?: number;
  120569. slerpAmount?: number;
  120570. });
  120571. private _setMaxAngle;
  120572. /**
  120573. * Force the controller to update the bones
  120574. */
  120575. update(): void;
  120576. }
  120577. }
  120578. declare module BABYLON {
  120579. /**
  120580. * Class used to make a bone look toward a point in space
  120581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120582. */
  120583. export class BoneLookController {
  120584. private static _tmpVecs;
  120585. private static _tmpQuat;
  120586. private static _tmpMats;
  120587. /**
  120588. * The target Vector3 that the bone will look at
  120589. */
  120590. target: Vector3;
  120591. /**
  120592. * The mesh that the bone is attached to
  120593. */
  120594. mesh: AbstractMesh;
  120595. /**
  120596. * The bone that will be looking to the target
  120597. */
  120598. bone: Bone;
  120599. /**
  120600. * The up axis of the coordinate system that is used when the bone is rotated
  120601. */
  120602. upAxis: Vector3;
  120603. /**
  120604. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120605. */
  120606. upAxisSpace: Space;
  120607. /**
  120608. * Used to make an adjustment to the yaw of the bone
  120609. */
  120610. adjustYaw: number;
  120611. /**
  120612. * Used to make an adjustment to the pitch of the bone
  120613. */
  120614. adjustPitch: number;
  120615. /**
  120616. * Used to make an adjustment to the roll of the bone
  120617. */
  120618. adjustRoll: number;
  120619. /**
  120620. * 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)
  120621. */
  120622. slerpAmount: number;
  120623. private _minYaw;
  120624. private _maxYaw;
  120625. private _minPitch;
  120626. private _maxPitch;
  120627. private _minYawSin;
  120628. private _minYawCos;
  120629. private _maxYawSin;
  120630. private _maxYawCos;
  120631. private _midYawConstraint;
  120632. private _minPitchTan;
  120633. private _maxPitchTan;
  120634. private _boneQuat;
  120635. private _slerping;
  120636. private _transformYawPitch;
  120637. private _transformYawPitchInv;
  120638. private _firstFrameSkipped;
  120639. private _yawRange;
  120640. private _fowardAxis;
  120641. /**
  120642. * Gets or sets the minimum yaw angle that the bone can look to
  120643. */
  120644. get minYaw(): number;
  120645. set minYaw(value: number);
  120646. /**
  120647. * Gets or sets the maximum yaw angle that the bone can look to
  120648. */
  120649. get maxYaw(): number;
  120650. set maxYaw(value: number);
  120651. /**
  120652. * Gets or sets the minimum pitch angle that the bone can look to
  120653. */
  120654. get minPitch(): number;
  120655. set minPitch(value: number);
  120656. /**
  120657. * Gets or sets the maximum pitch angle that the bone can look to
  120658. */
  120659. get maxPitch(): number;
  120660. set maxPitch(value: number);
  120661. /**
  120662. * Create a BoneLookController
  120663. * @param mesh the mesh that the bone belongs to
  120664. * @param bone the bone that will be looking to the target
  120665. * @param target the target Vector3 to look at
  120666. * @param options optional settings:
  120667. * * maxYaw: the maximum angle the bone will yaw to
  120668. * * minYaw: the minimum angle the bone will yaw to
  120669. * * maxPitch: the maximum angle the bone will pitch to
  120670. * * minPitch: the minimum angle the bone will yaw to
  120671. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120672. * * upAxis: the up axis of the coordinate system
  120673. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120674. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120675. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120676. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120677. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120678. * * adjustRoll: used to make an adjustment to the roll of the bone
  120679. **/
  120680. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120681. maxYaw?: number;
  120682. minYaw?: number;
  120683. maxPitch?: number;
  120684. minPitch?: number;
  120685. slerpAmount?: number;
  120686. upAxis?: Vector3;
  120687. upAxisSpace?: Space;
  120688. yawAxis?: Vector3;
  120689. pitchAxis?: Vector3;
  120690. adjustYaw?: number;
  120691. adjustPitch?: number;
  120692. adjustRoll?: number;
  120693. });
  120694. /**
  120695. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120696. */
  120697. update(): void;
  120698. private _getAngleDiff;
  120699. private _getAngleBetween;
  120700. private _isAngleBetween;
  120701. }
  120702. }
  120703. declare module BABYLON {
  120704. /**
  120705. * Manage the gamepad inputs to control an arc rotate camera.
  120706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120707. */
  120708. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120709. /**
  120710. * Defines the camera the input is attached to.
  120711. */
  120712. camera: ArcRotateCamera;
  120713. /**
  120714. * Defines the gamepad the input is gathering event from.
  120715. */
  120716. gamepad: Nullable<Gamepad>;
  120717. /**
  120718. * Defines the gamepad rotation sensiblity.
  120719. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120720. */
  120721. gamepadRotationSensibility: number;
  120722. /**
  120723. * Defines the gamepad move sensiblity.
  120724. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120725. */
  120726. gamepadMoveSensibility: number;
  120727. private _yAxisScale;
  120728. /**
  120729. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120730. */
  120731. get invertYAxis(): boolean;
  120732. set invertYAxis(value: boolean);
  120733. private _onGamepadConnectedObserver;
  120734. private _onGamepadDisconnectedObserver;
  120735. /**
  120736. * Attach the input controls to a specific dom element to get the input from.
  120737. * @param element Defines the element the controls should be listened from
  120738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120739. */
  120740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120741. /**
  120742. * Detach the current controls from the specified dom element.
  120743. * @param element Defines the element to stop listening the inputs from
  120744. */
  120745. detachControl(element: Nullable<HTMLElement>): void;
  120746. /**
  120747. * Update the current camera state depending on the inputs that have been used this frame.
  120748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120749. */
  120750. checkInputs(): void;
  120751. /**
  120752. * Gets the class name of the current intput.
  120753. * @returns the class name
  120754. */
  120755. getClassName(): string;
  120756. /**
  120757. * Get the friendly name associated with the input class.
  120758. * @returns the input friendly name
  120759. */
  120760. getSimpleName(): string;
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. interface ArcRotateCameraInputsManager {
  120765. /**
  120766. * Add orientation input support to the input manager.
  120767. * @returns the current input manager
  120768. */
  120769. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120770. }
  120771. /**
  120772. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120774. */
  120775. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120776. /**
  120777. * Defines the camera the input is attached to.
  120778. */
  120779. camera: ArcRotateCamera;
  120780. /**
  120781. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120782. */
  120783. alphaCorrection: number;
  120784. /**
  120785. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120786. */
  120787. gammaCorrection: number;
  120788. private _alpha;
  120789. private _gamma;
  120790. private _dirty;
  120791. private _deviceOrientationHandler;
  120792. /**
  120793. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120794. */
  120795. constructor();
  120796. /**
  120797. * Attach the input controls to a specific dom element to get the input from.
  120798. * @param element Defines the element the controls should be listened from
  120799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120800. */
  120801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120802. /** @hidden */
  120803. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120804. /**
  120805. * Update the current camera state depending on the inputs that have been used this frame.
  120806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120807. */
  120808. checkInputs(): void;
  120809. /**
  120810. * Detach the current controls from the specified dom element.
  120811. * @param element Defines the element to stop listening the inputs from
  120812. */
  120813. detachControl(element: Nullable<HTMLElement>): void;
  120814. /**
  120815. * Gets the class name of the current intput.
  120816. * @returns the class name
  120817. */
  120818. getClassName(): string;
  120819. /**
  120820. * Get the friendly name associated with the input class.
  120821. * @returns the input friendly name
  120822. */
  120823. getSimpleName(): string;
  120824. }
  120825. }
  120826. declare module BABYLON {
  120827. /**
  120828. * Listen to mouse events to control the camera.
  120829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120830. */
  120831. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120832. /**
  120833. * Defines the camera the input is attached to.
  120834. */
  120835. camera: FlyCamera;
  120836. /**
  120837. * Defines if touch is enabled. (Default is true.)
  120838. */
  120839. touchEnabled: boolean;
  120840. /**
  120841. * Defines the buttons associated with the input to handle camera rotation.
  120842. */
  120843. buttons: number[];
  120844. /**
  120845. * Assign buttons for Yaw control.
  120846. */
  120847. buttonsYaw: number[];
  120848. /**
  120849. * Assign buttons for Pitch control.
  120850. */
  120851. buttonsPitch: number[];
  120852. /**
  120853. * Assign buttons for Roll control.
  120854. */
  120855. buttonsRoll: number[];
  120856. /**
  120857. * Detect if any button is being pressed while mouse is moved.
  120858. * -1 = Mouse locked.
  120859. * 0 = Left button.
  120860. * 1 = Middle Button.
  120861. * 2 = Right Button.
  120862. */
  120863. activeButton: number;
  120864. /**
  120865. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120866. * Higher values reduce its sensitivity.
  120867. */
  120868. angularSensibility: number;
  120869. private _mousemoveCallback;
  120870. private _observer;
  120871. private _rollObserver;
  120872. private previousPosition;
  120873. private noPreventDefault;
  120874. private element;
  120875. /**
  120876. * Listen to mouse events to control the camera.
  120877. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120879. */
  120880. constructor(touchEnabled?: boolean);
  120881. /**
  120882. * Attach the mouse control to the HTML DOM element.
  120883. * @param element Defines the element that listens to the input events.
  120884. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120885. */
  120886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120887. /**
  120888. * Detach the current controls from the specified dom element.
  120889. * @param element Defines the element to stop listening the inputs from
  120890. */
  120891. detachControl(element: Nullable<HTMLElement>): void;
  120892. /**
  120893. * Gets the class name of the current input.
  120894. * @returns the class name.
  120895. */
  120896. getClassName(): string;
  120897. /**
  120898. * Get the friendly name associated with the input class.
  120899. * @returns the input's friendly name.
  120900. */
  120901. getSimpleName(): string;
  120902. private _pointerInput;
  120903. private _onMouseMove;
  120904. /**
  120905. * Rotate camera by mouse offset.
  120906. */
  120907. private rotateCamera;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /**
  120912. * Default Inputs manager for the FlyCamera.
  120913. * It groups all the default supported inputs for ease of use.
  120914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120915. */
  120916. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120917. /**
  120918. * Instantiates a new FlyCameraInputsManager.
  120919. * @param camera Defines the camera the inputs belong to.
  120920. */
  120921. constructor(camera: FlyCamera);
  120922. /**
  120923. * Add keyboard input support to the input manager.
  120924. * @returns the new FlyCameraKeyboardMoveInput().
  120925. */
  120926. addKeyboard(): FlyCameraInputsManager;
  120927. /**
  120928. * Add mouse input support to the input manager.
  120929. * @param touchEnabled Enable touch screen support.
  120930. * @returns the new FlyCameraMouseInput().
  120931. */
  120932. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120933. }
  120934. }
  120935. declare module BABYLON {
  120936. /**
  120937. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120938. * such as in a 3D Space Shooter or a Flight Simulator.
  120939. */
  120940. export class FlyCamera extends TargetCamera {
  120941. /**
  120942. * Define the collision ellipsoid of the camera.
  120943. * This is helpful for simulating a camera body, like a player's body.
  120944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120945. */
  120946. ellipsoid: Vector3;
  120947. /**
  120948. * Define an offset for the position of the ellipsoid around the camera.
  120949. * This can be helpful if the camera is attached away from the player's body center,
  120950. * such as at its head.
  120951. */
  120952. ellipsoidOffset: Vector3;
  120953. /**
  120954. * Enable or disable collisions of the camera with the rest of the scene objects.
  120955. */
  120956. checkCollisions: boolean;
  120957. /**
  120958. * Enable or disable gravity on the camera.
  120959. */
  120960. applyGravity: boolean;
  120961. /**
  120962. * Define the current direction the camera is moving to.
  120963. */
  120964. cameraDirection: Vector3;
  120965. /**
  120966. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120967. * This overrides and empties cameraRotation.
  120968. */
  120969. rotationQuaternion: Quaternion;
  120970. /**
  120971. * Track Roll to maintain the wanted Rolling when looking around.
  120972. */
  120973. _trackRoll: number;
  120974. /**
  120975. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120976. */
  120977. rollCorrect: number;
  120978. /**
  120979. * Mimic a banked turn, Rolling the camera when Yawing.
  120980. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120981. */
  120982. bankedTurn: boolean;
  120983. /**
  120984. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120985. */
  120986. bankedTurnLimit: number;
  120987. /**
  120988. * Value of 0 disables the banked Roll.
  120989. * Value of 1 is equal to the Yaw angle in radians.
  120990. */
  120991. bankedTurnMultiplier: number;
  120992. /**
  120993. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120994. */
  120995. inputs: FlyCameraInputsManager;
  120996. /**
  120997. * Gets the input sensibility for mouse input.
  120998. * Higher values reduce sensitivity.
  120999. */
  121000. get angularSensibility(): number;
  121001. /**
  121002. * Sets the input sensibility for a mouse input.
  121003. * Higher values reduce sensitivity.
  121004. */
  121005. set angularSensibility(value: number);
  121006. /**
  121007. * Get the keys for camera movement forward.
  121008. */
  121009. get keysForward(): number[];
  121010. /**
  121011. * Set the keys for camera movement forward.
  121012. */
  121013. set keysForward(value: number[]);
  121014. /**
  121015. * Get the keys for camera movement backward.
  121016. */
  121017. get keysBackward(): number[];
  121018. set keysBackward(value: number[]);
  121019. /**
  121020. * Get the keys for camera movement up.
  121021. */
  121022. get keysUp(): number[];
  121023. /**
  121024. * Set the keys for camera movement up.
  121025. */
  121026. set keysUp(value: number[]);
  121027. /**
  121028. * Get the keys for camera movement down.
  121029. */
  121030. get keysDown(): number[];
  121031. /**
  121032. * Set the keys for camera movement down.
  121033. */
  121034. set keysDown(value: number[]);
  121035. /**
  121036. * Get the keys for camera movement left.
  121037. */
  121038. get keysLeft(): number[];
  121039. /**
  121040. * Set the keys for camera movement left.
  121041. */
  121042. set keysLeft(value: number[]);
  121043. /**
  121044. * Set the keys for camera movement right.
  121045. */
  121046. get keysRight(): number[];
  121047. /**
  121048. * Set the keys for camera movement right.
  121049. */
  121050. set keysRight(value: number[]);
  121051. /**
  121052. * Event raised when the camera collides with a mesh in the scene.
  121053. */
  121054. onCollide: (collidedMesh: AbstractMesh) => void;
  121055. private _collider;
  121056. private _needMoveForGravity;
  121057. private _oldPosition;
  121058. private _diffPosition;
  121059. private _newPosition;
  121060. /** @hidden */
  121061. _localDirection: Vector3;
  121062. /** @hidden */
  121063. _transformedDirection: Vector3;
  121064. /**
  121065. * Instantiates a FlyCamera.
  121066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121067. * such as in a 3D Space Shooter or a Flight Simulator.
  121068. * @param name Define the name of the camera in the scene.
  121069. * @param position Define the starting position of the camera in the scene.
  121070. * @param scene Define the scene the camera belongs to.
  121071. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121072. */
  121073. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121074. /**
  121075. * Attach a control to the HTML DOM element.
  121076. * @param element Defines the element that listens to the input events.
  121077. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121078. */
  121079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121080. /**
  121081. * Detach a control from the HTML DOM element.
  121082. * The camera will stop reacting to that input.
  121083. * @param element Defines the element that listens to the input events.
  121084. */
  121085. detachControl(element: HTMLElement): void;
  121086. private _collisionMask;
  121087. /**
  121088. * Get the mask that the camera ignores in collision events.
  121089. */
  121090. get collisionMask(): number;
  121091. /**
  121092. * Set the mask that the camera ignores in collision events.
  121093. */
  121094. set collisionMask(mask: number);
  121095. /** @hidden */
  121096. _collideWithWorld(displacement: Vector3): void;
  121097. /** @hidden */
  121098. private _onCollisionPositionChange;
  121099. /** @hidden */
  121100. _checkInputs(): void;
  121101. /** @hidden */
  121102. _decideIfNeedsToMove(): boolean;
  121103. /** @hidden */
  121104. _updatePosition(): void;
  121105. /**
  121106. * Restore the Roll to its target value at the rate specified.
  121107. * @param rate - Higher means slower restoring.
  121108. * @hidden
  121109. */
  121110. restoreRoll(rate: number): void;
  121111. /**
  121112. * Destroy the camera and release the current resources held by it.
  121113. */
  121114. dispose(): void;
  121115. /**
  121116. * Get the current object class name.
  121117. * @returns the class name.
  121118. */
  121119. getClassName(): string;
  121120. }
  121121. }
  121122. declare module BABYLON {
  121123. /**
  121124. * Listen to keyboard events to control the camera.
  121125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121126. */
  121127. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121128. /**
  121129. * Defines the camera the input is attached to.
  121130. */
  121131. camera: FlyCamera;
  121132. /**
  121133. * The list of keyboard keys used to control the forward move of the camera.
  121134. */
  121135. keysForward: number[];
  121136. /**
  121137. * The list of keyboard keys used to control the backward move of the camera.
  121138. */
  121139. keysBackward: number[];
  121140. /**
  121141. * The list of keyboard keys used to control the forward move of the camera.
  121142. */
  121143. keysUp: number[];
  121144. /**
  121145. * The list of keyboard keys used to control the backward move of the camera.
  121146. */
  121147. keysDown: number[];
  121148. /**
  121149. * The list of keyboard keys used to control the right strafe move of the camera.
  121150. */
  121151. keysRight: number[];
  121152. /**
  121153. * The list of keyboard keys used to control the left strafe move of the camera.
  121154. */
  121155. keysLeft: number[];
  121156. private _keys;
  121157. private _onCanvasBlurObserver;
  121158. private _onKeyboardObserver;
  121159. private _engine;
  121160. private _scene;
  121161. /**
  121162. * Attach the input controls to a specific dom element to get the input from.
  121163. * @param element Defines the element the controls should be listened from
  121164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121165. */
  121166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121167. /**
  121168. * Detach the current controls from the specified dom element.
  121169. * @param element Defines the element to stop listening the inputs from
  121170. */
  121171. detachControl(element: Nullable<HTMLElement>): void;
  121172. /**
  121173. * Gets the class name of the current intput.
  121174. * @returns the class name
  121175. */
  121176. getClassName(): string;
  121177. /** @hidden */
  121178. _onLostFocus(e: FocusEvent): void;
  121179. /**
  121180. * Get the friendly name associated with the input class.
  121181. * @returns the input friendly name
  121182. */
  121183. getSimpleName(): string;
  121184. /**
  121185. * Update the current camera state depending on the inputs that have been used this frame.
  121186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121187. */
  121188. checkInputs(): void;
  121189. }
  121190. }
  121191. declare module BABYLON {
  121192. /**
  121193. * Manage the mouse wheel inputs to control a follow camera.
  121194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121195. */
  121196. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121197. /**
  121198. * Defines the camera the input is attached to.
  121199. */
  121200. camera: FollowCamera;
  121201. /**
  121202. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121203. */
  121204. axisControlRadius: boolean;
  121205. /**
  121206. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121207. */
  121208. axisControlHeight: boolean;
  121209. /**
  121210. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121211. */
  121212. axisControlRotation: boolean;
  121213. /**
  121214. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121215. * relation to mouseWheel events.
  121216. */
  121217. wheelPrecision: number;
  121218. /**
  121219. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121220. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121221. */
  121222. wheelDeltaPercentage: number;
  121223. private _wheel;
  121224. private _observer;
  121225. /**
  121226. * Attach the input controls to a specific dom element to get the input from.
  121227. * @param element Defines the element the controls should be listened from
  121228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121229. */
  121230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121231. /**
  121232. * Detach the current controls from the specified dom element.
  121233. * @param element Defines the element to stop listening the inputs from
  121234. */
  121235. detachControl(element: Nullable<HTMLElement>): void;
  121236. /**
  121237. * Gets the class name of the current intput.
  121238. * @returns the class name
  121239. */
  121240. getClassName(): string;
  121241. /**
  121242. * Get the friendly name associated with the input class.
  121243. * @returns the input friendly name
  121244. */
  121245. getSimpleName(): string;
  121246. }
  121247. }
  121248. declare module BABYLON {
  121249. /**
  121250. * Manage the pointers inputs to control an follow camera.
  121251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121252. */
  121253. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121254. /**
  121255. * Defines the camera the input is attached to.
  121256. */
  121257. camera: FollowCamera;
  121258. /**
  121259. * Gets the class name of the current input.
  121260. * @returns the class name
  121261. */
  121262. getClassName(): string;
  121263. /**
  121264. * Defines the pointer angular sensibility along the X axis or how fast is
  121265. * the camera rotating.
  121266. * A negative number will reverse the axis direction.
  121267. */
  121268. angularSensibilityX: number;
  121269. /**
  121270. * Defines the pointer angular sensibility along the Y axis or how fast is
  121271. * the camera rotating.
  121272. * A negative number will reverse the axis direction.
  121273. */
  121274. angularSensibilityY: number;
  121275. /**
  121276. * Defines the pointer pinch precision or how fast is the camera zooming.
  121277. * A negative number will reverse the axis direction.
  121278. */
  121279. pinchPrecision: number;
  121280. /**
  121281. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121282. * from 0.
  121283. * It defines the percentage of current camera.radius to use as delta when
  121284. * pinch zoom is used.
  121285. */
  121286. pinchDeltaPercentage: number;
  121287. /**
  121288. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121289. */
  121290. axisXControlRadius: boolean;
  121291. /**
  121292. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121293. */
  121294. axisXControlHeight: boolean;
  121295. /**
  121296. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121297. */
  121298. axisXControlRotation: boolean;
  121299. /**
  121300. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121301. */
  121302. axisYControlRadius: boolean;
  121303. /**
  121304. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121305. */
  121306. axisYControlHeight: boolean;
  121307. /**
  121308. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121309. */
  121310. axisYControlRotation: boolean;
  121311. /**
  121312. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121313. */
  121314. axisPinchControlRadius: boolean;
  121315. /**
  121316. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121317. */
  121318. axisPinchControlHeight: boolean;
  121319. /**
  121320. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121321. */
  121322. axisPinchControlRotation: boolean;
  121323. /**
  121324. * Log error messages if basic misconfiguration has occurred.
  121325. */
  121326. warningEnable: boolean;
  121327. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121328. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121329. private _warningCounter;
  121330. private _warning;
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Default Inputs manager for the FollowCamera.
  121336. * It groups all the default supported inputs for ease of use.
  121337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121338. */
  121339. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121340. /**
  121341. * Instantiates a new FollowCameraInputsManager.
  121342. * @param camera Defines the camera the inputs belong to
  121343. */
  121344. constructor(camera: FollowCamera);
  121345. /**
  121346. * Add keyboard input support to the input manager.
  121347. * @returns the current input manager
  121348. */
  121349. addKeyboard(): FollowCameraInputsManager;
  121350. /**
  121351. * Add mouse wheel input support to the input manager.
  121352. * @returns the current input manager
  121353. */
  121354. addMouseWheel(): FollowCameraInputsManager;
  121355. /**
  121356. * Add pointers input support to the input manager.
  121357. * @returns the current input manager
  121358. */
  121359. addPointers(): FollowCameraInputsManager;
  121360. /**
  121361. * Add orientation input support to the input manager.
  121362. * @returns the current input manager
  121363. */
  121364. addVRDeviceOrientation(): FollowCameraInputsManager;
  121365. }
  121366. }
  121367. declare module BABYLON {
  121368. /**
  121369. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121370. * an arc rotate version arcFollowCamera are available.
  121371. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121372. */
  121373. export class FollowCamera extends TargetCamera {
  121374. /**
  121375. * Distance the follow camera should follow an object at
  121376. */
  121377. radius: number;
  121378. /**
  121379. * Minimum allowed distance of the camera to the axis of rotation
  121380. * (The camera can not get closer).
  121381. * This can help limiting how the Camera is able to move in the scene.
  121382. */
  121383. lowerRadiusLimit: Nullable<number>;
  121384. /**
  121385. * Maximum allowed distance of the camera to the axis of rotation
  121386. * (The camera can not get further).
  121387. * This can help limiting how the Camera is able to move in the scene.
  121388. */
  121389. upperRadiusLimit: Nullable<number>;
  121390. /**
  121391. * Define a rotation offset between the camera and the object it follows
  121392. */
  121393. rotationOffset: number;
  121394. /**
  121395. * Minimum allowed angle to camera position relative to target object.
  121396. * This can help limiting how the Camera is able to move in the scene.
  121397. */
  121398. lowerRotationOffsetLimit: Nullable<number>;
  121399. /**
  121400. * Maximum allowed angle to camera position relative to target object.
  121401. * This can help limiting how the Camera is able to move in the scene.
  121402. */
  121403. upperRotationOffsetLimit: Nullable<number>;
  121404. /**
  121405. * Define a height offset between the camera and the object it follows.
  121406. * It can help following an object from the top (like a car chaing a plane)
  121407. */
  121408. heightOffset: number;
  121409. /**
  121410. * Minimum allowed height of camera position relative to target object.
  121411. * This can help limiting how the Camera is able to move in the scene.
  121412. */
  121413. lowerHeightOffsetLimit: Nullable<number>;
  121414. /**
  121415. * Maximum allowed height of camera position relative to target object.
  121416. * This can help limiting how the Camera is able to move in the scene.
  121417. */
  121418. upperHeightOffsetLimit: Nullable<number>;
  121419. /**
  121420. * Define how fast the camera can accelerate to follow it s target.
  121421. */
  121422. cameraAcceleration: number;
  121423. /**
  121424. * Define the speed limit of the camera following an object.
  121425. */
  121426. maxCameraSpeed: number;
  121427. /**
  121428. * Define the target of the camera.
  121429. */
  121430. lockedTarget: Nullable<AbstractMesh>;
  121431. /**
  121432. * Defines the input associated with the camera.
  121433. */
  121434. inputs: FollowCameraInputsManager;
  121435. /**
  121436. * Instantiates the follow camera.
  121437. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121438. * @param name Define the name of the camera in the scene
  121439. * @param position Define the position of the camera
  121440. * @param scene Define the scene the camera belong to
  121441. * @param lockedTarget Define the target of the camera
  121442. */
  121443. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121444. private _follow;
  121445. /**
  121446. * Attached controls to the current camera.
  121447. * @param element Defines the element the controls should be listened from
  121448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121449. */
  121450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121451. /**
  121452. * Detach the current controls from the camera.
  121453. * The camera will stop reacting to inputs.
  121454. * @param element Defines the element to stop listening the inputs from
  121455. */
  121456. detachControl(element: HTMLElement): void;
  121457. /** @hidden */
  121458. _checkInputs(): void;
  121459. private _checkLimits;
  121460. /**
  121461. * Gets the camera class name.
  121462. * @returns the class name
  121463. */
  121464. getClassName(): string;
  121465. }
  121466. /**
  121467. * Arc Rotate version of the follow camera.
  121468. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121469. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121470. */
  121471. export class ArcFollowCamera extends TargetCamera {
  121472. /** The longitudinal angle of the camera */
  121473. alpha: number;
  121474. /** The latitudinal angle of the camera */
  121475. beta: number;
  121476. /** The radius of the camera from its target */
  121477. radius: number;
  121478. /** Define the camera target (the mesh it should follow) */
  121479. target: Nullable<AbstractMesh>;
  121480. private _cartesianCoordinates;
  121481. /**
  121482. * Instantiates a new ArcFollowCamera
  121483. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121484. * @param name Define the name of the camera
  121485. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121486. * @param beta Define the rotation angle of the camera around the elevation axis
  121487. * @param radius Define the radius of the camera from its target point
  121488. * @param target Define the target of the camera
  121489. * @param scene Define the scene the camera belongs to
  121490. */
  121491. constructor(name: string,
  121492. /** The longitudinal angle of the camera */
  121493. alpha: number,
  121494. /** The latitudinal angle of the camera */
  121495. beta: number,
  121496. /** The radius of the camera from its target */
  121497. radius: number,
  121498. /** Define the camera target (the mesh it should follow) */
  121499. target: Nullable<AbstractMesh>, scene: Scene);
  121500. private _follow;
  121501. /** @hidden */
  121502. _checkInputs(): void;
  121503. /**
  121504. * Returns the class name of the object.
  121505. * It is mostly used internally for serialization purposes.
  121506. */
  121507. getClassName(): string;
  121508. }
  121509. }
  121510. declare module BABYLON {
  121511. /**
  121512. * Manage the keyboard inputs to control the movement of a follow camera.
  121513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121514. */
  121515. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121516. /**
  121517. * Defines the camera the input is attached to.
  121518. */
  121519. camera: FollowCamera;
  121520. /**
  121521. * Defines the list of key codes associated with the up action (increase heightOffset)
  121522. */
  121523. keysHeightOffsetIncr: number[];
  121524. /**
  121525. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121526. */
  121527. keysHeightOffsetDecr: number[];
  121528. /**
  121529. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121530. */
  121531. keysHeightOffsetModifierAlt: boolean;
  121532. /**
  121533. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121534. */
  121535. keysHeightOffsetModifierCtrl: boolean;
  121536. /**
  121537. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121538. */
  121539. keysHeightOffsetModifierShift: boolean;
  121540. /**
  121541. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121542. */
  121543. keysRotationOffsetIncr: number[];
  121544. /**
  121545. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121546. */
  121547. keysRotationOffsetDecr: number[];
  121548. /**
  121549. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121550. */
  121551. keysRotationOffsetModifierAlt: boolean;
  121552. /**
  121553. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121554. */
  121555. keysRotationOffsetModifierCtrl: boolean;
  121556. /**
  121557. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121558. */
  121559. keysRotationOffsetModifierShift: boolean;
  121560. /**
  121561. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121562. */
  121563. keysRadiusIncr: number[];
  121564. /**
  121565. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121566. */
  121567. keysRadiusDecr: number[];
  121568. /**
  121569. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121570. */
  121571. keysRadiusModifierAlt: boolean;
  121572. /**
  121573. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121574. */
  121575. keysRadiusModifierCtrl: boolean;
  121576. /**
  121577. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121578. */
  121579. keysRadiusModifierShift: boolean;
  121580. /**
  121581. * Defines the rate of change of heightOffset.
  121582. */
  121583. heightSensibility: number;
  121584. /**
  121585. * Defines the rate of change of rotationOffset.
  121586. */
  121587. rotationSensibility: number;
  121588. /**
  121589. * Defines the rate of change of radius.
  121590. */
  121591. radiusSensibility: number;
  121592. private _keys;
  121593. private _ctrlPressed;
  121594. private _altPressed;
  121595. private _shiftPressed;
  121596. private _onCanvasBlurObserver;
  121597. private _onKeyboardObserver;
  121598. private _engine;
  121599. private _scene;
  121600. /**
  121601. * Attach the input controls to a specific dom element to get the input from.
  121602. * @param element Defines the element the controls should be listened from
  121603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121604. */
  121605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121606. /**
  121607. * Detach the current controls from the specified dom element.
  121608. * @param element Defines the element to stop listening the inputs from
  121609. */
  121610. detachControl(element: Nullable<HTMLElement>): void;
  121611. /**
  121612. * Update the current camera state depending on the inputs that have been used this frame.
  121613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121614. */
  121615. checkInputs(): void;
  121616. /**
  121617. * Gets the class name of the current input.
  121618. * @returns the class name
  121619. */
  121620. getClassName(): string;
  121621. /**
  121622. * Get the friendly name associated with the input class.
  121623. * @returns the input friendly name
  121624. */
  121625. getSimpleName(): string;
  121626. /**
  121627. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121628. * allow modification of the heightOffset value.
  121629. */
  121630. private _modifierHeightOffset;
  121631. /**
  121632. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121633. * allow modification of the rotationOffset value.
  121634. */
  121635. private _modifierRotationOffset;
  121636. /**
  121637. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121638. * allow modification of the radius value.
  121639. */
  121640. private _modifierRadius;
  121641. }
  121642. }
  121643. declare module BABYLON {
  121644. interface FreeCameraInputsManager {
  121645. /**
  121646. * @hidden
  121647. */
  121648. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121649. /**
  121650. * Add orientation input support to the input manager.
  121651. * @returns the current input manager
  121652. */
  121653. addDeviceOrientation(): FreeCameraInputsManager;
  121654. }
  121655. /**
  121656. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121657. * Screen rotation is taken into account.
  121658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121659. */
  121660. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121661. private _camera;
  121662. private _screenOrientationAngle;
  121663. private _constantTranform;
  121664. private _screenQuaternion;
  121665. private _alpha;
  121666. private _beta;
  121667. private _gamma;
  121668. /**
  121669. * Can be used to detect if a device orientation sensor is available on a device
  121670. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121671. * @returns a promise that will resolve on orientation change
  121672. */
  121673. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121674. /**
  121675. * @hidden
  121676. */
  121677. _onDeviceOrientationChangedObservable: Observable<void>;
  121678. /**
  121679. * Instantiates a new input
  121680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121681. */
  121682. constructor();
  121683. /**
  121684. * Define the camera controlled by the input.
  121685. */
  121686. get camera(): FreeCamera;
  121687. set camera(camera: FreeCamera);
  121688. /**
  121689. * Attach the input controls to a specific dom element to get the input from.
  121690. * @param element Defines the element the controls should be listened from
  121691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121692. */
  121693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121694. private _orientationChanged;
  121695. private _deviceOrientation;
  121696. /**
  121697. * Detach the current controls from the specified dom element.
  121698. * @param element Defines the element to stop listening the inputs from
  121699. */
  121700. detachControl(element: Nullable<HTMLElement>): void;
  121701. /**
  121702. * Update the current camera state depending on the inputs that have been used this frame.
  121703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121704. */
  121705. checkInputs(): void;
  121706. /**
  121707. * Gets the class name of the current intput.
  121708. * @returns the class name
  121709. */
  121710. getClassName(): string;
  121711. /**
  121712. * Get the friendly name associated with the input class.
  121713. * @returns the input friendly name
  121714. */
  121715. getSimpleName(): string;
  121716. }
  121717. }
  121718. declare module BABYLON {
  121719. /**
  121720. * Manage the gamepad inputs to control a free camera.
  121721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121722. */
  121723. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121724. /**
  121725. * Define the camera the input is attached to.
  121726. */
  121727. camera: FreeCamera;
  121728. /**
  121729. * Define the Gamepad controlling the input
  121730. */
  121731. gamepad: Nullable<Gamepad>;
  121732. /**
  121733. * Defines the gamepad rotation sensiblity.
  121734. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121735. */
  121736. gamepadAngularSensibility: number;
  121737. /**
  121738. * Defines the gamepad move sensiblity.
  121739. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121740. */
  121741. gamepadMoveSensibility: number;
  121742. private _yAxisScale;
  121743. /**
  121744. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121745. */
  121746. get invertYAxis(): boolean;
  121747. set invertYAxis(value: boolean);
  121748. private _onGamepadConnectedObserver;
  121749. private _onGamepadDisconnectedObserver;
  121750. private _cameraTransform;
  121751. private _deltaTransform;
  121752. private _vector3;
  121753. private _vector2;
  121754. /**
  121755. * Attach the input controls to a specific dom element to get the input from.
  121756. * @param element Defines the element the controls should be listened from
  121757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121758. */
  121759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121760. /**
  121761. * Detach the current controls from the specified dom element.
  121762. * @param element Defines the element to stop listening the inputs from
  121763. */
  121764. detachControl(element: Nullable<HTMLElement>): void;
  121765. /**
  121766. * Update the current camera state depending on the inputs that have been used this frame.
  121767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121768. */
  121769. checkInputs(): void;
  121770. /**
  121771. * Gets the class name of the current intput.
  121772. * @returns the class name
  121773. */
  121774. getClassName(): string;
  121775. /**
  121776. * Get the friendly name associated with the input class.
  121777. * @returns the input friendly name
  121778. */
  121779. getSimpleName(): string;
  121780. }
  121781. }
  121782. declare module BABYLON {
  121783. /**
  121784. * Defines the potential axis of a Joystick
  121785. */
  121786. export enum JoystickAxis {
  121787. /** X axis */
  121788. X = 0,
  121789. /** Y axis */
  121790. Y = 1,
  121791. /** Z axis */
  121792. Z = 2
  121793. }
  121794. /**
  121795. * Class used to define virtual joystick (used in touch mode)
  121796. */
  121797. export class VirtualJoystick {
  121798. /**
  121799. * Gets or sets a boolean indicating that left and right values must be inverted
  121800. */
  121801. reverseLeftRight: boolean;
  121802. /**
  121803. * Gets or sets a boolean indicating that up and down values must be inverted
  121804. */
  121805. reverseUpDown: boolean;
  121806. /**
  121807. * Gets the offset value for the position (ie. the change of the position value)
  121808. */
  121809. deltaPosition: Vector3;
  121810. /**
  121811. * Gets a boolean indicating if the virtual joystick was pressed
  121812. */
  121813. pressed: boolean;
  121814. /**
  121815. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121816. */
  121817. static Canvas: Nullable<HTMLCanvasElement>;
  121818. private static _globalJoystickIndex;
  121819. private static vjCanvasContext;
  121820. private static vjCanvasWidth;
  121821. private static vjCanvasHeight;
  121822. private static halfWidth;
  121823. private _action;
  121824. private _axisTargetedByLeftAndRight;
  121825. private _axisTargetedByUpAndDown;
  121826. private _joystickSensibility;
  121827. private _inversedSensibility;
  121828. private _joystickPointerID;
  121829. private _joystickColor;
  121830. private _joystickPointerPos;
  121831. private _joystickPreviousPointerPos;
  121832. private _joystickPointerStartPos;
  121833. private _deltaJoystickVector;
  121834. private _leftJoystick;
  121835. private _touches;
  121836. private _onPointerDownHandlerRef;
  121837. private _onPointerMoveHandlerRef;
  121838. private _onPointerUpHandlerRef;
  121839. private _onResize;
  121840. /**
  121841. * Creates a new virtual joystick
  121842. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121843. */
  121844. constructor(leftJoystick?: boolean);
  121845. /**
  121846. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121847. * @param newJoystickSensibility defines the new sensibility
  121848. */
  121849. setJoystickSensibility(newJoystickSensibility: number): void;
  121850. private _onPointerDown;
  121851. private _onPointerMove;
  121852. private _onPointerUp;
  121853. /**
  121854. * Change the color of the virtual joystick
  121855. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121856. */
  121857. setJoystickColor(newColor: string): void;
  121858. /**
  121859. * Defines a callback to call when the joystick is touched
  121860. * @param action defines the callback
  121861. */
  121862. setActionOnTouch(action: () => any): void;
  121863. /**
  121864. * Defines which axis you'd like to control for left & right
  121865. * @param axis defines the axis to use
  121866. */
  121867. setAxisForLeftRight(axis: JoystickAxis): void;
  121868. /**
  121869. * Defines which axis you'd like to control for up & down
  121870. * @param axis defines the axis to use
  121871. */
  121872. setAxisForUpDown(axis: JoystickAxis): void;
  121873. private _drawVirtualJoystick;
  121874. /**
  121875. * Release internal HTML canvas
  121876. */
  121877. releaseCanvas(): void;
  121878. }
  121879. }
  121880. declare module BABYLON {
  121881. interface FreeCameraInputsManager {
  121882. /**
  121883. * Add virtual joystick input support to the input manager.
  121884. * @returns the current input manager
  121885. */
  121886. addVirtualJoystick(): FreeCameraInputsManager;
  121887. }
  121888. /**
  121889. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121891. */
  121892. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121893. /**
  121894. * Defines the camera the input is attached to.
  121895. */
  121896. camera: FreeCamera;
  121897. private _leftjoystick;
  121898. private _rightjoystick;
  121899. /**
  121900. * Gets the left stick of the virtual joystick.
  121901. * @returns The virtual Joystick
  121902. */
  121903. getLeftJoystick(): VirtualJoystick;
  121904. /**
  121905. * Gets the right stick of the virtual joystick.
  121906. * @returns The virtual Joystick
  121907. */
  121908. getRightJoystick(): VirtualJoystick;
  121909. /**
  121910. * Update the current camera state depending on the inputs that have been used this frame.
  121911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121912. */
  121913. checkInputs(): void;
  121914. /**
  121915. * Attach the input controls to a specific dom element to get the input from.
  121916. * @param element Defines the element the controls should be listened from
  121917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121918. */
  121919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121920. /**
  121921. * Detach the current controls from the specified dom element.
  121922. * @param element Defines the element to stop listening the inputs from
  121923. */
  121924. detachControl(element: Nullable<HTMLElement>): void;
  121925. /**
  121926. * Gets the class name of the current intput.
  121927. * @returns the class name
  121928. */
  121929. getClassName(): string;
  121930. /**
  121931. * Get the friendly name associated with the input class.
  121932. * @returns the input friendly name
  121933. */
  121934. getSimpleName(): string;
  121935. }
  121936. }
  121937. declare module BABYLON {
  121938. /**
  121939. * This represents a FPS type of camera controlled by touch.
  121940. * This is like a universal camera minus the Gamepad controls.
  121941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121942. */
  121943. export class TouchCamera extends FreeCamera {
  121944. /**
  121945. * Defines the touch sensibility for rotation.
  121946. * The higher the faster.
  121947. */
  121948. get touchAngularSensibility(): number;
  121949. set touchAngularSensibility(value: number);
  121950. /**
  121951. * Defines the touch sensibility for move.
  121952. * The higher the faster.
  121953. */
  121954. get touchMoveSensibility(): number;
  121955. set touchMoveSensibility(value: number);
  121956. /**
  121957. * Instantiates a new touch camera.
  121958. * This represents a FPS type of camera controlled by touch.
  121959. * This is like a universal camera minus the Gamepad controls.
  121960. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121961. * @param name Define the name of the camera in the scene
  121962. * @param position Define the start position of the camera in the scene
  121963. * @param scene Define the scene the camera belongs to
  121964. */
  121965. constructor(name: string, position: Vector3, scene: Scene);
  121966. /**
  121967. * Gets the current object class name.
  121968. * @return the class name
  121969. */
  121970. getClassName(): string;
  121971. /** @hidden */
  121972. _setupInputs(): void;
  121973. }
  121974. }
  121975. declare module BABYLON {
  121976. /**
  121977. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121978. * being tilted forward or back and left or right.
  121979. */
  121980. export class DeviceOrientationCamera extends FreeCamera {
  121981. private _initialQuaternion;
  121982. private _quaternionCache;
  121983. private _tmpDragQuaternion;
  121984. private _disablePointerInputWhenUsingDeviceOrientation;
  121985. /**
  121986. * Creates a new device orientation camera
  121987. * @param name The name of the camera
  121988. * @param position The start position camera
  121989. * @param scene The scene the camera belongs to
  121990. */
  121991. constructor(name: string, position: Vector3, scene: Scene);
  121992. /**
  121993. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121994. */
  121995. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121996. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121997. private _dragFactor;
  121998. /**
  121999. * Enabled turning on the y axis when the orientation sensor is active
  122000. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122001. */
  122002. enableHorizontalDragging(dragFactor?: number): void;
  122003. /**
  122004. * Gets the current instance class name ("DeviceOrientationCamera").
  122005. * This helps avoiding instanceof at run time.
  122006. * @returns the class name
  122007. */
  122008. getClassName(): string;
  122009. /**
  122010. * @hidden
  122011. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122012. */
  122013. _checkInputs(): void;
  122014. /**
  122015. * Reset the camera to its default orientation on the specified axis only.
  122016. * @param axis The axis to reset
  122017. */
  122018. resetToCurrentRotation(axis?: Axis): void;
  122019. }
  122020. }
  122021. declare module BABYLON {
  122022. /**
  122023. * Defines supported buttons for XBox360 compatible gamepads
  122024. */
  122025. export enum Xbox360Button {
  122026. /** A */
  122027. A = 0,
  122028. /** B */
  122029. B = 1,
  122030. /** X */
  122031. X = 2,
  122032. /** Y */
  122033. Y = 3,
  122034. /** Left button */
  122035. LB = 4,
  122036. /** Right button */
  122037. RB = 5,
  122038. /** Back */
  122039. Back = 8,
  122040. /** Start */
  122041. Start = 9,
  122042. /** Left stick */
  122043. LeftStick = 10,
  122044. /** Right stick */
  122045. RightStick = 11
  122046. }
  122047. /** Defines values for XBox360 DPad */
  122048. export enum Xbox360Dpad {
  122049. /** Up */
  122050. Up = 12,
  122051. /** Down */
  122052. Down = 13,
  122053. /** Left */
  122054. Left = 14,
  122055. /** Right */
  122056. Right = 15
  122057. }
  122058. /**
  122059. * Defines a XBox360 gamepad
  122060. */
  122061. export class Xbox360Pad extends Gamepad {
  122062. private _leftTrigger;
  122063. private _rightTrigger;
  122064. private _onlefttriggerchanged;
  122065. private _onrighttriggerchanged;
  122066. private _onbuttondown;
  122067. private _onbuttonup;
  122068. private _ondpaddown;
  122069. private _ondpadup;
  122070. /** Observable raised when a button is pressed */
  122071. onButtonDownObservable: Observable<Xbox360Button>;
  122072. /** Observable raised when a button is released */
  122073. onButtonUpObservable: Observable<Xbox360Button>;
  122074. /** Observable raised when a pad is pressed */
  122075. onPadDownObservable: Observable<Xbox360Dpad>;
  122076. /** Observable raised when a pad is released */
  122077. onPadUpObservable: Observable<Xbox360Dpad>;
  122078. private _buttonA;
  122079. private _buttonB;
  122080. private _buttonX;
  122081. private _buttonY;
  122082. private _buttonBack;
  122083. private _buttonStart;
  122084. private _buttonLB;
  122085. private _buttonRB;
  122086. private _buttonLeftStick;
  122087. private _buttonRightStick;
  122088. private _dPadUp;
  122089. private _dPadDown;
  122090. private _dPadLeft;
  122091. private _dPadRight;
  122092. private _isXboxOnePad;
  122093. /**
  122094. * Creates a new XBox360 gamepad object
  122095. * @param id defines the id of this gamepad
  122096. * @param index defines its index
  122097. * @param gamepad defines the internal HTML gamepad object
  122098. * @param xboxOne defines if it is a XBox One gamepad
  122099. */
  122100. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122101. /**
  122102. * Defines the callback to call when left trigger is pressed
  122103. * @param callback defines the callback to use
  122104. */
  122105. onlefttriggerchanged(callback: (value: number) => void): void;
  122106. /**
  122107. * Defines the callback to call when right trigger is pressed
  122108. * @param callback defines the callback to use
  122109. */
  122110. onrighttriggerchanged(callback: (value: number) => void): void;
  122111. /**
  122112. * Gets the left trigger value
  122113. */
  122114. get leftTrigger(): number;
  122115. /**
  122116. * Sets the left trigger value
  122117. */
  122118. set leftTrigger(newValue: number);
  122119. /**
  122120. * Gets the right trigger value
  122121. */
  122122. get rightTrigger(): number;
  122123. /**
  122124. * Sets the right trigger value
  122125. */
  122126. set rightTrigger(newValue: number);
  122127. /**
  122128. * Defines the callback to call when a button is pressed
  122129. * @param callback defines the callback to use
  122130. */
  122131. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122132. /**
  122133. * Defines the callback to call when a button is released
  122134. * @param callback defines the callback to use
  122135. */
  122136. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122137. /**
  122138. * Defines the callback to call when a pad is pressed
  122139. * @param callback defines the callback to use
  122140. */
  122141. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122142. /**
  122143. * Defines the callback to call when a pad is released
  122144. * @param callback defines the callback to use
  122145. */
  122146. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122147. private _setButtonValue;
  122148. private _setDPadValue;
  122149. /**
  122150. * Gets the value of the `A` button
  122151. */
  122152. get buttonA(): number;
  122153. /**
  122154. * Sets the value of the `A` button
  122155. */
  122156. set buttonA(value: number);
  122157. /**
  122158. * Gets the value of the `B` button
  122159. */
  122160. get buttonB(): number;
  122161. /**
  122162. * Sets the value of the `B` button
  122163. */
  122164. set buttonB(value: number);
  122165. /**
  122166. * Gets the value of the `X` button
  122167. */
  122168. get buttonX(): number;
  122169. /**
  122170. * Sets the value of the `X` button
  122171. */
  122172. set buttonX(value: number);
  122173. /**
  122174. * Gets the value of the `Y` button
  122175. */
  122176. get buttonY(): number;
  122177. /**
  122178. * Sets the value of the `Y` button
  122179. */
  122180. set buttonY(value: number);
  122181. /**
  122182. * Gets the value of the `Start` button
  122183. */
  122184. get buttonStart(): number;
  122185. /**
  122186. * Sets the value of the `Start` button
  122187. */
  122188. set buttonStart(value: number);
  122189. /**
  122190. * Gets the value of the `Back` button
  122191. */
  122192. get buttonBack(): number;
  122193. /**
  122194. * Sets the value of the `Back` button
  122195. */
  122196. set buttonBack(value: number);
  122197. /**
  122198. * Gets the value of the `Left` button
  122199. */
  122200. get buttonLB(): number;
  122201. /**
  122202. * Sets the value of the `Left` button
  122203. */
  122204. set buttonLB(value: number);
  122205. /**
  122206. * Gets the value of the `Right` button
  122207. */
  122208. get buttonRB(): number;
  122209. /**
  122210. * Sets the value of the `Right` button
  122211. */
  122212. set buttonRB(value: number);
  122213. /**
  122214. * Gets the value of the Left joystick
  122215. */
  122216. get buttonLeftStick(): number;
  122217. /**
  122218. * Sets the value of the Left joystick
  122219. */
  122220. set buttonLeftStick(value: number);
  122221. /**
  122222. * Gets the value of the Right joystick
  122223. */
  122224. get buttonRightStick(): number;
  122225. /**
  122226. * Sets the value of the Right joystick
  122227. */
  122228. set buttonRightStick(value: number);
  122229. /**
  122230. * Gets the value of D-pad up
  122231. */
  122232. get dPadUp(): number;
  122233. /**
  122234. * Sets the value of D-pad up
  122235. */
  122236. set dPadUp(value: number);
  122237. /**
  122238. * Gets the value of D-pad down
  122239. */
  122240. get dPadDown(): number;
  122241. /**
  122242. * Sets the value of D-pad down
  122243. */
  122244. set dPadDown(value: number);
  122245. /**
  122246. * Gets the value of D-pad left
  122247. */
  122248. get dPadLeft(): number;
  122249. /**
  122250. * Sets the value of D-pad left
  122251. */
  122252. set dPadLeft(value: number);
  122253. /**
  122254. * Gets the value of D-pad right
  122255. */
  122256. get dPadRight(): number;
  122257. /**
  122258. * Sets the value of D-pad right
  122259. */
  122260. set dPadRight(value: number);
  122261. /**
  122262. * Force the gamepad to synchronize with device values
  122263. */
  122264. update(): void;
  122265. /**
  122266. * Disposes the gamepad
  122267. */
  122268. dispose(): void;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /**
  122273. * Defines supported buttons for DualShock compatible gamepads
  122274. */
  122275. export enum DualShockButton {
  122276. /** Cross */
  122277. Cross = 0,
  122278. /** Circle */
  122279. Circle = 1,
  122280. /** Square */
  122281. Square = 2,
  122282. /** Triangle */
  122283. Triangle = 3,
  122284. /** L1 */
  122285. L1 = 4,
  122286. /** R1 */
  122287. R1 = 5,
  122288. /** Share */
  122289. Share = 8,
  122290. /** Options */
  122291. Options = 9,
  122292. /** Left stick */
  122293. LeftStick = 10,
  122294. /** Right stick */
  122295. RightStick = 11
  122296. }
  122297. /** Defines values for DualShock DPad */
  122298. export enum DualShockDpad {
  122299. /** Up */
  122300. Up = 12,
  122301. /** Down */
  122302. Down = 13,
  122303. /** Left */
  122304. Left = 14,
  122305. /** Right */
  122306. Right = 15
  122307. }
  122308. /**
  122309. * Defines a DualShock gamepad
  122310. */
  122311. export class DualShockPad extends Gamepad {
  122312. private _leftTrigger;
  122313. private _rightTrigger;
  122314. private _onlefttriggerchanged;
  122315. private _onrighttriggerchanged;
  122316. private _onbuttondown;
  122317. private _onbuttonup;
  122318. private _ondpaddown;
  122319. private _ondpadup;
  122320. /** Observable raised when a button is pressed */
  122321. onButtonDownObservable: Observable<DualShockButton>;
  122322. /** Observable raised when a button is released */
  122323. onButtonUpObservable: Observable<DualShockButton>;
  122324. /** Observable raised when a pad is pressed */
  122325. onPadDownObservable: Observable<DualShockDpad>;
  122326. /** Observable raised when a pad is released */
  122327. onPadUpObservable: Observable<DualShockDpad>;
  122328. private _buttonCross;
  122329. private _buttonCircle;
  122330. private _buttonSquare;
  122331. private _buttonTriangle;
  122332. private _buttonShare;
  122333. private _buttonOptions;
  122334. private _buttonL1;
  122335. private _buttonR1;
  122336. private _buttonLeftStick;
  122337. private _buttonRightStick;
  122338. private _dPadUp;
  122339. private _dPadDown;
  122340. private _dPadLeft;
  122341. private _dPadRight;
  122342. /**
  122343. * Creates a new DualShock gamepad object
  122344. * @param id defines the id of this gamepad
  122345. * @param index defines its index
  122346. * @param gamepad defines the internal HTML gamepad object
  122347. */
  122348. constructor(id: string, index: number, gamepad: any);
  122349. /**
  122350. * Defines the callback to call when left trigger is pressed
  122351. * @param callback defines the callback to use
  122352. */
  122353. onlefttriggerchanged(callback: (value: number) => void): void;
  122354. /**
  122355. * Defines the callback to call when right trigger is pressed
  122356. * @param callback defines the callback to use
  122357. */
  122358. onrighttriggerchanged(callback: (value: number) => void): void;
  122359. /**
  122360. * Gets the left trigger value
  122361. */
  122362. get leftTrigger(): number;
  122363. /**
  122364. * Sets the left trigger value
  122365. */
  122366. set leftTrigger(newValue: number);
  122367. /**
  122368. * Gets the right trigger value
  122369. */
  122370. get rightTrigger(): number;
  122371. /**
  122372. * Sets the right trigger value
  122373. */
  122374. set rightTrigger(newValue: number);
  122375. /**
  122376. * Defines the callback to call when a button is pressed
  122377. * @param callback defines the callback to use
  122378. */
  122379. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122380. /**
  122381. * Defines the callback to call when a button is released
  122382. * @param callback defines the callback to use
  122383. */
  122384. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122385. /**
  122386. * Defines the callback to call when a pad is pressed
  122387. * @param callback defines the callback to use
  122388. */
  122389. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122390. /**
  122391. * Defines the callback to call when a pad is released
  122392. * @param callback defines the callback to use
  122393. */
  122394. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122395. private _setButtonValue;
  122396. private _setDPadValue;
  122397. /**
  122398. * Gets the value of the `Cross` button
  122399. */
  122400. get buttonCross(): number;
  122401. /**
  122402. * Sets the value of the `Cross` button
  122403. */
  122404. set buttonCross(value: number);
  122405. /**
  122406. * Gets the value of the `Circle` button
  122407. */
  122408. get buttonCircle(): number;
  122409. /**
  122410. * Sets the value of the `Circle` button
  122411. */
  122412. set buttonCircle(value: number);
  122413. /**
  122414. * Gets the value of the `Square` button
  122415. */
  122416. get buttonSquare(): number;
  122417. /**
  122418. * Sets the value of the `Square` button
  122419. */
  122420. set buttonSquare(value: number);
  122421. /**
  122422. * Gets the value of the `Triangle` button
  122423. */
  122424. get buttonTriangle(): number;
  122425. /**
  122426. * Sets the value of the `Triangle` button
  122427. */
  122428. set buttonTriangle(value: number);
  122429. /**
  122430. * Gets the value of the `Options` button
  122431. */
  122432. get buttonOptions(): number;
  122433. /**
  122434. * Sets the value of the `Options` button
  122435. */
  122436. set buttonOptions(value: number);
  122437. /**
  122438. * Gets the value of the `Share` button
  122439. */
  122440. get buttonShare(): number;
  122441. /**
  122442. * Sets the value of the `Share` button
  122443. */
  122444. set buttonShare(value: number);
  122445. /**
  122446. * Gets the value of the `L1` button
  122447. */
  122448. get buttonL1(): number;
  122449. /**
  122450. * Sets the value of the `L1` button
  122451. */
  122452. set buttonL1(value: number);
  122453. /**
  122454. * Gets the value of the `R1` button
  122455. */
  122456. get buttonR1(): number;
  122457. /**
  122458. * Sets the value of the `R1` button
  122459. */
  122460. set buttonR1(value: number);
  122461. /**
  122462. * Gets the value of the Left joystick
  122463. */
  122464. get buttonLeftStick(): number;
  122465. /**
  122466. * Sets the value of the Left joystick
  122467. */
  122468. set buttonLeftStick(value: number);
  122469. /**
  122470. * Gets the value of the Right joystick
  122471. */
  122472. get buttonRightStick(): number;
  122473. /**
  122474. * Sets the value of the Right joystick
  122475. */
  122476. set buttonRightStick(value: number);
  122477. /**
  122478. * Gets the value of D-pad up
  122479. */
  122480. get dPadUp(): number;
  122481. /**
  122482. * Sets the value of D-pad up
  122483. */
  122484. set dPadUp(value: number);
  122485. /**
  122486. * Gets the value of D-pad down
  122487. */
  122488. get dPadDown(): number;
  122489. /**
  122490. * Sets the value of D-pad down
  122491. */
  122492. set dPadDown(value: number);
  122493. /**
  122494. * Gets the value of D-pad left
  122495. */
  122496. get dPadLeft(): number;
  122497. /**
  122498. * Sets the value of D-pad left
  122499. */
  122500. set dPadLeft(value: number);
  122501. /**
  122502. * Gets the value of D-pad right
  122503. */
  122504. get dPadRight(): number;
  122505. /**
  122506. * Sets the value of D-pad right
  122507. */
  122508. set dPadRight(value: number);
  122509. /**
  122510. * Force the gamepad to synchronize with device values
  122511. */
  122512. update(): void;
  122513. /**
  122514. * Disposes the gamepad
  122515. */
  122516. dispose(): void;
  122517. }
  122518. }
  122519. declare module BABYLON {
  122520. /**
  122521. * Manager for handling gamepads
  122522. */
  122523. export class GamepadManager {
  122524. private _scene?;
  122525. private _babylonGamepads;
  122526. private _oneGamepadConnected;
  122527. /** @hidden */
  122528. _isMonitoring: boolean;
  122529. private _gamepadEventSupported;
  122530. private _gamepadSupport?;
  122531. /**
  122532. * observable to be triggered when the gamepad controller has been connected
  122533. */
  122534. onGamepadConnectedObservable: Observable<Gamepad>;
  122535. /**
  122536. * observable to be triggered when the gamepad controller has been disconnected
  122537. */
  122538. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122539. private _onGamepadConnectedEvent;
  122540. private _onGamepadDisconnectedEvent;
  122541. /**
  122542. * Initializes the gamepad manager
  122543. * @param _scene BabylonJS scene
  122544. */
  122545. constructor(_scene?: Scene | undefined);
  122546. /**
  122547. * The gamepads in the game pad manager
  122548. */
  122549. get gamepads(): Gamepad[];
  122550. /**
  122551. * Get the gamepad controllers based on type
  122552. * @param type The type of gamepad controller
  122553. * @returns Nullable gamepad
  122554. */
  122555. getGamepadByType(type?: number): Nullable<Gamepad>;
  122556. /**
  122557. * Disposes the gamepad manager
  122558. */
  122559. dispose(): void;
  122560. private _addNewGamepad;
  122561. private _startMonitoringGamepads;
  122562. private _stopMonitoringGamepads;
  122563. /** @hidden */
  122564. _checkGamepadsStatus(): void;
  122565. private _updateGamepadObjects;
  122566. }
  122567. }
  122568. declare module BABYLON {
  122569. interface Scene {
  122570. /** @hidden */
  122571. _gamepadManager: Nullable<GamepadManager>;
  122572. /**
  122573. * Gets the gamepad manager associated with the scene
  122574. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122575. */
  122576. gamepadManager: GamepadManager;
  122577. }
  122578. /**
  122579. * Interface representing a free camera inputs manager
  122580. */
  122581. interface FreeCameraInputsManager {
  122582. /**
  122583. * Adds gamepad input support to the FreeCameraInputsManager.
  122584. * @returns the FreeCameraInputsManager
  122585. */
  122586. addGamepad(): FreeCameraInputsManager;
  122587. }
  122588. /**
  122589. * Interface representing an arc rotate camera inputs manager
  122590. */
  122591. interface ArcRotateCameraInputsManager {
  122592. /**
  122593. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122594. * @returns the camera inputs manager
  122595. */
  122596. addGamepad(): ArcRotateCameraInputsManager;
  122597. }
  122598. /**
  122599. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122600. */
  122601. export class GamepadSystemSceneComponent implements ISceneComponent {
  122602. /**
  122603. * The component name helpfull to identify the component in the list of scene components.
  122604. */
  122605. readonly name: string;
  122606. /**
  122607. * The scene the component belongs to.
  122608. */
  122609. scene: Scene;
  122610. /**
  122611. * Creates a new instance of the component for the given scene
  122612. * @param scene Defines the scene to register the component in
  122613. */
  122614. constructor(scene: Scene);
  122615. /**
  122616. * Registers the component in a given scene
  122617. */
  122618. register(): void;
  122619. /**
  122620. * Rebuilds the elements related to this component in case of
  122621. * context lost for instance.
  122622. */
  122623. rebuild(): void;
  122624. /**
  122625. * Disposes the component and the associated ressources
  122626. */
  122627. dispose(): void;
  122628. private _beforeCameraUpdate;
  122629. }
  122630. }
  122631. declare module BABYLON {
  122632. /**
  122633. * 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,
  122634. * which still works and will still be found in many Playgrounds.
  122635. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122636. */
  122637. export class UniversalCamera extends TouchCamera {
  122638. /**
  122639. * Defines the gamepad rotation sensiblity.
  122640. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122641. */
  122642. get gamepadAngularSensibility(): number;
  122643. set gamepadAngularSensibility(value: number);
  122644. /**
  122645. * Defines the gamepad move sensiblity.
  122646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122647. */
  122648. get gamepadMoveSensibility(): number;
  122649. set gamepadMoveSensibility(value: number);
  122650. /**
  122651. * 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,
  122652. * which still works and will still be found in many Playgrounds.
  122653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122654. * @param name Define the name of the camera in the scene
  122655. * @param position Define the start position of the camera in the scene
  122656. * @param scene Define the scene the camera belongs to
  122657. */
  122658. constructor(name: string, position: Vector3, scene: Scene);
  122659. /**
  122660. * Gets the current object class name.
  122661. * @return the class name
  122662. */
  122663. getClassName(): string;
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * This represents a FPS type of camera. This is only here for back compat purpose.
  122669. * Please use the UniversalCamera instead as both are identical.
  122670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122671. */
  122672. export class GamepadCamera extends UniversalCamera {
  122673. /**
  122674. * Instantiates a new Gamepad Camera
  122675. * This represents a FPS type of camera. This is only here for back compat purpose.
  122676. * Please use the UniversalCamera instead as both are identical.
  122677. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122678. * @param name Define the name of the camera in the scene
  122679. * @param position Define the start position of the camera in the scene
  122680. * @param scene Define the scene the camera belongs to
  122681. */
  122682. constructor(name: string, position: Vector3, scene: Scene);
  122683. /**
  122684. * Gets the current object class name.
  122685. * @return the class name
  122686. */
  122687. getClassName(): string;
  122688. }
  122689. }
  122690. declare module BABYLON {
  122691. /** @hidden */
  122692. export var passPixelShader: {
  122693. name: string;
  122694. shader: string;
  122695. };
  122696. }
  122697. declare module BABYLON {
  122698. /** @hidden */
  122699. export var passCubePixelShader: {
  122700. name: string;
  122701. shader: string;
  122702. };
  122703. }
  122704. declare module BABYLON {
  122705. /**
  122706. * PassPostProcess which produces an output the same as it's input
  122707. */
  122708. export class PassPostProcess extends PostProcess {
  122709. /**
  122710. * Creates the PassPostProcess
  122711. * @param name The name of the effect.
  122712. * @param options The required width/height ratio to downsize to before computing the render pass.
  122713. * @param camera The camera to apply the render pass to.
  122714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122715. * @param engine The engine which the post process will be applied. (default: current engine)
  122716. * @param reusable If the post process can be reused on the same frame. (default: false)
  122717. * @param textureType The type of texture to be used when performing the post processing.
  122718. * @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)
  122719. */
  122720. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122721. }
  122722. /**
  122723. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122724. */
  122725. export class PassCubePostProcess extends PostProcess {
  122726. private _face;
  122727. /**
  122728. * Gets or sets the cube face to display.
  122729. * * 0 is +X
  122730. * * 1 is -X
  122731. * * 2 is +Y
  122732. * * 3 is -Y
  122733. * * 4 is +Z
  122734. * * 5 is -Z
  122735. */
  122736. get face(): number;
  122737. set face(value: number);
  122738. /**
  122739. * Creates the PassCubePostProcess
  122740. * @param name The name of the effect.
  122741. * @param options The required width/height ratio to downsize to before computing the render pass.
  122742. * @param camera The camera to apply the render pass to.
  122743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122744. * @param engine The engine which the post process will be applied. (default: current engine)
  122745. * @param reusable If the post process can be reused on the same frame. (default: false)
  122746. * @param textureType The type of texture to be used when performing the post processing.
  122747. * @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)
  122748. */
  122749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122750. }
  122751. }
  122752. declare module BABYLON {
  122753. /** @hidden */
  122754. export var anaglyphPixelShader: {
  122755. name: string;
  122756. shader: string;
  122757. };
  122758. }
  122759. declare module BABYLON {
  122760. /**
  122761. * Postprocess used to generate anaglyphic rendering
  122762. */
  122763. export class AnaglyphPostProcess extends PostProcess {
  122764. private _passedProcess;
  122765. /**
  122766. * Creates a new AnaglyphPostProcess
  122767. * @param name defines postprocess name
  122768. * @param options defines creation options or target ratio scale
  122769. * @param rigCameras defines cameras using this postprocess
  122770. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122771. * @param engine defines hosting engine
  122772. * @param reusable defines if the postprocess will be reused multiple times per frame
  122773. */
  122774. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122775. }
  122776. }
  122777. declare module BABYLON {
  122778. /**
  122779. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122781. */
  122782. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122783. /**
  122784. * Creates a new AnaglyphArcRotateCamera
  122785. * @param name defines camera name
  122786. * @param alpha defines alpha angle (in radians)
  122787. * @param beta defines beta angle (in radians)
  122788. * @param radius defines radius
  122789. * @param target defines camera target
  122790. * @param interaxialDistance defines distance between each color axis
  122791. * @param scene defines the hosting scene
  122792. */
  122793. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122794. /**
  122795. * Gets camera class name
  122796. * @returns AnaglyphArcRotateCamera
  122797. */
  122798. getClassName(): string;
  122799. }
  122800. }
  122801. declare module BABYLON {
  122802. /**
  122803. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122804. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122805. */
  122806. export class AnaglyphFreeCamera extends FreeCamera {
  122807. /**
  122808. * Creates a new AnaglyphFreeCamera
  122809. * @param name defines camera name
  122810. * @param position defines initial position
  122811. * @param interaxialDistance defines distance between each color axis
  122812. * @param scene defines the hosting scene
  122813. */
  122814. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122815. /**
  122816. * Gets camera class name
  122817. * @returns AnaglyphFreeCamera
  122818. */
  122819. getClassName(): string;
  122820. }
  122821. }
  122822. declare module BABYLON {
  122823. /**
  122824. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122825. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122826. */
  122827. export class AnaglyphGamepadCamera extends GamepadCamera {
  122828. /**
  122829. * Creates a new AnaglyphGamepadCamera
  122830. * @param name defines camera name
  122831. * @param position defines initial position
  122832. * @param interaxialDistance defines distance between each color axis
  122833. * @param scene defines the hosting scene
  122834. */
  122835. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122836. /**
  122837. * Gets camera class name
  122838. * @returns AnaglyphGamepadCamera
  122839. */
  122840. getClassName(): string;
  122841. }
  122842. }
  122843. declare module BABYLON {
  122844. /**
  122845. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122846. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122847. */
  122848. export class AnaglyphUniversalCamera extends UniversalCamera {
  122849. /**
  122850. * Creates a new AnaglyphUniversalCamera
  122851. * @param name defines camera name
  122852. * @param position defines initial position
  122853. * @param interaxialDistance defines distance between each color axis
  122854. * @param scene defines the hosting scene
  122855. */
  122856. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122857. /**
  122858. * Gets camera class name
  122859. * @returns AnaglyphUniversalCamera
  122860. */
  122861. getClassName(): string;
  122862. }
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122867. * @see http://doc.babylonjs.com/features/cameras
  122868. */
  122869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122870. /**
  122871. * Creates a new StereoscopicArcRotateCamera
  122872. * @param name defines camera name
  122873. * @param alpha defines alpha angle (in radians)
  122874. * @param beta defines beta angle (in radians)
  122875. * @param radius defines radius
  122876. * @param target defines camera target
  122877. * @param interaxialDistance defines distance between each color axis
  122878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122879. * @param scene defines the hosting scene
  122880. */
  122881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122882. /**
  122883. * Gets camera class name
  122884. * @returns StereoscopicArcRotateCamera
  122885. */
  122886. getClassName(): string;
  122887. }
  122888. }
  122889. declare module BABYLON {
  122890. /**
  122891. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122892. * @see http://doc.babylonjs.com/features/cameras
  122893. */
  122894. export class StereoscopicFreeCamera extends FreeCamera {
  122895. /**
  122896. * Creates a new StereoscopicFreeCamera
  122897. * @param name defines camera name
  122898. * @param position defines initial position
  122899. * @param interaxialDistance defines distance between each color axis
  122900. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122901. * @param scene defines the hosting scene
  122902. */
  122903. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122904. /**
  122905. * Gets camera class name
  122906. * @returns StereoscopicFreeCamera
  122907. */
  122908. getClassName(): string;
  122909. }
  122910. }
  122911. declare module BABYLON {
  122912. /**
  122913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122914. * @see http://doc.babylonjs.com/features/cameras
  122915. */
  122916. export class StereoscopicGamepadCamera extends GamepadCamera {
  122917. /**
  122918. * Creates a new StereoscopicGamepadCamera
  122919. * @param name defines camera name
  122920. * @param position defines initial position
  122921. * @param interaxialDistance defines distance between each color axis
  122922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122923. * @param scene defines the hosting scene
  122924. */
  122925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122926. /**
  122927. * Gets camera class name
  122928. * @returns StereoscopicGamepadCamera
  122929. */
  122930. getClassName(): string;
  122931. }
  122932. }
  122933. declare module BABYLON {
  122934. /**
  122935. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122936. * @see http://doc.babylonjs.com/features/cameras
  122937. */
  122938. export class StereoscopicUniversalCamera extends UniversalCamera {
  122939. /**
  122940. * Creates a new StereoscopicUniversalCamera
  122941. * @param name defines camera name
  122942. * @param position defines initial position
  122943. * @param interaxialDistance defines distance between each color axis
  122944. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122945. * @param scene defines the hosting scene
  122946. */
  122947. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122948. /**
  122949. * Gets camera class name
  122950. * @returns StereoscopicUniversalCamera
  122951. */
  122952. getClassName(): string;
  122953. }
  122954. }
  122955. declare module BABYLON {
  122956. /**
  122957. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122958. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122959. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122960. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122961. */
  122962. export class VirtualJoysticksCamera extends FreeCamera {
  122963. /**
  122964. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122965. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122966. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122967. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122968. * @param name Define the name of the camera in the scene
  122969. * @param position Define the start position of the camera in the scene
  122970. * @param scene Define the scene the camera belongs to
  122971. */
  122972. constructor(name: string, position: Vector3, scene: Scene);
  122973. /**
  122974. * Gets the current object class name.
  122975. * @return the class name
  122976. */
  122977. getClassName(): string;
  122978. }
  122979. }
  122980. declare module BABYLON {
  122981. /**
  122982. * This represents all the required metrics to create a VR camera.
  122983. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122984. */
  122985. export class VRCameraMetrics {
  122986. /**
  122987. * Define the horizontal resolution off the screen.
  122988. */
  122989. hResolution: number;
  122990. /**
  122991. * Define the vertical resolution off the screen.
  122992. */
  122993. vResolution: number;
  122994. /**
  122995. * Define the horizontal screen size.
  122996. */
  122997. hScreenSize: number;
  122998. /**
  122999. * Define the vertical screen size.
  123000. */
  123001. vScreenSize: number;
  123002. /**
  123003. * Define the vertical screen center position.
  123004. */
  123005. vScreenCenter: number;
  123006. /**
  123007. * Define the distance of the eyes to the screen.
  123008. */
  123009. eyeToScreenDistance: number;
  123010. /**
  123011. * Define the distance between both lenses
  123012. */
  123013. lensSeparationDistance: number;
  123014. /**
  123015. * Define the distance between both viewer's eyes.
  123016. */
  123017. interpupillaryDistance: number;
  123018. /**
  123019. * Define the distortion factor of the VR postprocess.
  123020. * Please, touch with care.
  123021. */
  123022. distortionK: number[];
  123023. /**
  123024. * Define the chromatic aberration correction factors for the VR post process.
  123025. */
  123026. chromaAbCorrection: number[];
  123027. /**
  123028. * Define the scale factor of the post process.
  123029. * The smaller the better but the slower.
  123030. */
  123031. postProcessScaleFactor: number;
  123032. /**
  123033. * Define an offset for the lens center.
  123034. */
  123035. lensCenterOffset: number;
  123036. /**
  123037. * Define if the current vr camera should compensate the distortion of the lense or not.
  123038. */
  123039. compensateDistortion: boolean;
  123040. /**
  123041. * Defines if multiview should be enabled when rendering (Default: false)
  123042. */
  123043. multiviewEnabled: boolean;
  123044. /**
  123045. * Gets the rendering aspect ratio based on the provided resolutions.
  123046. */
  123047. get aspectRatio(): number;
  123048. /**
  123049. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123050. */
  123051. get aspectRatioFov(): number;
  123052. /**
  123053. * @hidden
  123054. */
  123055. get leftHMatrix(): Matrix;
  123056. /**
  123057. * @hidden
  123058. */
  123059. get rightHMatrix(): Matrix;
  123060. /**
  123061. * @hidden
  123062. */
  123063. get leftPreViewMatrix(): Matrix;
  123064. /**
  123065. * @hidden
  123066. */
  123067. get rightPreViewMatrix(): Matrix;
  123068. /**
  123069. * Get the default VRMetrics based on the most generic setup.
  123070. * @returns the default vr metrics
  123071. */
  123072. static GetDefault(): VRCameraMetrics;
  123073. }
  123074. }
  123075. declare module BABYLON {
  123076. /** @hidden */
  123077. export var vrDistortionCorrectionPixelShader: {
  123078. name: string;
  123079. shader: string;
  123080. };
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * VRDistortionCorrectionPostProcess used for mobile VR
  123085. */
  123086. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123087. private _isRightEye;
  123088. private _distortionFactors;
  123089. private _postProcessScaleFactor;
  123090. private _lensCenterOffset;
  123091. private _scaleIn;
  123092. private _scaleFactor;
  123093. private _lensCenter;
  123094. /**
  123095. * Initializes the VRDistortionCorrectionPostProcess
  123096. * @param name The name of the effect.
  123097. * @param camera The camera to apply the render pass to.
  123098. * @param isRightEye If this is for the right eye distortion
  123099. * @param vrMetrics All the required metrics for the VR camera
  123100. */
  123101. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123102. }
  123103. }
  123104. declare module BABYLON {
  123105. /**
  123106. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123107. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123108. */
  123109. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123110. /**
  123111. * Creates a new VRDeviceOrientationArcRotateCamera
  123112. * @param name defines camera name
  123113. * @param alpha defines the camera rotation along the logitudinal axis
  123114. * @param beta defines the camera rotation along the latitudinal axis
  123115. * @param radius defines the camera distance from its target
  123116. * @param target defines the camera target
  123117. * @param scene defines the scene the camera belongs to
  123118. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123119. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123120. */
  123121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123122. /**
  123123. * Gets camera class name
  123124. * @returns VRDeviceOrientationArcRotateCamera
  123125. */
  123126. getClassName(): string;
  123127. }
  123128. }
  123129. declare module BABYLON {
  123130. /**
  123131. * Camera used to simulate VR rendering (based on FreeCamera)
  123132. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123133. */
  123134. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123135. /**
  123136. * Creates a new VRDeviceOrientationFreeCamera
  123137. * @param name defines camera name
  123138. * @param position defines the start position of the camera
  123139. * @param scene defines the scene the camera belongs to
  123140. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123141. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123142. */
  123143. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123144. /**
  123145. * Gets camera class name
  123146. * @returns VRDeviceOrientationFreeCamera
  123147. */
  123148. getClassName(): string;
  123149. }
  123150. }
  123151. declare module BABYLON {
  123152. /**
  123153. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123154. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123155. */
  123156. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123157. /**
  123158. * Creates a new VRDeviceOrientationGamepadCamera
  123159. * @param name defines camera name
  123160. * @param position defines the start position of the camera
  123161. * @param scene defines the scene the camera belongs to
  123162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123164. */
  123165. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123166. /**
  123167. * Gets camera class name
  123168. * @returns VRDeviceOrientationGamepadCamera
  123169. */
  123170. getClassName(): string;
  123171. }
  123172. }
  123173. declare module BABYLON {
  123174. /** @hidden */
  123175. export var imageProcessingPixelShader: {
  123176. name: string;
  123177. shader: string;
  123178. };
  123179. }
  123180. declare module BABYLON {
  123181. /**
  123182. * ImageProcessingPostProcess
  123183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123184. */
  123185. export class ImageProcessingPostProcess extends PostProcess {
  123186. /**
  123187. * Default configuration related to image processing available in the PBR Material.
  123188. */
  123189. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123190. /**
  123191. * Gets the image processing configuration used either in this material.
  123192. */
  123193. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123194. /**
  123195. * Sets the Default image processing configuration used either in the this material.
  123196. *
  123197. * If sets to null, the scene one is in use.
  123198. */
  123199. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123200. /**
  123201. * Keep track of the image processing observer to allow dispose and replace.
  123202. */
  123203. private _imageProcessingObserver;
  123204. /**
  123205. * Attaches a new image processing configuration to the PBR Material.
  123206. * @param configuration
  123207. */
  123208. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123209. /**
  123210. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123211. */
  123212. get colorCurves(): Nullable<ColorCurves>;
  123213. /**
  123214. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123215. */
  123216. set colorCurves(value: Nullable<ColorCurves>);
  123217. /**
  123218. * Gets wether the color curves effect is enabled.
  123219. */
  123220. get colorCurvesEnabled(): boolean;
  123221. /**
  123222. * Sets wether the color curves effect is enabled.
  123223. */
  123224. set colorCurvesEnabled(value: boolean);
  123225. /**
  123226. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123227. */
  123228. get colorGradingTexture(): Nullable<BaseTexture>;
  123229. /**
  123230. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123231. */
  123232. set colorGradingTexture(value: Nullable<BaseTexture>);
  123233. /**
  123234. * Gets wether the color grading effect is enabled.
  123235. */
  123236. get colorGradingEnabled(): boolean;
  123237. /**
  123238. * Gets wether the color grading effect is enabled.
  123239. */
  123240. set colorGradingEnabled(value: boolean);
  123241. /**
  123242. * Gets exposure used in the effect.
  123243. */
  123244. get exposure(): number;
  123245. /**
  123246. * Sets exposure used in the effect.
  123247. */
  123248. set exposure(value: number);
  123249. /**
  123250. * Gets wether tonemapping is enabled or not.
  123251. */
  123252. get toneMappingEnabled(): boolean;
  123253. /**
  123254. * Sets wether tonemapping is enabled or not
  123255. */
  123256. set toneMappingEnabled(value: boolean);
  123257. /**
  123258. * Gets the type of tone mapping effect.
  123259. */
  123260. get toneMappingType(): number;
  123261. /**
  123262. * Sets the type of tone mapping effect.
  123263. */
  123264. set toneMappingType(value: number);
  123265. /**
  123266. * Gets contrast used in the effect.
  123267. */
  123268. get contrast(): number;
  123269. /**
  123270. * Sets contrast used in the effect.
  123271. */
  123272. set contrast(value: number);
  123273. /**
  123274. * Gets Vignette stretch size.
  123275. */
  123276. get vignetteStretch(): number;
  123277. /**
  123278. * Sets Vignette stretch size.
  123279. */
  123280. set vignetteStretch(value: number);
  123281. /**
  123282. * Gets Vignette centre X Offset.
  123283. */
  123284. get vignetteCentreX(): number;
  123285. /**
  123286. * Sets Vignette centre X Offset.
  123287. */
  123288. set vignetteCentreX(value: number);
  123289. /**
  123290. * Gets Vignette centre Y Offset.
  123291. */
  123292. get vignetteCentreY(): number;
  123293. /**
  123294. * Sets Vignette centre Y Offset.
  123295. */
  123296. set vignetteCentreY(value: number);
  123297. /**
  123298. * Gets Vignette weight or intensity of the vignette effect.
  123299. */
  123300. get vignetteWeight(): number;
  123301. /**
  123302. * Sets Vignette weight or intensity of the vignette effect.
  123303. */
  123304. set vignetteWeight(value: number);
  123305. /**
  123306. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123307. * if vignetteEnabled is set to true.
  123308. */
  123309. get vignetteColor(): Color4;
  123310. /**
  123311. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123312. * if vignetteEnabled is set to true.
  123313. */
  123314. set vignetteColor(value: Color4);
  123315. /**
  123316. * Gets Camera field of view used by the Vignette effect.
  123317. */
  123318. get vignetteCameraFov(): number;
  123319. /**
  123320. * Sets Camera field of view used by the Vignette effect.
  123321. */
  123322. set vignetteCameraFov(value: number);
  123323. /**
  123324. * Gets the vignette blend mode allowing different kind of effect.
  123325. */
  123326. get vignetteBlendMode(): number;
  123327. /**
  123328. * Sets the vignette blend mode allowing different kind of effect.
  123329. */
  123330. set vignetteBlendMode(value: number);
  123331. /**
  123332. * Gets wether the vignette effect is enabled.
  123333. */
  123334. get vignetteEnabled(): boolean;
  123335. /**
  123336. * Sets wether the vignette effect is enabled.
  123337. */
  123338. set vignetteEnabled(value: boolean);
  123339. private _fromLinearSpace;
  123340. /**
  123341. * Gets wether the input of the processing is in Gamma or Linear Space.
  123342. */
  123343. get fromLinearSpace(): boolean;
  123344. /**
  123345. * Sets wether the input of the processing is in Gamma or Linear Space.
  123346. */
  123347. set fromLinearSpace(value: boolean);
  123348. /**
  123349. * Defines cache preventing GC.
  123350. */
  123351. private _defines;
  123352. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  123353. /**
  123354. * "ImageProcessingPostProcess"
  123355. * @returns "ImageProcessingPostProcess"
  123356. */
  123357. getClassName(): string;
  123358. protected _updateParameters(): void;
  123359. dispose(camera?: Camera): void;
  123360. }
  123361. }
  123362. declare module BABYLON {
  123363. /**
  123364. * Class containing static functions to help procedurally build meshes
  123365. */
  123366. export class GroundBuilder {
  123367. /**
  123368. * Creates a ground mesh
  123369. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123370. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123372. * @param name defines the name of the mesh
  123373. * @param options defines the options used to create the mesh
  123374. * @param scene defines the hosting scene
  123375. * @returns the ground mesh
  123376. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123377. */
  123378. static CreateGround(name: string, options: {
  123379. width?: number;
  123380. height?: number;
  123381. subdivisions?: number;
  123382. subdivisionsX?: number;
  123383. subdivisionsY?: number;
  123384. updatable?: boolean;
  123385. }, scene: any): Mesh;
  123386. /**
  123387. * Creates a tiled ground mesh
  123388. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123389. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123390. * * 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
  123391. * * 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
  123392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123393. * @param name defines the name of the mesh
  123394. * @param options defines the options used to create the mesh
  123395. * @param scene defines the hosting scene
  123396. * @returns the tiled ground mesh
  123397. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123398. */
  123399. static CreateTiledGround(name: string, options: {
  123400. xmin: number;
  123401. zmin: number;
  123402. xmax: number;
  123403. zmax: number;
  123404. subdivisions?: {
  123405. w: number;
  123406. h: number;
  123407. };
  123408. precision?: {
  123409. w: number;
  123410. h: number;
  123411. };
  123412. updatable?: boolean;
  123413. }, scene?: Nullable<Scene>): Mesh;
  123414. /**
  123415. * Creates a ground mesh from a height map
  123416. * * The parameter `url` sets the URL of the height map image resource.
  123417. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123418. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123419. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123420. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123421. * * 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.
  123422. * * 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).
  123423. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123425. * @param name defines the name of the mesh
  123426. * @param url defines the url to the height map
  123427. * @param options defines the options used to create the mesh
  123428. * @param scene defines the hosting scene
  123429. * @returns the ground mesh
  123430. * @see https://doc.babylonjs.com/babylon101/height_map
  123431. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123432. */
  123433. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123434. width?: number;
  123435. height?: number;
  123436. subdivisions?: number;
  123437. minHeight?: number;
  123438. maxHeight?: number;
  123439. colorFilter?: Color3;
  123440. alphaFilter?: number;
  123441. updatable?: boolean;
  123442. onReady?: (mesh: GroundMesh) => void;
  123443. }, scene?: Nullable<Scene>): GroundMesh;
  123444. }
  123445. }
  123446. declare module BABYLON {
  123447. /**
  123448. * Class containing static functions to help procedurally build meshes
  123449. */
  123450. export class TorusBuilder {
  123451. /**
  123452. * Creates a torus mesh
  123453. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123454. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123455. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123459. * @param name defines the name of the mesh
  123460. * @param options defines the options used to create the mesh
  123461. * @param scene defines the hosting scene
  123462. * @returns the torus mesh
  123463. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123464. */
  123465. static CreateTorus(name: string, options: {
  123466. diameter?: number;
  123467. thickness?: number;
  123468. tessellation?: number;
  123469. updatable?: boolean;
  123470. sideOrientation?: number;
  123471. frontUVs?: Vector4;
  123472. backUVs?: Vector4;
  123473. }, scene: any): Mesh;
  123474. }
  123475. }
  123476. declare module BABYLON {
  123477. /**
  123478. * Class containing static functions to help procedurally build meshes
  123479. */
  123480. export class CylinderBuilder {
  123481. /**
  123482. * Creates a cylinder or a cone mesh
  123483. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123484. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123485. * * 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.
  123486. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123487. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123488. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123489. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123490. * * 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).
  123491. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123492. * * 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).
  123493. * * 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
  123494. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123495. * * 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
  123496. * * 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.
  123497. * * If `enclose` is false, a ring surface is one element.
  123498. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123499. * * 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
  123500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123503. * @param name defines the name of the mesh
  123504. * @param options defines the options used to create the mesh
  123505. * @param scene defines the hosting scene
  123506. * @returns the cylinder mesh
  123507. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123508. */
  123509. static CreateCylinder(name: string, options: {
  123510. height?: number;
  123511. diameterTop?: number;
  123512. diameterBottom?: number;
  123513. diameter?: number;
  123514. tessellation?: number;
  123515. subdivisions?: number;
  123516. arc?: number;
  123517. faceColors?: Color4[];
  123518. faceUV?: Vector4[];
  123519. updatable?: boolean;
  123520. hasRings?: boolean;
  123521. enclose?: boolean;
  123522. cap?: number;
  123523. sideOrientation?: number;
  123524. frontUVs?: Vector4;
  123525. backUVs?: Vector4;
  123526. }, scene: any): Mesh;
  123527. }
  123528. }
  123529. declare module BABYLON {
  123530. /**
  123531. * States of the webXR experience
  123532. */
  123533. export enum WebXRState {
  123534. /**
  123535. * Transitioning to being in XR mode
  123536. */
  123537. ENTERING_XR = 0,
  123538. /**
  123539. * Transitioning to non XR mode
  123540. */
  123541. EXITING_XR = 1,
  123542. /**
  123543. * In XR mode and presenting
  123544. */
  123545. IN_XR = 2,
  123546. /**
  123547. * Not entered XR mode
  123548. */
  123549. NOT_IN_XR = 3
  123550. }
  123551. /**
  123552. * Abstraction of the XR render target
  123553. */
  123554. export interface WebXRRenderTarget extends IDisposable {
  123555. /**
  123556. * xrpresent context of the canvas which can be used to display/mirror xr content
  123557. */
  123558. canvasContext: WebGLRenderingContext;
  123559. /**
  123560. * xr layer for the canvas
  123561. */
  123562. xrLayer: Nullable<XRWebGLLayer>;
  123563. /**
  123564. * Initializes the xr layer for the session
  123565. * @param xrSession xr session
  123566. * @returns a promise that will resolve once the XR Layer has been created
  123567. */
  123568. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123569. }
  123570. }
  123571. declare module BABYLON {
  123572. /**
  123573. * COnfiguration object for WebXR output canvas
  123574. */
  123575. export class WebXRManagedOutputCanvasOptions {
  123576. /**
  123577. * An optional canvas in case you wish to create it yourself and provide it here.
  123578. * If not provided, a new canvas will be created
  123579. */
  123580. canvasElement?: HTMLCanvasElement;
  123581. /**
  123582. * Options for this XR Layer output
  123583. */
  123584. canvasOptions?: XRWebGLLayerOptions;
  123585. /**
  123586. * CSS styling for a newly created canvas (if not provided)
  123587. */
  123588. newCanvasCssStyle?: string;
  123589. /**
  123590. * Get the default values of the configuration object
  123591. * @returns default values of this configuration object
  123592. */
  123593. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123594. }
  123595. /**
  123596. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123597. */
  123598. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123599. private _options;
  123600. private _canvas;
  123601. private _engine;
  123602. /**
  123603. * Rendering context of the canvas which can be used to display/mirror xr content
  123604. */
  123605. canvasContext: WebGLRenderingContext;
  123606. /**
  123607. * xr layer for the canvas
  123608. */
  123609. xrLayer: Nullable<XRWebGLLayer>;
  123610. /**
  123611. * Initializes the canvas to be added/removed upon entering/exiting xr
  123612. * @param _xrSessionManager The XR Session manager
  123613. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123614. */
  123615. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123616. /**
  123617. * Disposes of the object
  123618. */
  123619. dispose(): void;
  123620. /**
  123621. * Initializes the xr layer for the session
  123622. * @param xrSession xr session
  123623. * @returns a promise that will resolve once the XR Layer has been created
  123624. */
  123625. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123626. private _addCanvas;
  123627. private _removeCanvas;
  123628. private _setManagedOutputCanvas;
  123629. }
  123630. }
  123631. declare module BABYLON {
  123632. /**
  123633. * Manages an XRSession to work with Babylon's engine
  123634. * @see https://doc.babylonjs.com/how_to/webxr
  123635. */
  123636. export class WebXRSessionManager implements IDisposable {
  123637. /** The scene which the session should be created for */
  123638. scene: Scene;
  123639. private _referenceSpace;
  123640. private _rttProvider;
  123641. private _sessionEnded;
  123642. private _xrNavigator;
  123643. private baseLayer;
  123644. /**
  123645. * The base reference space from which the session started. good if you want to reset your
  123646. * reference space
  123647. */
  123648. baseReferenceSpace: XRReferenceSpace;
  123649. /**
  123650. * Current XR frame
  123651. */
  123652. currentFrame: Nullable<XRFrame>;
  123653. /** WebXR timestamp updated every frame */
  123654. currentTimestamp: number;
  123655. /**
  123656. * Used just in case of a failure to initialize an immersive session.
  123657. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123658. */
  123659. defaultHeightCompensation: number;
  123660. /**
  123661. * Fires every time a new xrFrame arrives which can be used to update the camera
  123662. */
  123663. onXRFrameObservable: Observable<XRFrame>;
  123664. /**
  123665. * Fires when the reference space changed
  123666. */
  123667. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123668. /**
  123669. * Fires when the xr session is ended either by the device or manually done
  123670. */
  123671. onXRSessionEnded: Observable<any>;
  123672. /**
  123673. * Fires when the xr session is ended either by the device or manually done
  123674. */
  123675. onXRSessionInit: Observable<XRSession>;
  123676. /**
  123677. * Underlying xr session
  123678. */
  123679. session: XRSession;
  123680. /**
  123681. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123682. * or get the offset the player is currently at.
  123683. */
  123684. viewerReferenceSpace: XRReferenceSpace;
  123685. /**
  123686. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123687. * @param scene The scene which the session should be created for
  123688. */
  123689. constructor(
  123690. /** The scene which the session should be created for */
  123691. scene: Scene);
  123692. /**
  123693. * The current reference space used in this session. This reference space can constantly change!
  123694. * It is mainly used to offset the camera's position.
  123695. */
  123696. get referenceSpace(): XRReferenceSpace;
  123697. /**
  123698. * Set a new reference space and triggers the observable
  123699. */
  123700. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123701. /**
  123702. * Disposes of the session manager
  123703. */
  123704. dispose(): void;
  123705. /**
  123706. * Stops the xrSession and restores the render loop
  123707. * @returns Promise which resolves after it exits XR
  123708. */
  123709. exitXRAsync(): Promise<void>;
  123710. /**
  123711. * Gets the correct render target texture to be rendered this frame for this eye
  123712. * @param eye the eye for which to get the render target
  123713. * @returns the render target for the specified eye
  123714. */
  123715. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123716. /**
  123717. * Creates a WebXRRenderTarget object for the XR session
  123718. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123719. * @param options optional options to provide when creating a new render target
  123720. * @returns a WebXR render target to which the session can render
  123721. */
  123722. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123723. /**
  123724. * Initializes the manager
  123725. * After initialization enterXR can be called to start an XR session
  123726. * @returns Promise which resolves after it is initialized
  123727. */
  123728. initializeAsync(): Promise<void>;
  123729. /**
  123730. * Initializes an xr session
  123731. * @param xrSessionMode mode to initialize
  123732. * @param xrSessionInit defines optional and required values to pass to the session builder
  123733. * @returns a promise which will resolve once the session has been initialized
  123734. */
  123735. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123736. /**
  123737. * Checks if a session would be supported for the creation options specified
  123738. * @param sessionMode session mode to check if supported eg. immersive-vr
  123739. * @returns A Promise that resolves to true if supported and false if not
  123740. */
  123741. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123742. /**
  123743. * Resets the reference space to the one started the session
  123744. */
  123745. resetReferenceSpace(): void;
  123746. /**
  123747. * Starts rendering to the xr layer
  123748. */
  123749. runXRRenderLoop(): void;
  123750. /**
  123751. * Sets the reference space on the xr session
  123752. * @param referenceSpaceType space to set
  123753. * @returns a promise that will resolve once the reference space has been set
  123754. */
  123755. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123756. /**
  123757. * Updates the render state of the session
  123758. * @param state state to set
  123759. * @returns a promise that resolves once the render state has been updated
  123760. */
  123761. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123762. /**
  123763. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123764. * @param sessionMode defines the session to test
  123765. * @returns a promise with boolean as final value
  123766. */
  123767. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123768. private _createRenderTargetTexture;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /**
  123773. * WebXR Camera which holds the views for the xrSession
  123774. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123775. */
  123776. export class WebXRCamera extends FreeCamera {
  123777. private _xrSessionManager;
  123778. private _firstFrame;
  123779. private _referenceQuaternion;
  123780. private _referencedPosition;
  123781. private _xrInvPositionCache;
  123782. private _xrInvQuaternionCache;
  123783. /**
  123784. * Should position compensation execute on first frame.
  123785. * This is used when copying the position from a native (non XR) camera
  123786. */
  123787. compensateOnFirstFrame: boolean;
  123788. /**
  123789. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123790. * @param name the name of the camera
  123791. * @param scene the scene to add the camera to
  123792. * @param _xrSessionManager a constructed xr session manager
  123793. */
  123794. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123795. /**
  123796. * Return the user's height, unrelated to the current ground.
  123797. * This will be the y position of this camera, when ground level is 0.
  123798. */
  123799. get realWorldHeight(): number;
  123800. /** @hidden */
  123801. _updateForDualEyeDebugging(): void;
  123802. /**
  123803. * Sets this camera's transformation based on a non-vr camera
  123804. * @param otherCamera the non-vr camera to copy the transformation from
  123805. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123806. */
  123807. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123808. /**
  123809. * Gets the current instance class name ("WebXRCamera").
  123810. * @returns the class name
  123811. */
  123812. getClassName(): string;
  123813. /**
  123814. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123815. */
  123816. _getViewMatrix(): Matrix;
  123817. private _updateFromXRSession;
  123818. private _updateNumberOfRigCameras;
  123819. private _updateReferenceSpace;
  123820. private _updateReferenceSpaceOffset;
  123821. }
  123822. }
  123823. declare module BABYLON {
  123824. /**
  123825. * Defining the interface required for a (webxr) feature
  123826. */
  123827. export interface IWebXRFeature extends IDisposable {
  123828. /**
  123829. * Is this feature attached
  123830. */
  123831. attached: boolean;
  123832. /**
  123833. * Should auto-attach be disabled?
  123834. */
  123835. disableAutoAttach: boolean;
  123836. /**
  123837. * Attach the feature to the session
  123838. * Will usually be called by the features manager
  123839. *
  123840. * @param force should attachment be forced (even when already attached)
  123841. * @returns true if successful.
  123842. */
  123843. attach(force?: boolean): boolean;
  123844. /**
  123845. * Detach the feature from the session
  123846. * Will usually be called by the features manager
  123847. *
  123848. * @returns true if successful.
  123849. */
  123850. detach(): boolean;
  123851. }
  123852. /**
  123853. * A list of the currently available features without referencing them
  123854. */
  123855. export class WebXRFeatureName {
  123856. /**
  123857. * The name of the anchor system feature
  123858. */
  123859. static ANCHOR_SYSTEM: string;
  123860. /**
  123861. * The name of the background remover feature
  123862. */
  123863. static BACKGROUND_REMOVER: string;
  123864. /**
  123865. * The name of the hit test feature
  123866. */
  123867. static HIT_TEST: string;
  123868. /**
  123869. * physics impostors for xr controllers feature
  123870. */
  123871. static PHYSICS_CONTROLLERS: string;
  123872. /**
  123873. * The name of the plane detection feature
  123874. */
  123875. static PLANE_DETECTION: string;
  123876. /**
  123877. * The name of the pointer selection feature
  123878. */
  123879. static POINTER_SELECTION: string;
  123880. /**
  123881. * The name of the teleportation feature
  123882. */
  123883. static TELEPORTATION: string;
  123884. }
  123885. /**
  123886. * Defining the constructor of a feature. Used to register the modules.
  123887. */
  123888. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123889. /**
  123890. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123891. * It is mainly used in AR sessions.
  123892. *
  123893. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123894. */
  123895. export class WebXRFeaturesManager implements IDisposable {
  123896. private _xrSessionManager;
  123897. private static readonly _AvailableFeatures;
  123898. private _features;
  123899. /**
  123900. * constructs a new features manages.
  123901. *
  123902. * @param _xrSessionManager an instance of WebXRSessionManager
  123903. */
  123904. constructor(_xrSessionManager: WebXRSessionManager);
  123905. /**
  123906. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123907. * Mainly used internally.
  123908. *
  123909. * @param featureName the name of the feature to register
  123910. * @param constructorFunction the function used to construct the module
  123911. * @param version the (babylon) version of the module
  123912. * @param stable is that a stable version of this module
  123913. */
  123914. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123915. /**
  123916. * Returns a constructor of a specific feature.
  123917. *
  123918. * @param featureName the name of the feature to construct
  123919. * @param version the version of the feature to load
  123920. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123921. * @param options optional options provided to the module.
  123922. * @returns a function that, when called, will return a new instance of this feature
  123923. */
  123924. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123925. /**
  123926. * Can be used to return the list of features currently registered
  123927. *
  123928. * @returns an Array of available features
  123929. */
  123930. static GetAvailableFeatures(): string[];
  123931. /**
  123932. * Gets the versions available for a specific feature
  123933. * @param featureName the name of the feature
  123934. * @returns an array with the available versions
  123935. */
  123936. static GetAvailableVersions(featureName: string): string[];
  123937. /**
  123938. * Return the latest unstable version of this feature
  123939. * @param featureName the name of the feature to search
  123940. * @returns the version number. if not found will return -1
  123941. */
  123942. static GetLatestVersionOfFeature(featureName: string): number;
  123943. /**
  123944. * Return the latest stable version of this feature
  123945. * @param featureName the name of the feature to search
  123946. * @returns the version number. if not found will return -1
  123947. */
  123948. static GetStableVersionOfFeature(featureName: string): number;
  123949. /**
  123950. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123951. * Can be used during a session to start a feature
  123952. * @param featureName the name of feature to attach
  123953. */
  123954. attachFeature(featureName: string): void;
  123955. /**
  123956. * Can be used inside a session or when the session ends to detach a specific feature
  123957. * @param featureName the name of the feature to detach
  123958. */
  123959. detachFeature(featureName: string): void;
  123960. /**
  123961. * Used to disable an already-enabled feature
  123962. * The feature will be disposed and will be recreated once enabled.
  123963. * @param featureName the feature to disable
  123964. * @returns true if disable was successful
  123965. */
  123966. disableFeature(featureName: string | {
  123967. Name: string;
  123968. }): boolean;
  123969. /**
  123970. * dispose this features manager
  123971. */
  123972. dispose(): void;
  123973. /**
  123974. * 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.
  123975. * 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.
  123976. *
  123977. * @param featureName the name of the feature to load or the class of the feature
  123978. * @param version optional version to load. if not provided the latest version will be enabled
  123979. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123980. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123981. * @returns a new constructed feature or throws an error if feature not found.
  123982. */
  123983. enableFeature(featureName: string | {
  123984. Name: string;
  123985. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123986. /**
  123987. * get the implementation of an enabled feature.
  123988. * @param featureName the name of the feature to load
  123989. * @returns the feature class, if found
  123990. */
  123991. getEnabledFeature(featureName: string): IWebXRFeature;
  123992. /**
  123993. * Get the list of enabled features
  123994. * @returns an array of enabled features
  123995. */
  123996. getEnabledFeatures(): string[];
  123997. }
  123998. }
  123999. declare module BABYLON {
  124000. /**
  124001. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124002. * @see https://doc.babylonjs.com/how_to/webxr
  124003. */
  124004. export class WebXRExperienceHelper implements IDisposable {
  124005. private scene;
  124006. private _nonVRCamera;
  124007. private _originalSceneAutoClear;
  124008. private _supported;
  124009. /**
  124010. * Camera used to render xr content
  124011. */
  124012. camera: WebXRCamera;
  124013. /** A features manager for this xr session */
  124014. featuresManager: WebXRFeaturesManager;
  124015. /**
  124016. * Observers registered here will be triggered after the camera's initial transformation is set
  124017. * This can be used to set a different ground level or an extra rotation.
  124018. *
  124019. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124020. * to the position set after this observable is done executing.
  124021. */
  124022. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124023. /**
  124024. * Fires when the state of the experience helper has changed
  124025. */
  124026. onStateChangedObservable: Observable<WebXRState>;
  124027. /** Session manager used to keep track of xr session */
  124028. sessionManager: WebXRSessionManager;
  124029. /**
  124030. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124031. */
  124032. state: WebXRState;
  124033. /**
  124034. * Creates a WebXRExperienceHelper
  124035. * @param scene The scene the helper should be created in
  124036. */
  124037. private constructor();
  124038. /**
  124039. * Creates the experience helper
  124040. * @param scene the scene to attach the experience helper to
  124041. * @returns a promise for the experience helper
  124042. */
  124043. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124044. /**
  124045. * Disposes of the experience helper
  124046. */
  124047. dispose(): void;
  124048. /**
  124049. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124050. * @param sessionMode options for the XR session
  124051. * @param referenceSpaceType frame of reference of the XR session
  124052. * @param renderTarget the output canvas that will be used to enter XR mode
  124053. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124054. * @returns promise that resolves after xr mode has entered
  124055. */
  124056. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124057. /**
  124058. * Exits XR mode and returns the scene to its original state
  124059. * @returns promise that resolves after xr mode has exited
  124060. */
  124061. exitXRAsync(): Promise<void>;
  124062. private _nonXRToXRCamera;
  124063. private _setState;
  124064. }
  124065. }
  124066. declare module BABYLON {
  124067. /**
  124068. * X-Y values for axes in WebXR
  124069. */
  124070. export interface IWebXRMotionControllerAxesValue {
  124071. /**
  124072. * The value of the x axis
  124073. */
  124074. x: number;
  124075. /**
  124076. * The value of the y-axis
  124077. */
  124078. y: number;
  124079. }
  124080. /**
  124081. * changed / previous values for the values of this component
  124082. */
  124083. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124084. /**
  124085. * current (this frame) value
  124086. */
  124087. current: T;
  124088. /**
  124089. * previous (last change) value
  124090. */
  124091. previous: T;
  124092. }
  124093. /**
  124094. * Represents changes in the component between current frame and last values recorded
  124095. */
  124096. export interface IWebXRMotionControllerComponentChanges {
  124097. /**
  124098. * will be populated with previous and current values if axes changed
  124099. */
  124100. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124101. /**
  124102. * will be populated with previous and current values if pressed changed
  124103. */
  124104. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124105. /**
  124106. * will be populated with previous and current values if touched changed
  124107. */
  124108. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124109. /**
  124110. * will be populated with previous and current values if value changed
  124111. */
  124112. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124113. }
  124114. /**
  124115. * This class represents a single component (for example button or thumbstick) of a motion controller
  124116. */
  124117. export class WebXRControllerComponent implements IDisposable {
  124118. /**
  124119. * the id of this component
  124120. */
  124121. id: string;
  124122. /**
  124123. * the type of the component
  124124. */
  124125. type: MotionControllerComponentType;
  124126. private _buttonIndex;
  124127. private _axesIndices;
  124128. private _axes;
  124129. private _changes;
  124130. private _currentValue;
  124131. private _hasChanges;
  124132. private _pressed;
  124133. private _touched;
  124134. /**
  124135. * button component type
  124136. */
  124137. static BUTTON_TYPE: MotionControllerComponentType;
  124138. /**
  124139. * squeeze component type
  124140. */
  124141. static SQUEEZE_TYPE: MotionControllerComponentType;
  124142. /**
  124143. * Thumbstick component type
  124144. */
  124145. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124146. /**
  124147. * Touchpad component type
  124148. */
  124149. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124150. /**
  124151. * trigger component type
  124152. */
  124153. static TRIGGER_TYPE: MotionControllerComponentType;
  124154. /**
  124155. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124156. * the axes data changes
  124157. */
  124158. onAxisValueChangedObservable: Observable<{
  124159. x: number;
  124160. y: number;
  124161. }>;
  124162. /**
  124163. * Observers registered here will be triggered when the state of a button changes
  124164. * State change is either pressed / touched / value
  124165. */
  124166. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124167. /**
  124168. * Creates a new component for a motion controller.
  124169. * It is created by the motion controller itself
  124170. *
  124171. * @param id the id of this component
  124172. * @param type the type of the component
  124173. * @param _buttonIndex index in the buttons array of the gamepad
  124174. * @param _axesIndices indices of the values in the axes array of the gamepad
  124175. */
  124176. constructor(
  124177. /**
  124178. * the id of this component
  124179. */
  124180. id: string,
  124181. /**
  124182. * the type of the component
  124183. */
  124184. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124185. /**
  124186. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124187. */
  124188. get axes(): IWebXRMotionControllerAxesValue;
  124189. /**
  124190. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124191. */
  124192. get changes(): IWebXRMotionControllerComponentChanges;
  124193. /**
  124194. * Return whether or not the component changed the last frame
  124195. */
  124196. get hasChanges(): boolean;
  124197. /**
  124198. * is the button currently pressed
  124199. */
  124200. get pressed(): boolean;
  124201. /**
  124202. * is the button currently touched
  124203. */
  124204. get touched(): boolean;
  124205. /**
  124206. * Get the current value of this component
  124207. */
  124208. get value(): number;
  124209. /**
  124210. * Dispose this component
  124211. */
  124212. dispose(): void;
  124213. /**
  124214. * Are there axes correlating to this component
  124215. * @return true is axes data is available
  124216. */
  124217. isAxes(): boolean;
  124218. /**
  124219. * Is this component a button (hence - pressable)
  124220. * @returns true if can be pressed
  124221. */
  124222. isButton(): boolean;
  124223. /**
  124224. * update this component using the gamepad object it is in. Called on every frame
  124225. * @param nativeController the native gamepad controller object
  124226. */
  124227. update(nativeController: IMinimalMotionControllerObject): void;
  124228. }
  124229. }
  124230. declare module BABYLON {
  124231. /**
  124232. * Class used to represent data loading progression
  124233. */
  124234. export class SceneLoaderProgressEvent {
  124235. /** defines if data length to load can be evaluated */
  124236. readonly lengthComputable: boolean;
  124237. /** defines the loaded data length */
  124238. readonly loaded: number;
  124239. /** defines the data length to load */
  124240. readonly total: number;
  124241. /**
  124242. * Create a new progress event
  124243. * @param lengthComputable defines if data length to load can be evaluated
  124244. * @param loaded defines the loaded data length
  124245. * @param total defines the data length to load
  124246. */
  124247. constructor(
  124248. /** defines if data length to load can be evaluated */
  124249. lengthComputable: boolean,
  124250. /** defines the loaded data length */
  124251. loaded: number,
  124252. /** defines the data length to load */
  124253. total: number);
  124254. /**
  124255. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  124256. * @param event defines the source event
  124257. * @returns a new SceneLoaderProgressEvent
  124258. */
  124259. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  124260. }
  124261. /**
  124262. * Interface used by SceneLoader plugins to define supported file extensions
  124263. */
  124264. export interface ISceneLoaderPluginExtensions {
  124265. /**
  124266. * Defines the list of supported extensions
  124267. */
  124268. [extension: string]: {
  124269. isBinary: boolean;
  124270. };
  124271. }
  124272. /**
  124273. * Interface used by SceneLoader plugin factory
  124274. */
  124275. export interface ISceneLoaderPluginFactory {
  124276. /**
  124277. * Defines the name of the factory
  124278. */
  124279. name: string;
  124280. /**
  124281. * Function called to create a new plugin
  124282. * @return the new plugin
  124283. */
  124284. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124285. /**
  124286. * The callback that returns true if the data can be directly loaded.
  124287. * @param data string containing the file data
  124288. * @returns if the data can be loaded directly
  124289. */
  124290. canDirectLoad?(data: string): boolean;
  124291. }
  124292. /**
  124293. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124294. */
  124295. export interface ISceneLoaderPluginBase {
  124296. /**
  124297. * The friendly name of this plugin.
  124298. */
  124299. name: string;
  124300. /**
  124301. * The file extensions supported by this plugin.
  124302. */
  124303. extensions: string | ISceneLoaderPluginExtensions;
  124304. /**
  124305. * The callback called when loading from a url.
  124306. * @param scene scene loading this url
  124307. * @param url url to load
  124308. * @param onSuccess callback called when the file successfully loads
  124309. * @param onProgress callback called while file is loading (if the server supports this mode)
  124310. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124311. * @param onError callback called when the file fails to load
  124312. * @returns a file request object
  124313. */
  124314. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124315. /**
  124316. * The callback called when loading from a file object.
  124317. * @param scene scene loading this file
  124318. * @param file defines the file to load
  124319. * @param onSuccess defines the callback to call when data is loaded
  124320. * @param onProgress defines the callback to call during loading process
  124321. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124322. * @param onError defines the callback to call when an error occurs
  124323. * @returns a file request object
  124324. */
  124325. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124326. /**
  124327. * The callback that returns true if the data can be directly loaded.
  124328. * @param data string containing the file data
  124329. * @returns if the data can be loaded directly
  124330. */
  124331. canDirectLoad?(data: string): boolean;
  124332. /**
  124333. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124334. * @param scene scene loading this data
  124335. * @param data string containing the data
  124336. * @returns data to pass to the plugin
  124337. */
  124338. directLoad?(scene: Scene, data: string): any;
  124339. /**
  124340. * The callback that allows custom handling of the root url based on the response url.
  124341. * @param rootUrl the original root url
  124342. * @param responseURL the response url if available
  124343. * @returns the new root url
  124344. */
  124345. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124346. }
  124347. /**
  124348. * Interface used to define a SceneLoader plugin
  124349. */
  124350. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  124351. /**
  124352. * Import meshes into a scene.
  124353. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124354. * @param scene The scene to import into
  124355. * @param data The data to import
  124356. * @param rootUrl The root url for scene and resources
  124357. * @param meshes The meshes array to import into
  124358. * @param particleSystems The particle systems array to import into
  124359. * @param skeletons The skeletons array to import into
  124360. * @param onError The callback when import fails
  124361. * @returns True if successful or false otherwise
  124362. */
  124363. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124364. /**
  124365. * Load into a scene.
  124366. * @param scene The scene to load into
  124367. * @param data The data to import
  124368. * @param rootUrl The root url for scene and resources
  124369. * @param onError The callback when import fails
  124370. * @returns True if successful or false otherwise
  124371. */
  124372. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124373. /**
  124374. * Load into an asset container.
  124375. * @param scene The scene to load into
  124376. * @param data The data to import
  124377. * @param rootUrl The root url for scene and resources
  124378. * @param onError The callback when import fails
  124379. * @returns The loaded asset container
  124380. */
  124381. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124382. }
  124383. /**
  124384. * Interface used to define an async SceneLoader plugin
  124385. */
  124386. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124387. /**
  124388. * Import meshes into a scene.
  124389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124390. * @param scene The scene to import into
  124391. * @param data The data to import
  124392. * @param rootUrl The root url for scene and resources
  124393. * @param onProgress The callback when the load progresses
  124394. * @param fileName Defines the name of the file to load
  124395. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124396. */
  124397. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124398. meshes: AbstractMesh[];
  124399. particleSystems: IParticleSystem[];
  124400. skeletons: Skeleton[];
  124401. animationGroups: AnimationGroup[];
  124402. }>;
  124403. /**
  124404. * Load into a scene.
  124405. * @param scene The scene to load into
  124406. * @param data The data to import
  124407. * @param rootUrl The root url for scene and resources
  124408. * @param onProgress The callback when the load progresses
  124409. * @param fileName Defines the name of the file to load
  124410. * @returns Nothing
  124411. */
  124412. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124413. /**
  124414. * Load into an asset container.
  124415. * @param scene The scene to load into
  124416. * @param data The data to import
  124417. * @param rootUrl The root url for scene and resources
  124418. * @param onProgress The callback when the load progresses
  124419. * @param fileName Defines the name of the file to load
  124420. * @returns The loaded asset container
  124421. */
  124422. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124423. }
  124424. /**
  124425. * Mode that determines how to handle old animation groups before loading new ones.
  124426. */
  124427. export enum SceneLoaderAnimationGroupLoadingMode {
  124428. /**
  124429. * Reset all old animations to initial state then dispose them.
  124430. */
  124431. Clean = 0,
  124432. /**
  124433. * Stop all old animations.
  124434. */
  124435. Stop = 1,
  124436. /**
  124437. * Restart old animations from first frame.
  124438. */
  124439. Sync = 2,
  124440. /**
  124441. * Old animations remains untouched.
  124442. */
  124443. NoSync = 3
  124444. }
  124445. /**
  124446. * Class used to load scene from various file formats using registered plugins
  124447. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124448. */
  124449. export class SceneLoader {
  124450. /**
  124451. * No logging while loading
  124452. */
  124453. static readonly NO_LOGGING: number;
  124454. /**
  124455. * Minimal logging while loading
  124456. */
  124457. static readonly MINIMAL_LOGGING: number;
  124458. /**
  124459. * Summary logging while loading
  124460. */
  124461. static readonly SUMMARY_LOGGING: number;
  124462. /**
  124463. * Detailled logging while loading
  124464. */
  124465. static readonly DETAILED_LOGGING: number;
  124466. /**
  124467. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124468. */
  124469. static get ForceFullSceneLoadingForIncremental(): boolean;
  124470. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124471. /**
  124472. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124473. */
  124474. static get ShowLoadingScreen(): boolean;
  124475. static set ShowLoadingScreen(value: boolean);
  124476. /**
  124477. * Defines the current logging level (while loading the scene)
  124478. * @ignorenaming
  124479. */
  124480. static get loggingLevel(): number;
  124481. static set loggingLevel(value: number);
  124482. /**
  124483. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124484. */
  124485. static get CleanBoneMatrixWeights(): boolean;
  124486. static set CleanBoneMatrixWeights(value: boolean);
  124487. /**
  124488. * Event raised when a plugin is used to load a scene
  124489. */
  124490. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124491. private static _registeredPlugins;
  124492. private static _getDefaultPlugin;
  124493. private static _getPluginForExtension;
  124494. private static _getPluginForDirectLoad;
  124495. private static _getPluginForFilename;
  124496. private static _getDirectLoad;
  124497. private static _loadData;
  124498. private static _getFileInfo;
  124499. /**
  124500. * Gets a plugin that can load the given extension
  124501. * @param extension defines the extension to load
  124502. * @returns a plugin or null if none works
  124503. */
  124504. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124505. /**
  124506. * Gets a boolean indicating that the given extension can be loaded
  124507. * @param extension defines the extension to load
  124508. * @returns true if the extension is supported
  124509. */
  124510. static IsPluginForExtensionAvailable(extension: string): boolean;
  124511. /**
  124512. * Adds a new plugin to the list of registered plugins
  124513. * @param plugin defines the plugin to add
  124514. */
  124515. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124516. /**
  124517. * Import meshes into a scene
  124518. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124519. * @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)
  124520. * @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)
  124521. * @param scene the instance of BABYLON.Scene to append to
  124522. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124523. * @param onProgress a callback with a progress event for each file being loaded
  124524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124525. * @param pluginExtension the extension used to determine the plugin
  124526. * @returns The loaded plugin
  124527. */
  124528. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124529. /**
  124530. * Import meshes into a scene
  124531. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124532. * @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)
  124533. * @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)
  124534. * @param scene the instance of BABYLON.Scene to append to
  124535. * @param onProgress a callback with a progress event for each file being loaded
  124536. * @param pluginExtension the extension used to determine the plugin
  124537. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124538. */
  124539. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124540. meshes: AbstractMesh[];
  124541. particleSystems: IParticleSystem[];
  124542. skeletons: Skeleton[];
  124543. animationGroups: AnimationGroup[];
  124544. }>;
  124545. /**
  124546. * Load a scene
  124547. * @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)
  124548. * @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)
  124549. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124550. * @param onSuccess a callback with the scene when import succeeds
  124551. * @param onProgress a callback with a progress event for each file being loaded
  124552. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124553. * @param pluginExtension the extension used to determine the plugin
  124554. * @returns The loaded plugin
  124555. */
  124556. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124557. /**
  124558. * Load a scene
  124559. * @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)
  124560. * @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)
  124561. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124562. * @param onProgress a callback with a progress event for each file being loaded
  124563. * @param pluginExtension the extension used to determine the plugin
  124564. * @returns The loaded scene
  124565. */
  124566. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124567. /**
  124568. * Append a scene
  124569. * @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)
  124570. * @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)
  124571. * @param scene is the instance of BABYLON.Scene to append to
  124572. * @param onSuccess a callback with the scene when import succeeds
  124573. * @param onProgress a callback with a progress event for each file being loaded
  124574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124575. * @param pluginExtension the extension used to determine the plugin
  124576. * @returns The loaded plugin
  124577. */
  124578. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124579. /**
  124580. * Append a scene
  124581. * @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)
  124582. * @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)
  124583. * @param scene is the instance of BABYLON.Scene to append to
  124584. * @param onProgress a callback with a progress event for each file being loaded
  124585. * @param pluginExtension the extension used to determine the plugin
  124586. * @returns The given scene
  124587. */
  124588. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124589. /**
  124590. * Load a scene into an asset container
  124591. * @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)
  124592. * @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)
  124593. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124594. * @param onSuccess a callback with the scene when import succeeds
  124595. * @param onProgress a callback with a progress event for each file being loaded
  124596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124597. * @param pluginExtension the extension used to determine the plugin
  124598. * @returns The loaded plugin
  124599. */
  124600. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124601. /**
  124602. * Load a scene into an asset container
  124603. * @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)
  124604. * @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)
  124605. * @param scene is the instance of Scene to append to
  124606. * @param onProgress a callback with a progress event for each file being loaded
  124607. * @param pluginExtension the extension used to determine the plugin
  124608. * @returns The loaded asset container
  124609. */
  124610. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124611. /**
  124612. * Import animations from a file into a scene
  124613. * @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)
  124614. * @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)
  124615. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124616. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124617. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124618. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124619. * @param onSuccess a callback with the scene when import succeeds
  124620. * @param onProgress a callback with a progress event for each file being loaded
  124621. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124622. */
  124623. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  124624. /**
  124625. * Import animations from a file into a scene
  124626. * @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)
  124627. * @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)
  124628. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124629. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124630. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124631. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124632. * @param onSuccess a callback with the scene when import succeeds
  124633. * @param onProgress a callback with a progress event for each file being loaded
  124634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124635. * @returns the updated scene with imported animations
  124636. */
  124637. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  124638. }
  124639. }
  124640. declare module BABYLON {
  124641. /**
  124642. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124643. */
  124644. export type MotionControllerHandedness = "none" | "left" | "right";
  124645. /**
  124646. * The type of components available in motion controllers.
  124647. * This is not the name of the component.
  124648. */
  124649. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124650. /**
  124651. * The state of a controller component
  124652. */
  124653. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124654. /**
  124655. * The schema of motion controller layout.
  124656. * No object will be initialized using this interface
  124657. * This is used just to define the profile.
  124658. */
  124659. export interface IMotionControllerLayout {
  124660. /**
  124661. * Path to load the assets. Usually relative to the base path
  124662. */
  124663. assetPath: string;
  124664. /**
  124665. * Available components (unsorted)
  124666. */
  124667. components: {
  124668. /**
  124669. * A map of component Ids
  124670. */
  124671. [componentId: string]: {
  124672. /**
  124673. * The type of input the component outputs
  124674. */
  124675. type: MotionControllerComponentType;
  124676. /**
  124677. * The indices of this component in the gamepad object
  124678. */
  124679. gamepadIndices: {
  124680. /**
  124681. * Index of button
  124682. */
  124683. button?: number;
  124684. /**
  124685. * If available, index of x-axis
  124686. */
  124687. xAxis?: number;
  124688. /**
  124689. * If available, index of y-axis
  124690. */
  124691. yAxis?: number;
  124692. };
  124693. /**
  124694. * The mesh's root node name
  124695. */
  124696. rootNodeName: string;
  124697. /**
  124698. * Animation definitions for this model
  124699. */
  124700. visualResponses: {
  124701. [stateKey: string]: {
  124702. /**
  124703. * What property will be animated
  124704. */
  124705. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124706. /**
  124707. * What states influence this visual response
  124708. */
  124709. states: MotionControllerComponentStateType[];
  124710. /**
  124711. * Type of animation - movement or visibility
  124712. */
  124713. valueNodeProperty: "transform" | "visibility";
  124714. /**
  124715. * Base node name to move. Its position will be calculated according to the min and max nodes
  124716. */
  124717. valueNodeName?: string;
  124718. /**
  124719. * Minimum movement node
  124720. */
  124721. minNodeName?: string;
  124722. /**
  124723. * Max movement node
  124724. */
  124725. maxNodeName?: string;
  124726. };
  124727. };
  124728. /**
  124729. * If touch enabled, what is the name of node to display user feedback
  124730. */
  124731. touchPointNodeName?: string;
  124732. };
  124733. };
  124734. /**
  124735. * Is it xr standard mapping or not
  124736. */
  124737. gamepadMapping: "" | "xr-standard";
  124738. /**
  124739. * Base root node of this entire model
  124740. */
  124741. rootNodeName: string;
  124742. /**
  124743. * Defines the main button component id
  124744. */
  124745. selectComponentId: string;
  124746. }
  124747. /**
  124748. * A definition for the layout map in the input profile
  124749. */
  124750. export interface IMotionControllerLayoutMap {
  124751. /**
  124752. * Layouts with handedness type as a key
  124753. */
  124754. [handedness: string]: IMotionControllerLayout;
  124755. }
  124756. /**
  124757. * The XR Input profile schema
  124758. * Profiles can be found here:
  124759. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124760. */
  124761. export interface IMotionControllerProfile {
  124762. /**
  124763. * fallback profiles for this profileId
  124764. */
  124765. fallbackProfileIds: string[];
  124766. /**
  124767. * The layout map, with handedness as key
  124768. */
  124769. layouts: IMotionControllerLayoutMap;
  124770. /**
  124771. * The id of this profile
  124772. * correlates to the profile(s) in the xrInput.profiles array
  124773. */
  124774. profileId: string;
  124775. }
  124776. /**
  124777. * A helper-interface for the 3 meshes needed for controller button animation
  124778. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124779. */
  124780. export interface IMotionControllerButtonMeshMap {
  124781. /**
  124782. * the mesh that defines the pressed value mesh position.
  124783. * This is used to find the max-position of this button
  124784. */
  124785. pressedMesh: AbstractMesh;
  124786. /**
  124787. * the mesh that defines the unpressed value mesh position.
  124788. * This is used to find the min (or initial) position of this button
  124789. */
  124790. unpressedMesh: AbstractMesh;
  124791. /**
  124792. * The mesh that will be changed when value changes
  124793. */
  124794. valueMesh: AbstractMesh;
  124795. }
  124796. /**
  124797. * A helper-interface for the 3 meshes needed for controller axis animation.
  124798. * This will be expanded when touchpad animations are fully supported
  124799. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124800. */
  124801. export interface IMotionControllerMeshMap {
  124802. /**
  124803. * the mesh that defines the maximum value mesh position.
  124804. */
  124805. maxMesh?: AbstractMesh;
  124806. /**
  124807. * the mesh that defines the minimum value mesh position.
  124808. */
  124809. minMesh?: AbstractMesh;
  124810. /**
  124811. * The mesh that will be changed when axis value changes
  124812. */
  124813. valueMesh: AbstractMesh;
  124814. }
  124815. /**
  124816. * The elements needed for change-detection of the gamepad objects in motion controllers
  124817. */
  124818. export interface IMinimalMotionControllerObject {
  124819. /**
  124820. * Available axes of this controller
  124821. */
  124822. axes: number[];
  124823. /**
  124824. * An array of available buttons
  124825. */
  124826. buttons: Array<{
  124827. /**
  124828. * Value of the button/trigger
  124829. */
  124830. value: number;
  124831. /**
  124832. * If the button/trigger is currently touched
  124833. */
  124834. touched: boolean;
  124835. /**
  124836. * If the button/trigger is currently pressed
  124837. */
  124838. pressed: boolean;
  124839. }>;
  124840. /**
  124841. * EXPERIMENTAL haptic support.
  124842. */
  124843. hapticActuators?: Array<{
  124844. pulse: (value: number, duration: number) => Promise<boolean>;
  124845. }>;
  124846. }
  124847. /**
  124848. * An Abstract Motion controller
  124849. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124850. * Each component has an observable to check for changes in value and state
  124851. */
  124852. export abstract class WebXRAbstractMotionController implements IDisposable {
  124853. protected scene: Scene;
  124854. protected layout: IMotionControllerLayout;
  124855. /**
  124856. * The gamepad object correlating to this controller
  124857. */
  124858. gamepadObject: IMinimalMotionControllerObject;
  124859. /**
  124860. * handedness (left/right/none) of this controller
  124861. */
  124862. handedness: MotionControllerHandedness;
  124863. private _initComponent;
  124864. private _modelReady;
  124865. /**
  124866. * A map of components (WebXRControllerComponent) in this motion controller
  124867. * Components have a ComponentType and can also have both button and axis definitions
  124868. */
  124869. readonly components: {
  124870. [id: string]: WebXRControllerComponent;
  124871. };
  124872. /**
  124873. * Disable the model's animation. Can be set at any time.
  124874. */
  124875. disableAnimation: boolean;
  124876. /**
  124877. * Observers registered here will be triggered when the model of this controller is done loading
  124878. */
  124879. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124880. /**
  124881. * The profile id of this motion controller
  124882. */
  124883. abstract profileId: string;
  124884. /**
  124885. * The root mesh of the model. It is null if the model was not yet initialized
  124886. */
  124887. rootMesh: Nullable<AbstractMesh>;
  124888. /**
  124889. * constructs a new abstract motion controller
  124890. * @param scene the scene to which the model of the controller will be added
  124891. * @param layout The profile layout to load
  124892. * @param gamepadObject The gamepad object correlating to this controller
  124893. * @param handedness handedness (left/right/none) of this controller
  124894. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124895. */
  124896. constructor(scene: Scene, layout: IMotionControllerLayout,
  124897. /**
  124898. * The gamepad object correlating to this controller
  124899. */
  124900. gamepadObject: IMinimalMotionControllerObject,
  124901. /**
  124902. * handedness (left/right/none) of this controller
  124903. */
  124904. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124905. /**
  124906. * Dispose this controller, the model mesh and all its components
  124907. */
  124908. dispose(): void;
  124909. /**
  124910. * Returns all components of specific type
  124911. * @param type the type to search for
  124912. * @return an array of components with this type
  124913. */
  124914. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124915. /**
  124916. * get a component based an its component id as defined in layout.components
  124917. * @param id the id of the component
  124918. * @returns the component correlates to the id or undefined if not found
  124919. */
  124920. getComponent(id: string): WebXRControllerComponent;
  124921. /**
  124922. * Get the list of components available in this motion controller
  124923. * @returns an array of strings correlating to available components
  124924. */
  124925. getComponentIds(): string[];
  124926. /**
  124927. * Get the first component of specific type
  124928. * @param type type of component to find
  124929. * @return a controller component or null if not found
  124930. */
  124931. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124932. /**
  124933. * Get the main (Select) component of this controller as defined in the layout
  124934. * @returns the main component of this controller
  124935. */
  124936. getMainComponent(): WebXRControllerComponent;
  124937. /**
  124938. * Loads the model correlating to this controller
  124939. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124940. * @returns A promise fulfilled with the result of the model loading
  124941. */
  124942. loadModel(): Promise<boolean>;
  124943. /**
  124944. * Update this model using the current XRFrame
  124945. * @param xrFrame the current xr frame to use and update the model
  124946. */
  124947. updateFromXRFrame(xrFrame: XRFrame): void;
  124948. /**
  124949. * Backwards compatibility due to a deeply-integrated typo
  124950. */
  124951. get handness(): XREye;
  124952. /**
  124953. * Pulse (vibrate) this controller
  124954. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124955. * Consecutive calls to this function will cancel the last pulse call
  124956. *
  124957. * @param value the strength of the pulse in 0.0...1.0 range
  124958. * @param duration Duration of the pulse in milliseconds
  124959. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124960. * @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
  124961. */
  124962. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124963. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124964. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124965. /**
  124966. * Moves the axis on the controller mesh based on its current state
  124967. * @param axis the index of the axis
  124968. * @param axisValue the value of the axis which determines the meshes new position
  124969. * @hidden
  124970. */
  124971. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124972. /**
  124973. * Update the model itself with the current frame data
  124974. * @param xrFrame the frame to use for updating the model mesh
  124975. */
  124976. protected updateModel(xrFrame: XRFrame): void;
  124977. /**
  124978. * Get the filename and path for this controller's model
  124979. * @returns a map of filename and path
  124980. */
  124981. protected abstract _getFilenameAndPath(): {
  124982. filename: string;
  124983. path: string;
  124984. };
  124985. /**
  124986. * This function is called before the mesh is loaded. It checks for loading constraints.
  124987. * For example, this function can check if the GLB loader is available
  124988. * If this function returns false, the generic controller will be loaded instead
  124989. * @returns Is the client ready to load the mesh
  124990. */
  124991. protected abstract _getModelLoadingConstraints(): boolean;
  124992. /**
  124993. * This function will be called after the model was successfully loaded and can be used
  124994. * for mesh transformations before it is available for the user
  124995. * @param meshes the loaded meshes
  124996. */
  124997. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124998. /**
  124999. * Set the root mesh for this controller. Important for the WebXR controller class
  125000. * @param meshes the loaded meshes
  125001. */
  125002. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125003. /**
  125004. * A function executed each frame that updates the mesh (if needed)
  125005. * @param xrFrame the current xrFrame
  125006. */
  125007. protected abstract _updateModel(xrFrame: XRFrame): void;
  125008. private _getGenericFilenameAndPath;
  125009. private _getGenericParentMesh;
  125010. }
  125011. }
  125012. declare module BABYLON {
  125013. /**
  125014. * A generic trigger-only motion controller for WebXR
  125015. */
  125016. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125017. /**
  125018. * Static version of the profile id of this controller
  125019. */
  125020. static ProfileId: string;
  125021. profileId: string;
  125022. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125023. protected _getFilenameAndPath(): {
  125024. filename: string;
  125025. path: string;
  125026. };
  125027. protected _getModelLoadingConstraints(): boolean;
  125028. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125029. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125030. protected _updateModel(): void;
  125031. }
  125032. }
  125033. declare module BABYLON {
  125034. /**
  125035. * Class containing static functions to help procedurally build meshes
  125036. */
  125037. export class SphereBuilder {
  125038. /**
  125039. * Creates a sphere mesh
  125040. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125041. * * 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`)
  125042. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125043. * * 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
  125044. * * 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)
  125045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125048. * @param name defines the name of the mesh
  125049. * @param options defines the options used to create the mesh
  125050. * @param scene defines the hosting scene
  125051. * @returns the sphere mesh
  125052. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125053. */
  125054. static CreateSphere(name: string, options: {
  125055. segments?: number;
  125056. diameter?: number;
  125057. diameterX?: number;
  125058. diameterY?: number;
  125059. diameterZ?: number;
  125060. arc?: number;
  125061. slice?: number;
  125062. sideOrientation?: number;
  125063. frontUVs?: Vector4;
  125064. backUVs?: Vector4;
  125065. updatable?: boolean;
  125066. }, scene?: Nullable<Scene>): Mesh;
  125067. }
  125068. }
  125069. declare module BABYLON {
  125070. /**
  125071. * A profiled motion controller has its profile loaded from an online repository.
  125072. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125073. */
  125074. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125075. private _repositoryUrl;
  125076. private _buttonMeshMapping;
  125077. private _touchDots;
  125078. /**
  125079. * The profile ID of this controller. Will be populated when the controller initializes.
  125080. */
  125081. profileId: string;
  125082. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125083. dispose(): void;
  125084. protected _getFilenameAndPath(): {
  125085. filename: string;
  125086. path: string;
  125087. };
  125088. protected _getModelLoadingConstraints(): boolean;
  125089. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125090. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125091. protected _updateModel(_xrFrame: XRFrame): void;
  125092. }
  125093. }
  125094. declare module BABYLON {
  125095. /**
  125096. * A construction function type to create a new controller based on an xrInput object
  125097. */
  125098. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125099. /**
  125100. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125101. *
  125102. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125103. * it should be replaced with auto-loaded controllers.
  125104. *
  125105. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125106. */
  125107. export class WebXRMotionControllerManager {
  125108. private static _AvailableControllers;
  125109. private static _Fallbacks;
  125110. private static _ProfileLoadingPromises;
  125111. private static _ProfilesList;
  125112. /**
  125113. * The base URL of the online controller repository. Can be changed at any time.
  125114. */
  125115. static BaseRepositoryUrl: string;
  125116. /**
  125117. * Which repository gets priority - local or online
  125118. */
  125119. static PrioritizeOnlineRepository: boolean;
  125120. /**
  125121. * Use the online repository, or use only locally-defined controllers
  125122. */
  125123. static UseOnlineRepository: boolean;
  125124. /**
  125125. * Clear the cache used for profile loading and reload when requested again
  125126. */
  125127. static ClearProfilesCache(): void;
  125128. /**
  125129. * Register the default fallbacks.
  125130. * This function is called automatically when this file is imported.
  125131. */
  125132. static DefaultFallbacks(): void;
  125133. /**
  125134. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125135. * @param profileId the profile to which a fallback needs to be found
  125136. * @return an array with corresponding fallback profiles
  125137. */
  125138. static FindFallbackWithProfileId(profileId: string): string[];
  125139. /**
  125140. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125141. * The order of search:
  125142. *
  125143. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125144. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125145. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125146. * 4) return the generic trigger controller if none were found
  125147. *
  125148. * @param xrInput the xrInput to which a new controller is initialized
  125149. * @param scene the scene to which the model will be added
  125150. * @param forceProfile force a certain profile for this controller
  125151. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125152. */
  125153. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125154. /**
  125155. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125156. *
  125157. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125158. *
  125159. * @param type the profile type to register
  125160. * @param constructFunction the function to be called when loading this profile
  125161. */
  125162. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125163. /**
  125164. * Register a fallback to a specific profile.
  125165. * @param profileId the profileId that will receive the fallbacks
  125166. * @param fallbacks A list of fallback profiles
  125167. */
  125168. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125169. /**
  125170. * Will update the list of profiles available in the repository
  125171. * @return a promise that resolves to a map of profiles available online
  125172. */
  125173. static UpdateProfilesList(): Promise<{
  125174. [profile: string]: string;
  125175. }>;
  125176. private static _LoadProfileFromRepository;
  125177. private static _LoadProfilesFromAvailableControllers;
  125178. }
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Configuration options for the WebXR controller creation
  125183. */
  125184. export interface IWebXRControllerOptions {
  125185. /**
  125186. * Should the controller mesh be animated when a user interacts with it
  125187. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125188. */
  125189. disableMotionControllerAnimation?: boolean;
  125190. /**
  125191. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125192. */
  125193. doNotLoadControllerMesh?: boolean;
  125194. /**
  125195. * Force a specific controller type for this controller.
  125196. * This can be used when creating your own profile or when testing different controllers
  125197. */
  125198. forceControllerProfile?: string;
  125199. /**
  125200. * Defines a rendering group ID for meshes that will be loaded.
  125201. * This is for the default controllers only.
  125202. */
  125203. renderingGroupId?: number;
  125204. }
  125205. /**
  125206. * Represents an XR controller
  125207. */
  125208. export class WebXRInputSource {
  125209. private _scene;
  125210. /** The underlying input source for the controller */
  125211. inputSource: XRInputSource;
  125212. private _options;
  125213. private _tmpVector;
  125214. private _uniqueId;
  125215. /**
  125216. * 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
  125217. */
  125218. grip?: AbstractMesh;
  125219. /**
  125220. * If available, this is the gamepad object related to this controller.
  125221. * Using this object it is possible to get click events and trackpad changes of the
  125222. * webxr controller that is currently being used.
  125223. */
  125224. motionController?: WebXRAbstractMotionController;
  125225. /**
  125226. * Event that fires when the controller is removed/disposed.
  125227. * The object provided as event data is this controller, after associated assets were disposed.
  125228. * uniqueId is still available.
  125229. */
  125230. onDisposeObservable: Observable<WebXRInputSource>;
  125231. /**
  125232. * Will be triggered when the mesh associated with the motion controller is done loading.
  125233. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125234. * A shortened version of controller -> motion controller -> on mesh loaded.
  125235. */
  125236. onMeshLoadedObservable: Observable<AbstractMesh>;
  125237. /**
  125238. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125239. */
  125240. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125241. /**
  125242. * Pointer which can be used to select objects or attach a visible laser to
  125243. */
  125244. pointer: AbstractMesh;
  125245. /**
  125246. * Creates the controller
  125247. * @see https://doc.babylonjs.com/how_to/webxr
  125248. * @param _scene the scene which the controller should be associated to
  125249. * @param inputSource the underlying input source for the controller
  125250. * @param _options options for this controller creation
  125251. */
  125252. constructor(_scene: Scene,
  125253. /** The underlying input source for the controller */
  125254. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125255. /**
  125256. * Get this controllers unique id
  125257. */
  125258. get uniqueId(): string;
  125259. /**
  125260. * Disposes of the object
  125261. */
  125262. dispose(): void;
  125263. /**
  125264. * Gets a world space ray coming from the pointer or grip
  125265. * @param result the resulting ray
  125266. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125267. */
  125268. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125269. /**
  125270. * Updates the controller pose based on the given XRFrame
  125271. * @param xrFrame xr frame to update the pose with
  125272. * @param referenceSpace reference space to use
  125273. */
  125274. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125275. }
  125276. }
  125277. declare module BABYLON {
  125278. /**
  125279. * The schema for initialization options of the XR Input class
  125280. */
  125281. export interface IWebXRInputOptions {
  125282. /**
  125283. * If set to true no model will be automatically loaded
  125284. */
  125285. doNotLoadControllerMeshes?: boolean;
  125286. /**
  125287. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125288. * If not found, the xr input profile data will be used.
  125289. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125290. */
  125291. forceInputProfile?: string;
  125292. /**
  125293. * Do not send a request to the controller repository to load the profile.
  125294. *
  125295. * Instead, use the controllers available in babylon itself.
  125296. */
  125297. disableOnlineControllerRepository?: boolean;
  125298. /**
  125299. * A custom URL for the controllers repository
  125300. */
  125301. customControllersRepositoryURL?: string;
  125302. /**
  125303. * Should the controller model's components not move according to the user input
  125304. */
  125305. disableControllerAnimation?: boolean;
  125306. /**
  125307. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125308. */
  125309. controllerOptions?: IWebXRControllerOptions;
  125310. }
  125311. /**
  125312. * XR input used to track XR inputs such as controllers/rays
  125313. */
  125314. export class WebXRInput implements IDisposable {
  125315. /**
  125316. * the xr session manager for this session
  125317. */
  125318. xrSessionManager: WebXRSessionManager;
  125319. /**
  125320. * the WebXR camera for this session. Mainly used for teleportation
  125321. */
  125322. xrCamera: WebXRCamera;
  125323. private readonly options;
  125324. /**
  125325. * XR controllers being tracked
  125326. */
  125327. controllers: Array<WebXRInputSource>;
  125328. private _frameObserver;
  125329. private _sessionEndedObserver;
  125330. private _sessionInitObserver;
  125331. /**
  125332. * Event when a controller has been connected/added
  125333. */
  125334. onControllerAddedObservable: Observable<WebXRInputSource>;
  125335. /**
  125336. * Event when a controller has been removed/disconnected
  125337. */
  125338. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125339. /**
  125340. * Initializes the WebXRInput
  125341. * @param xrSessionManager the xr session manager for this session
  125342. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125343. * @param options = initialization options for this xr input
  125344. */
  125345. constructor(
  125346. /**
  125347. * the xr session manager for this session
  125348. */
  125349. xrSessionManager: WebXRSessionManager,
  125350. /**
  125351. * the WebXR camera for this session. Mainly used for teleportation
  125352. */
  125353. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125354. private _onInputSourcesChange;
  125355. private _addAndRemoveControllers;
  125356. /**
  125357. * Disposes of the object
  125358. */
  125359. dispose(): void;
  125360. }
  125361. }
  125362. declare module BABYLON {
  125363. /**
  125364. * This is the base class for all WebXR features.
  125365. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125366. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125367. */
  125368. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125369. protected _xrSessionManager: WebXRSessionManager;
  125370. private _attached;
  125371. private _removeOnDetach;
  125372. /**
  125373. * Should auto-attach be disabled?
  125374. */
  125375. disableAutoAttach: boolean;
  125376. /**
  125377. * Construct a new (abstract) WebXR feature
  125378. * @param _xrSessionManager the xr session manager for this feature
  125379. */
  125380. constructor(_xrSessionManager: WebXRSessionManager);
  125381. /**
  125382. * Is this feature attached
  125383. */
  125384. get attached(): boolean;
  125385. /**
  125386. * attach this feature
  125387. *
  125388. * @param force should attachment be forced (even when already attached)
  125389. * @returns true if successful, false is failed or already attached
  125390. */
  125391. attach(force?: boolean): boolean;
  125392. /**
  125393. * detach this feature.
  125394. *
  125395. * @returns true if successful, false if failed or already detached
  125396. */
  125397. detach(): boolean;
  125398. /**
  125399. * Dispose this feature and all of the resources attached
  125400. */
  125401. dispose(): void;
  125402. /**
  125403. * This is used to register callbacks that will automatically be removed when detach is called.
  125404. * @param observable the observable to which the observer will be attached
  125405. * @param callback the callback to register
  125406. */
  125407. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125408. /**
  125409. * Code in this function will be executed on each xrFrame received from the browser.
  125410. * This function will not execute after the feature is detached.
  125411. * @param _xrFrame the current frame
  125412. */
  125413. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125414. }
  125415. }
  125416. declare module BABYLON {
  125417. /**
  125418. * Renders a layer on top of an existing scene
  125419. */
  125420. export class UtilityLayerRenderer implements IDisposable {
  125421. /** the original scene that will be rendered on top of */
  125422. originalScene: Scene;
  125423. private _pointerCaptures;
  125424. private _lastPointerEvents;
  125425. private static _DefaultUtilityLayer;
  125426. private static _DefaultKeepDepthUtilityLayer;
  125427. private _sharedGizmoLight;
  125428. private _renderCamera;
  125429. /**
  125430. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125431. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125432. * @returns the camera that is used when rendering the utility layer
  125433. */
  125434. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125435. /**
  125436. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125437. * @param cam the camera that should be used when rendering the utility layer
  125438. */
  125439. setRenderCamera(cam: Nullable<Camera>): void;
  125440. /**
  125441. * @hidden
  125442. * Light which used by gizmos to get light shading
  125443. */
  125444. _getSharedGizmoLight(): HemisphericLight;
  125445. /**
  125446. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125447. */
  125448. pickUtilitySceneFirst: boolean;
  125449. /**
  125450. * 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)
  125451. */
  125452. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125453. /**
  125454. * 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)
  125455. */
  125456. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125457. /**
  125458. * The scene that is rendered on top of the original scene
  125459. */
  125460. utilityLayerScene: Scene;
  125461. /**
  125462. * If the utility layer should automatically be rendered on top of existing scene
  125463. */
  125464. shouldRender: boolean;
  125465. /**
  125466. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125467. */
  125468. onlyCheckPointerDownEvents: boolean;
  125469. /**
  125470. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125471. */
  125472. processAllEvents: boolean;
  125473. /**
  125474. * Observable raised when the pointer move from the utility layer scene to the main scene
  125475. */
  125476. onPointerOutObservable: Observable<number>;
  125477. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125478. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125479. private _afterRenderObserver;
  125480. private _sceneDisposeObserver;
  125481. private _originalPointerObserver;
  125482. /**
  125483. * Instantiates a UtilityLayerRenderer
  125484. * @param originalScene the original scene that will be rendered on top of
  125485. * @param handleEvents boolean indicating if the utility layer should handle events
  125486. */
  125487. constructor(
  125488. /** the original scene that will be rendered on top of */
  125489. originalScene: Scene, handleEvents?: boolean);
  125490. private _notifyObservers;
  125491. /**
  125492. * Renders the utility layers scene on top of the original scene
  125493. */
  125494. render(): void;
  125495. /**
  125496. * Disposes of the renderer
  125497. */
  125498. dispose(): void;
  125499. private _updateCamera;
  125500. }
  125501. }
  125502. declare module BABYLON {
  125503. /**
  125504. * Options interface for the pointer selection module
  125505. */
  125506. export interface IWebXRControllerPointerSelectionOptions {
  125507. /**
  125508. * if provided, this scene will be used to render meshes.
  125509. */
  125510. customUtilityLayerScene?: Scene;
  125511. /**
  125512. * 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)
  125513. * If not disabled, the last picked point will be used to execute a pointer up event
  125514. * If disabled, pointer up event will be triggered right after the pointer down event.
  125515. * Used in screen and gaze target ray mode only
  125516. */
  125517. disablePointerUpOnTouchOut: boolean;
  125518. /**
  125519. * For gaze mode (time to select instead of press)
  125520. */
  125521. forceGazeMode: boolean;
  125522. /**
  125523. * 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
  125524. * to start a new countdown to the pointer down event.
  125525. * Defaults to 1.
  125526. */
  125527. gazeModePointerMovedFactor?: number;
  125528. /**
  125529. * Different button type to use instead of the main component
  125530. */
  125531. overrideButtonId?: string;
  125532. /**
  125533. * use this rendering group id for the meshes (optional)
  125534. */
  125535. renderingGroupId?: number;
  125536. /**
  125537. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125538. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125539. * 3000 means 3 seconds between pointing at something and selecting it
  125540. */
  125541. timeToSelect?: number;
  125542. /**
  125543. * Should meshes created here be added to a utility layer or the main scene
  125544. */
  125545. useUtilityLayer?: boolean;
  125546. /**
  125547. * the xr input to use with this pointer selection
  125548. */
  125549. xrInput: WebXRInput;
  125550. }
  125551. /**
  125552. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125553. */
  125554. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125555. private readonly _options;
  125556. private static _idCounter;
  125557. private _attachController;
  125558. private _controllers;
  125559. private _scene;
  125560. private _tmpVectorForPickCompare;
  125561. /**
  125562. * The module's name
  125563. */
  125564. static readonly Name: string;
  125565. /**
  125566. * The (Babylon) version of this module.
  125567. * This is an integer representing the implementation version.
  125568. * This number does not correspond to the WebXR specs version
  125569. */
  125570. static readonly Version: number;
  125571. /**
  125572. * Disable lighting on the laser pointer (so it will always be visible)
  125573. */
  125574. disablePointerLighting: boolean;
  125575. /**
  125576. * Disable lighting on the selection mesh (so it will always be visible)
  125577. */
  125578. disableSelectionMeshLighting: boolean;
  125579. /**
  125580. * Should the laser pointer be displayed
  125581. */
  125582. displayLaserPointer: boolean;
  125583. /**
  125584. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125585. */
  125586. displaySelectionMesh: boolean;
  125587. /**
  125588. * This color will be set to the laser pointer when selection is triggered
  125589. */
  125590. laserPointerPickedColor: Color3;
  125591. /**
  125592. * Default color of the laser pointer
  125593. */
  125594. laserPointerDefaultColor: Color3;
  125595. /**
  125596. * default color of the selection ring
  125597. */
  125598. selectionMeshDefaultColor: Color3;
  125599. /**
  125600. * This color will be applied to the selection ring when selection is triggered
  125601. */
  125602. selectionMeshPickedColor: Color3;
  125603. /**
  125604. * Optional filter to be used for ray selection. This predicate shares behavior with
  125605. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125606. */
  125607. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125608. /**
  125609. * constructs a new background remover module
  125610. * @param _xrSessionManager the session manager for this module
  125611. * @param _options read-only options to be used in this module
  125612. */
  125613. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125614. /**
  125615. * attach this feature
  125616. * Will usually be called by the features manager
  125617. *
  125618. * @returns true if successful.
  125619. */
  125620. attach(): boolean;
  125621. /**
  125622. * detach this feature.
  125623. * Will usually be called by the features manager
  125624. *
  125625. * @returns true if successful.
  125626. */
  125627. detach(): boolean;
  125628. /**
  125629. * Will get the mesh under a specific pointer.
  125630. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125631. * @param controllerId the controllerId to check
  125632. * @returns The mesh under pointer or null if no mesh is under the pointer
  125633. */
  125634. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125635. /**
  125636. * Get the xr controller that correlates to the pointer id in the pointer event
  125637. *
  125638. * @param id the pointer id to search for
  125639. * @returns the controller that correlates to this id or null if not found
  125640. */
  125641. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125642. protected _onXRFrame(_xrFrame: XRFrame): void;
  125643. private _attachGazeMode;
  125644. private _attachScreenRayMode;
  125645. private _attachTrackedPointerRayMode;
  125646. private _convertNormalToDirectionOfRay;
  125647. private _detachController;
  125648. private _generateNewMeshPair;
  125649. private _pickingMoved;
  125650. private _updatePointerDistance;
  125651. /** @hidden */
  125652. get lasterPointerDefaultColor(): Color3;
  125653. }
  125654. }
  125655. declare module BABYLON {
  125656. /**
  125657. * Button which can be used to enter a different mode of XR
  125658. */
  125659. export class WebXREnterExitUIButton {
  125660. /** button element */
  125661. element: HTMLElement;
  125662. /** XR initialization options for the button */
  125663. sessionMode: XRSessionMode;
  125664. /** Reference space type */
  125665. referenceSpaceType: XRReferenceSpaceType;
  125666. /**
  125667. * Creates a WebXREnterExitUIButton
  125668. * @param element button element
  125669. * @param sessionMode XR initialization session mode
  125670. * @param referenceSpaceType the type of reference space to be used
  125671. */
  125672. constructor(
  125673. /** button element */
  125674. element: HTMLElement,
  125675. /** XR initialization options for the button */
  125676. sessionMode: XRSessionMode,
  125677. /** Reference space type */
  125678. referenceSpaceType: XRReferenceSpaceType);
  125679. /**
  125680. * Extendable function which can be used to update the button's visuals when the state changes
  125681. * @param activeButton the current active button in the UI
  125682. */
  125683. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125684. }
  125685. /**
  125686. * Options to create the webXR UI
  125687. */
  125688. export class WebXREnterExitUIOptions {
  125689. /**
  125690. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125691. */
  125692. customButtons?: Array<WebXREnterExitUIButton>;
  125693. /**
  125694. * A reference space type to use when creating the default button.
  125695. * Default is local-floor
  125696. */
  125697. referenceSpaceType?: XRReferenceSpaceType;
  125698. /**
  125699. * Context to enter xr with
  125700. */
  125701. renderTarget?: Nullable<WebXRRenderTarget>;
  125702. /**
  125703. * A session mode to use when creating the default button.
  125704. * Default is immersive-vr
  125705. */
  125706. sessionMode?: XRSessionMode;
  125707. /**
  125708. * A list of optional features to init the session with
  125709. */
  125710. optionalFeatures?: string[];
  125711. }
  125712. /**
  125713. * UI to allow the user to enter/exit XR mode
  125714. */
  125715. export class WebXREnterExitUI implements IDisposable {
  125716. private scene;
  125717. /** version of the options passed to this UI */
  125718. options: WebXREnterExitUIOptions;
  125719. private _activeButton;
  125720. private _buttons;
  125721. private _overlay;
  125722. /**
  125723. * Fired every time the active button is changed.
  125724. *
  125725. * When xr is entered via a button that launches xr that button will be the callback parameter
  125726. *
  125727. * When exiting xr the callback parameter will be null)
  125728. */
  125729. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125730. /**
  125731. *
  125732. * @param scene babylon scene object to use
  125733. * @param options (read-only) version of the options passed to this UI
  125734. */
  125735. private constructor();
  125736. /**
  125737. * Creates UI to allow the user to enter/exit XR mode
  125738. * @param scene the scene to add the ui to
  125739. * @param helper the xr experience helper to enter/exit xr with
  125740. * @param options options to configure the UI
  125741. * @returns the created ui
  125742. */
  125743. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125744. /**
  125745. * Disposes of the XR UI component
  125746. */
  125747. dispose(): void;
  125748. private _updateButtons;
  125749. }
  125750. }
  125751. declare module BABYLON {
  125752. /**
  125753. * Class containing static functions to help procedurally build meshes
  125754. */
  125755. export class LinesBuilder {
  125756. /**
  125757. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125758. * * 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
  125759. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125760. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125761. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125762. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125763. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125764. * * 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
  125765. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125768. * @param name defines the name of the new line system
  125769. * @param options defines the options used to create the line system
  125770. * @param scene defines the hosting scene
  125771. * @returns a new line system mesh
  125772. */
  125773. static CreateLineSystem(name: string, options: {
  125774. lines: Vector3[][];
  125775. updatable?: boolean;
  125776. instance?: Nullable<LinesMesh>;
  125777. colors?: Nullable<Color4[][]>;
  125778. useVertexAlpha?: boolean;
  125779. }, scene: Nullable<Scene>): LinesMesh;
  125780. /**
  125781. * Creates a line mesh
  125782. * 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
  125783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125784. * * The parameter `points` is an array successive Vector3
  125785. * * 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
  125786. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125788. * * When updating an instance, remember that only point positions can change, not the number of points
  125789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125791. * @param name defines the name of the new line system
  125792. * @param options defines the options used to create the line system
  125793. * @param scene defines the hosting scene
  125794. * @returns a new line mesh
  125795. */
  125796. static CreateLines(name: string, options: {
  125797. points: Vector3[];
  125798. updatable?: boolean;
  125799. instance?: Nullable<LinesMesh>;
  125800. colors?: Color4[];
  125801. useVertexAlpha?: boolean;
  125802. }, scene?: Nullable<Scene>): LinesMesh;
  125803. /**
  125804. * Creates a dashed line mesh
  125805. * * 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
  125806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125807. * * The parameter `points` is an array successive Vector3
  125808. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125809. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125810. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125811. * * 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
  125812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125813. * * When updating an instance, remember that only point positions can change, not the number of points
  125814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125815. * @param name defines the name of the mesh
  125816. * @param options defines the options used to create the mesh
  125817. * @param scene defines the hosting scene
  125818. * @returns the dashed line mesh
  125819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125820. */
  125821. static CreateDashedLines(name: string, options: {
  125822. points: Vector3[];
  125823. dashSize?: number;
  125824. gapSize?: number;
  125825. dashNb?: number;
  125826. updatable?: boolean;
  125827. instance?: LinesMesh;
  125828. useVertexAlpha?: boolean;
  125829. }, scene?: Nullable<Scene>): LinesMesh;
  125830. }
  125831. }
  125832. declare module BABYLON {
  125833. /**
  125834. * Construction options for a timer
  125835. */
  125836. export interface ITimerOptions<T> {
  125837. /**
  125838. * Time-to-end
  125839. */
  125840. timeout: number;
  125841. /**
  125842. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  125843. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  125844. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  125845. */
  125846. contextObservable: Observable<T>;
  125847. /**
  125848. * Optional parameters when adding an observer to the observable
  125849. */
  125850. observableParameters?: {
  125851. mask?: number;
  125852. insertFirst?: boolean;
  125853. scope?: any;
  125854. };
  125855. /**
  125856. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  125857. */
  125858. breakCondition?: (data?: ITimerData<T>) => boolean;
  125859. /**
  125860. * Will be triggered when the time condition has met
  125861. */
  125862. onEnded?: (data: ITimerData<any>) => void;
  125863. /**
  125864. * Will be triggered when the break condition has met (prematurely ended)
  125865. */
  125866. onAborted?: (data: ITimerData<any>) => void;
  125867. /**
  125868. * Optional function to execute on each tick (or count)
  125869. */
  125870. onTick?: (data: ITimerData<any>) => void;
  125871. }
  125872. /**
  125873. * An interface defining the data sent by the timer
  125874. */
  125875. export interface ITimerData<T> {
  125876. /**
  125877. * When did it start
  125878. */
  125879. startTime: number;
  125880. /**
  125881. * Time now
  125882. */
  125883. currentTime: number;
  125884. /**
  125885. * Time passed since started
  125886. */
  125887. deltaTime: number;
  125888. /**
  125889. * How much is completed, in [0.0...1.0].
  125890. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  125891. */
  125892. completeRate: number;
  125893. /**
  125894. * What the registered observable sent in the last count
  125895. */
  125896. payload: T;
  125897. }
  125898. /**
  125899. * The current state of the timer
  125900. */
  125901. export enum TimerState {
  125902. /**
  125903. * Timer initialized, not yet started
  125904. */
  125905. INIT = 0,
  125906. /**
  125907. * Timer started and counting
  125908. */
  125909. STARTED = 1,
  125910. /**
  125911. * Timer ended (whether aborted or time reached)
  125912. */
  125913. ENDED = 2
  125914. }
  125915. /**
  125916. * A simple version of the timer. Will take options and start the timer immediately after calling it
  125917. *
  125918. * @param options options with which to initialize this timer
  125919. */
  125920. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  125921. /**
  125922. * An advanced implementation of a timer class
  125923. */
  125924. export class AdvancedTimer<T = any> implements IDisposable {
  125925. /**
  125926. * Will notify each time the timer calculates the remaining time
  125927. */
  125928. onEachCountObservable: Observable<ITimerData<T>>;
  125929. /**
  125930. * Will trigger when the timer was aborted due to the break condition
  125931. */
  125932. onTimerAbortedObservable: Observable<ITimerData<T>>;
  125933. /**
  125934. * Will trigger when the timer ended successfully
  125935. */
  125936. onTimerEndedObservable: Observable<ITimerData<T>>;
  125937. /**
  125938. * Will trigger when the timer state has changed
  125939. */
  125940. onStateChangedObservable: Observable<TimerState>;
  125941. private _observer;
  125942. private _contextObservable;
  125943. private _observableParameters;
  125944. private _startTime;
  125945. private _timer;
  125946. private _state;
  125947. private _breakCondition;
  125948. private _timeToEnd;
  125949. private _breakOnNextTick;
  125950. /**
  125951. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  125952. * @param options construction options for this advanced timer
  125953. */
  125954. constructor(options: ITimerOptions<T>);
  125955. /**
  125956. * set a breaking condition for this timer. Default is to never break during count
  125957. * @param predicate the new break condition. Returns true to break, false otherwise
  125958. */
  125959. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  125960. /**
  125961. * Reset ALL associated observables in this advanced timer
  125962. */
  125963. clearObservables(): void;
  125964. /**
  125965. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  125966. *
  125967. * @param timeToEnd how much time to measure until timer ended
  125968. */
  125969. start(timeToEnd?: number): void;
  125970. /**
  125971. * Will force a stop on the next tick.
  125972. */
  125973. stop(): void;
  125974. /**
  125975. * Dispose this timer, clearing all resources
  125976. */
  125977. dispose(): void;
  125978. private _setState;
  125979. private _tick;
  125980. private _stop;
  125981. }
  125982. }
  125983. declare module BABYLON {
  125984. /**
  125985. * The options container for the teleportation module
  125986. */
  125987. export interface IWebXRTeleportationOptions {
  125988. /**
  125989. * if provided, this scene will be used to render meshes.
  125990. */
  125991. customUtilityLayerScene?: Scene;
  125992. /**
  125993. * Values to configure the default target mesh
  125994. */
  125995. defaultTargetMeshOptions?: {
  125996. /**
  125997. * Fill color of the teleportation area
  125998. */
  125999. teleportationFillColor?: string;
  126000. /**
  126001. * Border color for the teleportation area
  126002. */
  126003. teleportationBorderColor?: string;
  126004. /**
  126005. * Disable the mesh's animation sequence
  126006. */
  126007. disableAnimation?: boolean;
  126008. /**
  126009. * Disable lighting on the material or the ring and arrow
  126010. */
  126011. disableLighting?: boolean;
  126012. /**
  126013. * Override the default material of the torus and arrow
  126014. */
  126015. torusArrowMaterial?: Material;
  126016. };
  126017. /**
  126018. * A list of meshes to use as floor meshes.
  126019. * Meshes can be added and removed after initializing the feature using the
  126020. * addFloorMesh and removeFloorMesh functions
  126021. * If empty, rotation will still work
  126022. */
  126023. floorMeshes?: AbstractMesh[];
  126024. /**
  126025. * use this rendering group id for the meshes (optional)
  126026. */
  126027. renderingGroupId?: number;
  126028. /**
  126029. * Should teleportation move only to snap points
  126030. */
  126031. snapPointsOnly?: boolean;
  126032. /**
  126033. * An array of points to which the teleportation will snap to.
  126034. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126035. */
  126036. snapPositions?: Vector3[];
  126037. /**
  126038. * How close should the teleportation ray be in order to snap to position.
  126039. * Default to 0.8 units (meters)
  126040. */
  126041. snapToPositionRadius?: number;
  126042. /**
  126043. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126044. * If you want to support rotation, make sure your mesh has a direction indicator.
  126045. *
  126046. * When left untouched, the default mesh will be initialized.
  126047. */
  126048. teleportationTargetMesh?: AbstractMesh;
  126049. /**
  126050. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126051. */
  126052. timeToTeleport?: number;
  126053. /**
  126054. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126055. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126056. */
  126057. useMainComponentOnly?: boolean;
  126058. /**
  126059. * Should meshes created here be added to a utility layer or the main scene
  126060. */
  126061. useUtilityLayer?: boolean;
  126062. /**
  126063. * Babylon XR Input class for controller
  126064. */
  126065. xrInput: WebXRInput;
  126066. }
  126067. /**
  126068. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126069. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126070. * the input of the attached controllers.
  126071. */
  126072. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126073. private _options;
  126074. private _controllers;
  126075. private _currentTeleportationControllerId;
  126076. private _floorMeshes;
  126077. private _quadraticBezierCurve;
  126078. private _selectionFeature;
  126079. private _snapToPositions;
  126080. private _snappedToPoint;
  126081. private _teleportationRingMaterial?;
  126082. private _tmpRay;
  126083. private _tmpVector;
  126084. /**
  126085. * The module's name
  126086. */
  126087. static readonly Name: string;
  126088. /**
  126089. * The (Babylon) version of this module.
  126090. * This is an integer representing the implementation version.
  126091. * This number does not correspond to the webxr specs version
  126092. */
  126093. static readonly Version: number;
  126094. /**
  126095. * Is movement backwards enabled
  126096. */
  126097. backwardsMovementEnabled: boolean;
  126098. /**
  126099. * Distance to travel when moving backwards
  126100. */
  126101. backwardsTeleportationDistance: number;
  126102. /**
  126103. * The distance from the user to the inspection point in the direction of the controller
  126104. * A higher number will allow the user to move further
  126105. * defaults to 5 (meters, in xr units)
  126106. */
  126107. parabolicCheckRadius: number;
  126108. /**
  126109. * Should the module support parabolic ray on top of direct ray
  126110. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126111. * Very helpful when moving between floors / different heights
  126112. */
  126113. parabolicRayEnabled: boolean;
  126114. /**
  126115. * How much rotation should be applied when rotating right and left
  126116. */
  126117. rotationAngle: number;
  126118. /**
  126119. * Is rotation enabled when moving forward?
  126120. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126121. */
  126122. rotationEnabled: boolean;
  126123. /**
  126124. * constructs a new anchor system
  126125. * @param _xrSessionManager an instance of WebXRSessionManager
  126126. * @param _options configuration object for this feature
  126127. */
  126128. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126129. /**
  126130. * Get the snapPointsOnly flag
  126131. */
  126132. get snapPointsOnly(): boolean;
  126133. /**
  126134. * Sets the snapPointsOnly flag
  126135. * @param snapToPoints should teleportation be exclusively to snap points
  126136. */
  126137. set snapPointsOnly(snapToPoints: boolean);
  126138. /**
  126139. * Add a new mesh to the floor meshes array
  126140. * @param mesh the mesh to use as floor mesh
  126141. */
  126142. addFloorMesh(mesh: AbstractMesh): void;
  126143. /**
  126144. * Add a new snap-to point to fix teleportation to this position
  126145. * @param newSnapPoint The new Snap-To point
  126146. */
  126147. addSnapPoint(newSnapPoint: Vector3): void;
  126148. attach(): boolean;
  126149. detach(): boolean;
  126150. dispose(): void;
  126151. /**
  126152. * Remove a mesh from the floor meshes array
  126153. * @param mesh the mesh to remove
  126154. */
  126155. removeFloorMesh(mesh: AbstractMesh): void;
  126156. /**
  126157. * Remove a mesh from the floor meshes array using its name
  126158. * @param name the mesh name to remove
  126159. */
  126160. removeFloorMeshByName(name: string): void;
  126161. /**
  126162. * 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
  126163. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126164. * @returns was the point found and removed or not
  126165. */
  126166. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126167. /**
  126168. * This function sets a selection feature that will be disabled when
  126169. * the forward ray is shown and will be reattached when hidden.
  126170. * This is used to remove the selection rays when moving.
  126171. * @param selectionFeature the feature to disable when forward movement is enabled
  126172. */
  126173. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126174. protected _onXRFrame(_xrFrame: XRFrame): void;
  126175. private _attachController;
  126176. private _createDefaultTargetMesh;
  126177. private _detachController;
  126178. private _findClosestSnapPointWithRadius;
  126179. private _setTargetMeshPosition;
  126180. private _setTargetMeshVisibility;
  126181. private _showParabolicPath;
  126182. private _teleportForward;
  126183. }
  126184. }
  126185. declare module BABYLON {
  126186. /**
  126187. * Options for the default xr helper
  126188. */
  126189. export class WebXRDefaultExperienceOptions {
  126190. /**
  126191. * Enable or disable default UI to enter XR
  126192. */
  126193. disableDefaultUI?: boolean;
  126194. /**
  126195. * Should teleportation not initialize. defaults to false.
  126196. */
  126197. disableTeleportation?: boolean;
  126198. /**
  126199. * Floor meshes that will be used for teleport
  126200. */
  126201. floorMeshes?: Array<AbstractMesh>;
  126202. /**
  126203. * If set to true, the first frame will not be used to reset position
  126204. * The first frame is mainly used when copying transformation from the old camera
  126205. * Mainly used in AR
  126206. */
  126207. ignoreNativeCameraTransformation?: boolean;
  126208. /**
  126209. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126210. */
  126211. inputOptions?: IWebXRInputOptions;
  126212. /**
  126213. * optional configuration for the output canvas
  126214. */
  126215. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126216. /**
  126217. * optional UI options. This can be used among other to change session mode and reference space type
  126218. */
  126219. uiOptions?: WebXREnterExitUIOptions;
  126220. /**
  126221. * When loading teleportation and pointer select, use stable versions instead of latest.
  126222. */
  126223. useStablePlugins?: boolean;
  126224. /**
  126225. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126226. */
  126227. renderingGroupId?: number;
  126228. /**
  126229. * A list of optional features to init the session with
  126230. * If set to true, all features we support will be added
  126231. */
  126232. optionalFeatures?: boolean | string[];
  126233. }
  126234. /**
  126235. * Default experience which provides a similar setup to the previous webVRExperience
  126236. */
  126237. export class WebXRDefaultExperience {
  126238. /**
  126239. * Base experience
  126240. */
  126241. baseExperience: WebXRExperienceHelper;
  126242. /**
  126243. * Enables ui for entering/exiting xr
  126244. */
  126245. enterExitUI: WebXREnterExitUI;
  126246. /**
  126247. * Input experience extension
  126248. */
  126249. input: WebXRInput;
  126250. /**
  126251. * Enables laser pointer and selection
  126252. */
  126253. pointerSelection: WebXRControllerPointerSelection;
  126254. /**
  126255. * Default target xr should render to
  126256. */
  126257. renderTarget: WebXRRenderTarget;
  126258. /**
  126259. * Enables teleportation
  126260. */
  126261. teleportation: WebXRMotionControllerTeleportation;
  126262. private constructor();
  126263. /**
  126264. * Creates the default xr experience
  126265. * @param scene scene
  126266. * @param options options for basic configuration
  126267. * @returns resulting WebXRDefaultExperience
  126268. */
  126269. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126270. /**
  126271. * DIsposes of the experience helper
  126272. */
  126273. dispose(): void;
  126274. }
  126275. }
  126276. declare module BABYLON {
  126277. /**
  126278. * Options to modify the vr teleportation behavior.
  126279. */
  126280. export interface VRTeleportationOptions {
  126281. /**
  126282. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126283. */
  126284. floorMeshName?: string;
  126285. /**
  126286. * A list of meshes to be used as the teleportation floor. (default: empty)
  126287. */
  126288. floorMeshes?: Mesh[];
  126289. /**
  126290. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126291. */
  126292. teleportationMode?: number;
  126293. /**
  126294. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126295. */
  126296. teleportationTime?: number;
  126297. /**
  126298. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126299. */
  126300. teleportationSpeed?: number;
  126301. /**
  126302. * The easing function used in the animation or null for Linear. (default CircleEase)
  126303. */
  126304. easingFunction?: EasingFunction;
  126305. }
  126306. /**
  126307. * Options to modify the vr experience helper's behavior.
  126308. */
  126309. export interface VRExperienceHelperOptions extends WebVROptions {
  126310. /**
  126311. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126312. */
  126313. createDeviceOrientationCamera?: boolean;
  126314. /**
  126315. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126316. */
  126317. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126318. /**
  126319. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126320. */
  126321. laserToggle?: boolean;
  126322. /**
  126323. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126324. */
  126325. floorMeshes?: Mesh[];
  126326. /**
  126327. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126328. */
  126329. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126330. /**
  126331. * Defines if WebXR should be used instead of WebVR (if available)
  126332. */
  126333. useXR?: boolean;
  126334. }
  126335. /**
  126336. * Event containing information after VR has been entered
  126337. */
  126338. export class OnAfterEnteringVRObservableEvent {
  126339. /**
  126340. * If entering vr was successful
  126341. */
  126342. success: boolean;
  126343. }
  126344. /**
  126345. * Helps to quickly add VR support to an existing scene.
  126346. * See http://doc.babylonjs.com/how_to/webvr_helper
  126347. */
  126348. export class VRExperienceHelper {
  126349. /** Options to modify the vr experience helper's behavior. */
  126350. webVROptions: VRExperienceHelperOptions;
  126351. private _scene;
  126352. private _position;
  126353. private _btnVR;
  126354. private _btnVRDisplayed;
  126355. private _webVRsupported;
  126356. private _webVRready;
  126357. private _webVRrequesting;
  126358. private _webVRpresenting;
  126359. private _hasEnteredVR;
  126360. private _fullscreenVRpresenting;
  126361. private _inputElement;
  126362. private _webVRCamera;
  126363. private _vrDeviceOrientationCamera;
  126364. private _deviceOrientationCamera;
  126365. private _existingCamera;
  126366. private _onKeyDown;
  126367. private _onVrDisplayPresentChange;
  126368. private _onVRDisplayChanged;
  126369. private _onVRRequestPresentStart;
  126370. private _onVRRequestPresentComplete;
  126371. /**
  126372. * 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)
  126373. */
  126374. enableGazeEvenWhenNoPointerLock: boolean;
  126375. /**
  126376. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126377. */
  126378. exitVROnDoubleTap: boolean;
  126379. /**
  126380. * Observable raised right before entering VR.
  126381. */
  126382. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126383. /**
  126384. * Observable raised when entering VR has completed.
  126385. */
  126386. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126387. /**
  126388. * Observable raised when exiting VR.
  126389. */
  126390. onExitingVRObservable: Observable<VRExperienceHelper>;
  126391. /**
  126392. * Observable raised when controller mesh is loaded.
  126393. */
  126394. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126395. /** Return this.onEnteringVRObservable
  126396. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126397. */
  126398. get onEnteringVR(): Observable<VRExperienceHelper>;
  126399. /** Return this.onExitingVRObservable
  126400. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126401. */
  126402. get onExitingVR(): Observable<VRExperienceHelper>;
  126403. /** Return this.onControllerMeshLoadedObservable
  126404. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126405. */
  126406. get onControllerMeshLoaded(): Observable<WebVRController>;
  126407. private _rayLength;
  126408. private _useCustomVRButton;
  126409. private _teleportationRequested;
  126410. private _teleportActive;
  126411. private _floorMeshName;
  126412. private _floorMeshesCollection;
  126413. private _teleportationMode;
  126414. private _teleportationTime;
  126415. private _teleportationSpeed;
  126416. private _teleportationEasing;
  126417. private _rotationAllowed;
  126418. private _teleportBackwardsVector;
  126419. private _teleportationTarget;
  126420. private _isDefaultTeleportationTarget;
  126421. private _postProcessMove;
  126422. private _teleportationFillColor;
  126423. private _teleportationBorderColor;
  126424. private _rotationAngle;
  126425. private _haloCenter;
  126426. private _cameraGazer;
  126427. private _padSensibilityUp;
  126428. private _padSensibilityDown;
  126429. private _leftController;
  126430. private _rightController;
  126431. private _gazeColor;
  126432. private _laserColor;
  126433. private _pickedLaserColor;
  126434. private _pickedGazeColor;
  126435. /**
  126436. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126437. */
  126438. onNewMeshSelected: Observable<AbstractMesh>;
  126439. /**
  126440. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126441. * This observable will provide the mesh and the controller used to select the mesh
  126442. */
  126443. onMeshSelectedWithController: Observable<{
  126444. mesh: AbstractMesh;
  126445. controller: WebVRController;
  126446. }>;
  126447. /**
  126448. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126449. */
  126450. onNewMeshPicked: Observable<PickingInfo>;
  126451. private _circleEase;
  126452. /**
  126453. * Observable raised before camera teleportation
  126454. */
  126455. onBeforeCameraTeleport: Observable<Vector3>;
  126456. /**
  126457. * Observable raised after camera teleportation
  126458. */
  126459. onAfterCameraTeleport: Observable<Vector3>;
  126460. /**
  126461. * Observable raised when current selected mesh gets unselected
  126462. */
  126463. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126464. private _raySelectionPredicate;
  126465. /**
  126466. * To be optionaly changed by user to define custom ray selection
  126467. */
  126468. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126469. /**
  126470. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126471. */
  126472. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126473. /**
  126474. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126475. */
  126476. teleportationEnabled: boolean;
  126477. private _defaultHeight;
  126478. private _teleportationInitialized;
  126479. private _interactionsEnabled;
  126480. private _interactionsRequested;
  126481. private _displayGaze;
  126482. private _displayLaserPointer;
  126483. /**
  126484. * The mesh used to display where the user is going to teleport.
  126485. */
  126486. get teleportationTarget(): Mesh;
  126487. /**
  126488. * Sets the mesh to be used to display where the user is going to teleport.
  126489. */
  126490. set teleportationTarget(value: Mesh);
  126491. /**
  126492. * 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
  126493. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126494. * See http://doc.babylonjs.com/resources/baking_transformations
  126495. */
  126496. get gazeTrackerMesh(): Mesh;
  126497. set gazeTrackerMesh(value: Mesh);
  126498. /**
  126499. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126500. */
  126501. updateGazeTrackerScale: boolean;
  126502. /**
  126503. * If the gaze trackers color should be updated when selecting meshes
  126504. */
  126505. updateGazeTrackerColor: boolean;
  126506. /**
  126507. * If the controller laser color should be updated when selecting meshes
  126508. */
  126509. updateControllerLaserColor: boolean;
  126510. /**
  126511. * The gaze tracking mesh corresponding to the left controller
  126512. */
  126513. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126514. /**
  126515. * The gaze tracking mesh corresponding to the right controller
  126516. */
  126517. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126518. /**
  126519. * If the ray of the gaze should be displayed.
  126520. */
  126521. get displayGaze(): boolean;
  126522. /**
  126523. * Sets if the ray of the gaze should be displayed.
  126524. */
  126525. set displayGaze(value: boolean);
  126526. /**
  126527. * If the ray of the LaserPointer should be displayed.
  126528. */
  126529. get displayLaserPointer(): boolean;
  126530. /**
  126531. * Sets if the ray of the LaserPointer should be displayed.
  126532. */
  126533. set displayLaserPointer(value: boolean);
  126534. /**
  126535. * The deviceOrientationCamera used as the camera when not in VR.
  126536. */
  126537. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126538. /**
  126539. * Based on the current WebVR support, returns the current VR camera used.
  126540. */
  126541. get currentVRCamera(): Nullable<Camera>;
  126542. /**
  126543. * The webVRCamera which is used when in VR.
  126544. */
  126545. get webVRCamera(): WebVRFreeCamera;
  126546. /**
  126547. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126548. */
  126549. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126550. /**
  126551. * The html button that is used to trigger entering into VR.
  126552. */
  126553. get vrButton(): Nullable<HTMLButtonElement>;
  126554. private get _teleportationRequestInitiated();
  126555. /**
  126556. * Defines whether or not Pointer lock should be requested when switching to
  126557. * full screen.
  126558. */
  126559. requestPointerLockOnFullScreen: boolean;
  126560. /**
  126561. * If asking to force XR, this will be populated with the default xr experience
  126562. */
  126563. xr: WebXRDefaultExperience;
  126564. /**
  126565. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126566. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126567. */
  126568. xrTestDone: boolean;
  126569. /**
  126570. * Instantiates a VRExperienceHelper.
  126571. * Helps to quickly add VR support to an existing scene.
  126572. * @param scene The scene the VRExperienceHelper belongs to.
  126573. * @param webVROptions Options to modify the vr experience helper's behavior.
  126574. */
  126575. constructor(scene: Scene,
  126576. /** Options to modify the vr experience helper's behavior. */
  126577. webVROptions?: VRExperienceHelperOptions);
  126578. private completeVRInit;
  126579. private _onDefaultMeshLoaded;
  126580. private _onResize;
  126581. private _onFullscreenChange;
  126582. /**
  126583. * Gets a value indicating if we are currently in VR mode.
  126584. */
  126585. get isInVRMode(): boolean;
  126586. private onVrDisplayPresentChange;
  126587. private onVRDisplayChanged;
  126588. private moveButtonToBottomRight;
  126589. private displayVRButton;
  126590. private updateButtonVisibility;
  126591. private _cachedAngularSensibility;
  126592. /**
  126593. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126594. * Otherwise, will use the fullscreen API.
  126595. */
  126596. enterVR(): void;
  126597. /**
  126598. * Attempt to exit VR, or fullscreen.
  126599. */
  126600. exitVR(): void;
  126601. /**
  126602. * The position of the vr experience helper.
  126603. */
  126604. get position(): Vector3;
  126605. /**
  126606. * Sets the position of the vr experience helper.
  126607. */
  126608. set position(value: Vector3);
  126609. /**
  126610. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126611. */
  126612. enableInteractions(): void;
  126613. private get _noControllerIsActive();
  126614. private beforeRender;
  126615. private _isTeleportationFloor;
  126616. /**
  126617. * Adds a floor mesh to be used for teleportation.
  126618. * @param floorMesh the mesh to be used for teleportation.
  126619. */
  126620. addFloorMesh(floorMesh: Mesh): void;
  126621. /**
  126622. * Removes a floor mesh from being used for teleportation.
  126623. * @param floorMesh the mesh to be removed.
  126624. */
  126625. removeFloorMesh(floorMesh: Mesh): void;
  126626. /**
  126627. * Enables interactions and teleportation using the VR controllers and gaze.
  126628. * @param vrTeleportationOptions options to modify teleportation behavior.
  126629. */
  126630. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126631. private _onNewGamepadConnected;
  126632. private _tryEnableInteractionOnController;
  126633. private _onNewGamepadDisconnected;
  126634. private _enableInteractionOnController;
  126635. private _checkTeleportWithRay;
  126636. private _checkRotate;
  126637. private _checkTeleportBackwards;
  126638. private _enableTeleportationOnController;
  126639. private _createTeleportationCircles;
  126640. private _displayTeleportationTarget;
  126641. private _hideTeleportationTarget;
  126642. private _rotateCamera;
  126643. private _moveTeleportationSelectorTo;
  126644. private _workingVector;
  126645. private _workingQuaternion;
  126646. private _workingMatrix;
  126647. /**
  126648. * Time Constant Teleportation Mode
  126649. */
  126650. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126651. /**
  126652. * Speed Constant Teleportation Mode
  126653. */
  126654. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126655. /**
  126656. * Teleports the users feet to the desired location
  126657. * @param location The location where the user's feet should be placed
  126658. */
  126659. teleportCamera(location: Vector3): void;
  126660. private _convertNormalToDirectionOfRay;
  126661. private _castRayAndSelectObject;
  126662. private _notifySelectedMeshUnselected;
  126663. /**
  126664. * Permanently set new colors for the laser pointer
  126665. * @param color the new laser color
  126666. * @param pickedColor the new laser color when picked mesh detected
  126667. */
  126668. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126669. /**
  126670. * Set lighting enabled / disabled on the laser pointer of both controllers
  126671. * @param enabled should the lighting be enabled on the laser pointer
  126672. */
  126673. setLaserLightingState(enabled?: boolean): void;
  126674. /**
  126675. * Permanently set new colors for the gaze pointer
  126676. * @param color the new gaze color
  126677. * @param pickedColor the new gaze color when picked mesh detected
  126678. */
  126679. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126680. /**
  126681. * Sets the color of the laser ray from the vr controllers.
  126682. * @param color new color for the ray.
  126683. */
  126684. changeLaserColor(color: Color3): void;
  126685. /**
  126686. * Sets the color of the ray from the vr headsets gaze.
  126687. * @param color new color for the ray.
  126688. */
  126689. changeGazeColor(color: Color3): void;
  126690. /**
  126691. * Exits VR and disposes of the vr experience helper
  126692. */
  126693. dispose(): void;
  126694. /**
  126695. * Gets the name of the VRExperienceHelper class
  126696. * @returns "VRExperienceHelper"
  126697. */
  126698. getClassName(): string;
  126699. }
  126700. }
  126701. declare module BABYLON {
  126702. /**
  126703. * Contains an array of blocks representing the octree
  126704. */
  126705. export interface IOctreeContainer<T> {
  126706. /**
  126707. * Blocks within the octree
  126708. */
  126709. blocks: Array<OctreeBlock<T>>;
  126710. }
  126711. /**
  126712. * Class used to store a cell in an octree
  126713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126714. */
  126715. export class OctreeBlock<T> {
  126716. /**
  126717. * Gets the content of the current block
  126718. */
  126719. entries: T[];
  126720. /**
  126721. * Gets the list of block children
  126722. */
  126723. blocks: Array<OctreeBlock<T>>;
  126724. private _depth;
  126725. private _maxDepth;
  126726. private _capacity;
  126727. private _minPoint;
  126728. private _maxPoint;
  126729. private _boundingVectors;
  126730. private _creationFunc;
  126731. /**
  126732. * Creates a new block
  126733. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126734. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126735. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126736. * @param depth defines the current depth of this block in the octree
  126737. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126738. * @param creationFunc defines a callback to call when an element is added to the block
  126739. */
  126740. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126741. /**
  126742. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126743. */
  126744. get capacity(): number;
  126745. /**
  126746. * Gets the minimum vector (in world space) of the block's bounding box
  126747. */
  126748. get minPoint(): Vector3;
  126749. /**
  126750. * Gets the maximum vector (in world space) of the block's bounding box
  126751. */
  126752. get maxPoint(): Vector3;
  126753. /**
  126754. * Add a new element to this block
  126755. * @param entry defines the element to add
  126756. */
  126757. addEntry(entry: T): void;
  126758. /**
  126759. * Remove an element from this block
  126760. * @param entry defines the element to remove
  126761. */
  126762. removeEntry(entry: T): void;
  126763. /**
  126764. * Add an array of elements to this block
  126765. * @param entries defines the array of elements to add
  126766. */
  126767. addEntries(entries: T[]): void;
  126768. /**
  126769. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  126770. * @param frustumPlanes defines the frustum planes to test
  126771. * @param selection defines the array to store current content if selection is positive
  126772. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126773. */
  126774. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126775. /**
  126776. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  126777. * @param sphereCenter defines the bounding sphere center
  126778. * @param sphereRadius defines the bounding sphere radius
  126779. * @param selection defines the array to store current content if selection is positive
  126780. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126781. */
  126782. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126783. /**
  126784. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  126785. * @param ray defines the ray to test with
  126786. * @param selection defines the array to store current content if selection is positive
  126787. */
  126788. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  126789. /**
  126790. * Subdivide the content into child blocks (this block will then be empty)
  126791. */
  126792. createInnerBlocks(): void;
  126793. /**
  126794. * @hidden
  126795. */
  126796. 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;
  126797. }
  126798. }
  126799. declare module BABYLON {
  126800. /**
  126801. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  126802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126803. */
  126804. export class Octree<T> {
  126805. /** 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.) */
  126806. maxDepth: number;
  126807. /**
  126808. * Blocks within the octree containing objects
  126809. */
  126810. blocks: Array<OctreeBlock<T>>;
  126811. /**
  126812. * Content stored in the octree
  126813. */
  126814. dynamicContent: T[];
  126815. private _maxBlockCapacity;
  126816. private _selectionContent;
  126817. private _creationFunc;
  126818. /**
  126819. * Creates a octree
  126820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126821. * @param creationFunc function to be used to instatiate the octree
  126822. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126823. * @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.)
  126824. */
  126825. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126826. /** 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.) */
  126827. maxDepth?: number);
  126828. /**
  126829. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126830. * @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);
  126831. * @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);
  126832. * @param entries meshes to be added to the octree blocks
  126833. */
  126834. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126835. /**
  126836. * Adds a mesh to the octree
  126837. * @param entry Mesh to add to the octree
  126838. */
  126839. addMesh(entry: T): void;
  126840. /**
  126841. * Remove an element from the octree
  126842. * @param entry defines the element to remove
  126843. */
  126844. removeMesh(entry: T): void;
  126845. /**
  126846. * Selects an array of meshes within the frustum
  126847. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126848. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126849. * @returns array of meshes within the frustum
  126850. */
  126851. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126852. /**
  126853. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126854. * @param sphereCenter defines the bounding sphere center
  126855. * @param sphereRadius defines the bounding sphere radius
  126856. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126857. * @returns an array of objects that intersect the sphere
  126858. */
  126859. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126860. /**
  126861. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126862. * @param ray defines the ray to test with
  126863. * @returns array of intersected objects
  126864. */
  126865. intersectsRay(ray: Ray): SmartArray<T>;
  126866. /**
  126867. * Adds a mesh into the octree block if it intersects the block
  126868. */
  126869. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126870. /**
  126871. * Adds a submesh into the octree block if it intersects the block
  126872. */
  126873. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126874. }
  126875. }
  126876. declare module BABYLON {
  126877. interface Scene {
  126878. /**
  126879. * @hidden
  126880. * Backing Filed
  126881. */
  126882. _selectionOctree: Octree<AbstractMesh>;
  126883. /**
  126884. * Gets the octree used to boost mesh selection (picking)
  126885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126886. */
  126887. selectionOctree: Octree<AbstractMesh>;
  126888. /**
  126889. * Creates or updates the octree used to boost selection (picking)
  126890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126891. * @param maxCapacity defines the maximum capacity per leaf
  126892. * @param maxDepth defines the maximum depth of the octree
  126893. * @returns an octree of AbstractMesh
  126894. */
  126895. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126896. }
  126897. interface AbstractMesh {
  126898. /**
  126899. * @hidden
  126900. * Backing Field
  126901. */
  126902. _submeshesOctree: Octree<SubMesh>;
  126903. /**
  126904. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126905. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126906. * @param maxCapacity defines the maximum size of each block (64 by default)
  126907. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126908. * @returns the new octree
  126909. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126911. */
  126912. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126913. }
  126914. /**
  126915. * Defines the octree scene component responsible to manage any octrees
  126916. * in a given scene.
  126917. */
  126918. export class OctreeSceneComponent {
  126919. /**
  126920. * The component name help to identify the component in the list of scene components.
  126921. */
  126922. readonly name: string;
  126923. /**
  126924. * The scene the component belongs to.
  126925. */
  126926. scene: Scene;
  126927. /**
  126928. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126929. */
  126930. readonly checksIsEnabled: boolean;
  126931. /**
  126932. * Creates a new instance of the component for the given scene
  126933. * @param scene Defines the scene to register the component in
  126934. */
  126935. constructor(scene: Scene);
  126936. /**
  126937. * Registers the component in a given scene
  126938. */
  126939. register(): void;
  126940. /**
  126941. * Return the list of active meshes
  126942. * @returns the list of active meshes
  126943. */
  126944. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126945. /**
  126946. * Return the list of active sub meshes
  126947. * @param mesh The mesh to get the candidates sub meshes from
  126948. * @returns the list of active sub meshes
  126949. */
  126950. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126951. private _tempRay;
  126952. /**
  126953. * Return the list of sub meshes intersecting with a given local ray
  126954. * @param mesh defines the mesh to find the submesh for
  126955. * @param localRay defines the ray in local space
  126956. * @returns the list of intersecting sub meshes
  126957. */
  126958. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126959. /**
  126960. * Return the list of sub meshes colliding with a collider
  126961. * @param mesh defines the mesh to find the submesh for
  126962. * @param collider defines the collider to evaluate the collision against
  126963. * @returns the list of colliding sub meshes
  126964. */
  126965. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126966. /**
  126967. * Rebuilds the elements related to this component in case of
  126968. * context lost for instance.
  126969. */
  126970. rebuild(): void;
  126971. /**
  126972. * Disposes the component and the associated ressources.
  126973. */
  126974. dispose(): void;
  126975. }
  126976. }
  126977. declare module BABYLON {
  126978. /**
  126979. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126980. */
  126981. export class Gizmo implements IDisposable {
  126982. /** The utility layer the gizmo will be added to */
  126983. gizmoLayer: UtilityLayerRenderer;
  126984. /**
  126985. * The root mesh of the gizmo
  126986. */
  126987. _rootMesh: Mesh;
  126988. private _attachedMesh;
  126989. /**
  126990. * Ratio for the scale of the gizmo (Default: 1)
  126991. */
  126992. scaleRatio: number;
  126993. /**
  126994. * If a custom mesh has been set (Default: false)
  126995. */
  126996. protected _customMeshSet: boolean;
  126997. /**
  126998. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126999. * * When set, interactions will be enabled
  127000. */
  127001. get attachedMesh(): Nullable<AbstractMesh>;
  127002. set attachedMesh(value: Nullable<AbstractMesh>);
  127003. /**
  127004. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127005. * @param mesh The mesh to replace the default mesh of the gizmo
  127006. */
  127007. setCustomMesh(mesh: Mesh): void;
  127008. /**
  127009. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127010. */
  127011. updateGizmoRotationToMatchAttachedMesh: boolean;
  127012. /**
  127013. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127014. */
  127015. updateGizmoPositionToMatchAttachedMesh: boolean;
  127016. /**
  127017. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127018. */
  127019. updateScale: boolean;
  127020. protected _interactionsEnabled: boolean;
  127021. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127022. private _beforeRenderObserver;
  127023. private _tempVector;
  127024. /**
  127025. * Creates a gizmo
  127026. * @param gizmoLayer The utility layer the gizmo will be added to
  127027. */
  127028. constructor(
  127029. /** The utility layer the gizmo will be added to */
  127030. gizmoLayer?: UtilityLayerRenderer);
  127031. /**
  127032. * Updates the gizmo to match the attached mesh's position/rotation
  127033. */
  127034. protected _update(): void;
  127035. /**
  127036. * Disposes of the gizmo
  127037. */
  127038. dispose(): void;
  127039. }
  127040. }
  127041. declare module BABYLON {
  127042. /**
  127043. * Single plane drag gizmo
  127044. */
  127045. export class PlaneDragGizmo extends Gizmo {
  127046. /**
  127047. * Drag behavior responsible for the gizmos dragging interactions
  127048. */
  127049. dragBehavior: PointerDragBehavior;
  127050. private _pointerObserver;
  127051. /**
  127052. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127053. */
  127054. snapDistance: number;
  127055. /**
  127056. * Event that fires each time the gizmo snaps to a new location.
  127057. * * snapDistance is the the change in distance
  127058. */
  127059. onSnapObservable: Observable<{
  127060. snapDistance: number;
  127061. }>;
  127062. private _plane;
  127063. private _coloredMaterial;
  127064. private _hoverMaterial;
  127065. private _isEnabled;
  127066. private _parent;
  127067. /** @hidden */
  127068. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127069. /** @hidden */
  127070. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127071. /**
  127072. * Creates a PlaneDragGizmo
  127073. * @param gizmoLayer The utility layer the gizmo will be added to
  127074. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127075. * @param color The color of the gizmo
  127076. */
  127077. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127078. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127079. /**
  127080. * If the gizmo is enabled
  127081. */
  127082. set isEnabled(value: boolean);
  127083. get isEnabled(): boolean;
  127084. /**
  127085. * Disposes of the gizmo
  127086. */
  127087. dispose(): void;
  127088. }
  127089. }
  127090. declare module BABYLON {
  127091. /**
  127092. * Gizmo that enables dragging a mesh along 3 axis
  127093. */
  127094. export class PositionGizmo extends Gizmo {
  127095. /**
  127096. * Internal gizmo used for interactions on the x axis
  127097. */
  127098. xGizmo: AxisDragGizmo;
  127099. /**
  127100. * Internal gizmo used for interactions on the y axis
  127101. */
  127102. yGizmo: AxisDragGizmo;
  127103. /**
  127104. * Internal gizmo used for interactions on the z axis
  127105. */
  127106. zGizmo: AxisDragGizmo;
  127107. /**
  127108. * Internal gizmo used for interactions on the yz plane
  127109. */
  127110. xPlaneGizmo: PlaneDragGizmo;
  127111. /**
  127112. * Internal gizmo used for interactions on the xz plane
  127113. */
  127114. yPlaneGizmo: PlaneDragGizmo;
  127115. /**
  127116. * Internal gizmo used for interactions on the xy plane
  127117. */
  127118. zPlaneGizmo: PlaneDragGizmo;
  127119. /**
  127120. * private variables
  127121. */
  127122. private _meshAttached;
  127123. private _updateGizmoRotationToMatchAttachedMesh;
  127124. private _snapDistance;
  127125. private _scaleRatio;
  127126. /** Fires an event when any of it's sub gizmos are dragged */
  127127. onDragStartObservable: Observable<unknown>;
  127128. /** Fires an event when any of it's sub gizmos are released from dragging */
  127129. onDragEndObservable: Observable<unknown>;
  127130. /**
  127131. * If set to true, planar drag is enabled
  127132. */
  127133. private _planarGizmoEnabled;
  127134. get attachedMesh(): Nullable<AbstractMesh>;
  127135. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127136. /**
  127137. * Creates a PositionGizmo
  127138. * @param gizmoLayer The utility layer the gizmo will be added to
  127139. */
  127140. constructor(gizmoLayer?: UtilityLayerRenderer);
  127141. /**
  127142. * If the planar drag gizmo is enabled
  127143. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127144. */
  127145. set planarGizmoEnabled(value: boolean);
  127146. get planarGizmoEnabled(): boolean;
  127147. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127148. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127149. /**
  127150. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127151. */
  127152. set snapDistance(value: number);
  127153. get snapDistance(): number;
  127154. /**
  127155. * Ratio for the scale of the gizmo (Default: 1)
  127156. */
  127157. set scaleRatio(value: number);
  127158. get scaleRatio(): number;
  127159. /**
  127160. * Disposes of the gizmo
  127161. */
  127162. dispose(): void;
  127163. /**
  127164. * CustomMeshes are not supported by this gizmo
  127165. * @param mesh The mesh to replace the default mesh of the gizmo
  127166. */
  127167. setCustomMesh(mesh: Mesh): void;
  127168. }
  127169. }
  127170. declare module BABYLON {
  127171. /**
  127172. * Single axis drag gizmo
  127173. */
  127174. export class AxisDragGizmo extends Gizmo {
  127175. /**
  127176. * Drag behavior responsible for the gizmos dragging interactions
  127177. */
  127178. dragBehavior: PointerDragBehavior;
  127179. private _pointerObserver;
  127180. /**
  127181. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127182. */
  127183. snapDistance: number;
  127184. /**
  127185. * Event that fires each time the gizmo snaps to a new location.
  127186. * * snapDistance is the the change in distance
  127187. */
  127188. onSnapObservable: Observable<{
  127189. snapDistance: number;
  127190. }>;
  127191. private _isEnabled;
  127192. private _parent;
  127193. private _arrow;
  127194. private _coloredMaterial;
  127195. private _hoverMaterial;
  127196. /** @hidden */
  127197. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127198. /** @hidden */
  127199. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127200. /**
  127201. * Creates an AxisDragGizmo
  127202. * @param gizmoLayer The utility layer the gizmo will be added to
  127203. * @param dragAxis The axis which the gizmo will be able to drag on
  127204. * @param color The color of the gizmo
  127205. */
  127206. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127207. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127208. /**
  127209. * If the gizmo is enabled
  127210. */
  127211. set isEnabled(value: boolean);
  127212. get isEnabled(): boolean;
  127213. /**
  127214. * Disposes of the gizmo
  127215. */
  127216. dispose(): void;
  127217. }
  127218. }
  127219. declare module BABYLON.Debug {
  127220. /**
  127221. * The Axes viewer will show 3 axes in a specific point in space
  127222. */
  127223. export class AxesViewer {
  127224. private _xAxis;
  127225. private _yAxis;
  127226. private _zAxis;
  127227. private _scaleLinesFactor;
  127228. private _instanced;
  127229. /**
  127230. * Gets the hosting scene
  127231. */
  127232. scene: Scene;
  127233. /**
  127234. * Gets or sets a number used to scale line length
  127235. */
  127236. scaleLines: number;
  127237. /** Gets the node hierarchy used to render x-axis */
  127238. get xAxis(): TransformNode;
  127239. /** Gets the node hierarchy used to render y-axis */
  127240. get yAxis(): TransformNode;
  127241. /** Gets the node hierarchy used to render z-axis */
  127242. get zAxis(): TransformNode;
  127243. /**
  127244. * Creates a new AxesViewer
  127245. * @param scene defines the hosting scene
  127246. * @param scaleLines defines a number used to scale line length (1 by default)
  127247. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127248. * @param xAxis defines the node hierarchy used to render the x-axis
  127249. * @param yAxis defines the node hierarchy used to render the y-axis
  127250. * @param zAxis defines the node hierarchy used to render the z-axis
  127251. */
  127252. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127253. /**
  127254. * Force the viewer to update
  127255. * @param position defines the position of the viewer
  127256. * @param xaxis defines the x axis of the viewer
  127257. * @param yaxis defines the y axis of the viewer
  127258. * @param zaxis defines the z axis of the viewer
  127259. */
  127260. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127261. /**
  127262. * Creates an instance of this axes viewer.
  127263. * @returns a new axes viewer with instanced meshes
  127264. */
  127265. createInstance(): AxesViewer;
  127266. /** Releases resources */
  127267. dispose(): void;
  127268. private static _SetRenderingGroupId;
  127269. }
  127270. }
  127271. declare module BABYLON.Debug {
  127272. /**
  127273. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127274. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127275. */
  127276. export class BoneAxesViewer extends AxesViewer {
  127277. /**
  127278. * Gets or sets the target mesh where to display the axes viewer
  127279. */
  127280. mesh: Nullable<Mesh>;
  127281. /**
  127282. * Gets or sets the target bone where to display the axes viewer
  127283. */
  127284. bone: Nullable<Bone>;
  127285. /** Gets current position */
  127286. pos: Vector3;
  127287. /** Gets direction of X axis */
  127288. xaxis: Vector3;
  127289. /** Gets direction of Y axis */
  127290. yaxis: Vector3;
  127291. /** Gets direction of Z axis */
  127292. zaxis: Vector3;
  127293. /**
  127294. * Creates a new BoneAxesViewer
  127295. * @param scene defines the hosting scene
  127296. * @param bone defines the target bone
  127297. * @param mesh defines the target mesh
  127298. * @param scaleLines defines a scaling factor for line length (1 by default)
  127299. */
  127300. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127301. /**
  127302. * Force the viewer to update
  127303. */
  127304. update(): void;
  127305. /** Releases resources */
  127306. dispose(): void;
  127307. }
  127308. }
  127309. declare module BABYLON {
  127310. /**
  127311. * Interface used to define scene explorer extensibility option
  127312. */
  127313. export interface IExplorerExtensibilityOption {
  127314. /**
  127315. * Define the option label
  127316. */
  127317. label: string;
  127318. /**
  127319. * Defines the action to execute on click
  127320. */
  127321. action: (entity: any) => void;
  127322. }
  127323. /**
  127324. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127325. */
  127326. export interface IExplorerExtensibilityGroup {
  127327. /**
  127328. * Defines a predicate to test if a given type mut be extended
  127329. */
  127330. predicate: (entity: any) => boolean;
  127331. /**
  127332. * Gets the list of options added to a type
  127333. */
  127334. entries: IExplorerExtensibilityOption[];
  127335. }
  127336. /**
  127337. * Interface used to define the options to use to create the Inspector
  127338. */
  127339. export interface IInspectorOptions {
  127340. /**
  127341. * Display in overlay mode (default: false)
  127342. */
  127343. overlay?: boolean;
  127344. /**
  127345. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127346. */
  127347. globalRoot?: HTMLElement;
  127348. /**
  127349. * Display the Scene explorer
  127350. */
  127351. showExplorer?: boolean;
  127352. /**
  127353. * Display the property inspector
  127354. */
  127355. showInspector?: boolean;
  127356. /**
  127357. * Display in embed mode (both panes on the right)
  127358. */
  127359. embedMode?: boolean;
  127360. /**
  127361. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127362. */
  127363. handleResize?: boolean;
  127364. /**
  127365. * Allow the panes to popup (default: true)
  127366. */
  127367. enablePopup?: boolean;
  127368. /**
  127369. * Allow the panes to be closed by users (default: true)
  127370. */
  127371. enableClose?: boolean;
  127372. /**
  127373. * Optional list of extensibility entries
  127374. */
  127375. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127376. /**
  127377. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127378. */
  127379. inspectorURL?: string;
  127380. /**
  127381. * Optional initial tab (default to DebugLayerTab.Properties)
  127382. */
  127383. initialTab?: DebugLayerTab;
  127384. }
  127385. interface Scene {
  127386. /**
  127387. * @hidden
  127388. * Backing field
  127389. */
  127390. _debugLayer: DebugLayer;
  127391. /**
  127392. * Gets the debug layer (aka Inspector) associated with the scene
  127393. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127394. */
  127395. debugLayer: DebugLayer;
  127396. }
  127397. /**
  127398. * Enum of inspector action tab
  127399. */
  127400. export enum DebugLayerTab {
  127401. /**
  127402. * Properties tag (default)
  127403. */
  127404. Properties = 0,
  127405. /**
  127406. * Debug tab
  127407. */
  127408. Debug = 1,
  127409. /**
  127410. * Statistics tab
  127411. */
  127412. Statistics = 2,
  127413. /**
  127414. * Tools tab
  127415. */
  127416. Tools = 3,
  127417. /**
  127418. * Settings tab
  127419. */
  127420. Settings = 4
  127421. }
  127422. /**
  127423. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127424. * what is happening in your scene
  127425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127426. */
  127427. export class DebugLayer {
  127428. /**
  127429. * Define the url to get the inspector script from.
  127430. * By default it uses the babylonjs CDN.
  127431. * @ignoreNaming
  127432. */
  127433. static InspectorURL: string;
  127434. private _scene;
  127435. private BJSINSPECTOR;
  127436. private _onPropertyChangedObservable?;
  127437. /**
  127438. * Observable triggered when a property is changed through the inspector.
  127439. */
  127440. get onPropertyChangedObservable(): any;
  127441. /**
  127442. * Instantiates a new debug layer.
  127443. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127444. * what is happening in your scene
  127445. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127446. * @param scene Defines the scene to inspect
  127447. */
  127448. constructor(scene: Scene);
  127449. /** Creates the inspector window. */
  127450. private _createInspector;
  127451. /**
  127452. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127453. * @param entity defines the entity to select
  127454. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127455. */
  127456. select(entity: any, lineContainerTitles?: string | string[]): void;
  127457. /** Get the inspector from bundle or global */
  127458. private _getGlobalInspector;
  127459. /**
  127460. * Get if the inspector is visible or not.
  127461. * @returns true if visible otherwise, false
  127462. */
  127463. isVisible(): boolean;
  127464. /**
  127465. * Hide the inspector and close its window.
  127466. */
  127467. hide(): void;
  127468. /**
  127469. * Update the scene in the inspector
  127470. */
  127471. setAsActiveScene(): void;
  127472. /**
  127473. * Launch the debugLayer.
  127474. * @param config Define the configuration of the inspector
  127475. * @return a promise fulfilled when the debug layer is visible
  127476. */
  127477. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127478. }
  127479. }
  127480. declare module BABYLON {
  127481. /**
  127482. * Class containing static functions to help procedurally build meshes
  127483. */
  127484. export class BoxBuilder {
  127485. /**
  127486. * Creates a box mesh
  127487. * * The parameter `size` sets the size (float) of each box side (default 1)
  127488. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127489. * * 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)
  127490. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127494. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127495. * @param name defines the name of the mesh
  127496. * @param options defines the options used to create the mesh
  127497. * @param scene defines the hosting scene
  127498. * @returns the box mesh
  127499. */
  127500. static CreateBox(name: string, options: {
  127501. size?: number;
  127502. width?: number;
  127503. height?: number;
  127504. depth?: number;
  127505. faceUV?: Vector4[];
  127506. faceColors?: Color4[];
  127507. sideOrientation?: number;
  127508. frontUVs?: Vector4;
  127509. backUVs?: Vector4;
  127510. wrap?: boolean;
  127511. topBaseAt?: number;
  127512. bottomBaseAt?: number;
  127513. updatable?: boolean;
  127514. }, scene?: Nullable<Scene>): Mesh;
  127515. }
  127516. }
  127517. declare module BABYLON.Debug {
  127518. /**
  127519. * Used to show the physics impostor around the specific mesh
  127520. */
  127521. export class PhysicsViewer {
  127522. /** @hidden */
  127523. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127524. /** @hidden */
  127525. protected _meshes: Array<Nullable<AbstractMesh>>;
  127526. /** @hidden */
  127527. protected _scene: Nullable<Scene>;
  127528. /** @hidden */
  127529. protected _numMeshes: number;
  127530. /** @hidden */
  127531. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127532. private _renderFunction;
  127533. private _utilityLayer;
  127534. private _debugBoxMesh;
  127535. private _debugSphereMesh;
  127536. private _debugCylinderMesh;
  127537. private _debugMaterial;
  127538. private _debugMeshMeshes;
  127539. /**
  127540. * Creates a new PhysicsViewer
  127541. * @param scene defines the hosting scene
  127542. */
  127543. constructor(scene: Scene);
  127544. /** @hidden */
  127545. protected _updateDebugMeshes(): void;
  127546. /**
  127547. * Renders a specified physic impostor
  127548. * @param impostor defines the impostor to render
  127549. * @param targetMesh defines the mesh represented by the impostor
  127550. * @returns the new debug mesh used to render the impostor
  127551. */
  127552. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127553. /**
  127554. * Hides a specified physic impostor
  127555. * @param impostor defines the impostor to hide
  127556. */
  127557. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127558. private _getDebugMaterial;
  127559. private _getDebugBoxMesh;
  127560. private _getDebugSphereMesh;
  127561. private _getDebugCylinderMesh;
  127562. private _getDebugMeshMesh;
  127563. private _getDebugMesh;
  127564. /** Releases all resources */
  127565. dispose(): void;
  127566. }
  127567. }
  127568. declare module BABYLON {
  127569. /**
  127570. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127571. * in order to better appreciate the issue one might have.
  127572. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127573. */
  127574. export class RayHelper {
  127575. /**
  127576. * Defines the ray we are currently tryin to visualize.
  127577. */
  127578. ray: Nullable<Ray>;
  127579. private _renderPoints;
  127580. private _renderLine;
  127581. private _renderFunction;
  127582. private _scene;
  127583. private _updateToMeshFunction;
  127584. private _attachedToMesh;
  127585. private _meshSpaceDirection;
  127586. private _meshSpaceOrigin;
  127587. /**
  127588. * Helper function to create a colored helper in a scene in one line.
  127589. * @param ray Defines the ray we are currently tryin to visualize
  127590. * @param scene Defines the scene the ray is used in
  127591. * @param color Defines the color we want to see the ray in
  127592. * @returns The newly created ray helper.
  127593. */
  127594. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127595. /**
  127596. * Instantiate a new ray helper.
  127597. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127598. * in order to better appreciate the issue one might have.
  127599. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127600. * @param ray Defines the ray we are currently tryin to visualize
  127601. */
  127602. constructor(ray: Ray);
  127603. /**
  127604. * Shows the ray we are willing to debug.
  127605. * @param scene Defines the scene the ray needs to be rendered in
  127606. * @param color Defines the color the ray needs to be rendered in
  127607. */
  127608. show(scene: Scene, color?: Color3): void;
  127609. /**
  127610. * Hides the ray we are debugging.
  127611. */
  127612. hide(): void;
  127613. private _render;
  127614. /**
  127615. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127616. * @param mesh Defines the mesh we want the helper attached to
  127617. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127618. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127619. * @param length Defines the length of the ray
  127620. */
  127621. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127622. /**
  127623. * Detach the ray helper from the mesh it has previously been attached to.
  127624. */
  127625. detachFromMesh(): void;
  127626. private _updateToMesh;
  127627. /**
  127628. * Dispose the helper and release its associated resources.
  127629. */
  127630. dispose(): void;
  127631. }
  127632. }
  127633. declare module BABYLON.Debug {
  127634. /**
  127635. * Class used to render a debug view of a given skeleton
  127636. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127637. */
  127638. export class SkeletonViewer {
  127639. /** defines the skeleton to render */
  127640. skeleton: Skeleton;
  127641. /** defines the mesh attached to the skeleton */
  127642. mesh: AbstractMesh;
  127643. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127644. autoUpdateBonesMatrices: boolean;
  127645. /** defines the rendering group id to use with the viewer */
  127646. renderingGroupId: number;
  127647. /** Gets or sets the color used to render the skeleton */
  127648. color: Color3;
  127649. private _scene;
  127650. private _debugLines;
  127651. private _debugMesh;
  127652. private _isEnabled;
  127653. private _renderFunction;
  127654. private _utilityLayer;
  127655. /**
  127656. * Returns the mesh used to render the bones
  127657. */
  127658. get debugMesh(): Nullable<LinesMesh>;
  127659. /**
  127660. * Creates a new SkeletonViewer
  127661. * @param skeleton defines the skeleton to render
  127662. * @param mesh defines the mesh attached to the skeleton
  127663. * @param scene defines the hosting scene
  127664. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127665. * @param renderingGroupId defines the rendering group id to use with the viewer
  127666. */
  127667. constructor(
  127668. /** defines the skeleton to render */
  127669. skeleton: Skeleton,
  127670. /** defines the mesh attached to the skeleton */
  127671. mesh: AbstractMesh, scene: Scene,
  127672. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127673. autoUpdateBonesMatrices?: boolean,
  127674. /** defines the rendering group id to use with the viewer */
  127675. renderingGroupId?: number);
  127676. /** Gets or sets a boolean indicating if the viewer is enabled */
  127677. set isEnabled(value: boolean);
  127678. get isEnabled(): boolean;
  127679. private _getBonePosition;
  127680. private _getLinesForBonesWithLength;
  127681. private _getLinesForBonesNoLength;
  127682. /** Update the viewer to sync with current skeleton state */
  127683. update(): void;
  127684. /** Release associated resources */
  127685. dispose(): void;
  127686. }
  127687. }
  127688. declare module BABYLON {
  127689. /**
  127690. * Enum for Device Types
  127691. */
  127692. export enum DeviceType {
  127693. /** Generic */
  127694. Generic = 0,
  127695. /** Keyboard */
  127696. Keyboard = 1,
  127697. /** Mouse */
  127698. Mouse = 2,
  127699. /** Touch Pointers */
  127700. Touch = 3,
  127701. /** PS4 Dual Shock */
  127702. DualShock = 4,
  127703. /** Xbox */
  127704. Xbox = 5,
  127705. /** Switch Controller */
  127706. Switch = 6
  127707. }
  127708. /**
  127709. * Enum for All Pointers (Touch/Mouse)
  127710. */
  127711. export enum PointerInput {
  127712. /** Horizontal Axis */
  127713. Horizontal = 0,
  127714. /** Vertical Axis */
  127715. Vertical = 1,
  127716. /** Left Click or Touch */
  127717. LeftClick = 2,
  127718. /** Middle Click */
  127719. MiddleClick = 3,
  127720. /** Right Click */
  127721. RightClick = 4,
  127722. /** Browser Back */
  127723. BrowserBack = 5,
  127724. /** Browser Forward */
  127725. BrowserForward = 6
  127726. }
  127727. /**
  127728. * Enum for Dual Shock Gamepad
  127729. */
  127730. export enum DualShockInput {
  127731. /** Cross */
  127732. Cross = 0,
  127733. /** Circle */
  127734. Circle = 1,
  127735. /** Square */
  127736. Square = 2,
  127737. /** Triangle */
  127738. Triangle = 3,
  127739. /** L1 */
  127740. L1 = 4,
  127741. /** R1 */
  127742. R1 = 5,
  127743. /** L2 */
  127744. L2 = 6,
  127745. /** R2 */
  127746. R2 = 7,
  127747. /** Share */
  127748. Share = 8,
  127749. /** Options */
  127750. Options = 9,
  127751. /** L3 */
  127752. L3 = 10,
  127753. /** R3 */
  127754. R3 = 11,
  127755. /** DPadUp */
  127756. DPadUp = 12,
  127757. /** DPadDown */
  127758. DPadDown = 13,
  127759. /** DPadLeft */
  127760. DPadLeft = 14,
  127761. /** DRight */
  127762. DPadRight = 15,
  127763. /** Home */
  127764. Home = 16,
  127765. /** TouchPad */
  127766. TouchPad = 17,
  127767. /** LStickXAxis */
  127768. LStickXAxis = 18,
  127769. /** LStickYAxis */
  127770. LStickYAxis = 19,
  127771. /** RStickXAxis */
  127772. RStickXAxis = 20,
  127773. /** RStickYAxis */
  127774. RStickYAxis = 21
  127775. }
  127776. /**
  127777. * Enum for Xbox Gamepad
  127778. */
  127779. export enum XboxInput {
  127780. /** A */
  127781. A = 0,
  127782. /** B */
  127783. B = 1,
  127784. /** X */
  127785. X = 2,
  127786. /** Y */
  127787. Y = 3,
  127788. /** LB */
  127789. LB = 4,
  127790. /** RB */
  127791. RB = 5,
  127792. /** LT */
  127793. LT = 6,
  127794. /** RT */
  127795. RT = 7,
  127796. /** Back */
  127797. Back = 8,
  127798. /** Start */
  127799. Start = 9,
  127800. /** LS */
  127801. LS = 10,
  127802. /** RS */
  127803. RS = 11,
  127804. /** DPadUp */
  127805. DPadUp = 12,
  127806. /** DPadDown */
  127807. DPadDown = 13,
  127808. /** DPadLeft */
  127809. DPadLeft = 14,
  127810. /** DRight */
  127811. DPadRight = 15,
  127812. /** Home */
  127813. Home = 16,
  127814. /** LStickXAxis */
  127815. LStickXAxis = 17,
  127816. /** LStickYAxis */
  127817. LStickYAxis = 18,
  127818. /** RStickXAxis */
  127819. RStickXAxis = 19,
  127820. /** RStickYAxis */
  127821. RStickYAxis = 20
  127822. }
  127823. /**
  127824. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127825. */
  127826. export enum SwitchInput {
  127827. /** B */
  127828. B = 0,
  127829. /** A */
  127830. A = 1,
  127831. /** Y */
  127832. Y = 2,
  127833. /** X */
  127834. X = 3,
  127835. /** L */
  127836. L = 4,
  127837. /** R */
  127838. R = 5,
  127839. /** ZL */
  127840. ZL = 6,
  127841. /** ZR */
  127842. ZR = 7,
  127843. /** Minus */
  127844. Minus = 8,
  127845. /** Plus */
  127846. Plus = 9,
  127847. /** LS */
  127848. LS = 10,
  127849. /** RS */
  127850. RS = 11,
  127851. /** DPadUp */
  127852. DPadUp = 12,
  127853. /** DPadDown */
  127854. DPadDown = 13,
  127855. /** DPadLeft */
  127856. DPadLeft = 14,
  127857. /** DRight */
  127858. DPadRight = 15,
  127859. /** Home */
  127860. Home = 16,
  127861. /** Capture */
  127862. Capture = 17,
  127863. /** LStickXAxis */
  127864. LStickXAxis = 18,
  127865. /** LStickYAxis */
  127866. LStickYAxis = 19,
  127867. /** RStickXAxis */
  127868. RStickXAxis = 20,
  127869. /** RStickYAxis */
  127870. RStickYAxis = 21
  127871. }
  127872. }
  127873. declare module BABYLON {
  127874. /**
  127875. * This class will take all inputs from Keyboard, Pointer, and
  127876. * any Gamepads and provide a polling system that all devices
  127877. * will use. This class assumes that there will only be one
  127878. * pointer device and one keyboard.
  127879. */
  127880. export class DeviceInputSystem implements IDisposable {
  127881. /**
  127882. * Callback to be triggered when a device is connected
  127883. */
  127884. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127885. /**
  127886. * Callback to be triggered when a device is disconnected
  127887. */
  127888. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127889. /**
  127890. * Callback to be triggered when event driven input is updated
  127891. */
  127892. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127893. private _inputs;
  127894. private _gamepads;
  127895. private _keyboardActive;
  127896. private _pointerActive;
  127897. private _elementToAttachTo;
  127898. private _keyboardDownEvent;
  127899. private _keyboardUpEvent;
  127900. private _pointerMoveEvent;
  127901. private _pointerDownEvent;
  127902. private _pointerUpEvent;
  127903. private _gamepadConnectedEvent;
  127904. private _gamepadDisconnectedEvent;
  127905. private static _MAX_KEYCODES;
  127906. private static _MAX_POINTER_INPUTS;
  127907. private constructor();
  127908. /**
  127909. * Creates a new DeviceInputSystem instance
  127910. * @param engine Engine to pull input element from
  127911. * @returns The new instance
  127912. */
  127913. static Create(engine: Engine): DeviceInputSystem;
  127914. /**
  127915. * Checks for current device input value, given an id and input index
  127916. * @param deviceName Id of connected device
  127917. * @param inputIndex Index of device input
  127918. * @returns Current value of input
  127919. */
  127920. /**
  127921. * Checks for current device input value, given an id and input index
  127922. * @param deviceType Enum specifiying device type
  127923. * @param deviceSlot "Slot" or index that device is referenced in
  127924. * @param inputIndex Id of input to be checked
  127925. * @returns Current value of input
  127926. */
  127927. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127928. /**
  127929. * Dispose of all the eventlisteners
  127930. */
  127931. dispose(): void;
  127932. /**
  127933. * Add device and inputs to device array
  127934. * @param deviceType Enum specifiying device type
  127935. * @param deviceSlot "Slot" or index that device is referenced in
  127936. * @param numberOfInputs Number of input entries to create for given device
  127937. */
  127938. private _registerDevice;
  127939. /**
  127940. * Given a specific device name, remove that device from the device map
  127941. * @param deviceType Enum specifiying device type
  127942. * @param deviceSlot "Slot" or index that device is referenced in
  127943. */
  127944. private _unregisterDevice;
  127945. /**
  127946. * Handle all actions that come from keyboard interaction
  127947. */
  127948. private _handleKeyActions;
  127949. /**
  127950. * Handle all actions that come from pointer interaction
  127951. */
  127952. private _handlePointerActions;
  127953. /**
  127954. * Handle all actions that come from gamepad interaction
  127955. */
  127956. private _handleGamepadActions;
  127957. /**
  127958. * Update all non-event based devices with each frame
  127959. * @param deviceType Enum specifiying device type
  127960. * @param deviceSlot "Slot" or index that device is referenced in
  127961. * @param inputIndex Id of input to be checked
  127962. */
  127963. private _updateDevice;
  127964. /**
  127965. * Gets DeviceType from the device name
  127966. * @param deviceName Name of Device from DeviceInputSystem
  127967. * @returns DeviceType enum value
  127968. */
  127969. private _getGamepadDeviceType;
  127970. }
  127971. }
  127972. declare module BABYLON {
  127973. /**
  127974. * Type to handle enforcement of inputs
  127975. */
  127976. 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;
  127977. }
  127978. declare module BABYLON {
  127979. /**
  127980. * Class that handles all input for a specific device
  127981. */
  127982. export class DeviceSource<T extends DeviceType> {
  127983. /** Type of device */
  127984. readonly deviceType: DeviceType;
  127985. /** "Slot" or index that device is referenced in */
  127986. readonly deviceSlot: number;
  127987. /**
  127988. * Observable to handle device input changes per device
  127989. */
  127990. readonly onInputChangedObservable: Observable<{
  127991. inputIndex: DeviceInput<T>;
  127992. previousState: Nullable<number>;
  127993. currentState: Nullable<number>;
  127994. }>;
  127995. private readonly _deviceInputSystem;
  127996. /**
  127997. * Default Constructor
  127998. * @param deviceInputSystem Reference to DeviceInputSystem
  127999. * @param deviceType Type of device
  128000. * @param deviceSlot "Slot" or index that device is referenced in
  128001. */
  128002. constructor(deviceInputSystem: DeviceInputSystem,
  128003. /** Type of device */
  128004. deviceType: DeviceType,
  128005. /** "Slot" or index that device is referenced in */
  128006. deviceSlot?: number);
  128007. /**
  128008. * Get input for specific input
  128009. * @param inputIndex index of specific input on device
  128010. * @returns Input value from DeviceInputSystem
  128011. */
  128012. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128013. }
  128014. /**
  128015. * Class to keep track of devices
  128016. */
  128017. export class DeviceSourceManager implements IDisposable {
  128018. /**
  128019. * Observable to be triggered when before a device is connected
  128020. */
  128021. readonly onBeforeDeviceConnectedObservable: Observable<{
  128022. deviceType: DeviceType;
  128023. deviceSlot: number;
  128024. }>;
  128025. /**
  128026. * Observable to be triggered when before a device is disconnected
  128027. */
  128028. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128029. deviceType: DeviceType;
  128030. deviceSlot: number;
  128031. }>;
  128032. /**
  128033. * Observable to be triggered when after a device is connected
  128034. */
  128035. readonly onAfterDeviceConnectedObservable: Observable<{
  128036. deviceType: DeviceType;
  128037. deviceSlot: number;
  128038. }>;
  128039. /**
  128040. * Observable to be triggered when after a device is disconnected
  128041. */
  128042. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128043. deviceType: DeviceType;
  128044. deviceSlot: number;
  128045. }>;
  128046. private readonly _devices;
  128047. private readonly _firstDevice;
  128048. private readonly _deviceInputSystem;
  128049. /**
  128050. * Default Constructor
  128051. * @param engine engine to pull input element from
  128052. */
  128053. constructor(engine: Engine);
  128054. /**
  128055. * Gets a DeviceSource, given a type and slot
  128056. * @param deviceType Enum specifying device type
  128057. * @param deviceSlot "Slot" or index that device is referenced in
  128058. * @returns DeviceSource object
  128059. */
  128060. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128061. /**
  128062. * Gets an array of DeviceSource objects for a given device type
  128063. * @param deviceType Enum specifying device type
  128064. * @returns Array of DeviceSource objects
  128065. */
  128066. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128067. /**
  128068. * Dispose of DeviceInputSystem and other parts
  128069. */
  128070. dispose(): void;
  128071. /**
  128072. * Function to add device name to device list
  128073. * @param deviceType Enum specifying device type
  128074. * @param deviceSlot "Slot" or index that device is referenced in
  128075. */
  128076. private _addDevice;
  128077. /**
  128078. * Function to remove device name to device list
  128079. * @param deviceType Enum specifying device type
  128080. * @param deviceSlot "Slot" or index that device is referenced in
  128081. */
  128082. private _removeDevice;
  128083. /**
  128084. * Updates array storing first connected device of each type
  128085. * @param type Type of Device
  128086. */
  128087. private _updateFirstDevices;
  128088. }
  128089. }
  128090. declare module BABYLON {
  128091. /**
  128092. * Options to create the null engine
  128093. */
  128094. export class NullEngineOptions {
  128095. /**
  128096. * Render width (Default: 512)
  128097. */
  128098. renderWidth: number;
  128099. /**
  128100. * Render height (Default: 256)
  128101. */
  128102. renderHeight: number;
  128103. /**
  128104. * Texture size (Default: 512)
  128105. */
  128106. textureSize: number;
  128107. /**
  128108. * If delta time between frames should be constant
  128109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128110. */
  128111. deterministicLockstep: boolean;
  128112. /**
  128113. * Maximum about of steps between frames (Default: 4)
  128114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128115. */
  128116. lockstepMaxSteps: number;
  128117. }
  128118. /**
  128119. * The null engine class provides support for headless version of babylon.js.
  128120. * This can be used in server side scenario or for testing purposes
  128121. */
  128122. export class NullEngine extends Engine {
  128123. private _options;
  128124. /**
  128125. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128126. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128127. * @returns true if engine is in deterministic lock step mode
  128128. */
  128129. isDeterministicLockStep(): boolean;
  128130. /**
  128131. * Gets the max steps when engine is running in deterministic lock step
  128132. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128133. * @returns the max steps
  128134. */
  128135. getLockstepMaxSteps(): number;
  128136. /**
  128137. * Gets the current hardware scaling level.
  128138. * By default the hardware scaling level is computed from the window device ratio.
  128139. * 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.
  128140. * @returns a number indicating the current hardware scaling level
  128141. */
  128142. getHardwareScalingLevel(): number;
  128143. constructor(options?: NullEngineOptions);
  128144. /**
  128145. * Creates a vertex buffer
  128146. * @param vertices the data for the vertex buffer
  128147. * @returns the new WebGL static buffer
  128148. */
  128149. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128150. /**
  128151. * Creates a new index buffer
  128152. * @param indices defines the content of the index buffer
  128153. * @param updatable defines if the index buffer must be updatable
  128154. * @returns a new webGL buffer
  128155. */
  128156. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128157. /**
  128158. * Clear the current render buffer or the current render target (if any is set up)
  128159. * @param color defines the color to use
  128160. * @param backBuffer defines if the back buffer must be cleared
  128161. * @param depth defines if the depth buffer must be cleared
  128162. * @param stencil defines if the stencil buffer must be cleared
  128163. */
  128164. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128165. /**
  128166. * Gets the current render width
  128167. * @param useScreen defines if screen size must be used (or the current render target if any)
  128168. * @returns a number defining the current render width
  128169. */
  128170. getRenderWidth(useScreen?: boolean): number;
  128171. /**
  128172. * Gets the current render height
  128173. * @param useScreen defines if screen size must be used (or the current render target if any)
  128174. * @returns a number defining the current render height
  128175. */
  128176. getRenderHeight(useScreen?: boolean): number;
  128177. /**
  128178. * Set the WebGL's viewport
  128179. * @param viewport defines the viewport element to be used
  128180. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128181. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128182. */
  128183. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128184. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128185. /**
  128186. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128187. * @param pipelineContext defines the pipeline context to use
  128188. * @param uniformsNames defines the list of uniform names
  128189. * @returns an array of webGL uniform locations
  128190. */
  128191. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128192. /**
  128193. * Gets the lsit of active attributes for a given webGL program
  128194. * @param pipelineContext defines the pipeline context to use
  128195. * @param attributesNames defines the list of attribute names to get
  128196. * @returns an array of indices indicating the offset of each attribute
  128197. */
  128198. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128199. /**
  128200. * Binds an effect to the webGL context
  128201. * @param effect defines the effect to bind
  128202. */
  128203. bindSamplers(effect: Effect): void;
  128204. /**
  128205. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128206. * @param effect defines the effect to activate
  128207. */
  128208. enableEffect(effect: Effect): void;
  128209. /**
  128210. * Set various states to the webGL context
  128211. * @param culling defines backface culling state
  128212. * @param zOffset defines the value to apply to zOffset (0 by default)
  128213. * @param force defines if states must be applied even if cache is up to date
  128214. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128215. */
  128216. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128217. /**
  128218. * Set the value of an uniform to an array of int32
  128219. * @param uniform defines the webGL uniform location where to store the value
  128220. * @param array defines the array of int32 to store
  128221. */
  128222. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128223. /**
  128224. * Set the value of an uniform to an array of int32 (stored as vec2)
  128225. * @param uniform defines the webGL uniform location where to store the value
  128226. * @param array defines the array of int32 to store
  128227. */
  128228. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128229. /**
  128230. * Set the value of an uniform to an array of int32 (stored as vec3)
  128231. * @param uniform defines the webGL uniform location where to store the value
  128232. * @param array defines the array of int32 to store
  128233. */
  128234. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128235. /**
  128236. * Set the value of an uniform to an array of int32 (stored as vec4)
  128237. * @param uniform defines the webGL uniform location where to store the value
  128238. * @param array defines the array of int32 to store
  128239. */
  128240. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128241. /**
  128242. * Set the value of an uniform to an array of float32
  128243. * @param uniform defines the webGL uniform location where to store the value
  128244. * @param array defines the array of float32 to store
  128245. */
  128246. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128247. /**
  128248. * Set the value of an uniform to an array of float32 (stored as vec2)
  128249. * @param uniform defines the webGL uniform location where to store the value
  128250. * @param array defines the array of float32 to store
  128251. */
  128252. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128253. /**
  128254. * Set the value of an uniform to an array of float32 (stored as vec3)
  128255. * @param uniform defines the webGL uniform location where to store the value
  128256. * @param array defines the array of float32 to store
  128257. */
  128258. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128259. /**
  128260. * Set the value of an uniform to an array of float32 (stored as vec4)
  128261. * @param uniform defines the webGL uniform location where to store the value
  128262. * @param array defines the array of float32 to store
  128263. */
  128264. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128265. /**
  128266. * Set the value of an uniform to an array of number
  128267. * @param uniform defines the webGL uniform location where to store the value
  128268. * @param array defines the array of number to store
  128269. */
  128270. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128271. /**
  128272. * Set the value of an uniform to an array of number (stored as vec2)
  128273. * @param uniform defines the webGL uniform location where to store the value
  128274. * @param array defines the array of number to store
  128275. */
  128276. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128277. /**
  128278. * Set the value of an uniform to an array of number (stored as vec3)
  128279. * @param uniform defines the webGL uniform location where to store the value
  128280. * @param array defines the array of number to store
  128281. */
  128282. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128283. /**
  128284. * Set the value of an uniform to an array of number (stored as vec4)
  128285. * @param uniform defines the webGL uniform location where to store the value
  128286. * @param array defines the array of number to store
  128287. */
  128288. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128289. /**
  128290. * Set the value of an uniform to an array of float32 (stored as matrices)
  128291. * @param uniform defines the webGL uniform location where to store the value
  128292. * @param matrices defines the array of float32 to store
  128293. */
  128294. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128295. /**
  128296. * Set the value of an uniform to a matrix (3x3)
  128297. * @param uniform defines the webGL uniform location where to store the value
  128298. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128299. */
  128300. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128301. /**
  128302. * Set the value of an uniform to a matrix (2x2)
  128303. * @param uniform defines the webGL uniform location where to store the value
  128304. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128305. */
  128306. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128307. /**
  128308. * Set the value of an uniform to a number (float)
  128309. * @param uniform defines the webGL uniform location where to store the value
  128310. * @param value defines the float number to store
  128311. */
  128312. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128313. /**
  128314. * Set the value of an uniform to a vec2
  128315. * @param uniform defines the webGL uniform location where to store the value
  128316. * @param x defines the 1st component of the value
  128317. * @param y defines the 2nd component of the value
  128318. */
  128319. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128320. /**
  128321. * Set the value of an uniform to a vec3
  128322. * @param uniform defines the webGL uniform location where to store the value
  128323. * @param x defines the 1st component of the value
  128324. * @param y defines the 2nd component of the value
  128325. * @param z defines the 3rd component of the value
  128326. */
  128327. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128328. /**
  128329. * Set the value of an uniform to a boolean
  128330. * @param uniform defines the webGL uniform location where to store the value
  128331. * @param bool defines the boolean to store
  128332. */
  128333. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128334. /**
  128335. * Set the value of an uniform to a vec4
  128336. * @param uniform defines the webGL uniform location where to store the value
  128337. * @param x defines the 1st component of the value
  128338. * @param y defines the 2nd component of the value
  128339. * @param z defines the 3rd component of the value
  128340. * @param w defines the 4th component of the value
  128341. */
  128342. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128343. /**
  128344. * Sets the current alpha mode
  128345. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128346. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128348. */
  128349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128350. /**
  128351. * Bind webGl buffers directly to the webGL context
  128352. * @param vertexBuffers defines the vertex buffer to bind
  128353. * @param indexBuffer defines the index buffer to bind
  128354. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128355. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128356. * @param effect defines the effect associated with the vertex buffer
  128357. */
  128358. bindBuffers(vertexBuffers: {
  128359. [key: string]: VertexBuffer;
  128360. }, indexBuffer: DataBuffer, effect: Effect): void;
  128361. /**
  128362. * Force the entire cache to be cleared
  128363. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128364. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128365. */
  128366. wipeCaches(bruteForce?: boolean): void;
  128367. /**
  128368. * Send a draw order
  128369. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128370. * @param indexStart defines the starting index
  128371. * @param indexCount defines the number of index to draw
  128372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128373. */
  128374. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128375. /**
  128376. * Draw a list of indexed primitives
  128377. * @param fillMode defines the primitive to use
  128378. * @param indexStart defines the starting index
  128379. * @param indexCount defines the number of index to draw
  128380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128381. */
  128382. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128383. /**
  128384. * Draw a list of unindexed primitives
  128385. * @param fillMode defines the primitive to use
  128386. * @param verticesStart defines the index of first vertex to draw
  128387. * @param verticesCount defines the count of vertices to draw
  128388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128389. */
  128390. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128391. /** @hidden */
  128392. _createTexture(): WebGLTexture;
  128393. /** @hidden */
  128394. _releaseTexture(texture: InternalTexture): void;
  128395. /**
  128396. * Usually called from Texture.ts.
  128397. * Passed information to create a WebGLTexture
  128398. * @param urlArg defines a value which contains one of the following:
  128399. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128400. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128401. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128402. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128403. * @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)
  128404. * @param scene needed for loading to the correct scene
  128405. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128406. * @param onLoad optional callback to be called upon successful completion
  128407. * @param onError optional callback to be called upon failure
  128408. * @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
  128409. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128410. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128411. * @param forcedExtension defines the extension to use to pick the right loader
  128412. * @param mimeType defines an optional mime type
  128413. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128414. */
  128415. 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;
  128416. /**
  128417. * Creates a new render target texture
  128418. * @param size defines the size of the texture
  128419. * @param options defines the options used to create the texture
  128420. * @returns a new render target texture stored in an InternalTexture
  128421. */
  128422. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128423. /**
  128424. * Update the sampling mode of a given texture
  128425. * @param samplingMode defines the required sampling mode
  128426. * @param texture defines the texture to update
  128427. */
  128428. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128429. /**
  128430. * Binds the frame buffer to the specified texture.
  128431. * @param texture The texture to render to or null for the default canvas
  128432. * @param faceIndex The face of the texture to render to in case of cube texture
  128433. * @param requiredWidth The width of the target to render to
  128434. * @param requiredHeight The height of the target to render to
  128435. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128436. * @param lodLevel defines le lod level to bind to the frame buffer
  128437. */
  128438. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128439. /**
  128440. * Unbind the current render target texture from the webGL context
  128441. * @param texture defines the render target texture to unbind
  128442. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128443. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128444. */
  128445. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128446. /**
  128447. * Creates a dynamic vertex buffer
  128448. * @param vertices the data for the dynamic vertex buffer
  128449. * @returns the new WebGL dynamic buffer
  128450. */
  128451. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128452. /**
  128453. * Update the content of a dynamic texture
  128454. * @param texture defines the texture to update
  128455. * @param canvas defines the canvas containing the source
  128456. * @param invertY defines if data must be stored with Y axis inverted
  128457. * @param premulAlpha defines if alpha is stored as premultiplied
  128458. * @param format defines the format of the data
  128459. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128460. */
  128461. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128462. /**
  128463. * Gets a boolean indicating if all created effects are ready
  128464. * @returns true if all effects are ready
  128465. */
  128466. areAllEffectsReady(): boolean;
  128467. /**
  128468. * @hidden
  128469. * Get the current error code of the webGL context
  128470. * @returns the error code
  128471. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128472. */
  128473. getError(): number;
  128474. /** @hidden */
  128475. _getUnpackAlignement(): number;
  128476. /** @hidden */
  128477. _unpackFlipY(value: boolean): void;
  128478. /**
  128479. * Update a dynamic index buffer
  128480. * @param indexBuffer defines the target index buffer
  128481. * @param indices defines the data to update
  128482. * @param offset defines the offset in the target index buffer where update should start
  128483. */
  128484. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128485. /**
  128486. * Updates a dynamic vertex buffer.
  128487. * @param vertexBuffer the vertex buffer to update
  128488. * @param vertices the data used to update the vertex buffer
  128489. * @param byteOffset the byte offset of the data (optional)
  128490. * @param byteLength the byte length of the data (optional)
  128491. */
  128492. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128493. /** @hidden */
  128494. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128495. /** @hidden */
  128496. _bindTexture(channel: number, texture: InternalTexture): void;
  128497. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128498. /**
  128499. * 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
  128500. */
  128501. releaseEffects(): void;
  128502. displayLoadingUI(): void;
  128503. hideLoadingUI(): void;
  128504. /** @hidden */
  128505. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128506. /** @hidden */
  128507. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128508. /** @hidden */
  128509. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128510. /** @hidden */
  128511. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128512. }
  128513. }
  128514. declare module BABYLON {
  128515. /**
  128516. * @hidden
  128517. **/
  128518. export class _TimeToken {
  128519. _startTimeQuery: Nullable<WebGLQuery>;
  128520. _endTimeQuery: Nullable<WebGLQuery>;
  128521. _timeElapsedQuery: Nullable<WebGLQuery>;
  128522. _timeElapsedQueryEnded: boolean;
  128523. }
  128524. }
  128525. declare module BABYLON {
  128526. /** @hidden */
  128527. export class _OcclusionDataStorage {
  128528. /** @hidden */
  128529. occlusionInternalRetryCounter: number;
  128530. /** @hidden */
  128531. isOcclusionQueryInProgress: boolean;
  128532. /** @hidden */
  128533. isOccluded: boolean;
  128534. /** @hidden */
  128535. occlusionRetryCount: number;
  128536. /** @hidden */
  128537. occlusionType: number;
  128538. /** @hidden */
  128539. occlusionQueryAlgorithmType: number;
  128540. }
  128541. interface Engine {
  128542. /**
  128543. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128544. * @return the new query
  128545. */
  128546. createQuery(): WebGLQuery;
  128547. /**
  128548. * Delete and release a webGL query
  128549. * @param query defines the query to delete
  128550. * @return the current engine
  128551. */
  128552. deleteQuery(query: WebGLQuery): Engine;
  128553. /**
  128554. * Check if a given query has resolved and got its value
  128555. * @param query defines the query to check
  128556. * @returns true if the query got its value
  128557. */
  128558. isQueryResultAvailable(query: WebGLQuery): boolean;
  128559. /**
  128560. * Gets the value of a given query
  128561. * @param query defines the query to check
  128562. * @returns the value of the query
  128563. */
  128564. getQueryResult(query: WebGLQuery): number;
  128565. /**
  128566. * Initiates an occlusion query
  128567. * @param algorithmType defines the algorithm to use
  128568. * @param query defines the query to use
  128569. * @returns the current engine
  128570. * @see http://doc.babylonjs.com/features/occlusionquery
  128571. */
  128572. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128573. /**
  128574. * Ends an occlusion query
  128575. * @see http://doc.babylonjs.com/features/occlusionquery
  128576. * @param algorithmType defines the algorithm to use
  128577. * @returns the current engine
  128578. */
  128579. endOcclusionQuery(algorithmType: number): Engine;
  128580. /**
  128581. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128582. * Please note that only one query can be issued at a time
  128583. * @returns a time token used to track the time span
  128584. */
  128585. startTimeQuery(): Nullable<_TimeToken>;
  128586. /**
  128587. * Ends a time query
  128588. * @param token defines the token used to measure the time span
  128589. * @returns the time spent (in ns)
  128590. */
  128591. endTimeQuery(token: _TimeToken): int;
  128592. /** @hidden */
  128593. _currentNonTimestampToken: Nullable<_TimeToken>;
  128594. /** @hidden */
  128595. _createTimeQuery(): WebGLQuery;
  128596. /** @hidden */
  128597. _deleteTimeQuery(query: WebGLQuery): void;
  128598. /** @hidden */
  128599. _getGlAlgorithmType(algorithmType: number): number;
  128600. /** @hidden */
  128601. _getTimeQueryResult(query: WebGLQuery): any;
  128602. /** @hidden */
  128603. _getTimeQueryAvailability(query: WebGLQuery): any;
  128604. }
  128605. interface AbstractMesh {
  128606. /**
  128607. * Backing filed
  128608. * @hidden
  128609. */
  128610. __occlusionDataStorage: _OcclusionDataStorage;
  128611. /**
  128612. * Access property
  128613. * @hidden
  128614. */
  128615. _occlusionDataStorage: _OcclusionDataStorage;
  128616. /**
  128617. * 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.
  128618. * The default value is -1 which means don't break the query and wait till the result
  128619. * @see http://doc.babylonjs.com/features/occlusionquery
  128620. */
  128621. occlusionRetryCount: number;
  128622. /**
  128623. * 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:
  128624. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128625. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128626. * * 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.
  128627. * @see http://doc.babylonjs.com/features/occlusionquery
  128628. */
  128629. occlusionType: number;
  128630. /**
  128631. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128632. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128633. * * 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.
  128634. * @see http://doc.babylonjs.com/features/occlusionquery
  128635. */
  128636. occlusionQueryAlgorithmType: number;
  128637. /**
  128638. * 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
  128639. * @see http://doc.babylonjs.com/features/occlusionquery
  128640. */
  128641. isOccluded: boolean;
  128642. /**
  128643. * Flag to check the progress status of the query
  128644. * @see http://doc.babylonjs.com/features/occlusionquery
  128645. */
  128646. isOcclusionQueryInProgress: boolean;
  128647. }
  128648. }
  128649. declare module BABYLON {
  128650. /** @hidden */
  128651. export var _forceTransformFeedbackToBundle: boolean;
  128652. interface Engine {
  128653. /**
  128654. * Creates a webGL transform feedback object
  128655. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128656. * @returns the webGL transform feedback object
  128657. */
  128658. createTransformFeedback(): WebGLTransformFeedback;
  128659. /**
  128660. * Delete a webGL transform feedback object
  128661. * @param value defines the webGL transform feedback object to delete
  128662. */
  128663. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128664. /**
  128665. * Bind a webGL transform feedback object to the webgl context
  128666. * @param value defines the webGL transform feedback object to bind
  128667. */
  128668. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128669. /**
  128670. * Begins a transform feedback operation
  128671. * @param usePoints defines if points or triangles must be used
  128672. */
  128673. beginTransformFeedback(usePoints: boolean): void;
  128674. /**
  128675. * Ends a transform feedback operation
  128676. */
  128677. endTransformFeedback(): void;
  128678. /**
  128679. * Specify the varyings to use with transform feedback
  128680. * @param program defines the associated webGL program
  128681. * @param value defines the list of strings representing the varying names
  128682. */
  128683. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128684. /**
  128685. * Bind a webGL buffer for a transform feedback operation
  128686. * @param value defines the webGL buffer to bind
  128687. */
  128688. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128689. }
  128690. }
  128691. declare module BABYLON {
  128692. /**
  128693. * Creation options of the multi render target texture.
  128694. */
  128695. export interface IMultiRenderTargetOptions {
  128696. /**
  128697. * Define if the texture needs to create mip maps after render.
  128698. */
  128699. generateMipMaps?: boolean;
  128700. /**
  128701. * Define the types of all the draw buffers we want to create
  128702. */
  128703. types?: number[];
  128704. /**
  128705. * Define the sampling modes of all the draw buffers we want to create
  128706. */
  128707. samplingModes?: number[];
  128708. /**
  128709. * Define if a depth buffer is required
  128710. */
  128711. generateDepthBuffer?: boolean;
  128712. /**
  128713. * Define if a stencil buffer is required
  128714. */
  128715. generateStencilBuffer?: boolean;
  128716. /**
  128717. * Define if a depth texture is required instead of a depth buffer
  128718. */
  128719. generateDepthTexture?: boolean;
  128720. /**
  128721. * Define the number of desired draw buffers
  128722. */
  128723. textureCount?: number;
  128724. /**
  128725. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128726. */
  128727. doNotChangeAspectRatio?: boolean;
  128728. /**
  128729. * Define the default type of the buffers we are creating
  128730. */
  128731. defaultType?: number;
  128732. }
  128733. /**
  128734. * A multi render target, like a render target provides the ability to render to a texture.
  128735. * Unlike the render target, it can render to several draw buffers in one draw.
  128736. * This is specially interesting in deferred rendering or for any effects requiring more than
  128737. * just one color from a single pass.
  128738. */
  128739. export class MultiRenderTarget extends RenderTargetTexture {
  128740. private _internalTextures;
  128741. private _textures;
  128742. private _multiRenderTargetOptions;
  128743. /**
  128744. * Get if draw buffers are currently supported by the used hardware and browser.
  128745. */
  128746. get isSupported(): boolean;
  128747. /**
  128748. * Get the list of textures generated by the multi render target.
  128749. */
  128750. get textures(): Texture[];
  128751. /**
  128752. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128753. */
  128754. get depthTexture(): Texture;
  128755. /**
  128756. * Set the wrapping mode on U of all the textures we are rendering to.
  128757. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128758. */
  128759. set wrapU(wrap: number);
  128760. /**
  128761. * Set the wrapping mode on V of all the textures we are rendering to.
  128762. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128763. */
  128764. set wrapV(wrap: number);
  128765. /**
  128766. * Instantiate a new multi render target texture.
  128767. * A multi render target, like a render target provides the ability to render to a texture.
  128768. * Unlike the render target, it can render to several draw buffers in one draw.
  128769. * This is specially interesting in deferred rendering or for any effects requiring more than
  128770. * just one color from a single pass.
  128771. * @param name Define the name of the texture
  128772. * @param size Define the size of the buffers to render to
  128773. * @param count Define the number of target we are rendering into
  128774. * @param scene Define the scene the texture belongs to
  128775. * @param options Define the options used to create the multi render target
  128776. */
  128777. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  128778. /** @hidden */
  128779. _rebuild(): void;
  128780. private _createInternalTextures;
  128781. private _createTextures;
  128782. /**
  128783. * Define the number of samples used if MSAA is enabled.
  128784. */
  128785. get samples(): number;
  128786. set samples(value: number);
  128787. /**
  128788. * Resize all the textures in the multi render target.
  128789. * Be carrefull as it will recreate all the data in the new texture.
  128790. * @param size Define the new size
  128791. */
  128792. resize(size: any): void;
  128793. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  128794. /**
  128795. * Dispose the render targets and their associated resources
  128796. */
  128797. dispose(): void;
  128798. /**
  128799. * Release all the underlying texture used as draw buffers.
  128800. */
  128801. releaseInternalTextures(): void;
  128802. }
  128803. }
  128804. declare module BABYLON {
  128805. interface ThinEngine {
  128806. /**
  128807. * Unbind a list of render target textures from the webGL context
  128808. * This is used only when drawBuffer extension or webGL2 are active
  128809. * @param textures defines the render target textures to unbind
  128810. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128811. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128812. */
  128813. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128814. /**
  128815. * Create a multi render target texture
  128816. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128817. * @param size defines the size of the texture
  128818. * @param options defines the creation options
  128819. * @returns the cube texture as an InternalTexture
  128820. */
  128821. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128822. /**
  128823. * Update the sample count for a given multiple render target texture
  128824. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128825. * @param textures defines the textures to update
  128826. * @param samples defines the sample count to set
  128827. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128828. */
  128829. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. /**
  128834. * Class used to define an additional view for the engine
  128835. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128836. */
  128837. export class EngineView {
  128838. /** Defines the canvas where to render the view */
  128839. target: HTMLCanvasElement;
  128840. /** Defines an optional camera used to render the view (will use active camera else) */
  128841. camera?: Camera;
  128842. }
  128843. interface Engine {
  128844. /**
  128845. * Gets or sets the HTML element to use for attaching events
  128846. */
  128847. inputElement: Nullable<HTMLElement>;
  128848. /**
  128849. * Gets the current engine view
  128850. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128851. */
  128852. activeView: Nullable<EngineView>;
  128853. /** Gets or sets the list of views */
  128854. views: EngineView[];
  128855. /**
  128856. * Register a new child canvas
  128857. * @param canvas defines the canvas to register
  128858. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128859. * @returns the associated view
  128860. */
  128861. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128862. /**
  128863. * Remove a registered child canvas
  128864. * @param canvas defines the canvas to remove
  128865. * @returns the current engine
  128866. */
  128867. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128868. }
  128869. }
  128870. declare module BABYLON {
  128871. interface Engine {
  128872. /** @hidden */
  128873. _excludedCompressedTextures: string[];
  128874. /** @hidden */
  128875. _textureFormatInUse: string;
  128876. /**
  128877. * Gets the list of texture formats supported
  128878. */
  128879. readonly texturesSupported: Array<string>;
  128880. /**
  128881. * Gets the texture format in use
  128882. */
  128883. readonly textureFormatInUse: Nullable<string>;
  128884. /**
  128885. * Set the compressed texture extensions or file names to skip.
  128886. *
  128887. * @param skippedFiles defines the list of those texture files you want to skip
  128888. * Example: [".dds", ".env", "myfile.png"]
  128889. */
  128890. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128891. /**
  128892. * Set the compressed texture format to use, based on the formats you have, and the formats
  128893. * supported by the hardware / browser.
  128894. *
  128895. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128896. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128897. * to API arguments needed to compressed textures. This puts the burden on the container
  128898. * generator to house the arcane code for determining these for current & future formats.
  128899. *
  128900. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128901. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128902. *
  128903. * Note: The result of this call is not taken into account when a texture is base64.
  128904. *
  128905. * @param formatsAvailable defines the list of those format families you have created
  128906. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128907. *
  128908. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128909. * @returns The extension selected.
  128910. */
  128911. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128912. }
  128913. }
  128914. declare module BABYLON {
  128915. /**
  128916. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128917. */
  128918. export interface CubeMapInfo {
  128919. /**
  128920. * The pixel array for the front face.
  128921. * This is stored in format, left to right, up to down format.
  128922. */
  128923. front: Nullable<ArrayBufferView>;
  128924. /**
  128925. * The pixel array for the back face.
  128926. * This is stored in format, left to right, up to down format.
  128927. */
  128928. back: Nullable<ArrayBufferView>;
  128929. /**
  128930. * The pixel array for the left face.
  128931. * This is stored in format, left to right, up to down format.
  128932. */
  128933. left: Nullable<ArrayBufferView>;
  128934. /**
  128935. * The pixel array for the right face.
  128936. * This is stored in format, left to right, up to down format.
  128937. */
  128938. right: Nullable<ArrayBufferView>;
  128939. /**
  128940. * The pixel array for the up face.
  128941. * This is stored in format, left to right, up to down format.
  128942. */
  128943. up: Nullable<ArrayBufferView>;
  128944. /**
  128945. * The pixel array for the down face.
  128946. * This is stored in format, left to right, up to down format.
  128947. */
  128948. down: Nullable<ArrayBufferView>;
  128949. /**
  128950. * The size of the cubemap stored.
  128951. *
  128952. * Each faces will be size * size pixels.
  128953. */
  128954. size: number;
  128955. /**
  128956. * The format of the texture.
  128957. *
  128958. * RGBA, RGB.
  128959. */
  128960. format: number;
  128961. /**
  128962. * The type of the texture data.
  128963. *
  128964. * UNSIGNED_INT, FLOAT.
  128965. */
  128966. type: number;
  128967. /**
  128968. * Specifies whether the texture is in gamma space.
  128969. */
  128970. gammaSpace: boolean;
  128971. }
  128972. /**
  128973. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128974. */
  128975. export class PanoramaToCubeMapTools {
  128976. private static FACE_LEFT;
  128977. private static FACE_RIGHT;
  128978. private static FACE_FRONT;
  128979. private static FACE_BACK;
  128980. private static FACE_DOWN;
  128981. private static FACE_UP;
  128982. /**
  128983. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128984. *
  128985. * @param float32Array The source data.
  128986. * @param inputWidth The width of the input panorama.
  128987. * @param inputHeight The height of the input panorama.
  128988. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128989. * @return The cubemap data
  128990. */
  128991. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128992. private static CreateCubemapTexture;
  128993. private static CalcProjectionSpherical;
  128994. }
  128995. }
  128996. declare module BABYLON {
  128997. /**
  128998. * Helper class dealing with the extraction of spherical polynomial dataArray
  128999. * from a cube map.
  129000. */
  129001. export class CubeMapToSphericalPolynomialTools {
  129002. private static FileFaces;
  129003. /**
  129004. * Converts a texture to the according Spherical Polynomial data.
  129005. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129006. *
  129007. * @param texture The texture to extract the information from.
  129008. * @return The Spherical Polynomial data.
  129009. */
  129010. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129011. /**
  129012. * Converts a cubemap to the according Spherical Polynomial data.
  129013. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129014. *
  129015. * @param cubeInfo The Cube map to extract the information from.
  129016. * @return The Spherical Polynomial data.
  129017. */
  129018. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129019. }
  129020. }
  129021. declare module BABYLON {
  129022. interface BaseTexture {
  129023. /**
  129024. * Get the polynomial representation of the texture data.
  129025. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129026. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129027. */
  129028. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129029. }
  129030. }
  129031. declare module BABYLON {
  129032. /** @hidden */
  129033. export var rgbdEncodePixelShader: {
  129034. name: string;
  129035. shader: string;
  129036. };
  129037. }
  129038. declare module BABYLON {
  129039. /** @hidden */
  129040. export var rgbdDecodePixelShader: {
  129041. name: string;
  129042. shader: string;
  129043. };
  129044. }
  129045. declare module BABYLON {
  129046. /**
  129047. * Raw texture data and descriptor sufficient for WebGL texture upload
  129048. */
  129049. export interface EnvironmentTextureInfo {
  129050. /**
  129051. * Version of the environment map
  129052. */
  129053. version: number;
  129054. /**
  129055. * Width of image
  129056. */
  129057. width: number;
  129058. /**
  129059. * Irradiance information stored in the file.
  129060. */
  129061. irradiance: any;
  129062. /**
  129063. * Specular information stored in the file.
  129064. */
  129065. specular: any;
  129066. }
  129067. /**
  129068. * Defines One Image in the file. It requires only the position in the file
  129069. * as well as the length.
  129070. */
  129071. interface BufferImageData {
  129072. /**
  129073. * Length of the image data.
  129074. */
  129075. length: number;
  129076. /**
  129077. * Position of the data from the null terminator delimiting the end of the JSON.
  129078. */
  129079. position: number;
  129080. }
  129081. /**
  129082. * Defines the specular data enclosed in the file.
  129083. * This corresponds to the version 1 of the data.
  129084. */
  129085. export interface EnvironmentTextureSpecularInfoV1 {
  129086. /**
  129087. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129088. */
  129089. specularDataPosition?: number;
  129090. /**
  129091. * This contains all the images data needed to reconstruct the cubemap.
  129092. */
  129093. mipmaps: Array<BufferImageData>;
  129094. /**
  129095. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129096. */
  129097. lodGenerationScale: number;
  129098. }
  129099. /**
  129100. * Sets of helpers addressing the serialization and deserialization of environment texture
  129101. * stored in a BabylonJS env file.
  129102. * Those files are usually stored as .env files.
  129103. */
  129104. export class EnvironmentTextureTools {
  129105. /**
  129106. * Magic number identifying the env file.
  129107. */
  129108. private static _MagicBytes;
  129109. /**
  129110. * Gets the environment info from an env file.
  129111. * @param data The array buffer containing the .env bytes.
  129112. * @returns the environment file info (the json header) if successfully parsed.
  129113. */
  129114. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129115. /**
  129116. * Creates an environment texture from a loaded cube texture.
  129117. * @param texture defines the cube texture to convert in env file
  129118. * @return a promise containing the environment data if succesfull.
  129119. */
  129120. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129121. /**
  129122. * Creates a JSON representation of the spherical data.
  129123. * @param texture defines the texture containing the polynomials
  129124. * @return the JSON representation of the spherical info
  129125. */
  129126. private static _CreateEnvTextureIrradiance;
  129127. /**
  129128. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129129. * @param data the image data
  129130. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129131. * @return the views described by info providing access to the underlying buffer
  129132. */
  129133. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129134. /**
  129135. * Uploads the texture info contained in the env file to the GPU.
  129136. * @param texture defines the internal texture to upload to
  129137. * @param data defines the data to load
  129138. * @param info defines the texture info retrieved through the GetEnvInfo method
  129139. * @returns a promise
  129140. */
  129141. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129142. private static _OnImageReadyAsync;
  129143. /**
  129144. * Uploads the levels of image data to the GPU.
  129145. * @param texture defines the internal texture to upload to
  129146. * @param imageData defines the array buffer views of image data [mipmap][face]
  129147. * @returns a promise
  129148. */
  129149. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129150. /**
  129151. * Uploads spherical polynomials information to the texture.
  129152. * @param texture defines the texture we are trying to upload the information to
  129153. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129154. */
  129155. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129156. /** @hidden */
  129157. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129158. }
  129159. }
  129160. declare module BABYLON {
  129161. /** @hidden */
  129162. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  129163. private _genericAttributeLocation;
  129164. private _varyingLocationCount;
  129165. private _varyingLocationMap;
  129166. private _replacements;
  129167. private _textureCount;
  129168. private _uniforms;
  129169. lineProcessor(line: string): string;
  129170. attributeProcessor(attribute: string): string;
  129171. varyingProcessor(varying: string, isFragment: boolean): string;
  129172. uniformProcessor(uniform: string): string;
  129173. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  129174. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  129175. }
  129176. }
  129177. declare module BABYLON {
  129178. /**
  129179. * Class used to inline functions in shader code
  129180. */
  129181. export class ShaderCodeInliner {
  129182. private static readonly _RegexpFindFunctionNameAndType;
  129183. private _sourceCode;
  129184. private _functionDescr;
  129185. private _numMaxIterations;
  129186. /** Gets or sets the token used to mark the functions to inline */
  129187. inlineToken: string;
  129188. /** Gets or sets the debug mode */
  129189. debug: boolean;
  129190. /** Gets the code after the inlining process */
  129191. get code(): string;
  129192. /**
  129193. * Initializes the inliner
  129194. * @param sourceCode shader code source to inline
  129195. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129196. */
  129197. constructor(sourceCode: string, numMaxIterations?: number);
  129198. /**
  129199. * Start the processing of the shader code
  129200. */
  129201. processCode(): void;
  129202. private _collectFunctions;
  129203. private _processInlining;
  129204. private _extractBetweenMarkers;
  129205. private _skipWhitespaces;
  129206. private _removeComments;
  129207. private _replaceFunctionCallsByCode;
  129208. private _findBackward;
  129209. private _escapeRegExp;
  129210. private _replaceNames;
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * Container for accessors for natively-stored mesh data buffers.
  129216. */
  129217. class NativeDataBuffer extends DataBuffer {
  129218. /**
  129219. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129220. */
  129221. nativeIndexBuffer?: any;
  129222. /**
  129223. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129224. */
  129225. nativeVertexBuffer?: any;
  129226. }
  129227. /** @hidden */
  129228. class NativeTexture extends InternalTexture {
  129229. getInternalTexture(): InternalTexture;
  129230. getViewCount(): number;
  129231. }
  129232. /** @hidden */
  129233. export class NativeEngine extends Engine {
  129234. private readonly _native;
  129235. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129236. private readonly INVALID_HANDLE;
  129237. getHardwareScalingLevel(): number;
  129238. constructor();
  129239. dispose(): void;
  129240. /**
  129241. * Can be used to override the current requestAnimationFrame requester.
  129242. * @hidden
  129243. */
  129244. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129245. /**
  129246. * Override default engine behavior.
  129247. * @param color
  129248. * @param backBuffer
  129249. * @param depth
  129250. * @param stencil
  129251. */
  129252. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129253. /**
  129254. * Gets host document
  129255. * @returns the host document object
  129256. */
  129257. getHostDocument(): Nullable<Document>;
  129258. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129259. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129260. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129261. recordVertexArrayObject(vertexBuffers: {
  129262. [key: string]: VertexBuffer;
  129263. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129264. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129265. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129266. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129267. /**
  129268. * Draw a list of indexed primitives
  129269. * @param fillMode defines the primitive to use
  129270. * @param indexStart defines the starting index
  129271. * @param indexCount defines the number of index to draw
  129272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129273. */
  129274. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129275. /**
  129276. * Draw a list of unindexed primitives
  129277. * @param fillMode defines the primitive to use
  129278. * @param verticesStart defines the index of first vertex to draw
  129279. * @param verticesCount defines the count of vertices to draw
  129280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129281. */
  129282. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129283. createPipelineContext(): IPipelineContext;
  129284. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129285. /** @hidden */
  129286. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129287. /** @hidden */
  129288. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129289. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129290. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129291. protected _setProgram(program: WebGLProgram): void;
  129292. _releaseEffect(effect: Effect): void;
  129293. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129294. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129295. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129296. bindSamplers(effect: Effect): void;
  129297. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129298. getRenderWidth(useScreen?: boolean): number;
  129299. getRenderHeight(useScreen?: boolean): number;
  129300. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129301. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129302. /**
  129303. * Set the z offset to apply to current rendering
  129304. * @param value defines the offset to apply
  129305. */
  129306. setZOffset(value: number): void;
  129307. /**
  129308. * Gets the current value of the zOffset
  129309. * @returns the current zOffset state
  129310. */
  129311. getZOffset(): number;
  129312. /**
  129313. * Enable or disable depth buffering
  129314. * @param enable defines the state to set
  129315. */
  129316. setDepthBuffer(enable: boolean): void;
  129317. /**
  129318. * Gets a boolean indicating if depth writing is enabled
  129319. * @returns the current depth writing state
  129320. */
  129321. getDepthWrite(): boolean;
  129322. /**
  129323. * Enable or disable depth writing
  129324. * @param enable defines the state to set
  129325. */
  129326. setDepthWrite(enable: boolean): void;
  129327. /**
  129328. * Enable or disable color writing
  129329. * @param enable defines the state to set
  129330. */
  129331. setColorWrite(enable: boolean): void;
  129332. /**
  129333. * Gets a boolean indicating if color writing is enabled
  129334. * @returns the current color writing state
  129335. */
  129336. getColorWrite(): boolean;
  129337. /**
  129338. * Sets alpha constants used by some alpha blending modes
  129339. * @param r defines the red component
  129340. * @param g defines the green component
  129341. * @param b defines the blue component
  129342. * @param a defines the alpha component
  129343. */
  129344. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129345. /**
  129346. * Sets the current alpha mode
  129347. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129348. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129350. */
  129351. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129352. /**
  129353. * Gets the current alpha mode
  129354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129355. * @returns the current alpha mode
  129356. */
  129357. getAlphaMode(): number;
  129358. setInt(uniform: WebGLUniformLocation, int: number): void;
  129359. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129360. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129361. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129362. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129363. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129364. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129365. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129366. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129367. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129368. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129369. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129370. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129371. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129372. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129373. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129374. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129375. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129376. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129377. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129378. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129379. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129380. wipeCaches(bruteForce?: boolean): void;
  129381. _createTexture(): WebGLTexture;
  129382. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129383. /**
  129384. * Usually called from Texture.ts.
  129385. * Passed information to create a WebGLTexture
  129386. * @param url defines a value which contains one of the following:
  129387. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129388. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129389. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129391. * @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)
  129392. * @param scene needed for loading to the correct scene
  129393. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129394. * @param onLoad optional callback to be called upon successful completion
  129395. * @param onError optional callback to be called upon failure
  129396. * @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
  129397. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129398. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129399. * @param forcedExtension defines the extension to use to pick the right loader
  129400. * @param mimeType defines an optional mime type
  129401. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129402. */
  129403. 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;
  129404. /**
  129405. * Creates a cube texture
  129406. * @param rootUrl defines the url where the files to load is located
  129407. * @param scene defines the current scene
  129408. * @param files defines the list of files to load (1 per face)
  129409. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129410. * @param onLoad defines an optional callback raised when the texture is loaded
  129411. * @param onError defines an optional callback raised if there is an issue to load the texture
  129412. * @param format defines the format of the data
  129413. * @param forcedExtension defines the extension to use to pick the right loader
  129414. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129415. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129416. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129417. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129418. * @returns the cube texture as an InternalTexture
  129419. */
  129420. 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;
  129421. private _getSamplingFilter;
  129422. private static _GetNativeTextureFormat;
  129423. createRenderTargetTexture(size: number | {
  129424. width: number;
  129425. height: number;
  129426. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129427. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129428. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129429. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129430. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129431. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129432. /**
  129433. * Updates a dynamic vertex buffer.
  129434. * @param vertexBuffer the vertex buffer to update
  129435. * @param data the data used to update the vertex buffer
  129436. * @param byteOffset the byte offset of the data (optional)
  129437. * @param byteLength the byte length of the data (optional)
  129438. */
  129439. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129440. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129441. private _updateAnisotropicLevel;
  129442. private _getAddressMode;
  129443. /** @hidden */
  129444. _bindTexture(channel: number, texture: InternalTexture): void;
  129445. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129446. releaseEffects(): void;
  129447. /** @hidden */
  129448. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129449. /** @hidden */
  129450. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129451. /** @hidden */
  129452. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129453. /** @hidden */
  129454. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129455. }
  129456. }
  129457. declare module BABYLON {
  129458. /**
  129459. * Gather the list of clipboard event types as constants.
  129460. */
  129461. export class ClipboardEventTypes {
  129462. /**
  129463. * The clipboard event is fired when a copy command is active (pressed).
  129464. */
  129465. static readonly COPY: number;
  129466. /**
  129467. * The clipboard event is fired when a cut command is active (pressed).
  129468. */
  129469. static readonly CUT: number;
  129470. /**
  129471. * The clipboard event is fired when a paste command is active (pressed).
  129472. */
  129473. static readonly PASTE: number;
  129474. }
  129475. /**
  129476. * This class is used to store clipboard related info for the onClipboardObservable event.
  129477. */
  129478. export class ClipboardInfo {
  129479. /**
  129480. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129481. */
  129482. type: number;
  129483. /**
  129484. * Defines the related dom event
  129485. */
  129486. event: ClipboardEvent;
  129487. /**
  129488. *Creates an instance of ClipboardInfo.
  129489. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129490. * @param event Defines the related dom event
  129491. */
  129492. constructor(
  129493. /**
  129494. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129495. */
  129496. type: number,
  129497. /**
  129498. * Defines the related dom event
  129499. */
  129500. event: ClipboardEvent);
  129501. /**
  129502. * Get the clipboard event's type from the keycode.
  129503. * @param keyCode Defines the keyCode for the current keyboard event.
  129504. * @return {number}
  129505. */
  129506. static GetTypeFromCharacter(keyCode: number): number;
  129507. }
  129508. }
  129509. declare module BABYLON {
  129510. /**
  129511. * Google Daydream controller
  129512. */
  129513. export class DaydreamController extends WebVRController {
  129514. /**
  129515. * Base Url for the controller model.
  129516. */
  129517. static MODEL_BASE_URL: string;
  129518. /**
  129519. * File name for the controller model.
  129520. */
  129521. static MODEL_FILENAME: string;
  129522. /**
  129523. * Gamepad Id prefix used to identify Daydream Controller.
  129524. */
  129525. static readonly GAMEPAD_ID_PREFIX: string;
  129526. /**
  129527. * Creates a new DaydreamController from a gamepad
  129528. * @param vrGamepad the gamepad that the controller should be created from
  129529. */
  129530. constructor(vrGamepad: any);
  129531. /**
  129532. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129533. * @param scene scene in which to add meshes
  129534. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129535. */
  129536. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129537. /**
  129538. * Called once for each button that changed state since the last frame
  129539. * @param buttonIdx Which button index changed
  129540. * @param state New state of the button
  129541. * @param changes Which properties on the state changed since last frame
  129542. */
  129543. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129544. }
  129545. }
  129546. declare module BABYLON {
  129547. /**
  129548. * Gear VR Controller
  129549. */
  129550. export class GearVRController extends WebVRController {
  129551. /**
  129552. * Base Url for the controller model.
  129553. */
  129554. static MODEL_BASE_URL: string;
  129555. /**
  129556. * File name for the controller model.
  129557. */
  129558. static MODEL_FILENAME: string;
  129559. /**
  129560. * Gamepad Id prefix used to identify this controller.
  129561. */
  129562. static readonly GAMEPAD_ID_PREFIX: string;
  129563. private readonly _buttonIndexToObservableNameMap;
  129564. /**
  129565. * Creates a new GearVRController from a gamepad
  129566. * @param vrGamepad the gamepad that the controller should be created from
  129567. */
  129568. constructor(vrGamepad: any);
  129569. /**
  129570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129571. * @param scene scene in which to add meshes
  129572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129573. */
  129574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129575. /**
  129576. * Called once for each button that changed state since the last frame
  129577. * @param buttonIdx Which button index changed
  129578. * @param state New state of the button
  129579. * @param changes Which properties on the state changed since last frame
  129580. */
  129581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129582. }
  129583. }
  129584. declare module BABYLON {
  129585. /**
  129586. * Generic Controller
  129587. */
  129588. export class GenericController extends WebVRController {
  129589. /**
  129590. * Base Url for the controller model.
  129591. */
  129592. static readonly MODEL_BASE_URL: string;
  129593. /**
  129594. * File name for the controller model.
  129595. */
  129596. static readonly MODEL_FILENAME: string;
  129597. /**
  129598. * Creates a new GenericController from a gamepad
  129599. * @param vrGamepad the gamepad that the controller should be created from
  129600. */
  129601. constructor(vrGamepad: any);
  129602. /**
  129603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129604. * @param scene scene in which to add meshes
  129605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129606. */
  129607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129608. /**
  129609. * Called once for each button that changed state since the last frame
  129610. * @param buttonIdx Which button index changed
  129611. * @param state New state of the button
  129612. * @param changes Which properties on the state changed since last frame
  129613. */
  129614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129615. }
  129616. }
  129617. declare module BABYLON {
  129618. /**
  129619. * Oculus Touch Controller
  129620. */
  129621. export class OculusTouchController extends WebVRController {
  129622. /**
  129623. * Base Url for the controller model.
  129624. */
  129625. static MODEL_BASE_URL: string;
  129626. /**
  129627. * File name for the left controller model.
  129628. */
  129629. static MODEL_LEFT_FILENAME: string;
  129630. /**
  129631. * File name for the right controller model.
  129632. */
  129633. static MODEL_RIGHT_FILENAME: string;
  129634. /**
  129635. * Base Url for the Quest controller model.
  129636. */
  129637. static QUEST_MODEL_BASE_URL: string;
  129638. /**
  129639. * @hidden
  129640. * If the controllers are running on a device that needs the updated Quest controller models
  129641. */
  129642. static _IsQuest: boolean;
  129643. /**
  129644. * Fired when the secondary trigger on this controller is modified
  129645. */
  129646. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129647. /**
  129648. * Fired when the thumb rest on this controller is modified
  129649. */
  129650. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129651. /**
  129652. * Creates a new OculusTouchController from a gamepad
  129653. * @param vrGamepad the gamepad that the controller should be created from
  129654. */
  129655. constructor(vrGamepad: any);
  129656. /**
  129657. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129658. * @param scene scene in which to add meshes
  129659. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129660. */
  129661. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129662. /**
  129663. * Fired when the A button on this controller is modified
  129664. */
  129665. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129666. /**
  129667. * Fired when the B button on this controller is modified
  129668. */
  129669. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129670. /**
  129671. * Fired when the X button on this controller is modified
  129672. */
  129673. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129674. /**
  129675. * Fired when the Y button on this controller is modified
  129676. */
  129677. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129678. /**
  129679. * Called once for each button that changed state since the last frame
  129680. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129681. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129682. * 2) secondary trigger (same)
  129683. * 3) A (right) X (left), touch, pressed = value
  129684. * 4) B / Y
  129685. * 5) thumb rest
  129686. * @param buttonIdx Which button index changed
  129687. * @param state New state of the button
  129688. * @param changes Which properties on the state changed since last frame
  129689. */
  129690. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129691. }
  129692. }
  129693. declare module BABYLON {
  129694. /**
  129695. * Vive Controller
  129696. */
  129697. export class ViveController extends WebVRController {
  129698. /**
  129699. * Base Url for the controller model.
  129700. */
  129701. static MODEL_BASE_URL: string;
  129702. /**
  129703. * File name for the controller model.
  129704. */
  129705. static MODEL_FILENAME: string;
  129706. /**
  129707. * Creates a new ViveController from a gamepad
  129708. * @param vrGamepad the gamepad that the controller should be created from
  129709. */
  129710. constructor(vrGamepad: any);
  129711. /**
  129712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129713. * @param scene scene in which to add meshes
  129714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129715. */
  129716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129717. /**
  129718. * Fired when the left button on this controller is modified
  129719. */
  129720. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129721. /**
  129722. * Fired when the right button on this controller is modified
  129723. */
  129724. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129725. /**
  129726. * Fired when the menu button on this controller is modified
  129727. */
  129728. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129729. /**
  129730. * Called once for each button that changed state since the last frame
  129731. * Vive mapping:
  129732. * 0: touchpad
  129733. * 1: trigger
  129734. * 2: left AND right buttons
  129735. * 3: menu button
  129736. * @param buttonIdx Which button index changed
  129737. * @param state New state of the button
  129738. * @param changes Which properties on the state changed since last frame
  129739. */
  129740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129741. }
  129742. }
  129743. declare module BABYLON {
  129744. /**
  129745. * Defines the WindowsMotionController object that the state of the windows motion controller
  129746. */
  129747. export class WindowsMotionController extends WebVRController {
  129748. /**
  129749. * The base url used to load the left and right controller models
  129750. */
  129751. static MODEL_BASE_URL: string;
  129752. /**
  129753. * The name of the left controller model file
  129754. */
  129755. static MODEL_LEFT_FILENAME: string;
  129756. /**
  129757. * The name of the right controller model file
  129758. */
  129759. static MODEL_RIGHT_FILENAME: string;
  129760. /**
  129761. * The controller name prefix for this controller type
  129762. */
  129763. static readonly GAMEPAD_ID_PREFIX: string;
  129764. /**
  129765. * The controller id pattern for this controller type
  129766. */
  129767. private static readonly GAMEPAD_ID_PATTERN;
  129768. private _loadedMeshInfo;
  129769. protected readonly _mapping: {
  129770. buttons: string[];
  129771. buttonMeshNames: {
  129772. trigger: string;
  129773. menu: string;
  129774. grip: string;
  129775. thumbstick: string;
  129776. trackpad: string;
  129777. };
  129778. buttonObservableNames: {
  129779. trigger: string;
  129780. menu: string;
  129781. grip: string;
  129782. thumbstick: string;
  129783. trackpad: string;
  129784. };
  129785. axisMeshNames: string[];
  129786. pointingPoseMeshName: string;
  129787. };
  129788. /**
  129789. * Fired when the trackpad on this controller is clicked
  129790. */
  129791. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129792. /**
  129793. * Fired when the trackpad on this controller is modified
  129794. */
  129795. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129796. /**
  129797. * The current x and y values of this controller's trackpad
  129798. */
  129799. trackpad: StickValues;
  129800. /**
  129801. * Creates a new WindowsMotionController from a gamepad
  129802. * @param vrGamepad the gamepad that the controller should be created from
  129803. */
  129804. constructor(vrGamepad: any);
  129805. /**
  129806. * Fired when the trigger on this controller is modified
  129807. */
  129808. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129809. /**
  129810. * Fired when the menu button on this controller is modified
  129811. */
  129812. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129813. /**
  129814. * Fired when the grip button on this controller is modified
  129815. */
  129816. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129817. /**
  129818. * Fired when the thumbstick button on this controller is modified
  129819. */
  129820. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129821. /**
  129822. * Fired when the touchpad button on this controller is modified
  129823. */
  129824. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129825. /**
  129826. * Fired when the touchpad values on this controller are modified
  129827. */
  129828. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129829. protected _updateTrackpad(): void;
  129830. /**
  129831. * Called once per frame by the engine.
  129832. */
  129833. update(): void;
  129834. /**
  129835. * Called once for each button that changed state since the last frame
  129836. * @param buttonIdx Which button index changed
  129837. * @param state New state of the button
  129838. * @param changes Which properties on the state changed since last frame
  129839. */
  129840. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129841. /**
  129842. * Moves the buttons on the controller mesh based on their current state
  129843. * @param buttonName the name of the button to move
  129844. * @param buttonValue the value of the button which determines the buttons new position
  129845. */
  129846. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129847. /**
  129848. * Moves the axis on the controller mesh based on its current state
  129849. * @param axis the index of the axis
  129850. * @param axisValue the value of the axis which determines the meshes new position
  129851. * @hidden
  129852. */
  129853. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129854. /**
  129855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129856. * @param scene scene in which to add meshes
  129857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129858. */
  129859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129860. /**
  129861. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129862. * can be transformed by button presses and axes values, based on this._mapping.
  129863. *
  129864. * @param scene scene in which the meshes exist
  129865. * @param meshes list of meshes that make up the controller model to process
  129866. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129867. */
  129868. private processModel;
  129869. private createMeshInfo;
  129870. /**
  129871. * Gets the ray of the controller in the direction the controller is pointing
  129872. * @param length the length the resulting ray should be
  129873. * @returns a ray in the direction the controller is pointing
  129874. */
  129875. getForwardRay(length?: number): Ray;
  129876. /**
  129877. * Disposes of the controller
  129878. */
  129879. dispose(): void;
  129880. }
  129881. /**
  129882. * This class represents a new windows motion controller in XR.
  129883. */
  129884. export class XRWindowsMotionController extends WindowsMotionController {
  129885. /**
  129886. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129887. */
  129888. protected readonly _mapping: {
  129889. buttons: string[];
  129890. buttonMeshNames: {
  129891. trigger: string;
  129892. menu: string;
  129893. grip: string;
  129894. thumbstick: string;
  129895. trackpad: string;
  129896. };
  129897. buttonObservableNames: {
  129898. trigger: string;
  129899. menu: string;
  129900. grip: string;
  129901. thumbstick: string;
  129902. trackpad: string;
  129903. };
  129904. axisMeshNames: string[];
  129905. pointingPoseMeshName: string;
  129906. };
  129907. /**
  129908. * Construct a new XR-Based windows motion controller
  129909. *
  129910. * @param gamepadInfo the gamepad object from the browser
  129911. */
  129912. constructor(gamepadInfo: any);
  129913. /**
  129914. * holds the thumbstick values (X,Y)
  129915. */
  129916. thumbstickValues: StickValues;
  129917. /**
  129918. * Fired when the thumbstick on this controller is clicked
  129919. */
  129920. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129921. /**
  129922. * Fired when the thumbstick on this controller is modified
  129923. */
  129924. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129925. /**
  129926. * Fired when the touchpad button on this controller is modified
  129927. */
  129928. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129929. /**
  129930. * Fired when the touchpad values on this controller are modified
  129931. */
  129932. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129933. /**
  129934. * Fired when the thumbstick button on this controller is modified
  129935. * here to prevent breaking changes
  129936. */
  129937. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129938. /**
  129939. * updating the thumbstick(!) and not the trackpad.
  129940. * This is named this way due to the difference between WebVR and XR and to avoid
  129941. * changing the parent class.
  129942. */
  129943. protected _updateTrackpad(): void;
  129944. /**
  129945. * Disposes the class with joy
  129946. */
  129947. dispose(): void;
  129948. }
  129949. }
  129950. declare module BABYLON {
  129951. /**
  129952. * Class containing static functions to help procedurally build meshes
  129953. */
  129954. export class PolyhedronBuilder {
  129955. /**
  129956. * Creates a polyhedron mesh
  129957. * * 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
  129958. * * The parameter `size` (positive float, default 1) sets the polygon size
  129959. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129960. * * 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`
  129961. * * 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
  129962. * * 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)`)
  129963. * * 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
  129964. * * 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
  129965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129968. * @param name defines the name of the mesh
  129969. * @param options defines the options used to create the mesh
  129970. * @param scene defines the hosting scene
  129971. * @returns the polyhedron mesh
  129972. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129973. */
  129974. static CreatePolyhedron(name: string, options: {
  129975. type?: number;
  129976. size?: number;
  129977. sizeX?: number;
  129978. sizeY?: number;
  129979. sizeZ?: number;
  129980. custom?: any;
  129981. faceUV?: Vector4[];
  129982. faceColors?: Color4[];
  129983. flat?: boolean;
  129984. updatable?: boolean;
  129985. sideOrientation?: number;
  129986. frontUVs?: Vector4;
  129987. backUVs?: Vector4;
  129988. }, scene?: Nullable<Scene>): Mesh;
  129989. }
  129990. }
  129991. declare module BABYLON {
  129992. /**
  129993. * Gizmo that enables scaling a mesh along 3 axis
  129994. */
  129995. export class ScaleGizmo extends Gizmo {
  129996. /**
  129997. * Internal gizmo used for interactions on the x axis
  129998. */
  129999. xGizmo: AxisScaleGizmo;
  130000. /**
  130001. * Internal gizmo used for interactions on the y axis
  130002. */
  130003. yGizmo: AxisScaleGizmo;
  130004. /**
  130005. * Internal gizmo used for interactions on the z axis
  130006. */
  130007. zGizmo: AxisScaleGizmo;
  130008. /**
  130009. * Internal gizmo used to scale all axis equally
  130010. */
  130011. uniformScaleGizmo: AxisScaleGizmo;
  130012. private _meshAttached;
  130013. private _updateGizmoRotationToMatchAttachedMesh;
  130014. private _snapDistance;
  130015. private _scaleRatio;
  130016. private _uniformScalingMesh;
  130017. private _octahedron;
  130018. private _sensitivity;
  130019. /** Fires an event when any of it's sub gizmos are dragged */
  130020. onDragStartObservable: Observable<unknown>;
  130021. /** Fires an event when any of it's sub gizmos are released from dragging */
  130022. onDragEndObservable: Observable<unknown>;
  130023. get attachedMesh(): Nullable<AbstractMesh>;
  130024. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130025. /**
  130026. * Creates a ScaleGizmo
  130027. * @param gizmoLayer The utility layer the gizmo will be added to
  130028. */
  130029. constructor(gizmoLayer?: UtilityLayerRenderer);
  130030. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130031. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130032. /**
  130033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130034. */
  130035. set snapDistance(value: number);
  130036. get snapDistance(): number;
  130037. /**
  130038. * Ratio for the scale of the gizmo (Default: 1)
  130039. */
  130040. set scaleRatio(value: number);
  130041. get scaleRatio(): number;
  130042. /**
  130043. * Sensitivity factor for dragging (Default: 1)
  130044. */
  130045. set sensitivity(value: number);
  130046. get sensitivity(): number;
  130047. /**
  130048. * Disposes of the gizmo
  130049. */
  130050. dispose(): void;
  130051. }
  130052. }
  130053. declare module BABYLON {
  130054. /**
  130055. * Single axis scale gizmo
  130056. */
  130057. export class AxisScaleGizmo extends Gizmo {
  130058. /**
  130059. * Drag behavior responsible for the gizmos dragging interactions
  130060. */
  130061. dragBehavior: PointerDragBehavior;
  130062. private _pointerObserver;
  130063. /**
  130064. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130065. */
  130066. snapDistance: number;
  130067. /**
  130068. * Event that fires each time the gizmo snaps to a new location.
  130069. * * snapDistance is the the change in distance
  130070. */
  130071. onSnapObservable: Observable<{
  130072. snapDistance: number;
  130073. }>;
  130074. /**
  130075. * If the scaling operation should be done on all axis (default: false)
  130076. */
  130077. uniformScaling: boolean;
  130078. /**
  130079. * Custom sensitivity value for the drag strength
  130080. */
  130081. sensitivity: number;
  130082. private _isEnabled;
  130083. private _parent;
  130084. private _arrow;
  130085. private _coloredMaterial;
  130086. private _hoverMaterial;
  130087. /**
  130088. * Creates an AxisScaleGizmo
  130089. * @param gizmoLayer The utility layer the gizmo will be added to
  130090. * @param dragAxis The axis which the gizmo will be able to scale on
  130091. * @param color The color of the gizmo
  130092. */
  130093. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130095. /**
  130096. * If the gizmo is enabled
  130097. */
  130098. set isEnabled(value: boolean);
  130099. get isEnabled(): boolean;
  130100. /**
  130101. * Disposes of the gizmo
  130102. */
  130103. dispose(): void;
  130104. /**
  130105. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130106. * @param mesh The mesh to replace the default mesh of the gizmo
  130107. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130108. */
  130109. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130110. }
  130111. }
  130112. declare module BABYLON {
  130113. /**
  130114. * Bounding box gizmo
  130115. */
  130116. export class BoundingBoxGizmo extends Gizmo {
  130117. private _lineBoundingBox;
  130118. private _rotateSpheresParent;
  130119. private _scaleBoxesParent;
  130120. private _boundingDimensions;
  130121. private _renderObserver;
  130122. private _pointerObserver;
  130123. private _scaleDragSpeed;
  130124. private _tmpQuaternion;
  130125. private _tmpVector;
  130126. private _tmpRotationMatrix;
  130127. /**
  130128. * 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)
  130129. */
  130130. ignoreChildren: boolean;
  130131. /**
  130132. * 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)
  130133. */
  130134. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130135. /**
  130136. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130137. */
  130138. rotationSphereSize: number;
  130139. /**
  130140. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130141. */
  130142. scaleBoxSize: number;
  130143. /**
  130144. * 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)
  130145. */
  130146. fixedDragMeshScreenSize: boolean;
  130147. /**
  130148. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130149. */
  130150. fixedDragMeshScreenSizeDistanceFactor: number;
  130151. /**
  130152. * Fired when a rotation sphere or scale box is dragged
  130153. */
  130154. onDragStartObservable: Observable<{}>;
  130155. /**
  130156. * Fired when a scale box is dragged
  130157. */
  130158. onScaleBoxDragObservable: Observable<{}>;
  130159. /**
  130160. * Fired when a scale box drag is ended
  130161. */
  130162. onScaleBoxDragEndObservable: Observable<{}>;
  130163. /**
  130164. * Fired when a rotation sphere is dragged
  130165. */
  130166. onRotationSphereDragObservable: Observable<{}>;
  130167. /**
  130168. * Fired when a rotation sphere drag is ended
  130169. */
  130170. onRotationSphereDragEndObservable: Observable<{}>;
  130171. /**
  130172. * Relative bounding box pivot used when scaling the attached mesh. 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)
  130173. */
  130174. scalePivot: Nullable<Vector3>;
  130175. /**
  130176. * Mesh used as a pivot to rotate the attached mesh
  130177. */
  130178. private _anchorMesh;
  130179. private _existingMeshScale;
  130180. private _dragMesh;
  130181. private pointerDragBehavior;
  130182. private coloredMaterial;
  130183. private hoverColoredMaterial;
  130184. /**
  130185. * Sets the color of the bounding box gizmo
  130186. * @param color the color to set
  130187. */
  130188. setColor(color: Color3): void;
  130189. /**
  130190. * Creates an BoundingBoxGizmo
  130191. * @param gizmoLayer The utility layer the gizmo will be added to
  130192. * @param color The color of the gizmo
  130193. */
  130194. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130195. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130196. private _selectNode;
  130197. /**
  130198. * Updates the bounding box information for the Gizmo
  130199. */
  130200. updateBoundingBox(): void;
  130201. private _updateRotationSpheres;
  130202. private _updateScaleBoxes;
  130203. /**
  130204. * Enables rotation on the specified axis and disables rotation on the others
  130205. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130206. */
  130207. setEnabledRotationAxis(axis: string): void;
  130208. /**
  130209. * Enables/disables scaling
  130210. * @param enable if scaling should be enabled
  130211. * @param homogeneousScaling defines if scaling should only be homogeneous
  130212. */
  130213. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130214. private _updateDummy;
  130215. /**
  130216. * Enables a pointer drag behavior on the bounding box of the gizmo
  130217. */
  130218. enableDragBehavior(): void;
  130219. /**
  130220. * Disposes of the gizmo
  130221. */
  130222. dispose(): void;
  130223. /**
  130224. * 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)
  130225. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130226. * @returns the bounding box mesh with the passed in mesh as a child
  130227. */
  130228. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130229. /**
  130230. * CustomMeshes are not supported by this gizmo
  130231. * @param mesh The mesh to replace the default mesh of the gizmo
  130232. */
  130233. setCustomMesh(mesh: Mesh): void;
  130234. }
  130235. }
  130236. declare module BABYLON {
  130237. /**
  130238. * Single plane rotation gizmo
  130239. */
  130240. export class PlaneRotationGizmo extends Gizmo {
  130241. /**
  130242. * Drag behavior responsible for the gizmos dragging interactions
  130243. */
  130244. dragBehavior: PointerDragBehavior;
  130245. private _pointerObserver;
  130246. /**
  130247. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130248. */
  130249. snapDistance: number;
  130250. /**
  130251. * Event that fires each time the gizmo snaps to a new location.
  130252. * * snapDistance is the the change in distance
  130253. */
  130254. onSnapObservable: Observable<{
  130255. snapDistance: number;
  130256. }>;
  130257. private _isEnabled;
  130258. private _parent;
  130259. /**
  130260. * Creates a PlaneRotationGizmo
  130261. * @param gizmoLayer The utility layer the gizmo will be added to
  130262. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130263. * @param color The color of the gizmo
  130264. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130265. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130266. */
  130267. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130269. /**
  130270. * If the gizmo is enabled
  130271. */
  130272. set isEnabled(value: boolean);
  130273. get isEnabled(): boolean;
  130274. /**
  130275. * Disposes of the gizmo
  130276. */
  130277. dispose(): void;
  130278. }
  130279. }
  130280. declare module BABYLON {
  130281. /**
  130282. * Gizmo that enables rotating a mesh along 3 axis
  130283. */
  130284. export class RotationGizmo extends Gizmo {
  130285. /**
  130286. * Internal gizmo used for interactions on the x axis
  130287. */
  130288. xGizmo: PlaneRotationGizmo;
  130289. /**
  130290. * Internal gizmo used for interactions on the y axis
  130291. */
  130292. yGizmo: PlaneRotationGizmo;
  130293. /**
  130294. * Internal gizmo used for interactions on the z axis
  130295. */
  130296. zGizmo: PlaneRotationGizmo;
  130297. /** Fires an event when any of it's sub gizmos are dragged */
  130298. onDragStartObservable: Observable<unknown>;
  130299. /** Fires an event when any of it's sub gizmos are released from dragging */
  130300. onDragEndObservable: Observable<unknown>;
  130301. private _meshAttached;
  130302. get attachedMesh(): Nullable<AbstractMesh>;
  130303. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130304. /**
  130305. * Creates a RotationGizmo
  130306. * @param gizmoLayer The utility layer the gizmo will be added to
  130307. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130308. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130309. */
  130310. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130311. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130312. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130313. /**
  130314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130315. */
  130316. set snapDistance(value: number);
  130317. get snapDistance(): number;
  130318. /**
  130319. * Ratio for the scale of the gizmo (Default: 1)
  130320. */
  130321. set scaleRatio(value: number);
  130322. get scaleRatio(): number;
  130323. /**
  130324. * Disposes of the gizmo
  130325. */
  130326. dispose(): void;
  130327. /**
  130328. * CustomMeshes are not supported by this gizmo
  130329. * @param mesh The mesh to replace the default mesh of the gizmo
  130330. */
  130331. setCustomMesh(mesh: Mesh): void;
  130332. }
  130333. }
  130334. declare module BABYLON {
  130335. /**
  130336. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130337. */
  130338. export class GizmoManager implements IDisposable {
  130339. private scene;
  130340. /**
  130341. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130342. */
  130343. gizmos: {
  130344. positionGizmo: Nullable<PositionGizmo>;
  130345. rotationGizmo: Nullable<RotationGizmo>;
  130346. scaleGizmo: Nullable<ScaleGizmo>;
  130347. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130348. };
  130349. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130350. clearGizmoOnEmptyPointerEvent: boolean;
  130351. /** Fires an event when the manager is attached to a mesh */
  130352. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130353. private _gizmosEnabled;
  130354. private _pointerObserver;
  130355. private _attachedMesh;
  130356. private _boundingBoxColor;
  130357. private _defaultUtilityLayer;
  130358. private _defaultKeepDepthUtilityLayer;
  130359. /**
  130360. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130361. */
  130362. boundingBoxDragBehavior: SixDofDragBehavior;
  130363. /**
  130364. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130365. */
  130366. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130367. /**
  130368. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130369. */
  130370. usePointerToAttachGizmos: boolean;
  130371. /**
  130372. * Utility layer that the bounding box gizmo belongs to
  130373. */
  130374. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130375. /**
  130376. * Utility layer that all gizmos besides bounding box belong to
  130377. */
  130378. get utilityLayer(): UtilityLayerRenderer;
  130379. /**
  130380. * Instatiates a gizmo manager
  130381. * @param scene the scene to overlay the gizmos on top of
  130382. */
  130383. constructor(scene: Scene);
  130384. /**
  130385. * Attaches a set of gizmos to the specified mesh
  130386. * @param mesh The mesh the gizmo's should be attached to
  130387. */
  130388. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130389. /**
  130390. * If the position gizmo is enabled
  130391. */
  130392. set positionGizmoEnabled(value: boolean);
  130393. get positionGizmoEnabled(): boolean;
  130394. /**
  130395. * If the rotation gizmo is enabled
  130396. */
  130397. set rotationGizmoEnabled(value: boolean);
  130398. get rotationGizmoEnabled(): boolean;
  130399. /**
  130400. * If the scale gizmo is enabled
  130401. */
  130402. set scaleGizmoEnabled(value: boolean);
  130403. get scaleGizmoEnabled(): boolean;
  130404. /**
  130405. * If the boundingBox gizmo is enabled
  130406. */
  130407. set boundingBoxGizmoEnabled(value: boolean);
  130408. get boundingBoxGizmoEnabled(): boolean;
  130409. /**
  130410. * Disposes of the gizmo manager
  130411. */
  130412. dispose(): void;
  130413. }
  130414. }
  130415. declare module BABYLON {
  130416. /**
  130417. * A directional light is defined by a direction (what a surprise!).
  130418. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130419. * 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.
  130420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130421. */
  130422. export class DirectionalLight extends ShadowLight {
  130423. private _shadowFrustumSize;
  130424. /**
  130425. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130426. */
  130427. get shadowFrustumSize(): number;
  130428. /**
  130429. * Specifies a fix frustum size for the shadow generation.
  130430. */
  130431. set shadowFrustumSize(value: number);
  130432. private _shadowOrthoScale;
  130433. /**
  130434. * Gets the shadow projection scale against the optimal computed one.
  130435. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130436. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130437. */
  130438. get shadowOrthoScale(): number;
  130439. /**
  130440. * Sets the shadow projection scale against the optimal computed one.
  130441. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130442. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130443. */
  130444. set shadowOrthoScale(value: number);
  130445. /**
  130446. * Automatically compute the projection matrix to best fit (including all the casters)
  130447. * on each frame.
  130448. */
  130449. autoUpdateExtends: boolean;
  130450. /**
  130451. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130452. * on each frame. autoUpdateExtends must be set to true for this to work
  130453. */
  130454. autoCalcShadowZBounds: boolean;
  130455. private _orthoLeft;
  130456. private _orthoRight;
  130457. private _orthoTop;
  130458. private _orthoBottom;
  130459. /**
  130460. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130461. * The directional light is emitted from everywhere in the given direction.
  130462. * It can cast shadows.
  130463. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130464. * @param name The friendly name of the light
  130465. * @param direction The direction of the light
  130466. * @param scene The scene the light belongs to
  130467. */
  130468. constructor(name: string, direction: Vector3, scene: Scene);
  130469. /**
  130470. * Returns the string "DirectionalLight".
  130471. * @return The class name
  130472. */
  130473. getClassName(): string;
  130474. /**
  130475. * Returns the integer 1.
  130476. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130477. */
  130478. getTypeID(): number;
  130479. /**
  130480. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130481. * Returns the DirectionalLight Shadow projection matrix.
  130482. */
  130483. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130484. /**
  130485. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130486. * Returns the DirectionalLight Shadow projection matrix.
  130487. */
  130488. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130489. /**
  130490. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130491. * Returns the DirectionalLight Shadow projection matrix.
  130492. */
  130493. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130494. protected _buildUniformLayout(): void;
  130495. /**
  130496. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130497. * @param effect The effect to update
  130498. * @param lightIndex The index of the light in the effect to update
  130499. * @returns The directional light
  130500. */
  130501. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130502. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130503. /**
  130504. * Gets the minZ used for shadow according to both the scene and the light.
  130505. *
  130506. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130507. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130508. * @param activeCamera The camera we are returning the min for
  130509. * @returns the depth min z
  130510. */
  130511. getDepthMinZ(activeCamera: Camera): number;
  130512. /**
  130513. * Gets the maxZ used for shadow according to both the scene and the light.
  130514. *
  130515. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130516. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130517. * @param activeCamera The camera we are returning the max for
  130518. * @returns the depth max z
  130519. */
  130520. getDepthMaxZ(activeCamera: Camera): number;
  130521. /**
  130522. * Prepares the list of defines specific to the light type.
  130523. * @param defines the list of defines
  130524. * @param lightIndex defines the index of the light for the effect
  130525. */
  130526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130527. }
  130528. }
  130529. declare module BABYLON {
  130530. /**
  130531. * Class containing static functions to help procedurally build meshes
  130532. */
  130533. export class HemisphereBuilder {
  130534. /**
  130535. * Creates a hemisphere mesh
  130536. * @param name defines the name of the mesh
  130537. * @param options defines the options used to create the mesh
  130538. * @param scene defines the hosting scene
  130539. * @returns the hemisphere mesh
  130540. */
  130541. static CreateHemisphere(name: string, options: {
  130542. segments?: number;
  130543. diameter?: number;
  130544. sideOrientation?: number;
  130545. }, scene: any): Mesh;
  130546. }
  130547. }
  130548. declare module BABYLON {
  130549. /**
  130550. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130551. * These values define a cone of light starting from the position, emitting toward the direction.
  130552. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130553. * and the exponent defines the speed of the decay of the light with distance (reach).
  130554. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130555. */
  130556. export class SpotLight extends ShadowLight {
  130557. private _angle;
  130558. private _innerAngle;
  130559. private _cosHalfAngle;
  130560. private _lightAngleScale;
  130561. private _lightAngleOffset;
  130562. /**
  130563. * Gets the cone angle of the spot light in Radians.
  130564. */
  130565. get angle(): number;
  130566. /**
  130567. * Sets the cone angle of the spot light in Radians.
  130568. */
  130569. set angle(value: number);
  130570. /**
  130571. * Only used in gltf falloff mode, this defines the angle where
  130572. * the directional falloff will start before cutting at angle which could be seen
  130573. * as outer angle.
  130574. */
  130575. get innerAngle(): number;
  130576. /**
  130577. * Only used in gltf falloff mode, this defines the angle where
  130578. * the directional falloff will start before cutting at angle which could be seen
  130579. * as outer angle.
  130580. */
  130581. set innerAngle(value: number);
  130582. private _shadowAngleScale;
  130583. /**
  130584. * Allows scaling the angle of the light for shadow generation only.
  130585. */
  130586. get shadowAngleScale(): number;
  130587. /**
  130588. * Allows scaling the angle of the light for shadow generation only.
  130589. */
  130590. set shadowAngleScale(value: number);
  130591. /**
  130592. * The light decay speed with the distance from the emission spot.
  130593. */
  130594. exponent: number;
  130595. private _projectionTextureMatrix;
  130596. /**
  130597. * Allows reading the projecton texture
  130598. */
  130599. get projectionTextureMatrix(): Matrix;
  130600. protected _projectionTextureLightNear: number;
  130601. /**
  130602. * Gets the near clip of the Spotlight for texture projection.
  130603. */
  130604. get projectionTextureLightNear(): number;
  130605. /**
  130606. * Sets the near clip of the Spotlight for texture projection.
  130607. */
  130608. set projectionTextureLightNear(value: number);
  130609. protected _projectionTextureLightFar: number;
  130610. /**
  130611. * Gets the far clip of the Spotlight for texture projection.
  130612. */
  130613. get projectionTextureLightFar(): number;
  130614. /**
  130615. * Sets the far clip of the Spotlight for texture projection.
  130616. */
  130617. set projectionTextureLightFar(value: number);
  130618. protected _projectionTextureUpDirection: Vector3;
  130619. /**
  130620. * Gets the Up vector of the Spotlight for texture projection.
  130621. */
  130622. get projectionTextureUpDirection(): Vector3;
  130623. /**
  130624. * Sets the Up vector of the Spotlight for texture projection.
  130625. */
  130626. set projectionTextureUpDirection(value: Vector3);
  130627. private _projectionTexture;
  130628. /**
  130629. * Gets the projection texture of the light.
  130630. */
  130631. get projectionTexture(): Nullable<BaseTexture>;
  130632. /**
  130633. * Sets the projection texture of the light.
  130634. */
  130635. set projectionTexture(value: Nullable<BaseTexture>);
  130636. private _projectionTextureViewLightDirty;
  130637. private _projectionTextureProjectionLightDirty;
  130638. private _projectionTextureDirty;
  130639. private _projectionTextureViewTargetVector;
  130640. private _projectionTextureViewLightMatrix;
  130641. private _projectionTextureProjectionLightMatrix;
  130642. private _projectionTextureScalingMatrix;
  130643. /**
  130644. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130645. * It can cast shadows.
  130646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130647. * @param name The light friendly name
  130648. * @param position The position of the spot light in the scene
  130649. * @param direction The direction of the light in the scene
  130650. * @param angle The cone angle of the light in Radians
  130651. * @param exponent The light decay speed with the distance from the emission spot
  130652. * @param scene The scene the lights belongs to
  130653. */
  130654. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130655. /**
  130656. * Returns the string "SpotLight".
  130657. * @returns the class name
  130658. */
  130659. getClassName(): string;
  130660. /**
  130661. * Returns the integer 2.
  130662. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130663. */
  130664. getTypeID(): number;
  130665. /**
  130666. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130667. */
  130668. protected _setDirection(value: Vector3): void;
  130669. /**
  130670. * Overrides the position setter to recompute the projection texture view light Matrix.
  130671. */
  130672. protected _setPosition(value: Vector3): void;
  130673. /**
  130674. * 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.
  130675. * Returns the SpotLight.
  130676. */
  130677. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130678. protected _computeProjectionTextureViewLightMatrix(): void;
  130679. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130680. /**
  130681. * Main function for light texture projection matrix computing.
  130682. */
  130683. protected _computeProjectionTextureMatrix(): void;
  130684. protected _buildUniformLayout(): void;
  130685. private _computeAngleValues;
  130686. /**
  130687. * Sets the passed Effect "effect" with the Light textures.
  130688. * @param effect The effect to update
  130689. * @param lightIndex The index of the light in the effect to update
  130690. * @returns The light
  130691. */
  130692. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130693. /**
  130694. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130695. * @param effect The effect to update
  130696. * @param lightIndex The index of the light in the effect to update
  130697. * @returns The spot light
  130698. */
  130699. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130700. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130701. /**
  130702. * Disposes the light and the associated resources.
  130703. */
  130704. dispose(): void;
  130705. /**
  130706. * Prepares the list of defines specific to the light type.
  130707. * @param defines the list of defines
  130708. * @param lightIndex defines the index of the light for the effect
  130709. */
  130710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130711. }
  130712. }
  130713. declare module BABYLON {
  130714. /**
  130715. * Gizmo that enables viewing a light
  130716. */
  130717. export class LightGizmo extends Gizmo {
  130718. private _lightMesh;
  130719. private _material;
  130720. private _cachedPosition;
  130721. private _cachedForward;
  130722. private _attachedMeshParent;
  130723. /**
  130724. * Creates a LightGizmo
  130725. * @param gizmoLayer The utility layer the gizmo will be added to
  130726. */
  130727. constructor(gizmoLayer?: UtilityLayerRenderer);
  130728. private _light;
  130729. /**
  130730. * The light that the gizmo is attached to
  130731. */
  130732. set light(light: Nullable<Light>);
  130733. get light(): Nullable<Light>;
  130734. /**
  130735. * Gets the material used to render the light gizmo
  130736. */
  130737. get material(): StandardMaterial;
  130738. /**
  130739. * @hidden
  130740. * Updates the gizmo to match the attached mesh's position/rotation
  130741. */
  130742. protected _update(): void;
  130743. private static _Scale;
  130744. /**
  130745. * Creates the lines for a light mesh
  130746. */
  130747. private static _CreateLightLines;
  130748. /**
  130749. * Disposes of the light gizmo
  130750. */
  130751. dispose(): void;
  130752. private static _CreateHemisphericLightMesh;
  130753. private static _CreatePointLightMesh;
  130754. private static _CreateSpotLightMesh;
  130755. private static _CreateDirectionalLightMesh;
  130756. }
  130757. }
  130758. declare module BABYLON {
  130759. /** @hidden */
  130760. export var backgroundFragmentDeclaration: {
  130761. name: string;
  130762. shader: string;
  130763. };
  130764. }
  130765. declare module BABYLON {
  130766. /** @hidden */
  130767. export var backgroundUboDeclaration: {
  130768. name: string;
  130769. shader: string;
  130770. };
  130771. }
  130772. declare module BABYLON {
  130773. /** @hidden */
  130774. export var backgroundPixelShader: {
  130775. name: string;
  130776. shader: string;
  130777. };
  130778. }
  130779. declare module BABYLON {
  130780. /** @hidden */
  130781. export var backgroundVertexDeclaration: {
  130782. name: string;
  130783. shader: string;
  130784. };
  130785. }
  130786. declare module BABYLON {
  130787. /** @hidden */
  130788. export var backgroundVertexShader: {
  130789. name: string;
  130790. shader: string;
  130791. };
  130792. }
  130793. declare module BABYLON {
  130794. /**
  130795. * Background material used to create an efficient environement around your scene.
  130796. */
  130797. export class BackgroundMaterial extends PushMaterial {
  130798. /**
  130799. * Standard reflectance value at parallel view angle.
  130800. */
  130801. static StandardReflectance0: number;
  130802. /**
  130803. * Standard reflectance value at grazing angle.
  130804. */
  130805. static StandardReflectance90: number;
  130806. protected _primaryColor: Color3;
  130807. /**
  130808. * Key light Color (multiply against the environement texture)
  130809. */
  130810. primaryColor: Color3;
  130811. protected __perceptualColor: Nullable<Color3>;
  130812. /**
  130813. * Experimental Internal Use Only.
  130814. *
  130815. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130816. * This acts as a helper to set the primary color to a more "human friendly" value.
  130817. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130818. * output color as close as possible from the chosen value.
  130819. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130820. * part of lighting setup.)
  130821. */
  130822. get _perceptualColor(): Nullable<Color3>;
  130823. set _perceptualColor(value: Nullable<Color3>);
  130824. protected _primaryColorShadowLevel: float;
  130825. /**
  130826. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130827. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130828. */
  130829. get primaryColorShadowLevel(): float;
  130830. set primaryColorShadowLevel(value: float);
  130831. protected _primaryColorHighlightLevel: float;
  130832. /**
  130833. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130834. * The primary color is used at the level chosen to define what the white area would look.
  130835. */
  130836. get primaryColorHighlightLevel(): float;
  130837. set primaryColorHighlightLevel(value: float);
  130838. protected _reflectionTexture: Nullable<BaseTexture>;
  130839. /**
  130840. * Reflection Texture used in the material.
  130841. * Should be author in a specific way for the best result (refer to the documentation).
  130842. */
  130843. reflectionTexture: Nullable<BaseTexture>;
  130844. protected _reflectionBlur: float;
  130845. /**
  130846. * Reflection Texture level of blur.
  130847. *
  130848. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130849. * texture twice.
  130850. */
  130851. reflectionBlur: float;
  130852. protected _diffuseTexture: Nullable<BaseTexture>;
  130853. /**
  130854. * Diffuse Texture used in the material.
  130855. * Should be author in a specific way for the best result (refer to the documentation).
  130856. */
  130857. diffuseTexture: Nullable<BaseTexture>;
  130858. protected _shadowLights: Nullable<IShadowLight[]>;
  130859. /**
  130860. * Specify the list of lights casting shadow on the material.
  130861. * All scene shadow lights will be included if null.
  130862. */
  130863. shadowLights: Nullable<IShadowLight[]>;
  130864. protected _shadowLevel: float;
  130865. /**
  130866. * Helps adjusting the shadow to a softer level if required.
  130867. * 0 means black shadows and 1 means no shadows.
  130868. */
  130869. shadowLevel: float;
  130870. protected _sceneCenter: Vector3;
  130871. /**
  130872. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130873. * It is usually zero but might be interesting to modify according to your setup.
  130874. */
  130875. sceneCenter: Vector3;
  130876. protected _opacityFresnel: boolean;
  130877. /**
  130878. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130879. * This helps ensuring a nice transition when the camera goes under the ground.
  130880. */
  130881. opacityFresnel: boolean;
  130882. protected _reflectionFresnel: boolean;
  130883. /**
  130884. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130885. * This helps adding a mirror texture on the ground.
  130886. */
  130887. reflectionFresnel: boolean;
  130888. protected _reflectionFalloffDistance: number;
  130889. /**
  130890. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130891. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130892. */
  130893. reflectionFalloffDistance: number;
  130894. protected _reflectionAmount: number;
  130895. /**
  130896. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130897. */
  130898. reflectionAmount: number;
  130899. protected _reflectionReflectance0: number;
  130900. /**
  130901. * This specifies the weight of the reflection at grazing angle.
  130902. */
  130903. reflectionReflectance0: number;
  130904. protected _reflectionReflectance90: number;
  130905. /**
  130906. * This specifies the weight of the reflection at a perpendicular point of view.
  130907. */
  130908. reflectionReflectance90: number;
  130909. /**
  130910. * Sets the reflection reflectance fresnel values according to the default standard
  130911. * empirically know to work well :-)
  130912. */
  130913. set reflectionStandardFresnelWeight(value: number);
  130914. protected _useRGBColor: boolean;
  130915. /**
  130916. * Helps to directly use the maps channels instead of their level.
  130917. */
  130918. useRGBColor: boolean;
  130919. protected _enableNoise: boolean;
  130920. /**
  130921. * This helps reducing the banding effect that could occur on the background.
  130922. */
  130923. enableNoise: boolean;
  130924. /**
  130925. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130926. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130927. * Recommended to be keep at 1.0 except for special cases.
  130928. */
  130929. get fovMultiplier(): number;
  130930. set fovMultiplier(value: number);
  130931. private _fovMultiplier;
  130932. /**
  130933. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130934. */
  130935. useEquirectangularFOV: boolean;
  130936. private _maxSimultaneousLights;
  130937. /**
  130938. * Number of Simultaneous lights allowed on the material.
  130939. */
  130940. maxSimultaneousLights: int;
  130941. /**
  130942. * Default configuration related to image processing available in the Background Material.
  130943. */
  130944. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130945. /**
  130946. * Keep track of the image processing observer to allow dispose and replace.
  130947. */
  130948. private _imageProcessingObserver;
  130949. /**
  130950. * Attaches a new image processing configuration to the PBR Material.
  130951. * @param configuration (if null the scene configuration will be use)
  130952. */
  130953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130954. /**
  130955. * Gets the image processing configuration used either in this material.
  130956. */
  130957. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130958. /**
  130959. * Sets the Default image processing configuration used either in the this material.
  130960. *
  130961. * If sets to null, the scene one is in use.
  130962. */
  130963. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130964. /**
  130965. * Gets wether the color curves effect is enabled.
  130966. */
  130967. get cameraColorCurvesEnabled(): boolean;
  130968. /**
  130969. * Sets wether the color curves effect is enabled.
  130970. */
  130971. set cameraColorCurvesEnabled(value: boolean);
  130972. /**
  130973. * Gets wether the color grading effect is enabled.
  130974. */
  130975. get cameraColorGradingEnabled(): boolean;
  130976. /**
  130977. * Gets wether the color grading effect is enabled.
  130978. */
  130979. set cameraColorGradingEnabled(value: boolean);
  130980. /**
  130981. * Gets wether tonemapping is enabled or not.
  130982. */
  130983. get cameraToneMappingEnabled(): boolean;
  130984. /**
  130985. * Sets wether tonemapping is enabled or not
  130986. */
  130987. set cameraToneMappingEnabled(value: boolean);
  130988. /**
  130989. * The camera exposure used on this material.
  130990. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130991. * This corresponds to a photographic exposure.
  130992. */
  130993. get cameraExposure(): float;
  130994. /**
  130995. * The camera exposure used on this material.
  130996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130997. * This corresponds to a photographic exposure.
  130998. */
  130999. set cameraExposure(value: float);
  131000. /**
  131001. * Gets The camera contrast used on this material.
  131002. */
  131003. get cameraContrast(): float;
  131004. /**
  131005. * Sets The camera contrast used on this material.
  131006. */
  131007. set cameraContrast(value: float);
  131008. /**
  131009. * Gets the Color Grading 2D Lookup Texture.
  131010. */
  131011. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131012. /**
  131013. * Sets the Color Grading 2D Lookup Texture.
  131014. */
  131015. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131016. /**
  131017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131019. * 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;
  131020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131021. */
  131022. get cameraColorCurves(): Nullable<ColorCurves>;
  131023. /**
  131024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131026. * 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;
  131027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131028. */
  131029. set cameraColorCurves(value: Nullable<ColorCurves>);
  131030. /**
  131031. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131032. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131033. */
  131034. switchToBGR: boolean;
  131035. private _renderTargets;
  131036. private _reflectionControls;
  131037. private _white;
  131038. private _primaryShadowColor;
  131039. private _primaryHighlightColor;
  131040. /**
  131041. * Instantiates a Background Material in the given scene
  131042. * @param name The friendly name of the material
  131043. * @param scene The scene to add the material to
  131044. */
  131045. constructor(name: string, scene: Scene);
  131046. /**
  131047. * Gets a boolean indicating that current material needs to register RTT
  131048. */
  131049. get hasRenderTargetTextures(): boolean;
  131050. /**
  131051. * The entire material has been created in order to prevent overdraw.
  131052. * @returns false
  131053. */
  131054. needAlphaTesting(): boolean;
  131055. /**
  131056. * The entire material has been created in order to prevent overdraw.
  131057. * @returns true if blending is enable
  131058. */
  131059. needAlphaBlending(): boolean;
  131060. /**
  131061. * Checks wether the material is ready to be rendered for a given mesh.
  131062. * @param mesh The mesh to render
  131063. * @param subMesh The submesh to check against
  131064. * @param useInstances Specify wether or not the material is used with instances
  131065. * @returns true if all the dependencies are ready (Textures, Effects...)
  131066. */
  131067. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131068. /**
  131069. * Compute the primary color according to the chosen perceptual color.
  131070. */
  131071. private _computePrimaryColorFromPerceptualColor;
  131072. /**
  131073. * Compute the highlights and shadow colors according to their chosen levels.
  131074. */
  131075. private _computePrimaryColors;
  131076. /**
  131077. * Build the uniform buffer used in the material.
  131078. */
  131079. buildUniformLayout(): void;
  131080. /**
  131081. * Unbind the material.
  131082. */
  131083. unbind(): void;
  131084. /**
  131085. * Bind only the world matrix to the material.
  131086. * @param world The world matrix to bind.
  131087. */
  131088. bindOnlyWorldMatrix(world: Matrix): void;
  131089. /**
  131090. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131091. * @param world The world matrix to bind.
  131092. * @param subMesh The submesh to bind for.
  131093. */
  131094. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131095. /**
  131096. * Checks to see if a texture is used in the material.
  131097. * @param texture - Base texture to use.
  131098. * @returns - Boolean specifying if a texture is used in the material.
  131099. */
  131100. hasTexture(texture: BaseTexture): boolean;
  131101. /**
  131102. * Dispose the material.
  131103. * @param forceDisposeEffect Force disposal of the associated effect.
  131104. * @param forceDisposeTextures Force disposal of the associated textures.
  131105. */
  131106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131107. /**
  131108. * Clones the material.
  131109. * @param name The cloned name.
  131110. * @returns The cloned material.
  131111. */
  131112. clone(name: string): BackgroundMaterial;
  131113. /**
  131114. * Serializes the current material to its JSON representation.
  131115. * @returns The JSON representation.
  131116. */
  131117. serialize(): any;
  131118. /**
  131119. * Gets the class name of the material
  131120. * @returns "BackgroundMaterial"
  131121. */
  131122. getClassName(): string;
  131123. /**
  131124. * Parse a JSON input to create back a background material.
  131125. * @param source The JSON data to parse
  131126. * @param scene The scene to create the parsed material in
  131127. * @param rootUrl The root url of the assets the material depends upon
  131128. * @returns the instantiated BackgroundMaterial.
  131129. */
  131130. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131131. }
  131132. }
  131133. declare module BABYLON {
  131134. /**
  131135. * Represents the different options available during the creation of
  131136. * a Environment helper.
  131137. *
  131138. * This can control the default ground, skybox and image processing setup of your scene.
  131139. */
  131140. export interface IEnvironmentHelperOptions {
  131141. /**
  131142. * Specifies whether or not to create a ground.
  131143. * True by default.
  131144. */
  131145. createGround: boolean;
  131146. /**
  131147. * Specifies the ground size.
  131148. * 15 by default.
  131149. */
  131150. groundSize: number;
  131151. /**
  131152. * The texture used on the ground for the main color.
  131153. * Comes from the BabylonJS CDN by default.
  131154. *
  131155. * Remarks: Can be either a texture or a url.
  131156. */
  131157. groundTexture: string | BaseTexture;
  131158. /**
  131159. * The color mixed in the ground texture by default.
  131160. * BabylonJS clearColor by default.
  131161. */
  131162. groundColor: Color3;
  131163. /**
  131164. * Specifies the ground opacity.
  131165. * 1 by default.
  131166. */
  131167. groundOpacity: number;
  131168. /**
  131169. * Enables the ground to receive shadows.
  131170. * True by default.
  131171. */
  131172. enableGroundShadow: boolean;
  131173. /**
  131174. * Helps preventing the shadow to be fully black on the ground.
  131175. * 0.5 by default.
  131176. */
  131177. groundShadowLevel: number;
  131178. /**
  131179. * Creates a mirror texture attach to the ground.
  131180. * false by default.
  131181. */
  131182. enableGroundMirror: boolean;
  131183. /**
  131184. * Specifies the ground mirror size ratio.
  131185. * 0.3 by default as the default kernel is 64.
  131186. */
  131187. groundMirrorSizeRatio: number;
  131188. /**
  131189. * Specifies the ground mirror blur kernel size.
  131190. * 64 by default.
  131191. */
  131192. groundMirrorBlurKernel: number;
  131193. /**
  131194. * Specifies the ground mirror visibility amount.
  131195. * 1 by default
  131196. */
  131197. groundMirrorAmount: number;
  131198. /**
  131199. * Specifies the ground mirror reflectance weight.
  131200. * This uses the standard weight of the background material to setup the fresnel effect
  131201. * of the mirror.
  131202. * 1 by default.
  131203. */
  131204. groundMirrorFresnelWeight: number;
  131205. /**
  131206. * Specifies the ground mirror Falloff distance.
  131207. * This can helps reducing the size of the reflection.
  131208. * 0 by Default.
  131209. */
  131210. groundMirrorFallOffDistance: number;
  131211. /**
  131212. * Specifies the ground mirror texture type.
  131213. * Unsigned Int by Default.
  131214. */
  131215. groundMirrorTextureType: number;
  131216. /**
  131217. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131218. * the shown objects.
  131219. */
  131220. groundYBias: number;
  131221. /**
  131222. * Specifies whether or not to create a skybox.
  131223. * True by default.
  131224. */
  131225. createSkybox: boolean;
  131226. /**
  131227. * Specifies the skybox size.
  131228. * 20 by default.
  131229. */
  131230. skyboxSize: number;
  131231. /**
  131232. * The texture used on the skybox for the main color.
  131233. * Comes from the BabylonJS CDN by default.
  131234. *
  131235. * Remarks: Can be either a texture or a url.
  131236. */
  131237. skyboxTexture: string | BaseTexture;
  131238. /**
  131239. * The color mixed in the skybox texture by default.
  131240. * BabylonJS clearColor by default.
  131241. */
  131242. skyboxColor: Color3;
  131243. /**
  131244. * The background rotation around the Y axis of the scene.
  131245. * This helps aligning the key lights of your scene with the background.
  131246. * 0 by default.
  131247. */
  131248. backgroundYRotation: number;
  131249. /**
  131250. * Compute automatically the size of the elements to best fit with the scene.
  131251. */
  131252. sizeAuto: boolean;
  131253. /**
  131254. * Default position of the rootMesh if autoSize is not true.
  131255. */
  131256. rootPosition: Vector3;
  131257. /**
  131258. * Sets up the image processing in the scene.
  131259. * true by default.
  131260. */
  131261. setupImageProcessing: boolean;
  131262. /**
  131263. * The texture used as your environment texture in the scene.
  131264. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131265. *
  131266. * Remarks: Can be either a texture or a url.
  131267. */
  131268. environmentTexture: string | BaseTexture;
  131269. /**
  131270. * The value of the exposure to apply to the scene.
  131271. * 0.6 by default if setupImageProcessing is true.
  131272. */
  131273. cameraExposure: number;
  131274. /**
  131275. * The value of the contrast to apply to the scene.
  131276. * 1.6 by default if setupImageProcessing is true.
  131277. */
  131278. cameraContrast: number;
  131279. /**
  131280. * Specifies whether or not tonemapping should be enabled in the scene.
  131281. * true by default if setupImageProcessing is true.
  131282. */
  131283. toneMappingEnabled: boolean;
  131284. }
  131285. /**
  131286. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131287. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131288. * It also helps with the default setup of your imageProcessing configuration.
  131289. */
  131290. export class EnvironmentHelper {
  131291. /**
  131292. * Default ground texture URL.
  131293. */
  131294. private static _groundTextureCDNUrl;
  131295. /**
  131296. * Default skybox texture URL.
  131297. */
  131298. private static _skyboxTextureCDNUrl;
  131299. /**
  131300. * Default environment texture URL.
  131301. */
  131302. private static _environmentTextureCDNUrl;
  131303. /**
  131304. * Creates the default options for the helper.
  131305. */
  131306. private static _getDefaultOptions;
  131307. private _rootMesh;
  131308. /**
  131309. * Gets the root mesh created by the helper.
  131310. */
  131311. get rootMesh(): Mesh;
  131312. private _skybox;
  131313. /**
  131314. * Gets the skybox created by the helper.
  131315. */
  131316. get skybox(): Nullable<Mesh>;
  131317. private _skyboxTexture;
  131318. /**
  131319. * Gets the skybox texture created by the helper.
  131320. */
  131321. get skyboxTexture(): Nullable<BaseTexture>;
  131322. private _skyboxMaterial;
  131323. /**
  131324. * Gets the skybox material created by the helper.
  131325. */
  131326. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131327. private _ground;
  131328. /**
  131329. * Gets the ground mesh created by the helper.
  131330. */
  131331. get ground(): Nullable<Mesh>;
  131332. private _groundTexture;
  131333. /**
  131334. * Gets the ground texture created by the helper.
  131335. */
  131336. get groundTexture(): Nullable<BaseTexture>;
  131337. private _groundMirror;
  131338. /**
  131339. * Gets the ground mirror created by the helper.
  131340. */
  131341. get groundMirror(): Nullable<MirrorTexture>;
  131342. /**
  131343. * Gets the ground mirror render list to helps pushing the meshes
  131344. * you wish in the ground reflection.
  131345. */
  131346. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131347. private _groundMaterial;
  131348. /**
  131349. * Gets the ground material created by the helper.
  131350. */
  131351. get groundMaterial(): Nullable<BackgroundMaterial>;
  131352. /**
  131353. * Stores the creation options.
  131354. */
  131355. private readonly _scene;
  131356. private _options;
  131357. /**
  131358. * This observable will be notified with any error during the creation of the environment,
  131359. * mainly texture creation errors.
  131360. */
  131361. onErrorObservable: Observable<{
  131362. message?: string;
  131363. exception?: any;
  131364. }>;
  131365. /**
  131366. * constructor
  131367. * @param options Defines the options we want to customize the helper
  131368. * @param scene The scene to add the material to
  131369. */
  131370. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131371. /**
  131372. * Updates the background according to the new options
  131373. * @param options
  131374. */
  131375. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131376. /**
  131377. * Sets the primary color of all the available elements.
  131378. * @param color the main color to affect to the ground and the background
  131379. */
  131380. setMainColor(color: Color3): void;
  131381. /**
  131382. * Setup the image processing according to the specified options.
  131383. */
  131384. private _setupImageProcessing;
  131385. /**
  131386. * Setup the environment texture according to the specified options.
  131387. */
  131388. private _setupEnvironmentTexture;
  131389. /**
  131390. * Setup the background according to the specified options.
  131391. */
  131392. private _setupBackground;
  131393. /**
  131394. * Get the scene sizes according to the setup.
  131395. */
  131396. private _getSceneSize;
  131397. /**
  131398. * Setup the ground according to the specified options.
  131399. */
  131400. private _setupGround;
  131401. /**
  131402. * Setup the ground material according to the specified options.
  131403. */
  131404. private _setupGroundMaterial;
  131405. /**
  131406. * Setup the ground diffuse texture according to the specified options.
  131407. */
  131408. private _setupGroundDiffuseTexture;
  131409. /**
  131410. * Setup the ground mirror texture according to the specified options.
  131411. */
  131412. private _setupGroundMirrorTexture;
  131413. /**
  131414. * Setup the ground to receive the mirror texture.
  131415. */
  131416. private _setupMirrorInGroundMaterial;
  131417. /**
  131418. * Setup the skybox according to the specified options.
  131419. */
  131420. private _setupSkybox;
  131421. /**
  131422. * Setup the skybox material according to the specified options.
  131423. */
  131424. private _setupSkyboxMaterial;
  131425. /**
  131426. * Setup the skybox reflection texture according to the specified options.
  131427. */
  131428. private _setupSkyboxReflectionTexture;
  131429. private _errorHandler;
  131430. /**
  131431. * Dispose all the elements created by the Helper.
  131432. */
  131433. dispose(): void;
  131434. }
  131435. }
  131436. declare module BABYLON {
  131437. /**
  131438. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131439. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131440. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131441. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131442. */
  131443. export class PhotoDome extends TransformNode {
  131444. /**
  131445. * Define the image as a Monoscopic panoramic 360 image.
  131446. */
  131447. static readonly MODE_MONOSCOPIC: number;
  131448. /**
  131449. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131450. */
  131451. static readonly MODE_TOPBOTTOM: number;
  131452. /**
  131453. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131454. */
  131455. static readonly MODE_SIDEBYSIDE: number;
  131456. private _useDirectMapping;
  131457. /**
  131458. * The texture being displayed on the sphere
  131459. */
  131460. protected _photoTexture: Texture;
  131461. /**
  131462. * Gets or sets the texture being displayed on the sphere
  131463. */
  131464. get photoTexture(): Texture;
  131465. set photoTexture(value: Texture);
  131466. /**
  131467. * Observable raised when an error occured while loading the 360 image
  131468. */
  131469. onLoadErrorObservable: Observable<string>;
  131470. /**
  131471. * The skybox material
  131472. */
  131473. protected _material: BackgroundMaterial;
  131474. /**
  131475. * The surface used for the skybox
  131476. */
  131477. protected _mesh: Mesh;
  131478. /**
  131479. * Gets the mesh used for the skybox.
  131480. */
  131481. get mesh(): Mesh;
  131482. /**
  131483. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131484. * Also see the options.resolution property.
  131485. */
  131486. get fovMultiplier(): number;
  131487. set fovMultiplier(value: number);
  131488. private _imageMode;
  131489. /**
  131490. * Gets or set the current video mode for the video. It can be:
  131491. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131492. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131493. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131494. */
  131495. get imageMode(): number;
  131496. set imageMode(value: number);
  131497. /**
  131498. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131499. * @param name Element's name, child elements will append suffixes for their own names.
  131500. * @param urlsOfPhoto defines the url of the photo to display
  131501. * @param options defines an object containing optional or exposed sub element properties
  131502. * @param onError defines a callback called when an error occured while loading the texture
  131503. */
  131504. constructor(name: string, urlOfPhoto: string, options: {
  131505. resolution?: number;
  131506. size?: number;
  131507. useDirectMapping?: boolean;
  131508. faceForward?: boolean;
  131509. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131510. private _onBeforeCameraRenderObserver;
  131511. private _changeImageMode;
  131512. /**
  131513. * Releases resources associated with this node.
  131514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131516. */
  131517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131518. }
  131519. }
  131520. declare module BABYLON {
  131521. /**
  131522. * Class used to host RGBD texture specific utilities
  131523. */
  131524. export class RGBDTextureTools {
  131525. /**
  131526. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131527. * @param texture the texture to expand.
  131528. */
  131529. static ExpandRGBDTexture(texture: Texture): void;
  131530. }
  131531. }
  131532. declare module BABYLON {
  131533. /**
  131534. * Class used to host texture specific utilities
  131535. */
  131536. export class BRDFTextureTools {
  131537. /**
  131538. * Prevents texture cache collision
  131539. */
  131540. private static _instanceNumber;
  131541. /**
  131542. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131543. * @param scene defines the hosting scene
  131544. * @returns the environment BRDF texture
  131545. */
  131546. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131547. private static _environmentBRDFBase64Texture;
  131548. }
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * @hidden
  131553. */
  131554. export interface IMaterialClearCoatDefines {
  131555. CLEARCOAT: boolean;
  131556. CLEARCOAT_DEFAULTIOR: boolean;
  131557. CLEARCOAT_TEXTURE: boolean;
  131558. CLEARCOAT_TEXTUREDIRECTUV: number;
  131559. CLEARCOAT_BUMP: boolean;
  131560. CLEARCOAT_BUMPDIRECTUV: number;
  131561. CLEARCOAT_TINT: boolean;
  131562. CLEARCOAT_TINT_TEXTURE: boolean;
  131563. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131564. /** @hidden */
  131565. _areTexturesDirty: boolean;
  131566. }
  131567. /**
  131568. * Define the code related to the clear coat parameters of the pbr material.
  131569. */
  131570. export class PBRClearCoatConfiguration {
  131571. /**
  131572. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131573. * The default fits with a polyurethane material.
  131574. */
  131575. private static readonly _DefaultIndexOfRefraction;
  131576. private _isEnabled;
  131577. /**
  131578. * Defines if the clear coat is enabled in the material.
  131579. */
  131580. isEnabled: boolean;
  131581. /**
  131582. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131583. */
  131584. intensity: number;
  131585. /**
  131586. * Defines the clear coat layer roughness.
  131587. */
  131588. roughness: number;
  131589. private _indexOfRefraction;
  131590. /**
  131591. * Defines the index of refraction of the clear coat.
  131592. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131593. * The default fits with a polyurethane material.
  131594. * Changing the default value is more performance intensive.
  131595. */
  131596. indexOfRefraction: number;
  131597. private _texture;
  131598. /**
  131599. * Stores the clear coat values in a texture.
  131600. */
  131601. texture: Nullable<BaseTexture>;
  131602. private _bumpTexture;
  131603. /**
  131604. * Define the clear coat specific bump texture.
  131605. */
  131606. bumpTexture: Nullable<BaseTexture>;
  131607. private _isTintEnabled;
  131608. /**
  131609. * Defines if the clear coat tint is enabled in the material.
  131610. */
  131611. isTintEnabled: boolean;
  131612. /**
  131613. * Defines the clear coat tint of the material.
  131614. * This is only use if tint is enabled
  131615. */
  131616. tintColor: Color3;
  131617. /**
  131618. * Defines the distance at which the tint color should be found in the
  131619. * clear coat media.
  131620. * This is only use if tint is enabled
  131621. */
  131622. tintColorAtDistance: number;
  131623. /**
  131624. * Defines the clear coat layer thickness.
  131625. * This is only use if tint is enabled
  131626. */
  131627. tintThickness: number;
  131628. private _tintTexture;
  131629. /**
  131630. * Stores the clear tint values in a texture.
  131631. * rgb is tint
  131632. * a is a thickness factor
  131633. */
  131634. tintTexture: Nullable<BaseTexture>;
  131635. /** @hidden */
  131636. private _internalMarkAllSubMeshesAsTexturesDirty;
  131637. /** @hidden */
  131638. _markAllSubMeshesAsTexturesDirty(): void;
  131639. /**
  131640. * Instantiate a new istance of clear coat configuration.
  131641. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131642. */
  131643. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131644. /**
  131645. * Gets wehter the submesh is ready to be used or not.
  131646. * @param defines the list of "defines" to update.
  131647. * @param scene defines the scene the material belongs to.
  131648. * @param engine defines the engine the material belongs to.
  131649. * @param disableBumpMap defines wether the material disables bump or not.
  131650. * @returns - boolean indicating that the submesh is ready or not.
  131651. */
  131652. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131653. /**
  131654. * Checks to see if a texture is used in the material.
  131655. * @param defines the list of "defines" to update.
  131656. * @param scene defines the scene to the material belongs to.
  131657. */
  131658. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131659. /**
  131660. * Binds the material data.
  131661. * @param uniformBuffer defines the Uniform buffer to fill in.
  131662. * @param scene defines the scene the material belongs to.
  131663. * @param engine defines the engine the material belongs to.
  131664. * @param disableBumpMap defines wether the material disables bump or not.
  131665. * @param isFrozen defines wether the material is frozen or not.
  131666. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131667. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131668. */
  131669. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131670. /**
  131671. * Checks to see if a texture is used in the material.
  131672. * @param texture - Base texture to use.
  131673. * @returns - Boolean specifying if a texture is used in the material.
  131674. */
  131675. hasTexture(texture: BaseTexture): boolean;
  131676. /**
  131677. * Returns an array of the actively used textures.
  131678. * @param activeTextures Array of BaseTextures
  131679. */
  131680. getActiveTextures(activeTextures: BaseTexture[]): void;
  131681. /**
  131682. * Returns the animatable textures.
  131683. * @param animatables Array of animatable textures.
  131684. */
  131685. getAnimatables(animatables: IAnimatable[]): void;
  131686. /**
  131687. * Disposes the resources of the material.
  131688. * @param forceDisposeTextures - Forces the disposal of all textures.
  131689. */
  131690. dispose(forceDisposeTextures?: boolean): void;
  131691. /**
  131692. * Get the current class name of the texture useful for serialization or dynamic coding.
  131693. * @returns "PBRClearCoatConfiguration"
  131694. */
  131695. getClassName(): string;
  131696. /**
  131697. * Add fallbacks to the effect fallbacks list.
  131698. * @param defines defines the Base texture to use.
  131699. * @param fallbacks defines the current fallback list.
  131700. * @param currentRank defines the current fallback rank.
  131701. * @returns the new fallback rank.
  131702. */
  131703. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131704. /**
  131705. * Add the required uniforms to the current list.
  131706. * @param uniforms defines the current uniform list.
  131707. */
  131708. static AddUniforms(uniforms: string[]): void;
  131709. /**
  131710. * Add the required samplers to the current list.
  131711. * @param samplers defines the current sampler list.
  131712. */
  131713. static AddSamplers(samplers: string[]): void;
  131714. /**
  131715. * Add the required uniforms to the current buffer.
  131716. * @param uniformBuffer defines the current uniform buffer.
  131717. */
  131718. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131719. /**
  131720. * Makes a duplicate of the current configuration into another one.
  131721. * @param clearCoatConfiguration define the config where to copy the info
  131722. */
  131723. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131724. /**
  131725. * Serializes this clear coat configuration.
  131726. * @returns - An object with the serialized config.
  131727. */
  131728. serialize(): any;
  131729. /**
  131730. * Parses a anisotropy Configuration from a serialized object.
  131731. * @param source - Serialized object.
  131732. * @param scene Defines the scene we are parsing for
  131733. * @param rootUrl Defines the rootUrl to load from
  131734. */
  131735. parse(source: any, scene: Scene, rootUrl: string): void;
  131736. }
  131737. }
  131738. declare module BABYLON {
  131739. /**
  131740. * @hidden
  131741. */
  131742. export interface IMaterialAnisotropicDefines {
  131743. ANISOTROPIC: boolean;
  131744. ANISOTROPIC_TEXTURE: boolean;
  131745. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131746. MAINUV1: boolean;
  131747. _areTexturesDirty: boolean;
  131748. _needUVs: boolean;
  131749. }
  131750. /**
  131751. * Define the code related to the anisotropic parameters of the pbr material.
  131752. */
  131753. export class PBRAnisotropicConfiguration {
  131754. private _isEnabled;
  131755. /**
  131756. * Defines if the anisotropy is enabled in the material.
  131757. */
  131758. isEnabled: boolean;
  131759. /**
  131760. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  131761. */
  131762. intensity: number;
  131763. /**
  131764. * Defines if the effect is along the tangents, bitangents or in between.
  131765. * By default, the effect is "strectching" the highlights along the tangents.
  131766. */
  131767. direction: Vector2;
  131768. private _texture;
  131769. /**
  131770. * Stores the anisotropy values in a texture.
  131771. * rg is direction (like normal from -1 to 1)
  131772. * b is a intensity
  131773. */
  131774. texture: Nullable<BaseTexture>;
  131775. /** @hidden */
  131776. private _internalMarkAllSubMeshesAsTexturesDirty;
  131777. /** @hidden */
  131778. _markAllSubMeshesAsTexturesDirty(): void;
  131779. /**
  131780. * Instantiate a new istance of anisotropy configuration.
  131781. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131782. */
  131783. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131784. /**
  131785. * Specifies that the submesh is ready to be used.
  131786. * @param defines the list of "defines" to update.
  131787. * @param scene defines the scene the material belongs to.
  131788. * @returns - boolean indicating that the submesh is ready or not.
  131789. */
  131790. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  131791. /**
  131792. * Checks to see if a texture is used in the material.
  131793. * @param defines the list of "defines" to update.
  131794. * @param mesh the mesh we are preparing the defines for.
  131795. * @param scene defines the scene the material belongs to.
  131796. */
  131797. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  131798. /**
  131799. * Binds the material data.
  131800. * @param uniformBuffer defines the Uniform buffer to fill in.
  131801. * @param scene defines the scene the material belongs to.
  131802. * @param isFrozen defines wether the material is frozen or not.
  131803. */
  131804. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131805. /**
  131806. * Checks to see if a texture is used in the material.
  131807. * @param texture - Base texture to use.
  131808. * @returns - Boolean specifying if a texture is used in the material.
  131809. */
  131810. hasTexture(texture: BaseTexture): boolean;
  131811. /**
  131812. * Returns an array of the actively used textures.
  131813. * @param activeTextures Array of BaseTextures
  131814. */
  131815. getActiveTextures(activeTextures: BaseTexture[]): void;
  131816. /**
  131817. * Returns the animatable textures.
  131818. * @param animatables Array of animatable textures.
  131819. */
  131820. getAnimatables(animatables: IAnimatable[]): void;
  131821. /**
  131822. * Disposes the resources of the material.
  131823. * @param forceDisposeTextures - Forces the disposal of all textures.
  131824. */
  131825. dispose(forceDisposeTextures?: boolean): void;
  131826. /**
  131827. * Get the current class name of the texture useful for serialization or dynamic coding.
  131828. * @returns "PBRAnisotropicConfiguration"
  131829. */
  131830. getClassName(): string;
  131831. /**
  131832. * Add fallbacks to the effect fallbacks list.
  131833. * @param defines defines the Base texture to use.
  131834. * @param fallbacks defines the current fallback list.
  131835. * @param currentRank defines the current fallback rank.
  131836. * @returns the new fallback rank.
  131837. */
  131838. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131839. /**
  131840. * Add the required uniforms to the current list.
  131841. * @param uniforms defines the current uniform list.
  131842. */
  131843. static AddUniforms(uniforms: string[]): void;
  131844. /**
  131845. * Add the required uniforms to the current buffer.
  131846. * @param uniformBuffer defines the current uniform buffer.
  131847. */
  131848. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131849. /**
  131850. * Add the required samplers to the current list.
  131851. * @param samplers defines the current sampler list.
  131852. */
  131853. static AddSamplers(samplers: string[]): void;
  131854. /**
  131855. * Makes a duplicate of the current configuration into another one.
  131856. * @param anisotropicConfiguration define the config where to copy the info
  131857. */
  131858. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131859. /**
  131860. * Serializes this anisotropy configuration.
  131861. * @returns - An object with the serialized config.
  131862. */
  131863. serialize(): any;
  131864. /**
  131865. * Parses a anisotropy Configuration from a serialized object.
  131866. * @param source - Serialized object.
  131867. * @param scene Defines the scene we are parsing for
  131868. * @param rootUrl Defines the rootUrl to load from
  131869. */
  131870. parse(source: any, scene: Scene, rootUrl: string): void;
  131871. }
  131872. }
  131873. declare module BABYLON {
  131874. /**
  131875. * @hidden
  131876. */
  131877. export interface IMaterialBRDFDefines {
  131878. BRDF_V_HEIGHT_CORRELATED: boolean;
  131879. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131880. SPHERICAL_HARMONICS: boolean;
  131881. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131882. /** @hidden */
  131883. _areMiscDirty: boolean;
  131884. }
  131885. /**
  131886. * Define the code related to the BRDF parameters of the pbr material.
  131887. */
  131888. export class PBRBRDFConfiguration {
  131889. /**
  131890. * Default value used for the energy conservation.
  131891. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131892. */
  131893. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131894. /**
  131895. * Default value used for the Smith Visibility Height Correlated mode.
  131896. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131897. */
  131898. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131899. /**
  131900. * Default value used for the IBL diffuse part.
  131901. * This can help switching back to the polynomials mode globally which is a tiny bit
  131902. * less GPU intensive at the drawback of a lower quality.
  131903. */
  131904. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131905. /**
  131906. * Default value used for activating energy conservation for the specular workflow.
  131907. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131908. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131909. */
  131910. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131911. private _useEnergyConservation;
  131912. /**
  131913. * Defines if the material uses energy conservation.
  131914. */
  131915. useEnergyConservation: boolean;
  131916. private _useSmithVisibilityHeightCorrelated;
  131917. /**
  131918. * LEGACY Mode set to false
  131919. * Defines if the material uses height smith correlated visibility term.
  131920. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131921. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131922. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131923. * Not relying on height correlated will also disable energy conservation.
  131924. */
  131925. useSmithVisibilityHeightCorrelated: boolean;
  131926. private _useSphericalHarmonics;
  131927. /**
  131928. * LEGACY Mode set to false
  131929. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131930. * diffuse part of the IBL.
  131931. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131932. * to the ground truth.
  131933. */
  131934. useSphericalHarmonics: boolean;
  131935. private _useSpecularGlossinessInputEnergyConservation;
  131936. /**
  131937. * Defines if the material uses energy conservation, when the specular workflow is active.
  131938. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131939. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131940. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131941. */
  131942. useSpecularGlossinessInputEnergyConservation: boolean;
  131943. /** @hidden */
  131944. private _internalMarkAllSubMeshesAsMiscDirty;
  131945. /** @hidden */
  131946. _markAllSubMeshesAsMiscDirty(): void;
  131947. /**
  131948. * Instantiate a new istance of clear coat configuration.
  131949. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131950. */
  131951. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131952. /**
  131953. * Checks to see if a texture is used in the material.
  131954. * @param defines the list of "defines" to update.
  131955. */
  131956. prepareDefines(defines: IMaterialBRDFDefines): void;
  131957. /**
  131958. * Get the current class name of the texture useful for serialization or dynamic coding.
  131959. * @returns "PBRClearCoatConfiguration"
  131960. */
  131961. getClassName(): string;
  131962. /**
  131963. * Makes a duplicate of the current configuration into another one.
  131964. * @param brdfConfiguration define the config where to copy the info
  131965. */
  131966. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131967. /**
  131968. * Serializes this BRDF configuration.
  131969. * @returns - An object with the serialized config.
  131970. */
  131971. serialize(): any;
  131972. /**
  131973. * Parses a anisotropy Configuration from a serialized object.
  131974. * @param source - Serialized object.
  131975. * @param scene Defines the scene we are parsing for
  131976. * @param rootUrl Defines the rootUrl to load from
  131977. */
  131978. parse(source: any, scene: Scene, rootUrl: string): void;
  131979. }
  131980. }
  131981. declare module BABYLON {
  131982. /**
  131983. * @hidden
  131984. */
  131985. export interface IMaterialSheenDefines {
  131986. SHEEN: boolean;
  131987. SHEEN_TEXTURE: boolean;
  131988. SHEEN_TEXTUREDIRECTUV: number;
  131989. SHEEN_LINKWITHALBEDO: boolean;
  131990. SHEEN_ROUGHNESS: boolean;
  131991. SHEEN_ALBEDOSCALING: boolean;
  131992. /** @hidden */
  131993. _areTexturesDirty: boolean;
  131994. }
  131995. /**
  131996. * Define the code related to the Sheen parameters of the pbr material.
  131997. */
  131998. export class PBRSheenConfiguration {
  131999. private _isEnabled;
  132000. /**
  132001. * Defines if the material uses sheen.
  132002. */
  132003. isEnabled: boolean;
  132004. private _linkSheenWithAlbedo;
  132005. /**
  132006. * Defines if the sheen is linked to the sheen color.
  132007. */
  132008. linkSheenWithAlbedo: boolean;
  132009. /**
  132010. * Defines the sheen intensity.
  132011. */
  132012. intensity: number;
  132013. /**
  132014. * Defines the sheen color.
  132015. */
  132016. color: Color3;
  132017. private _texture;
  132018. /**
  132019. * Stores the sheen tint values in a texture.
  132020. * rgb is tint
  132021. * a is a intensity
  132022. */
  132023. texture: Nullable<BaseTexture>;
  132024. private _roughness;
  132025. /**
  132026. * Defines the sheen roughness.
  132027. * It is not taken into account if linkSheenWithAlbedo is true.
  132028. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132029. */
  132030. roughness: Nullable<number>;
  132031. private _albedoScaling;
  132032. /**
  132033. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132034. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132035. * making it easier to setup and tweak the effect
  132036. */
  132037. albedoScaling: boolean;
  132038. /** @hidden */
  132039. private _internalMarkAllSubMeshesAsTexturesDirty;
  132040. /** @hidden */
  132041. _markAllSubMeshesAsTexturesDirty(): void;
  132042. /**
  132043. * Instantiate a new istance of clear coat configuration.
  132044. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132045. */
  132046. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132047. /**
  132048. * Specifies that the submesh is ready to be used.
  132049. * @param defines the list of "defines" to update.
  132050. * @param scene defines the scene the material belongs to.
  132051. * @returns - boolean indicating that the submesh is ready or not.
  132052. */
  132053. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132054. /**
  132055. * Checks to see if a texture is used in the material.
  132056. * @param defines the list of "defines" to update.
  132057. * @param scene defines the scene the material belongs to.
  132058. */
  132059. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132060. /**
  132061. * Binds the material data.
  132062. * @param uniformBuffer defines the Uniform buffer to fill in.
  132063. * @param scene defines the scene the material belongs to.
  132064. * @param isFrozen defines wether the material is frozen or not.
  132065. */
  132066. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132067. /**
  132068. * Checks to see if a texture is used in the material.
  132069. * @param texture - Base texture to use.
  132070. * @returns - Boolean specifying if a texture is used in the material.
  132071. */
  132072. hasTexture(texture: BaseTexture): boolean;
  132073. /**
  132074. * Returns an array of the actively used textures.
  132075. * @param activeTextures Array of BaseTextures
  132076. */
  132077. getActiveTextures(activeTextures: BaseTexture[]): void;
  132078. /**
  132079. * Returns the animatable textures.
  132080. * @param animatables Array of animatable textures.
  132081. */
  132082. getAnimatables(animatables: IAnimatable[]): void;
  132083. /**
  132084. * Disposes the resources of the material.
  132085. * @param forceDisposeTextures - Forces the disposal of all textures.
  132086. */
  132087. dispose(forceDisposeTextures?: boolean): void;
  132088. /**
  132089. * Get the current class name of the texture useful for serialization or dynamic coding.
  132090. * @returns "PBRSheenConfiguration"
  132091. */
  132092. getClassName(): string;
  132093. /**
  132094. * Add fallbacks to the effect fallbacks list.
  132095. * @param defines defines the Base texture to use.
  132096. * @param fallbacks defines the current fallback list.
  132097. * @param currentRank defines the current fallback rank.
  132098. * @returns the new fallback rank.
  132099. */
  132100. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132101. /**
  132102. * Add the required uniforms to the current list.
  132103. * @param uniforms defines the current uniform list.
  132104. */
  132105. static AddUniforms(uniforms: string[]): void;
  132106. /**
  132107. * Add the required uniforms to the current buffer.
  132108. * @param uniformBuffer defines the current uniform buffer.
  132109. */
  132110. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132111. /**
  132112. * Add the required samplers to the current list.
  132113. * @param samplers defines the current sampler list.
  132114. */
  132115. static AddSamplers(samplers: string[]): void;
  132116. /**
  132117. * Makes a duplicate of the current configuration into another one.
  132118. * @param sheenConfiguration define the config where to copy the info
  132119. */
  132120. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132121. /**
  132122. * Serializes this BRDF configuration.
  132123. * @returns - An object with the serialized config.
  132124. */
  132125. serialize(): any;
  132126. /**
  132127. * Parses a anisotropy Configuration from a serialized object.
  132128. * @param source - Serialized object.
  132129. * @param scene Defines the scene we are parsing for
  132130. * @param rootUrl Defines the rootUrl to load from
  132131. */
  132132. parse(source: any, scene: Scene, rootUrl: string): void;
  132133. }
  132134. }
  132135. declare module BABYLON {
  132136. /**
  132137. * @hidden
  132138. */
  132139. export interface IMaterialSubSurfaceDefines {
  132140. SUBSURFACE: boolean;
  132141. SS_REFRACTION: boolean;
  132142. SS_TRANSLUCENCY: boolean;
  132143. SS_SCATTERING: boolean;
  132144. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132145. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132146. SS_REFRACTIONMAP_3D: boolean;
  132147. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132148. SS_LODINREFRACTIONALPHA: boolean;
  132149. SS_GAMMAREFRACTION: boolean;
  132150. SS_RGBDREFRACTION: boolean;
  132151. SS_LINEARSPECULARREFRACTION: boolean;
  132152. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132153. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132154. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132155. /** @hidden */
  132156. _areTexturesDirty: boolean;
  132157. }
  132158. /**
  132159. * Define the code related to the sub surface parameters of the pbr material.
  132160. */
  132161. export class PBRSubSurfaceConfiguration {
  132162. private _isRefractionEnabled;
  132163. /**
  132164. * Defines if the refraction is enabled in the material.
  132165. */
  132166. isRefractionEnabled: boolean;
  132167. private _isTranslucencyEnabled;
  132168. /**
  132169. * Defines if the translucency is enabled in the material.
  132170. */
  132171. isTranslucencyEnabled: boolean;
  132172. private _isScatteringEnabled;
  132173. /**
  132174. * Defines the refraction intensity of the material.
  132175. * The refraction when enabled replaces the Diffuse part of the material.
  132176. * The intensity helps transitionning between diffuse and refraction.
  132177. */
  132178. refractionIntensity: number;
  132179. /**
  132180. * Defines the translucency intensity of the material.
  132181. * When translucency has been enabled, this defines how much of the "translucency"
  132182. * is addded to the diffuse part of the material.
  132183. */
  132184. translucencyIntensity: number;
  132185. /**
  132186. * Defines the scattering intensity of the material.
  132187. * When scattering has been enabled, this defines how much of the "scattered light"
  132188. * is addded to the diffuse part of the material.
  132189. */
  132190. scatteringIntensity: number;
  132191. /**
  132192. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132193. */
  132194. useAlbedoToTintRefraction: boolean;
  132195. private _thicknessTexture;
  132196. /**
  132197. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132198. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132199. * 0 would mean minimumThickness
  132200. * 1 would mean maximumThickness
  132201. * The other channels might be use as a mask to vary the different effects intensity.
  132202. */
  132203. thicknessTexture: Nullable<BaseTexture>;
  132204. private _refractionTexture;
  132205. /**
  132206. * Defines the texture to use for refraction.
  132207. */
  132208. refractionTexture: Nullable<BaseTexture>;
  132209. private _indexOfRefraction;
  132210. /**
  132211. * Index of refraction of the material base layer.
  132212. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132213. *
  132214. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132215. *
  132216. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132217. */
  132218. indexOfRefraction: number;
  132219. private _volumeIndexOfRefraction;
  132220. /**
  132221. * Index of refraction of the material's volume.
  132222. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132223. *
  132224. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132225. * the volume will use the same IOR as the surface.
  132226. */
  132227. get volumeIndexOfRefraction(): number;
  132228. set volumeIndexOfRefraction(value: number);
  132229. private _invertRefractionY;
  132230. /**
  132231. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132232. */
  132233. invertRefractionY: boolean;
  132234. private _linkRefractionWithTransparency;
  132235. /**
  132236. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132237. * Materials half opaque for instance using refraction could benefit from this control.
  132238. */
  132239. linkRefractionWithTransparency: boolean;
  132240. /**
  132241. * Defines the minimum thickness stored in the thickness map.
  132242. * If no thickness map is defined, this value will be used to simulate thickness.
  132243. */
  132244. minimumThickness: number;
  132245. /**
  132246. * Defines the maximum thickness stored in the thickness map.
  132247. */
  132248. maximumThickness: number;
  132249. /**
  132250. * Defines the volume tint of the material.
  132251. * This is used for both translucency and scattering.
  132252. */
  132253. tintColor: Color3;
  132254. /**
  132255. * Defines the distance at which the tint color should be found in the media.
  132256. * This is used for refraction only.
  132257. */
  132258. tintColorAtDistance: number;
  132259. /**
  132260. * Defines how far each channel transmit through the media.
  132261. * It is defined as a color to simplify it selection.
  132262. */
  132263. diffusionDistance: Color3;
  132264. private _useMaskFromThicknessTexture;
  132265. /**
  132266. * Stores the intensity of the different subsurface effects in the thickness texture.
  132267. * * the green channel is the translucency intensity.
  132268. * * the blue channel is the scattering intensity.
  132269. * * the alpha channel is the refraction intensity.
  132270. */
  132271. useMaskFromThicknessTexture: boolean;
  132272. /** @hidden */
  132273. private _internalMarkAllSubMeshesAsTexturesDirty;
  132274. /** @hidden */
  132275. _markAllSubMeshesAsTexturesDirty(): void;
  132276. /**
  132277. * Instantiate a new istance of sub surface configuration.
  132278. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132279. */
  132280. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132281. /**
  132282. * Gets wehter the submesh is ready to be used or not.
  132283. * @param defines the list of "defines" to update.
  132284. * @param scene defines the scene the material belongs to.
  132285. * @returns - boolean indicating that the submesh is ready or not.
  132286. */
  132287. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132288. /**
  132289. * Checks to see if a texture is used in the material.
  132290. * @param defines the list of "defines" to update.
  132291. * @param scene defines the scene to the material belongs to.
  132292. */
  132293. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132294. /**
  132295. * Binds the material data.
  132296. * @param uniformBuffer defines the Uniform buffer to fill in.
  132297. * @param scene defines the scene the material belongs to.
  132298. * @param engine defines the engine the material belongs to.
  132299. * @param isFrozen defines whether the material is frozen or not.
  132300. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132301. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132302. */
  132303. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132304. /**
  132305. * Unbinds the material from the mesh.
  132306. * @param activeEffect defines the effect that should be unbound from.
  132307. * @returns true if unbound, otherwise false
  132308. */
  132309. unbind(activeEffect: Effect): boolean;
  132310. /**
  132311. * Returns the texture used for refraction or null if none is used.
  132312. * @param scene defines the scene the material belongs to.
  132313. * @returns - Refraction texture if present. If no refraction texture and refraction
  132314. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132315. */
  132316. private _getRefractionTexture;
  132317. /**
  132318. * Returns true if alpha blending should be disabled.
  132319. */
  132320. get disableAlphaBlending(): boolean;
  132321. /**
  132322. * Fills the list of render target textures.
  132323. * @param renderTargets the list of render targets to update
  132324. */
  132325. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132326. /**
  132327. * Checks to see if a texture is used in the material.
  132328. * @param texture - Base texture to use.
  132329. * @returns - Boolean specifying if a texture is used in the material.
  132330. */
  132331. hasTexture(texture: BaseTexture): boolean;
  132332. /**
  132333. * Gets a boolean indicating that current material needs to register RTT
  132334. * @returns true if this uses a render target otherwise false.
  132335. */
  132336. hasRenderTargetTextures(): boolean;
  132337. /**
  132338. * Returns an array of the actively used textures.
  132339. * @param activeTextures Array of BaseTextures
  132340. */
  132341. getActiveTextures(activeTextures: BaseTexture[]): void;
  132342. /**
  132343. * Returns the animatable textures.
  132344. * @param animatables Array of animatable textures.
  132345. */
  132346. getAnimatables(animatables: IAnimatable[]): void;
  132347. /**
  132348. * Disposes the resources of the material.
  132349. * @param forceDisposeTextures - Forces the disposal of all textures.
  132350. */
  132351. dispose(forceDisposeTextures?: boolean): void;
  132352. /**
  132353. * Get the current class name of the texture useful for serialization or dynamic coding.
  132354. * @returns "PBRSubSurfaceConfiguration"
  132355. */
  132356. getClassName(): string;
  132357. /**
  132358. * Add fallbacks to the effect fallbacks list.
  132359. * @param defines defines the Base texture to use.
  132360. * @param fallbacks defines the current fallback list.
  132361. * @param currentRank defines the current fallback rank.
  132362. * @returns the new fallback rank.
  132363. */
  132364. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132365. /**
  132366. * Add the required uniforms to the current list.
  132367. * @param uniforms defines the current uniform list.
  132368. */
  132369. static AddUniforms(uniforms: string[]): void;
  132370. /**
  132371. * Add the required samplers to the current list.
  132372. * @param samplers defines the current sampler list.
  132373. */
  132374. static AddSamplers(samplers: string[]): void;
  132375. /**
  132376. * Add the required uniforms to the current buffer.
  132377. * @param uniformBuffer defines the current uniform buffer.
  132378. */
  132379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132380. /**
  132381. * Makes a duplicate of the current configuration into another one.
  132382. * @param configuration define the config where to copy the info
  132383. */
  132384. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132385. /**
  132386. * Serializes this Sub Surface configuration.
  132387. * @returns - An object with the serialized config.
  132388. */
  132389. serialize(): any;
  132390. /**
  132391. * Parses a anisotropy Configuration from a serialized object.
  132392. * @param source - Serialized object.
  132393. * @param scene Defines the scene we are parsing for
  132394. * @param rootUrl Defines the rootUrl to load from
  132395. */
  132396. parse(source: any, scene: Scene, rootUrl: string): void;
  132397. }
  132398. }
  132399. declare module BABYLON {
  132400. /** @hidden */
  132401. export var pbrFragmentDeclaration: {
  132402. name: string;
  132403. shader: string;
  132404. };
  132405. }
  132406. declare module BABYLON {
  132407. /** @hidden */
  132408. export var pbrUboDeclaration: {
  132409. name: string;
  132410. shader: string;
  132411. };
  132412. }
  132413. declare module BABYLON {
  132414. /** @hidden */
  132415. export var pbrFragmentExtraDeclaration: {
  132416. name: string;
  132417. shader: string;
  132418. };
  132419. }
  132420. declare module BABYLON {
  132421. /** @hidden */
  132422. export var pbrFragmentSamplersDeclaration: {
  132423. name: string;
  132424. shader: string;
  132425. };
  132426. }
  132427. declare module BABYLON {
  132428. /** @hidden */
  132429. export var importanceSampling: {
  132430. name: string;
  132431. shader: string;
  132432. };
  132433. }
  132434. declare module BABYLON {
  132435. /** @hidden */
  132436. export var pbrHelperFunctions: {
  132437. name: string;
  132438. shader: string;
  132439. };
  132440. }
  132441. declare module BABYLON {
  132442. /** @hidden */
  132443. export var harmonicsFunctions: {
  132444. name: string;
  132445. shader: string;
  132446. };
  132447. }
  132448. declare module BABYLON {
  132449. /** @hidden */
  132450. export var pbrDirectLightingSetupFunctions: {
  132451. name: string;
  132452. shader: string;
  132453. };
  132454. }
  132455. declare module BABYLON {
  132456. /** @hidden */
  132457. export var pbrDirectLightingFalloffFunctions: {
  132458. name: string;
  132459. shader: string;
  132460. };
  132461. }
  132462. declare module BABYLON {
  132463. /** @hidden */
  132464. export var pbrBRDFFunctions: {
  132465. name: string;
  132466. shader: string;
  132467. };
  132468. }
  132469. declare module BABYLON {
  132470. /** @hidden */
  132471. export var hdrFilteringFunctions: {
  132472. name: string;
  132473. shader: string;
  132474. };
  132475. }
  132476. declare module BABYLON {
  132477. /** @hidden */
  132478. export var pbrDirectLightingFunctions: {
  132479. name: string;
  132480. shader: string;
  132481. };
  132482. }
  132483. declare module BABYLON {
  132484. /** @hidden */
  132485. export var pbrIBLFunctions: {
  132486. name: string;
  132487. shader: string;
  132488. };
  132489. }
  132490. declare module BABYLON {
  132491. /** @hidden */
  132492. export var pbrBlockAlbedoOpacity: {
  132493. name: string;
  132494. shader: string;
  132495. };
  132496. }
  132497. declare module BABYLON {
  132498. /** @hidden */
  132499. export var pbrBlockReflectivity: {
  132500. name: string;
  132501. shader: string;
  132502. };
  132503. }
  132504. declare module BABYLON {
  132505. /** @hidden */
  132506. export var pbrBlockAmbientOcclusion: {
  132507. name: string;
  132508. shader: string;
  132509. };
  132510. }
  132511. declare module BABYLON {
  132512. /** @hidden */
  132513. export var pbrBlockAlphaFresnel: {
  132514. name: string;
  132515. shader: string;
  132516. };
  132517. }
  132518. declare module BABYLON {
  132519. /** @hidden */
  132520. export var pbrBlockAnisotropic: {
  132521. name: string;
  132522. shader: string;
  132523. };
  132524. }
  132525. declare module BABYLON {
  132526. /** @hidden */
  132527. export var pbrBlockReflection: {
  132528. name: string;
  132529. shader: string;
  132530. };
  132531. }
  132532. declare module BABYLON {
  132533. /** @hidden */
  132534. export var pbrBlockSheen: {
  132535. name: string;
  132536. shader: string;
  132537. };
  132538. }
  132539. declare module BABYLON {
  132540. /** @hidden */
  132541. export var pbrBlockClearcoat: {
  132542. name: string;
  132543. shader: string;
  132544. };
  132545. }
  132546. declare module BABYLON {
  132547. /** @hidden */
  132548. export var pbrBlockSubSurface: {
  132549. name: string;
  132550. shader: string;
  132551. };
  132552. }
  132553. declare module BABYLON {
  132554. /** @hidden */
  132555. export var pbrBlockNormalGeometric: {
  132556. name: string;
  132557. shader: string;
  132558. };
  132559. }
  132560. declare module BABYLON {
  132561. /** @hidden */
  132562. export var pbrBlockNormalFinal: {
  132563. name: string;
  132564. shader: string;
  132565. };
  132566. }
  132567. declare module BABYLON {
  132568. /** @hidden */
  132569. export var pbrBlockGeometryInfo: {
  132570. name: string;
  132571. shader: string;
  132572. };
  132573. }
  132574. declare module BABYLON {
  132575. /** @hidden */
  132576. export var pbrBlockReflectance0: {
  132577. name: string;
  132578. shader: string;
  132579. };
  132580. }
  132581. declare module BABYLON {
  132582. /** @hidden */
  132583. export var pbrBlockReflectance: {
  132584. name: string;
  132585. shader: string;
  132586. };
  132587. }
  132588. declare module BABYLON {
  132589. /** @hidden */
  132590. export var pbrBlockDirectLighting: {
  132591. name: string;
  132592. shader: string;
  132593. };
  132594. }
  132595. declare module BABYLON {
  132596. /** @hidden */
  132597. export var pbrBlockFinalLitComponents: {
  132598. name: string;
  132599. shader: string;
  132600. };
  132601. }
  132602. declare module BABYLON {
  132603. /** @hidden */
  132604. export var pbrBlockFinalUnlitComponents: {
  132605. name: string;
  132606. shader: string;
  132607. };
  132608. }
  132609. declare module BABYLON {
  132610. /** @hidden */
  132611. export var pbrBlockFinalColorComposition: {
  132612. name: string;
  132613. shader: string;
  132614. };
  132615. }
  132616. declare module BABYLON {
  132617. /** @hidden */
  132618. export var pbrBlockImageProcessing: {
  132619. name: string;
  132620. shader: string;
  132621. };
  132622. }
  132623. declare module BABYLON {
  132624. /** @hidden */
  132625. export var pbrDebug: {
  132626. name: string;
  132627. shader: string;
  132628. };
  132629. }
  132630. declare module BABYLON {
  132631. /** @hidden */
  132632. export var pbrPixelShader: {
  132633. name: string;
  132634. shader: string;
  132635. };
  132636. }
  132637. declare module BABYLON {
  132638. /** @hidden */
  132639. export var pbrVertexDeclaration: {
  132640. name: string;
  132641. shader: string;
  132642. };
  132643. }
  132644. declare module BABYLON {
  132645. /** @hidden */
  132646. export var pbrVertexShader: {
  132647. name: string;
  132648. shader: string;
  132649. };
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * Manages the defines for the PBR Material.
  132654. * @hidden
  132655. */
  132656. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  132657. PBR: boolean;
  132658. NUM_SAMPLES: string;
  132659. REALTIME_FILTERING: boolean;
  132660. MAINUV1: boolean;
  132661. MAINUV2: boolean;
  132662. UV1: boolean;
  132663. UV2: boolean;
  132664. ALBEDO: boolean;
  132665. GAMMAALBEDO: boolean;
  132666. ALBEDODIRECTUV: number;
  132667. VERTEXCOLOR: boolean;
  132668. DETAIL: boolean;
  132669. DETAILDIRECTUV: number;
  132670. DETAIL_NORMALBLENDMETHOD: number;
  132671. AMBIENT: boolean;
  132672. AMBIENTDIRECTUV: number;
  132673. AMBIENTINGRAYSCALE: boolean;
  132674. OPACITY: boolean;
  132675. VERTEXALPHA: boolean;
  132676. OPACITYDIRECTUV: number;
  132677. OPACITYRGB: boolean;
  132678. ALPHATEST: boolean;
  132679. DEPTHPREPASS: boolean;
  132680. ALPHABLEND: boolean;
  132681. ALPHAFROMALBEDO: boolean;
  132682. ALPHATESTVALUE: string;
  132683. SPECULAROVERALPHA: boolean;
  132684. RADIANCEOVERALPHA: boolean;
  132685. ALPHAFRESNEL: boolean;
  132686. LINEARALPHAFRESNEL: boolean;
  132687. PREMULTIPLYALPHA: boolean;
  132688. EMISSIVE: boolean;
  132689. EMISSIVEDIRECTUV: number;
  132690. REFLECTIVITY: boolean;
  132691. REFLECTIVITYDIRECTUV: number;
  132692. SPECULARTERM: boolean;
  132693. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132694. MICROSURFACEAUTOMATIC: boolean;
  132695. LODBASEDMICROSFURACE: boolean;
  132696. MICROSURFACEMAP: boolean;
  132697. MICROSURFACEMAPDIRECTUV: number;
  132698. METALLICWORKFLOW: boolean;
  132699. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132700. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132701. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132702. AOSTOREINMETALMAPRED: boolean;
  132703. METALLIC_REFLECTANCE: boolean;
  132704. METALLIC_REFLECTANCEDIRECTUV: number;
  132705. ENVIRONMENTBRDF: boolean;
  132706. ENVIRONMENTBRDF_RGBD: boolean;
  132707. NORMAL: boolean;
  132708. TANGENT: boolean;
  132709. BUMP: boolean;
  132710. BUMPDIRECTUV: number;
  132711. OBJECTSPACE_NORMALMAP: boolean;
  132712. PARALLAX: boolean;
  132713. PARALLAXOCCLUSION: boolean;
  132714. NORMALXYSCALE: boolean;
  132715. LIGHTMAP: boolean;
  132716. LIGHTMAPDIRECTUV: number;
  132717. USELIGHTMAPASSHADOWMAP: boolean;
  132718. GAMMALIGHTMAP: boolean;
  132719. RGBDLIGHTMAP: boolean;
  132720. REFLECTION: boolean;
  132721. REFLECTIONMAP_3D: boolean;
  132722. REFLECTIONMAP_SPHERICAL: boolean;
  132723. REFLECTIONMAP_PLANAR: boolean;
  132724. REFLECTIONMAP_CUBIC: boolean;
  132725. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132726. REFLECTIONMAP_PROJECTION: boolean;
  132727. REFLECTIONMAP_SKYBOX: boolean;
  132728. REFLECTIONMAP_EXPLICIT: boolean;
  132729. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132730. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132731. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132732. INVERTCUBICMAP: boolean;
  132733. USESPHERICALFROMREFLECTIONMAP: boolean;
  132734. USEIRRADIANCEMAP: boolean;
  132735. SPHERICAL_HARMONICS: boolean;
  132736. USESPHERICALINVERTEX: boolean;
  132737. REFLECTIONMAP_OPPOSITEZ: boolean;
  132738. LODINREFLECTIONALPHA: boolean;
  132739. GAMMAREFLECTION: boolean;
  132740. RGBDREFLECTION: boolean;
  132741. LINEARSPECULARREFLECTION: boolean;
  132742. RADIANCEOCCLUSION: boolean;
  132743. HORIZONOCCLUSION: boolean;
  132744. INSTANCES: boolean;
  132745. THIN_INSTANCES: boolean;
  132746. NUM_BONE_INFLUENCERS: number;
  132747. BonesPerMesh: number;
  132748. BONETEXTURE: boolean;
  132749. NONUNIFORMSCALING: boolean;
  132750. MORPHTARGETS: boolean;
  132751. MORPHTARGETS_NORMAL: boolean;
  132752. MORPHTARGETS_TANGENT: boolean;
  132753. MORPHTARGETS_UV: boolean;
  132754. NUM_MORPH_INFLUENCERS: number;
  132755. IMAGEPROCESSING: boolean;
  132756. VIGNETTE: boolean;
  132757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132758. VIGNETTEBLENDMODEOPAQUE: boolean;
  132759. TONEMAPPING: boolean;
  132760. TONEMAPPING_ACES: boolean;
  132761. CONTRAST: boolean;
  132762. COLORCURVES: boolean;
  132763. COLORGRADING: boolean;
  132764. COLORGRADING3D: boolean;
  132765. SAMPLER3DGREENDEPTH: boolean;
  132766. SAMPLER3DBGRMAP: boolean;
  132767. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132768. EXPOSURE: boolean;
  132769. MULTIVIEW: boolean;
  132770. USEPHYSICALLIGHTFALLOFF: boolean;
  132771. USEGLTFLIGHTFALLOFF: boolean;
  132772. TWOSIDEDLIGHTING: boolean;
  132773. SHADOWFLOAT: boolean;
  132774. CLIPPLANE: boolean;
  132775. CLIPPLANE2: boolean;
  132776. CLIPPLANE3: boolean;
  132777. CLIPPLANE4: boolean;
  132778. CLIPPLANE5: boolean;
  132779. CLIPPLANE6: boolean;
  132780. POINTSIZE: boolean;
  132781. FOG: boolean;
  132782. LOGARITHMICDEPTH: boolean;
  132783. FORCENORMALFORWARD: boolean;
  132784. SPECULARAA: boolean;
  132785. CLEARCOAT: boolean;
  132786. CLEARCOAT_DEFAULTIOR: boolean;
  132787. CLEARCOAT_TEXTURE: boolean;
  132788. CLEARCOAT_TEXTUREDIRECTUV: number;
  132789. CLEARCOAT_BUMP: boolean;
  132790. CLEARCOAT_BUMPDIRECTUV: number;
  132791. CLEARCOAT_TINT: boolean;
  132792. CLEARCOAT_TINT_TEXTURE: boolean;
  132793. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132794. ANISOTROPIC: boolean;
  132795. ANISOTROPIC_TEXTURE: boolean;
  132796. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132797. BRDF_V_HEIGHT_CORRELATED: boolean;
  132798. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132799. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132800. SHEEN: boolean;
  132801. SHEEN_TEXTURE: boolean;
  132802. SHEEN_TEXTUREDIRECTUV: number;
  132803. SHEEN_LINKWITHALBEDO: boolean;
  132804. SHEEN_ROUGHNESS: boolean;
  132805. SHEEN_ALBEDOSCALING: boolean;
  132806. SUBSURFACE: boolean;
  132807. SS_REFRACTION: boolean;
  132808. SS_TRANSLUCENCY: boolean;
  132809. SS_SCATTERING: boolean;
  132810. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132811. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132812. SS_REFRACTIONMAP_3D: boolean;
  132813. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132814. SS_LODINREFRACTIONALPHA: boolean;
  132815. SS_GAMMAREFRACTION: boolean;
  132816. SS_RGBDREFRACTION: boolean;
  132817. SS_LINEARSPECULARREFRACTION: boolean;
  132818. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132819. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132820. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132821. UNLIT: boolean;
  132822. DEBUGMODE: number;
  132823. /**
  132824. * Initializes the PBR Material defines.
  132825. */
  132826. constructor();
  132827. /**
  132828. * Resets the PBR Material defines.
  132829. */
  132830. reset(): void;
  132831. }
  132832. /**
  132833. * The Physically based material base class of BJS.
  132834. *
  132835. * This offers the main features of a standard PBR material.
  132836. * For more information, please refer to the documentation :
  132837. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132838. */
  132839. export abstract class PBRBaseMaterial extends PushMaterial {
  132840. /**
  132841. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132842. */
  132843. static readonly PBRMATERIAL_OPAQUE: number;
  132844. /**
  132845. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132846. */
  132847. static readonly PBRMATERIAL_ALPHATEST: number;
  132848. /**
  132849. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132850. */
  132851. static readonly PBRMATERIAL_ALPHABLEND: number;
  132852. /**
  132853. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132854. * They are also discarded below the alpha cutoff threshold to improve performances.
  132855. */
  132856. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132857. /**
  132858. * Defines the default value of how much AO map is occluding the analytical lights
  132859. * (point spot...).
  132860. */
  132861. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132862. /**
  132863. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132864. */
  132865. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132866. /**
  132867. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132868. * to enhance interoperability with other engines.
  132869. */
  132870. static readonly LIGHTFALLOFF_GLTF: number;
  132871. /**
  132872. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132873. * to enhance interoperability with other materials.
  132874. */
  132875. static readonly LIGHTFALLOFF_STANDARD: number;
  132876. /**
  132877. * Intensity of the direct lights e.g. the four lights available in your scene.
  132878. * This impacts both the direct diffuse and specular highlights.
  132879. */
  132880. protected _directIntensity: number;
  132881. /**
  132882. * Intensity of the emissive part of the material.
  132883. * This helps controlling the emissive effect without modifying the emissive color.
  132884. */
  132885. protected _emissiveIntensity: number;
  132886. /**
  132887. * Intensity of the environment e.g. how much the environment will light the object
  132888. * either through harmonics for rough material or through the refelction for shiny ones.
  132889. */
  132890. protected _environmentIntensity: number;
  132891. /**
  132892. * This is a special control allowing the reduction of the specular highlights coming from the
  132893. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132894. */
  132895. protected _specularIntensity: number;
  132896. /**
  132897. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132898. */
  132899. private _lightingInfos;
  132900. /**
  132901. * Debug Control allowing disabling the bump map on this material.
  132902. */
  132903. protected _disableBumpMap: boolean;
  132904. /**
  132905. * AKA Diffuse Texture in standard nomenclature.
  132906. */
  132907. protected _albedoTexture: Nullable<BaseTexture>;
  132908. /**
  132909. * AKA Occlusion Texture in other nomenclature.
  132910. */
  132911. protected _ambientTexture: Nullable<BaseTexture>;
  132912. /**
  132913. * AKA Occlusion Texture Intensity in other nomenclature.
  132914. */
  132915. protected _ambientTextureStrength: number;
  132916. /**
  132917. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132918. * 1 means it completely occludes it
  132919. * 0 mean it has no impact
  132920. */
  132921. protected _ambientTextureImpactOnAnalyticalLights: number;
  132922. /**
  132923. * Stores the alpha values in a texture.
  132924. */
  132925. protected _opacityTexture: Nullable<BaseTexture>;
  132926. /**
  132927. * Stores the reflection values in a texture.
  132928. */
  132929. protected _reflectionTexture: Nullable<BaseTexture>;
  132930. /**
  132931. * Stores the emissive values in a texture.
  132932. */
  132933. protected _emissiveTexture: Nullable<BaseTexture>;
  132934. /**
  132935. * AKA Specular texture in other nomenclature.
  132936. */
  132937. protected _reflectivityTexture: Nullable<BaseTexture>;
  132938. /**
  132939. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132940. */
  132941. protected _metallicTexture: Nullable<BaseTexture>;
  132942. /**
  132943. * Specifies the metallic scalar of the metallic/roughness workflow.
  132944. * Can also be used to scale the metalness values of the metallic texture.
  132945. */
  132946. protected _metallic: Nullable<number>;
  132947. /**
  132948. * Specifies the roughness scalar of the metallic/roughness workflow.
  132949. * Can also be used to scale the roughness values of the metallic texture.
  132950. */
  132951. protected _roughness: Nullable<number>;
  132952. /**
  132953. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132954. * By default the indexOfrefraction is used to compute F0;
  132955. *
  132956. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132957. *
  132958. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132959. * F90 = metallicReflectanceColor;
  132960. */
  132961. protected _metallicF0Factor: number;
  132962. /**
  132963. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132964. * By default the F90 is always 1;
  132965. *
  132966. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132967. *
  132968. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132969. * F90 = metallicReflectanceColor;
  132970. */
  132971. protected _metallicReflectanceColor: Color3;
  132972. /**
  132973. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132974. * This is multiply against the scalar values defined in the material.
  132975. */
  132976. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132977. /**
  132978. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132979. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132980. */
  132981. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132982. /**
  132983. * Stores surface normal data used to displace a mesh in a texture.
  132984. */
  132985. protected _bumpTexture: Nullable<BaseTexture>;
  132986. /**
  132987. * Stores the pre-calculated light information of a mesh in a texture.
  132988. */
  132989. protected _lightmapTexture: Nullable<BaseTexture>;
  132990. /**
  132991. * The color of a material in ambient lighting.
  132992. */
  132993. protected _ambientColor: Color3;
  132994. /**
  132995. * AKA Diffuse Color in other nomenclature.
  132996. */
  132997. protected _albedoColor: Color3;
  132998. /**
  132999. * AKA Specular Color in other nomenclature.
  133000. */
  133001. protected _reflectivityColor: Color3;
  133002. /**
  133003. * The color applied when light is reflected from a material.
  133004. */
  133005. protected _reflectionColor: Color3;
  133006. /**
  133007. * The color applied when light is emitted from a material.
  133008. */
  133009. protected _emissiveColor: Color3;
  133010. /**
  133011. * AKA Glossiness in other nomenclature.
  133012. */
  133013. protected _microSurface: number;
  133014. /**
  133015. * Specifies that the material will use the light map as a show map.
  133016. */
  133017. protected _useLightmapAsShadowmap: boolean;
  133018. /**
  133019. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133020. * makes the reflect vector face the model (under horizon).
  133021. */
  133022. protected _useHorizonOcclusion: boolean;
  133023. /**
  133024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133025. * too much the area relying on ambient texture to define their ambient occlusion.
  133026. */
  133027. protected _useRadianceOcclusion: boolean;
  133028. /**
  133029. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133030. */
  133031. protected _useAlphaFromAlbedoTexture: boolean;
  133032. /**
  133033. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133034. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133035. */
  133036. protected _useSpecularOverAlpha: boolean;
  133037. /**
  133038. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133039. */
  133040. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133041. /**
  133042. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133043. */
  133044. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133045. /**
  133046. * Specifies if the metallic texture contains the roughness information in its green channel.
  133047. */
  133048. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133049. /**
  133050. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133051. */
  133052. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133053. /**
  133054. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133055. */
  133056. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133057. /**
  133058. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133059. */
  133060. protected _useAmbientInGrayScale: boolean;
  133061. /**
  133062. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133063. * The material will try to infer what glossiness each pixel should be.
  133064. */
  133065. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133066. /**
  133067. * Defines the falloff type used in this material.
  133068. * It by default is Physical.
  133069. */
  133070. protected _lightFalloff: number;
  133071. /**
  133072. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133073. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133074. */
  133075. protected _useRadianceOverAlpha: boolean;
  133076. /**
  133077. * Allows using an object space normal map (instead of tangent space).
  133078. */
  133079. protected _useObjectSpaceNormalMap: boolean;
  133080. /**
  133081. * Allows using the bump map in parallax mode.
  133082. */
  133083. protected _useParallax: boolean;
  133084. /**
  133085. * Allows using the bump map in parallax occlusion mode.
  133086. */
  133087. protected _useParallaxOcclusion: boolean;
  133088. /**
  133089. * Controls the scale bias of the parallax mode.
  133090. */
  133091. protected _parallaxScaleBias: number;
  133092. /**
  133093. * If sets to true, disables all the lights affecting the material.
  133094. */
  133095. protected _disableLighting: boolean;
  133096. /**
  133097. * Number of Simultaneous lights allowed on the material.
  133098. */
  133099. protected _maxSimultaneousLights: number;
  133100. /**
  133101. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133102. */
  133103. protected _invertNormalMapX: boolean;
  133104. /**
  133105. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133106. */
  133107. protected _invertNormalMapY: boolean;
  133108. /**
  133109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133110. */
  133111. protected _twoSidedLighting: boolean;
  133112. /**
  133113. * Defines the alpha limits in alpha test mode.
  133114. */
  133115. protected _alphaCutOff: number;
  133116. /**
  133117. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133118. */
  133119. protected _forceAlphaTest: boolean;
  133120. /**
  133121. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133122. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133123. */
  133124. protected _useAlphaFresnel: boolean;
  133125. /**
  133126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133127. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133128. */
  133129. protected _useLinearAlphaFresnel: boolean;
  133130. /**
  133131. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133132. * from cos thetav and roughness:
  133133. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133134. */
  133135. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133136. /**
  133137. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133138. */
  133139. protected _forceIrradianceInFragment: boolean;
  133140. private _realTimeFiltering;
  133141. /**
  133142. * Enables realtime filtering on the texture.
  133143. */
  133144. get realTimeFiltering(): boolean;
  133145. set realTimeFiltering(b: boolean);
  133146. private _realTimeFilteringQuality;
  133147. /**
  133148. * Quality switch for realtime filtering
  133149. */
  133150. get realTimeFilteringQuality(): number;
  133151. set realTimeFilteringQuality(n: number);
  133152. /**
  133153. * Force normal to face away from face.
  133154. */
  133155. protected _forceNormalForward: boolean;
  133156. /**
  133157. * Enables specular anti aliasing in the PBR shader.
  133158. * It will both interacts on the Geometry for analytical and IBL lighting.
  133159. * It also prefilter the roughness map based on the bump values.
  133160. */
  133161. protected _enableSpecularAntiAliasing: boolean;
  133162. /**
  133163. * Default configuration related to image processing available in the PBR Material.
  133164. */
  133165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133166. /**
  133167. * Keep track of the image processing observer to allow dispose and replace.
  133168. */
  133169. private _imageProcessingObserver;
  133170. /**
  133171. * Attaches a new image processing configuration to the PBR Material.
  133172. * @param configuration
  133173. */
  133174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133175. /**
  133176. * Stores the available render targets.
  133177. */
  133178. private _renderTargets;
  133179. /**
  133180. * Sets the global ambient color for the material used in lighting calculations.
  133181. */
  133182. private _globalAmbientColor;
  133183. /**
  133184. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133185. */
  133186. private _useLogarithmicDepth;
  133187. /**
  133188. * If set to true, no lighting calculations will be applied.
  133189. */
  133190. private _unlit;
  133191. private _debugMode;
  133192. /**
  133193. * @hidden
  133194. * This is reserved for the inspector.
  133195. * Defines the material debug mode.
  133196. * It helps seeing only some components of the material while troubleshooting.
  133197. */
  133198. debugMode: number;
  133199. /**
  133200. * @hidden
  133201. * This is reserved for the inspector.
  133202. * Specify from where on screen the debug mode should start.
  133203. * The value goes from -1 (full screen) to 1 (not visible)
  133204. * It helps with side by side comparison against the final render
  133205. * This defaults to -1
  133206. */
  133207. private debugLimit;
  133208. /**
  133209. * @hidden
  133210. * This is reserved for the inspector.
  133211. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133212. * You can use the factor to better multiply the final value.
  133213. */
  133214. private debugFactor;
  133215. /**
  133216. * Defines the clear coat layer parameters for the material.
  133217. */
  133218. readonly clearCoat: PBRClearCoatConfiguration;
  133219. /**
  133220. * Defines the anisotropic parameters for the material.
  133221. */
  133222. readonly anisotropy: PBRAnisotropicConfiguration;
  133223. /**
  133224. * Defines the BRDF parameters for the material.
  133225. */
  133226. readonly brdf: PBRBRDFConfiguration;
  133227. /**
  133228. * Defines the Sheen parameters for the material.
  133229. */
  133230. readonly sheen: PBRSheenConfiguration;
  133231. /**
  133232. * Defines the SubSurface parameters for the material.
  133233. */
  133234. readonly subSurface: PBRSubSurfaceConfiguration;
  133235. /**
  133236. * Defines the detail map parameters for the material.
  133237. */
  133238. readonly detailMap: DetailMapConfiguration;
  133239. protected _rebuildInParallel: boolean;
  133240. /**
  133241. * Instantiates a new PBRMaterial instance.
  133242. *
  133243. * @param name The material name
  133244. * @param scene The scene the material will be use in.
  133245. */
  133246. constructor(name: string, scene: Scene);
  133247. /**
  133248. * Gets a boolean indicating that current material needs to register RTT
  133249. */
  133250. get hasRenderTargetTextures(): boolean;
  133251. /**
  133252. * Gets the name of the material class.
  133253. */
  133254. getClassName(): string;
  133255. /**
  133256. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133257. */
  133258. get useLogarithmicDepth(): boolean;
  133259. /**
  133260. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133261. */
  133262. set useLogarithmicDepth(value: boolean);
  133263. /**
  133264. * Returns true if alpha blending should be disabled.
  133265. */
  133266. protected get _disableAlphaBlending(): boolean;
  133267. /**
  133268. * Specifies whether or not this material should be rendered in alpha blend mode.
  133269. */
  133270. needAlphaBlending(): boolean;
  133271. /**
  133272. * Specifies whether or not this material should be rendered in alpha test mode.
  133273. */
  133274. needAlphaTesting(): boolean;
  133275. /**
  133276. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133277. */
  133278. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133279. /**
  133280. * Gets the texture used for the alpha test.
  133281. */
  133282. getAlphaTestTexture(): Nullable<BaseTexture>;
  133283. /**
  133284. * Specifies that the submesh is ready to be used.
  133285. * @param mesh - BJS mesh.
  133286. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133287. * @param useInstances - Specifies that instances should be used.
  133288. * @returns - boolean indicating that the submesh is ready or not.
  133289. */
  133290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133291. /**
  133292. * Specifies if the material uses metallic roughness workflow.
  133293. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133294. */
  133295. isMetallicWorkflow(): boolean;
  133296. private _prepareEffect;
  133297. private _prepareDefines;
  133298. /**
  133299. * Force shader compilation
  133300. */
  133301. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133302. /**
  133303. * Initializes the uniform buffer layout for the shader.
  133304. */
  133305. buildUniformLayout(): void;
  133306. /**
  133307. * Unbinds the material from the mesh
  133308. */
  133309. unbind(): void;
  133310. /**
  133311. * Binds the submesh data.
  133312. * @param world - The world matrix.
  133313. * @param mesh - The BJS mesh.
  133314. * @param subMesh - A submesh of the BJS mesh.
  133315. */
  133316. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133317. /**
  133318. * Returns the animatable textures.
  133319. * @returns - Array of animatable textures.
  133320. */
  133321. getAnimatables(): IAnimatable[];
  133322. /**
  133323. * Returns the texture used for reflections.
  133324. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  133325. */
  133326. private _getReflectionTexture;
  133327. /**
  133328. * Returns an array of the actively used textures.
  133329. * @returns - Array of BaseTextures
  133330. */
  133331. getActiveTextures(): BaseTexture[];
  133332. /**
  133333. * Checks to see if a texture is used in the material.
  133334. * @param texture - Base texture to use.
  133335. * @returns - Boolean specifying if a texture is used in the material.
  133336. */
  133337. hasTexture(texture: BaseTexture): boolean;
  133338. /**
  133339. * Disposes the resources of the material.
  133340. * @param forceDisposeEffect - Forces the disposal of effects.
  133341. * @param forceDisposeTextures - Forces the disposal of all textures.
  133342. */
  133343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133344. }
  133345. }
  133346. declare module BABYLON {
  133347. /**
  133348. * The Physically based material of BJS.
  133349. *
  133350. * This offers the main features of a standard PBR material.
  133351. * For more information, please refer to the documentation :
  133352. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133353. */
  133354. export class PBRMaterial extends PBRBaseMaterial {
  133355. /**
  133356. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133357. */
  133358. static readonly PBRMATERIAL_OPAQUE: number;
  133359. /**
  133360. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133361. */
  133362. static readonly PBRMATERIAL_ALPHATEST: number;
  133363. /**
  133364. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133365. */
  133366. static readonly PBRMATERIAL_ALPHABLEND: number;
  133367. /**
  133368. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133369. * They are also discarded below the alpha cutoff threshold to improve performances.
  133370. */
  133371. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133372. /**
  133373. * Defines the default value of how much AO map is occluding the analytical lights
  133374. * (point spot...).
  133375. */
  133376. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133377. /**
  133378. * Intensity of the direct lights e.g. the four lights available in your scene.
  133379. * This impacts both the direct diffuse and specular highlights.
  133380. */
  133381. directIntensity: number;
  133382. /**
  133383. * Intensity of the emissive part of the material.
  133384. * This helps controlling the emissive effect without modifying the emissive color.
  133385. */
  133386. emissiveIntensity: number;
  133387. /**
  133388. * Intensity of the environment e.g. how much the environment will light the object
  133389. * either through harmonics for rough material or through the refelction for shiny ones.
  133390. */
  133391. environmentIntensity: number;
  133392. /**
  133393. * This is a special control allowing the reduction of the specular highlights coming from the
  133394. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133395. */
  133396. specularIntensity: number;
  133397. /**
  133398. * Debug Control allowing disabling the bump map on this material.
  133399. */
  133400. disableBumpMap: boolean;
  133401. /**
  133402. * AKA Diffuse Texture in standard nomenclature.
  133403. */
  133404. albedoTexture: BaseTexture;
  133405. /**
  133406. * AKA Occlusion Texture in other nomenclature.
  133407. */
  133408. ambientTexture: BaseTexture;
  133409. /**
  133410. * AKA Occlusion Texture Intensity in other nomenclature.
  133411. */
  133412. ambientTextureStrength: number;
  133413. /**
  133414. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133415. * 1 means it completely occludes it
  133416. * 0 mean it has no impact
  133417. */
  133418. ambientTextureImpactOnAnalyticalLights: number;
  133419. /**
  133420. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133421. */
  133422. opacityTexture: BaseTexture;
  133423. /**
  133424. * Stores the reflection values in a texture.
  133425. */
  133426. reflectionTexture: Nullable<BaseTexture>;
  133427. /**
  133428. * Stores the emissive values in a texture.
  133429. */
  133430. emissiveTexture: BaseTexture;
  133431. /**
  133432. * AKA Specular texture in other nomenclature.
  133433. */
  133434. reflectivityTexture: BaseTexture;
  133435. /**
  133436. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133437. */
  133438. metallicTexture: BaseTexture;
  133439. /**
  133440. * Specifies the metallic scalar of the metallic/roughness workflow.
  133441. * Can also be used to scale the metalness values of the metallic texture.
  133442. */
  133443. metallic: Nullable<number>;
  133444. /**
  133445. * Specifies the roughness scalar of the metallic/roughness workflow.
  133446. * Can also be used to scale the roughness values of the metallic texture.
  133447. */
  133448. roughness: Nullable<number>;
  133449. /**
  133450. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133451. * By default the indexOfrefraction is used to compute F0;
  133452. *
  133453. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133454. *
  133455. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133456. * F90 = metallicReflectanceColor;
  133457. */
  133458. metallicF0Factor: number;
  133459. /**
  133460. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133461. * By default the F90 is always 1;
  133462. *
  133463. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133464. *
  133465. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133466. * F90 = metallicReflectanceColor;
  133467. */
  133468. metallicReflectanceColor: Color3;
  133469. /**
  133470. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133471. * This is multiply against the scalar values defined in the material.
  133472. */
  133473. metallicReflectanceTexture: Nullable<BaseTexture>;
  133474. /**
  133475. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133476. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133477. */
  133478. microSurfaceTexture: BaseTexture;
  133479. /**
  133480. * Stores surface normal data used to displace a mesh in a texture.
  133481. */
  133482. bumpTexture: BaseTexture;
  133483. /**
  133484. * Stores the pre-calculated light information of a mesh in a texture.
  133485. */
  133486. lightmapTexture: BaseTexture;
  133487. /**
  133488. * Stores the refracted light information in a texture.
  133489. */
  133490. get refractionTexture(): Nullable<BaseTexture>;
  133491. set refractionTexture(value: Nullable<BaseTexture>);
  133492. /**
  133493. * The color of a material in ambient lighting.
  133494. */
  133495. ambientColor: Color3;
  133496. /**
  133497. * AKA Diffuse Color in other nomenclature.
  133498. */
  133499. albedoColor: Color3;
  133500. /**
  133501. * AKA Specular Color in other nomenclature.
  133502. */
  133503. reflectivityColor: Color3;
  133504. /**
  133505. * The color reflected from the material.
  133506. */
  133507. reflectionColor: Color3;
  133508. /**
  133509. * The color emitted from the material.
  133510. */
  133511. emissiveColor: Color3;
  133512. /**
  133513. * AKA Glossiness in other nomenclature.
  133514. */
  133515. microSurface: number;
  133516. /**
  133517. * Index of refraction of the material base layer.
  133518. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133519. *
  133520. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133521. *
  133522. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133523. */
  133524. get indexOfRefraction(): number;
  133525. set indexOfRefraction(value: number);
  133526. /**
  133527. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133528. */
  133529. get invertRefractionY(): boolean;
  133530. set invertRefractionY(value: boolean);
  133531. /**
  133532. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133533. * Materials half opaque for instance using refraction could benefit from this control.
  133534. */
  133535. get linkRefractionWithTransparency(): boolean;
  133536. set linkRefractionWithTransparency(value: boolean);
  133537. /**
  133538. * If true, the light map contains occlusion information instead of lighting info.
  133539. */
  133540. useLightmapAsShadowmap: boolean;
  133541. /**
  133542. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133543. */
  133544. useAlphaFromAlbedoTexture: boolean;
  133545. /**
  133546. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133547. */
  133548. forceAlphaTest: boolean;
  133549. /**
  133550. * Defines the alpha limits in alpha test mode.
  133551. */
  133552. alphaCutOff: number;
  133553. /**
  133554. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133555. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133556. */
  133557. useSpecularOverAlpha: boolean;
  133558. /**
  133559. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133560. */
  133561. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133562. /**
  133563. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133564. */
  133565. useRoughnessFromMetallicTextureAlpha: boolean;
  133566. /**
  133567. * Specifies if the metallic texture contains the roughness information in its green channel.
  133568. */
  133569. useRoughnessFromMetallicTextureGreen: boolean;
  133570. /**
  133571. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133572. */
  133573. useMetallnessFromMetallicTextureBlue: boolean;
  133574. /**
  133575. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133576. */
  133577. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133578. /**
  133579. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133580. */
  133581. useAmbientInGrayScale: boolean;
  133582. /**
  133583. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133584. * The material will try to infer what glossiness each pixel should be.
  133585. */
  133586. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133587. /**
  133588. * BJS is using an harcoded light falloff based on a manually sets up range.
  133589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133591. */
  133592. get usePhysicalLightFalloff(): boolean;
  133593. /**
  133594. * BJS is using an harcoded light falloff based on a manually sets up range.
  133595. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133596. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133597. */
  133598. set usePhysicalLightFalloff(value: boolean);
  133599. /**
  133600. * In order to support the falloff compatibility with gltf, a special mode has been added
  133601. * to reproduce the gltf light falloff.
  133602. */
  133603. get useGLTFLightFalloff(): boolean;
  133604. /**
  133605. * In order to support the falloff compatibility with gltf, a special mode has been added
  133606. * to reproduce the gltf light falloff.
  133607. */
  133608. set useGLTFLightFalloff(value: boolean);
  133609. /**
  133610. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133611. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133612. */
  133613. useRadianceOverAlpha: boolean;
  133614. /**
  133615. * Allows using an object space normal map (instead of tangent space).
  133616. */
  133617. useObjectSpaceNormalMap: boolean;
  133618. /**
  133619. * Allows using the bump map in parallax mode.
  133620. */
  133621. useParallax: boolean;
  133622. /**
  133623. * Allows using the bump map in parallax occlusion mode.
  133624. */
  133625. useParallaxOcclusion: boolean;
  133626. /**
  133627. * Controls the scale bias of the parallax mode.
  133628. */
  133629. parallaxScaleBias: number;
  133630. /**
  133631. * If sets to true, disables all the lights affecting the material.
  133632. */
  133633. disableLighting: boolean;
  133634. /**
  133635. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133636. */
  133637. forceIrradianceInFragment: boolean;
  133638. /**
  133639. * Number of Simultaneous lights allowed on the material.
  133640. */
  133641. maxSimultaneousLights: number;
  133642. /**
  133643. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133644. */
  133645. invertNormalMapX: boolean;
  133646. /**
  133647. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133648. */
  133649. invertNormalMapY: boolean;
  133650. /**
  133651. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133652. */
  133653. twoSidedLighting: boolean;
  133654. /**
  133655. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133656. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133657. */
  133658. useAlphaFresnel: boolean;
  133659. /**
  133660. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133661. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133662. */
  133663. useLinearAlphaFresnel: boolean;
  133664. /**
  133665. * Let user defines the brdf lookup texture used for IBL.
  133666. * A default 8bit version is embedded but you could point at :
  133667. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133668. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133669. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133670. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133671. */
  133672. environmentBRDFTexture: Nullable<BaseTexture>;
  133673. /**
  133674. * Force normal to face away from face.
  133675. */
  133676. forceNormalForward: boolean;
  133677. /**
  133678. * Enables specular anti aliasing in the PBR shader.
  133679. * It will both interacts on the Geometry for analytical and IBL lighting.
  133680. * It also prefilter the roughness map based on the bump values.
  133681. */
  133682. enableSpecularAntiAliasing: boolean;
  133683. /**
  133684. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133685. * makes the reflect vector face the model (under horizon).
  133686. */
  133687. useHorizonOcclusion: boolean;
  133688. /**
  133689. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133690. * too much the area relying on ambient texture to define their ambient occlusion.
  133691. */
  133692. useRadianceOcclusion: boolean;
  133693. /**
  133694. * If set to true, no lighting calculations will be applied.
  133695. */
  133696. unlit: boolean;
  133697. /**
  133698. * Gets the image processing configuration used either in this material.
  133699. */
  133700. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133701. /**
  133702. * Sets the Default image processing configuration used either in the this material.
  133703. *
  133704. * If sets to null, the scene one is in use.
  133705. */
  133706. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133707. /**
  133708. * Gets wether the color curves effect is enabled.
  133709. */
  133710. get cameraColorCurvesEnabled(): boolean;
  133711. /**
  133712. * Sets wether the color curves effect is enabled.
  133713. */
  133714. set cameraColorCurvesEnabled(value: boolean);
  133715. /**
  133716. * Gets wether the color grading effect is enabled.
  133717. */
  133718. get cameraColorGradingEnabled(): boolean;
  133719. /**
  133720. * Gets wether the color grading effect is enabled.
  133721. */
  133722. set cameraColorGradingEnabled(value: boolean);
  133723. /**
  133724. * Gets wether tonemapping is enabled or not.
  133725. */
  133726. get cameraToneMappingEnabled(): boolean;
  133727. /**
  133728. * Sets wether tonemapping is enabled or not
  133729. */
  133730. set cameraToneMappingEnabled(value: boolean);
  133731. /**
  133732. * The camera exposure used on this material.
  133733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133734. * This corresponds to a photographic exposure.
  133735. */
  133736. get cameraExposure(): number;
  133737. /**
  133738. * The camera exposure used on this material.
  133739. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133740. * This corresponds to a photographic exposure.
  133741. */
  133742. set cameraExposure(value: number);
  133743. /**
  133744. * Gets The camera contrast used on this material.
  133745. */
  133746. get cameraContrast(): number;
  133747. /**
  133748. * Sets The camera contrast used on this material.
  133749. */
  133750. set cameraContrast(value: number);
  133751. /**
  133752. * Gets the Color Grading 2D Lookup Texture.
  133753. */
  133754. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133755. /**
  133756. * Sets the Color Grading 2D Lookup Texture.
  133757. */
  133758. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133759. /**
  133760. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133761. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133762. * 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;
  133763. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133764. */
  133765. get cameraColorCurves(): Nullable<ColorCurves>;
  133766. /**
  133767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133769. * 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;
  133770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133771. */
  133772. set cameraColorCurves(value: Nullable<ColorCurves>);
  133773. /**
  133774. * Instantiates a new PBRMaterial instance.
  133775. *
  133776. * @param name The material name
  133777. * @param scene The scene the material will be use in.
  133778. */
  133779. constructor(name: string, scene: Scene);
  133780. /**
  133781. * Returns the name of this material class.
  133782. */
  133783. getClassName(): string;
  133784. /**
  133785. * Makes a duplicate of the current material.
  133786. * @param name - name to use for the new material.
  133787. */
  133788. clone(name: string): PBRMaterial;
  133789. /**
  133790. * Serializes this PBR Material.
  133791. * @returns - An object with the serialized material.
  133792. */
  133793. serialize(): any;
  133794. /**
  133795. * Parses a PBR Material from a serialized object.
  133796. * @param source - Serialized object.
  133797. * @param scene - BJS scene instance.
  133798. * @param rootUrl - url for the scene object
  133799. * @returns - PBRMaterial
  133800. */
  133801. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  133802. }
  133803. }
  133804. declare module BABYLON {
  133805. /**
  133806. * Direct draw surface info
  133807. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  133808. */
  133809. export interface DDSInfo {
  133810. /**
  133811. * Width of the texture
  133812. */
  133813. width: number;
  133814. /**
  133815. * Width of the texture
  133816. */
  133817. height: number;
  133818. /**
  133819. * Number of Mipmaps for the texture
  133820. * @see https://en.wikipedia.org/wiki/Mipmap
  133821. */
  133822. mipmapCount: number;
  133823. /**
  133824. * If the textures format is a known fourCC format
  133825. * @see https://www.fourcc.org/
  133826. */
  133827. isFourCC: boolean;
  133828. /**
  133829. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  133830. */
  133831. isRGB: boolean;
  133832. /**
  133833. * If the texture is a lumincance format
  133834. */
  133835. isLuminance: boolean;
  133836. /**
  133837. * If this is a cube texture
  133838. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133839. */
  133840. isCube: boolean;
  133841. /**
  133842. * If the texture is a compressed format eg. FOURCC_DXT1
  133843. */
  133844. isCompressed: boolean;
  133845. /**
  133846. * The dxgiFormat of the texture
  133847. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133848. */
  133849. dxgiFormat: number;
  133850. /**
  133851. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133852. */
  133853. textureType: number;
  133854. /**
  133855. * Sphericle polynomial created for the dds texture
  133856. */
  133857. sphericalPolynomial?: SphericalPolynomial;
  133858. }
  133859. /**
  133860. * Class used to provide DDS decompression tools
  133861. */
  133862. export class DDSTools {
  133863. /**
  133864. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133865. */
  133866. static StoreLODInAlphaChannel: boolean;
  133867. /**
  133868. * Gets DDS information from an array buffer
  133869. * @param data defines the array buffer view to read data from
  133870. * @returns the DDS information
  133871. */
  133872. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133873. private static _FloatView;
  133874. private static _Int32View;
  133875. private static _ToHalfFloat;
  133876. private static _FromHalfFloat;
  133877. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133878. private static _GetHalfFloatRGBAArrayBuffer;
  133879. private static _GetFloatRGBAArrayBuffer;
  133880. private static _GetFloatAsUIntRGBAArrayBuffer;
  133881. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133882. private static _GetRGBAArrayBuffer;
  133883. private static _ExtractLongWordOrder;
  133884. private static _GetRGBArrayBuffer;
  133885. private static _GetLuminanceArrayBuffer;
  133886. /**
  133887. * Uploads DDS Levels to a Babylon Texture
  133888. * @hidden
  133889. */
  133890. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133891. }
  133892. interface ThinEngine {
  133893. /**
  133894. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133895. * @param rootUrl defines the url where the file to load is located
  133896. * @param scene defines the current scene
  133897. * @param lodScale defines scale to apply to the mip map selection
  133898. * @param lodOffset defines offset to apply to the mip map selection
  133899. * @param onLoad defines an optional callback raised when the texture is loaded
  133900. * @param onError defines an optional callback raised if there is an issue to load the texture
  133901. * @param format defines the format of the data
  133902. * @param forcedExtension defines the extension to use to pick the right loader
  133903. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133904. * @returns the cube texture as an InternalTexture
  133905. */
  133906. 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;
  133907. }
  133908. }
  133909. declare module BABYLON {
  133910. /**
  133911. * Implementation of the DDS Texture Loader.
  133912. * @hidden
  133913. */
  133914. export class _DDSTextureLoader implements IInternalTextureLoader {
  133915. /**
  133916. * Defines wether the loader supports cascade loading the different faces.
  133917. */
  133918. readonly supportCascades: boolean;
  133919. /**
  133920. * This returns if the loader support the current file information.
  133921. * @param extension defines the file extension of the file being loaded
  133922. * @returns true if the loader can load the specified file
  133923. */
  133924. canLoad(extension: string): boolean;
  133925. /**
  133926. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133927. * @param data contains the texture data
  133928. * @param texture defines the BabylonJS internal texture
  133929. * @param createPolynomials will be true if polynomials have been requested
  133930. * @param onLoad defines the callback to trigger once the texture is ready
  133931. * @param onError defines the callback to trigger in case of error
  133932. */
  133933. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133934. /**
  133935. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133936. * @param data contains the texture data
  133937. * @param texture defines the BabylonJS internal texture
  133938. * @param callback defines the method to call once ready to upload
  133939. */
  133940. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133941. }
  133942. }
  133943. declare module BABYLON {
  133944. /**
  133945. * Implementation of the ENV Texture Loader.
  133946. * @hidden
  133947. */
  133948. export class _ENVTextureLoader implements IInternalTextureLoader {
  133949. /**
  133950. * Defines wether the loader supports cascade loading the different faces.
  133951. */
  133952. readonly supportCascades: boolean;
  133953. /**
  133954. * This returns if the loader support the current file information.
  133955. * @param extension defines the file extension of the file being loaded
  133956. * @returns true if the loader can load the specified file
  133957. */
  133958. canLoad(extension: string): boolean;
  133959. /**
  133960. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133961. * @param data contains the texture data
  133962. * @param texture defines the BabylonJS internal texture
  133963. * @param createPolynomials will be true if polynomials have been requested
  133964. * @param onLoad defines the callback to trigger once the texture is ready
  133965. * @param onError defines the callback to trigger in case of error
  133966. */
  133967. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133968. /**
  133969. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133970. * @param data contains the texture data
  133971. * @param texture defines the BabylonJS internal texture
  133972. * @param callback defines the method to call once ready to upload
  133973. */
  133974. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133975. }
  133976. }
  133977. declare module BABYLON {
  133978. /**
  133979. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133980. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133981. */
  133982. export class KhronosTextureContainer {
  133983. /** contents of the KTX container file */
  133984. data: ArrayBufferView;
  133985. private static HEADER_LEN;
  133986. private static COMPRESSED_2D;
  133987. private static COMPRESSED_3D;
  133988. private static TEX_2D;
  133989. private static TEX_3D;
  133990. /**
  133991. * Gets the openGL type
  133992. */
  133993. glType: number;
  133994. /**
  133995. * Gets the openGL type size
  133996. */
  133997. glTypeSize: number;
  133998. /**
  133999. * Gets the openGL format
  134000. */
  134001. glFormat: number;
  134002. /**
  134003. * Gets the openGL internal format
  134004. */
  134005. glInternalFormat: number;
  134006. /**
  134007. * Gets the base internal format
  134008. */
  134009. glBaseInternalFormat: number;
  134010. /**
  134011. * Gets image width in pixel
  134012. */
  134013. pixelWidth: number;
  134014. /**
  134015. * Gets image height in pixel
  134016. */
  134017. pixelHeight: number;
  134018. /**
  134019. * Gets image depth in pixels
  134020. */
  134021. pixelDepth: number;
  134022. /**
  134023. * Gets the number of array elements
  134024. */
  134025. numberOfArrayElements: number;
  134026. /**
  134027. * Gets the number of faces
  134028. */
  134029. numberOfFaces: number;
  134030. /**
  134031. * Gets the number of mipmap levels
  134032. */
  134033. numberOfMipmapLevels: number;
  134034. /**
  134035. * Gets the bytes of key value data
  134036. */
  134037. bytesOfKeyValueData: number;
  134038. /**
  134039. * Gets the load type
  134040. */
  134041. loadType: number;
  134042. /**
  134043. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134044. */
  134045. isInvalid: boolean;
  134046. /**
  134047. * Creates a new KhronosTextureContainer
  134048. * @param data contents of the KTX container file
  134049. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134050. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134051. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134052. */
  134053. constructor(
  134054. /** contents of the KTX container file */
  134055. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134056. /**
  134057. * Uploads KTX content to a Babylon Texture.
  134058. * It is assumed that the texture has already been created & is currently bound
  134059. * @hidden
  134060. */
  134061. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134062. private _upload2DCompressedLevels;
  134063. /**
  134064. * Checks if the given data starts with a KTX file identifier.
  134065. * @param data the data to check
  134066. * @returns true if the data is a KTX file or false otherwise
  134067. */
  134068. static IsValid(data: ArrayBufferView): boolean;
  134069. }
  134070. }
  134071. declare module BABYLON {
  134072. /**
  134073. * Class for loading KTX2 files
  134074. * !!! Experimental Extension Subject to Changes !!!
  134075. * @hidden
  134076. */
  134077. export class KhronosTextureContainer2 {
  134078. private static _ModulePromise;
  134079. private static _TranscodeFormat;
  134080. constructor(engine: ThinEngine);
  134081. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134082. private _determineTranscodeFormat;
  134083. /**
  134084. * Checks if the given data starts with a KTX2 file identifier.
  134085. * @param data the data to check
  134086. * @returns true if the data is a KTX2 file or false otherwise
  134087. */
  134088. static IsValid(data: ArrayBufferView): boolean;
  134089. }
  134090. }
  134091. declare module BABYLON {
  134092. /**
  134093. * Implementation of the KTX Texture Loader.
  134094. * @hidden
  134095. */
  134096. export class _KTXTextureLoader implements IInternalTextureLoader {
  134097. /**
  134098. * Defines wether the loader supports cascade loading the different faces.
  134099. */
  134100. readonly supportCascades: boolean;
  134101. /**
  134102. * This returns if the loader support the current file information.
  134103. * @param extension defines the file extension of the file being loaded
  134104. * @returns true if the loader can load the specified file
  134105. */
  134106. canLoad(extension: string): boolean;
  134107. /**
  134108. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134109. * @param data contains the texture data
  134110. * @param texture defines the BabylonJS internal texture
  134111. * @param createPolynomials will be true if polynomials have been requested
  134112. * @param onLoad defines the callback to trigger once the texture is ready
  134113. * @param onError defines the callback to trigger in case of error
  134114. */
  134115. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134116. /**
  134117. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134118. * @param data contains the texture data
  134119. * @param texture defines the BabylonJS internal texture
  134120. * @param callback defines the method to call once ready to upload
  134121. */
  134122. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134123. }
  134124. }
  134125. declare module BABYLON {
  134126. /** @hidden */
  134127. export var _forceSceneHelpersToBundle: boolean;
  134128. interface Scene {
  134129. /**
  134130. * Creates a default light for the scene.
  134131. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134132. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134133. */
  134134. createDefaultLight(replace?: boolean): void;
  134135. /**
  134136. * Creates a default camera for the scene.
  134137. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134138. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134139. * @param replace has default false, when true replaces the active camera in the scene
  134140. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134141. */
  134142. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134143. /**
  134144. * Creates a default camera and a default light.
  134145. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134146. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134147. * @param replace has the default false, when true replaces the active camera/light in the scene
  134148. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134149. */
  134150. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134151. /**
  134152. * Creates a new sky box
  134153. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134154. * @param environmentTexture defines the texture to use as environment texture
  134155. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134156. * @param scale defines the overall scale of the skybox
  134157. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134158. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134159. * @returns a new mesh holding the sky box
  134160. */
  134161. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134162. /**
  134163. * Creates a new environment
  134164. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134165. * @param options defines the options you can use to configure the environment
  134166. * @returns the new EnvironmentHelper
  134167. */
  134168. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134169. /**
  134170. * Creates a new VREXperienceHelper
  134171. * @see http://doc.babylonjs.com/how_to/webvr_helper
  134172. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134173. * @returns a new VREXperienceHelper
  134174. */
  134175. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134176. /**
  134177. * Creates a new WebXRDefaultExperience
  134178. * @see http://doc.babylonjs.com/how_to/webxr
  134179. * @param options experience options
  134180. * @returns a promise for a new WebXRDefaultExperience
  134181. */
  134182. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134183. }
  134184. }
  134185. declare module BABYLON {
  134186. /**
  134187. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134188. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134189. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134190. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134191. */
  134192. export class VideoDome extends TransformNode {
  134193. /**
  134194. * Define the video source as a Monoscopic panoramic 360 video.
  134195. */
  134196. static readonly MODE_MONOSCOPIC: number;
  134197. /**
  134198. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134199. */
  134200. static readonly MODE_TOPBOTTOM: number;
  134201. /**
  134202. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134203. */
  134204. static readonly MODE_SIDEBYSIDE: number;
  134205. private _halfDome;
  134206. private _useDirectMapping;
  134207. /**
  134208. * The video texture being displayed on the sphere
  134209. */
  134210. protected _videoTexture: VideoTexture;
  134211. /**
  134212. * Gets the video texture being displayed on the sphere
  134213. */
  134214. get videoTexture(): VideoTexture;
  134215. /**
  134216. * The skybox material
  134217. */
  134218. protected _material: BackgroundMaterial;
  134219. /**
  134220. * The surface used for the skybox
  134221. */
  134222. protected _mesh: Mesh;
  134223. /**
  134224. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134225. */
  134226. private _halfDomeMask;
  134227. /**
  134228. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134229. * Also see the options.resolution property.
  134230. */
  134231. get fovMultiplier(): number;
  134232. set fovMultiplier(value: number);
  134233. private _videoMode;
  134234. /**
  134235. * Gets or set the current video mode for the video. It can be:
  134236. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134237. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134238. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134239. */
  134240. get videoMode(): number;
  134241. set videoMode(value: number);
  134242. /**
  134243. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134244. *
  134245. */
  134246. get halfDome(): boolean;
  134247. /**
  134248. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134249. */
  134250. set halfDome(enabled: boolean);
  134251. /**
  134252. * Oberserver used in Stereoscopic VR Mode.
  134253. */
  134254. private _onBeforeCameraRenderObserver;
  134255. /**
  134256. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134257. * @param name Element's name, child elements will append suffixes for their own names.
  134258. * @param urlsOrVideo defines the url(s) or the video element to use
  134259. * @param options An object containing optional or exposed sub element properties
  134260. */
  134261. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134262. resolution?: number;
  134263. clickToPlay?: boolean;
  134264. autoPlay?: boolean;
  134265. loop?: boolean;
  134266. size?: number;
  134267. poster?: string;
  134268. faceForward?: boolean;
  134269. useDirectMapping?: boolean;
  134270. halfDomeMode?: boolean;
  134271. }, scene: Scene);
  134272. private _changeVideoMode;
  134273. /**
  134274. * Releases resources associated with this node.
  134275. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134276. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134277. */
  134278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134279. }
  134280. }
  134281. declare module BABYLON {
  134282. /**
  134283. * This class can be used to get instrumentation data from a Babylon engine
  134284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134285. */
  134286. export class EngineInstrumentation implements IDisposable {
  134287. /**
  134288. * Define the instrumented engine.
  134289. */
  134290. engine: Engine;
  134291. private _captureGPUFrameTime;
  134292. private _gpuFrameTimeToken;
  134293. private _gpuFrameTime;
  134294. private _captureShaderCompilationTime;
  134295. private _shaderCompilationTime;
  134296. private _onBeginFrameObserver;
  134297. private _onEndFrameObserver;
  134298. private _onBeforeShaderCompilationObserver;
  134299. private _onAfterShaderCompilationObserver;
  134300. /**
  134301. * Gets the perf counter used for GPU frame time
  134302. */
  134303. get gpuFrameTimeCounter(): PerfCounter;
  134304. /**
  134305. * Gets the GPU frame time capture status
  134306. */
  134307. get captureGPUFrameTime(): boolean;
  134308. /**
  134309. * Enable or disable the GPU frame time capture
  134310. */
  134311. set captureGPUFrameTime(value: boolean);
  134312. /**
  134313. * Gets the perf counter used for shader compilation time
  134314. */
  134315. get shaderCompilationTimeCounter(): PerfCounter;
  134316. /**
  134317. * Gets the shader compilation time capture status
  134318. */
  134319. get captureShaderCompilationTime(): boolean;
  134320. /**
  134321. * Enable or disable the shader compilation time capture
  134322. */
  134323. set captureShaderCompilationTime(value: boolean);
  134324. /**
  134325. * Instantiates a new engine instrumentation.
  134326. * This class can be used to get instrumentation data from a Babylon engine
  134327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134328. * @param engine Defines the engine to instrument
  134329. */
  134330. constructor(
  134331. /**
  134332. * Define the instrumented engine.
  134333. */
  134334. engine: Engine);
  134335. /**
  134336. * Dispose and release associated resources.
  134337. */
  134338. dispose(): void;
  134339. }
  134340. }
  134341. declare module BABYLON {
  134342. /**
  134343. * This class can be used to get instrumentation data from a Babylon engine
  134344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134345. */
  134346. export class SceneInstrumentation implements IDisposable {
  134347. /**
  134348. * Defines the scene to instrument
  134349. */
  134350. scene: Scene;
  134351. private _captureActiveMeshesEvaluationTime;
  134352. private _activeMeshesEvaluationTime;
  134353. private _captureRenderTargetsRenderTime;
  134354. private _renderTargetsRenderTime;
  134355. private _captureFrameTime;
  134356. private _frameTime;
  134357. private _captureRenderTime;
  134358. private _renderTime;
  134359. private _captureInterFrameTime;
  134360. private _interFrameTime;
  134361. private _captureParticlesRenderTime;
  134362. private _particlesRenderTime;
  134363. private _captureSpritesRenderTime;
  134364. private _spritesRenderTime;
  134365. private _capturePhysicsTime;
  134366. private _physicsTime;
  134367. private _captureAnimationsTime;
  134368. private _animationsTime;
  134369. private _captureCameraRenderTime;
  134370. private _cameraRenderTime;
  134371. private _onBeforeActiveMeshesEvaluationObserver;
  134372. private _onAfterActiveMeshesEvaluationObserver;
  134373. private _onBeforeRenderTargetsRenderObserver;
  134374. private _onAfterRenderTargetsRenderObserver;
  134375. private _onAfterRenderObserver;
  134376. private _onBeforeDrawPhaseObserver;
  134377. private _onAfterDrawPhaseObserver;
  134378. private _onBeforeAnimationsObserver;
  134379. private _onBeforeParticlesRenderingObserver;
  134380. private _onAfterParticlesRenderingObserver;
  134381. private _onBeforeSpritesRenderingObserver;
  134382. private _onAfterSpritesRenderingObserver;
  134383. private _onBeforePhysicsObserver;
  134384. private _onAfterPhysicsObserver;
  134385. private _onAfterAnimationsObserver;
  134386. private _onBeforeCameraRenderObserver;
  134387. private _onAfterCameraRenderObserver;
  134388. /**
  134389. * Gets the perf counter used for active meshes evaluation time
  134390. */
  134391. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134392. /**
  134393. * Gets the active meshes evaluation time capture status
  134394. */
  134395. get captureActiveMeshesEvaluationTime(): boolean;
  134396. /**
  134397. * Enable or disable the active meshes evaluation time capture
  134398. */
  134399. set captureActiveMeshesEvaluationTime(value: boolean);
  134400. /**
  134401. * Gets the perf counter used for render targets render time
  134402. */
  134403. get renderTargetsRenderTimeCounter(): PerfCounter;
  134404. /**
  134405. * Gets the render targets render time capture status
  134406. */
  134407. get captureRenderTargetsRenderTime(): boolean;
  134408. /**
  134409. * Enable or disable the render targets render time capture
  134410. */
  134411. set captureRenderTargetsRenderTime(value: boolean);
  134412. /**
  134413. * Gets the perf counter used for particles render time
  134414. */
  134415. get particlesRenderTimeCounter(): PerfCounter;
  134416. /**
  134417. * Gets the particles render time capture status
  134418. */
  134419. get captureParticlesRenderTime(): boolean;
  134420. /**
  134421. * Enable or disable the particles render time capture
  134422. */
  134423. set captureParticlesRenderTime(value: boolean);
  134424. /**
  134425. * Gets the perf counter used for sprites render time
  134426. */
  134427. get spritesRenderTimeCounter(): PerfCounter;
  134428. /**
  134429. * Gets the sprites render time capture status
  134430. */
  134431. get captureSpritesRenderTime(): boolean;
  134432. /**
  134433. * Enable or disable the sprites render time capture
  134434. */
  134435. set captureSpritesRenderTime(value: boolean);
  134436. /**
  134437. * Gets the perf counter used for physics time
  134438. */
  134439. get physicsTimeCounter(): PerfCounter;
  134440. /**
  134441. * Gets the physics time capture status
  134442. */
  134443. get capturePhysicsTime(): boolean;
  134444. /**
  134445. * Enable or disable the physics time capture
  134446. */
  134447. set capturePhysicsTime(value: boolean);
  134448. /**
  134449. * Gets the perf counter used for animations time
  134450. */
  134451. get animationsTimeCounter(): PerfCounter;
  134452. /**
  134453. * Gets the animations time capture status
  134454. */
  134455. get captureAnimationsTime(): boolean;
  134456. /**
  134457. * Enable or disable the animations time capture
  134458. */
  134459. set captureAnimationsTime(value: boolean);
  134460. /**
  134461. * Gets the perf counter used for frame time capture
  134462. */
  134463. get frameTimeCounter(): PerfCounter;
  134464. /**
  134465. * Gets the frame time capture status
  134466. */
  134467. get captureFrameTime(): boolean;
  134468. /**
  134469. * Enable or disable the frame time capture
  134470. */
  134471. set captureFrameTime(value: boolean);
  134472. /**
  134473. * Gets the perf counter used for inter-frames time capture
  134474. */
  134475. get interFrameTimeCounter(): PerfCounter;
  134476. /**
  134477. * Gets the inter-frames time capture status
  134478. */
  134479. get captureInterFrameTime(): boolean;
  134480. /**
  134481. * Enable or disable the inter-frames time capture
  134482. */
  134483. set captureInterFrameTime(value: boolean);
  134484. /**
  134485. * Gets the perf counter used for render time capture
  134486. */
  134487. get renderTimeCounter(): PerfCounter;
  134488. /**
  134489. * Gets the render time capture status
  134490. */
  134491. get captureRenderTime(): boolean;
  134492. /**
  134493. * Enable or disable the render time capture
  134494. */
  134495. set captureRenderTime(value: boolean);
  134496. /**
  134497. * Gets the perf counter used for camera render time capture
  134498. */
  134499. get cameraRenderTimeCounter(): PerfCounter;
  134500. /**
  134501. * Gets the camera render time capture status
  134502. */
  134503. get captureCameraRenderTime(): boolean;
  134504. /**
  134505. * Enable or disable the camera render time capture
  134506. */
  134507. set captureCameraRenderTime(value: boolean);
  134508. /**
  134509. * Gets the perf counter used for draw calls
  134510. */
  134511. get drawCallsCounter(): PerfCounter;
  134512. /**
  134513. * Instantiates a new scene instrumentation.
  134514. * This class can be used to get instrumentation data from a Babylon engine
  134515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134516. * @param scene Defines the scene to instrument
  134517. */
  134518. constructor(
  134519. /**
  134520. * Defines the scene to instrument
  134521. */
  134522. scene: Scene);
  134523. /**
  134524. * Dispose and release associated resources.
  134525. */
  134526. dispose(): void;
  134527. }
  134528. }
  134529. declare module BABYLON {
  134530. /** @hidden */
  134531. export var glowMapGenerationPixelShader: {
  134532. name: string;
  134533. shader: string;
  134534. };
  134535. }
  134536. declare module BABYLON {
  134537. /** @hidden */
  134538. export var glowMapGenerationVertexShader: {
  134539. name: string;
  134540. shader: string;
  134541. };
  134542. }
  134543. declare module BABYLON {
  134544. /**
  134545. * Effect layer options. This helps customizing the behaviour
  134546. * of the effect layer.
  134547. */
  134548. export interface IEffectLayerOptions {
  134549. /**
  134550. * Multiplication factor apply to the canvas size to compute the render target size
  134551. * used to generated the objects (the smaller the faster).
  134552. */
  134553. mainTextureRatio: number;
  134554. /**
  134555. * Enforces a fixed size texture to ensure effect stability across devices.
  134556. */
  134557. mainTextureFixedSize?: number;
  134558. /**
  134559. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134560. */
  134561. alphaBlendingMode: number;
  134562. /**
  134563. * The camera attached to the layer.
  134564. */
  134565. camera: Nullable<Camera>;
  134566. /**
  134567. * The rendering group to draw the layer in.
  134568. */
  134569. renderingGroupId: number;
  134570. }
  134571. /**
  134572. * The effect layer Helps adding post process effect blended with the main pass.
  134573. *
  134574. * This can be for instance use to generate glow or higlight effects on the scene.
  134575. *
  134576. * The effect layer class can not be used directly and is intented to inherited from to be
  134577. * customized per effects.
  134578. */
  134579. export abstract class EffectLayer {
  134580. private _vertexBuffers;
  134581. private _indexBuffer;
  134582. private _cachedDefines;
  134583. private _effectLayerMapGenerationEffect;
  134584. private _effectLayerOptions;
  134585. private _mergeEffect;
  134586. protected _scene: Scene;
  134587. protected _engine: Engine;
  134588. protected _maxSize: number;
  134589. protected _mainTextureDesiredSize: ISize;
  134590. protected _mainTexture: RenderTargetTexture;
  134591. protected _shouldRender: boolean;
  134592. protected _postProcesses: PostProcess[];
  134593. protected _textures: BaseTexture[];
  134594. protected _emissiveTextureAndColor: {
  134595. texture: Nullable<BaseTexture>;
  134596. color: Color4;
  134597. };
  134598. /**
  134599. * The name of the layer
  134600. */
  134601. name: string;
  134602. /**
  134603. * The clear color of the texture used to generate the glow map.
  134604. */
  134605. neutralColor: Color4;
  134606. /**
  134607. * Specifies whether the highlight layer is enabled or not.
  134608. */
  134609. isEnabled: boolean;
  134610. /**
  134611. * Gets the camera attached to the layer.
  134612. */
  134613. get camera(): Nullable<Camera>;
  134614. /**
  134615. * Gets the rendering group id the layer should render in.
  134616. */
  134617. get renderingGroupId(): number;
  134618. set renderingGroupId(renderingGroupId: number);
  134619. /**
  134620. * An event triggered when the effect layer has been disposed.
  134621. */
  134622. onDisposeObservable: Observable<EffectLayer>;
  134623. /**
  134624. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134625. */
  134626. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134627. /**
  134628. * An event triggered when the generated texture is being merged in the scene.
  134629. */
  134630. onBeforeComposeObservable: Observable<EffectLayer>;
  134631. /**
  134632. * An event triggered when the mesh is rendered into the effect render target.
  134633. */
  134634. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134635. /**
  134636. * An event triggered after the mesh has been rendered into the effect render target.
  134637. */
  134638. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134639. /**
  134640. * An event triggered when the generated texture has been merged in the scene.
  134641. */
  134642. onAfterComposeObservable: Observable<EffectLayer>;
  134643. /**
  134644. * An event triggered when the efffect layer changes its size.
  134645. */
  134646. onSizeChangedObservable: Observable<EffectLayer>;
  134647. /** @hidden */
  134648. static _SceneComponentInitialization: (scene: Scene) => void;
  134649. /**
  134650. * Instantiates a new effect Layer and references it in the scene.
  134651. * @param name The name of the layer
  134652. * @param scene The scene to use the layer in
  134653. */
  134654. constructor(
  134655. /** The Friendly of the effect in the scene */
  134656. name: string, scene: Scene);
  134657. /**
  134658. * Get the effect name of the layer.
  134659. * @return The effect name
  134660. */
  134661. abstract getEffectName(): string;
  134662. /**
  134663. * Checks for the readiness of the element composing the layer.
  134664. * @param subMesh the mesh to check for
  134665. * @param useInstances specify whether or not to use instances to render the mesh
  134666. * @return true if ready otherwise, false
  134667. */
  134668. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134669. /**
  134670. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134671. * @returns true if the effect requires stencil during the main canvas render pass.
  134672. */
  134673. abstract needStencil(): boolean;
  134674. /**
  134675. * Create the merge effect. This is the shader use to blit the information back
  134676. * to the main canvas at the end of the scene rendering.
  134677. * @returns The effect containing the shader used to merge the effect on the main canvas
  134678. */
  134679. protected abstract _createMergeEffect(): Effect;
  134680. /**
  134681. * Creates the render target textures and post processes used in the effect layer.
  134682. */
  134683. protected abstract _createTextureAndPostProcesses(): void;
  134684. /**
  134685. * Implementation specific of rendering the generating effect on the main canvas.
  134686. * @param effect The effect used to render through
  134687. */
  134688. protected abstract _internalRender(effect: Effect): void;
  134689. /**
  134690. * Sets the required values for both the emissive texture and and the main color.
  134691. */
  134692. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134693. /**
  134694. * Free any resources and references associated to a mesh.
  134695. * Internal use
  134696. * @param mesh The mesh to free.
  134697. */
  134698. abstract _disposeMesh(mesh: Mesh): void;
  134699. /**
  134700. * Serializes this layer (Glow or Highlight for example)
  134701. * @returns a serialized layer object
  134702. */
  134703. abstract serialize?(): any;
  134704. /**
  134705. * Initializes the effect layer with the required options.
  134706. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134707. */
  134708. protected _init(options: Partial<IEffectLayerOptions>): void;
  134709. /**
  134710. * Generates the index buffer of the full screen quad blending to the main canvas.
  134711. */
  134712. private _generateIndexBuffer;
  134713. /**
  134714. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134715. */
  134716. private _generateVertexBuffer;
  134717. /**
  134718. * Sets the main texture desired size which is the closest power of two
  134719. * of the engine canvas size.
  134720. */
  134721. private _setMainTextureSize;
  134722. /**
  134723. * Creates the main texture for the effect layer.
  134724. */
  134725. protected _createMainTexture(): void;
  134726. /**
  134727. * Adds specific effects defines.
  134728. * @param defines The defines to add specifics to.
  134729. */
  134730. protected _addCustomEffectDefines(defines: string[]): void;
  134731. /**
  134732. * Checks for the readiness of the element composing the layer.
  134733. * @param subMesh the mesh to check for
  134734. * @param useInstances specify whether or not to use instances to render the mesh
  134735. * @param emissiveTexture the associated emissive texture used to generate the glow
  134736. * @return true if ready otherwise, false
  134737. */
  134738. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134739. /**
  134740. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134741. */
  134742. render(): void;
  134743. /**
  134744. * Determine if a given mesh will be used in the current effect.
  134745. * @param mesh mesh to test
  134746. * @returns true if the mesh will be used
  134747. */
  134748. hasMesh(mesh: AbstractMesh): boolean;
  134749. /**
  134750. * Returns true if the layer contains information to display, otherwise false.
  134751. * @returns true if the glow layer should be rendered
  134752. */
  134753. shouldRender(): boolean;
  134754. /**
  134755. * Returns true if the mesh should render, otherwise false.
  134756. * @param mesh The mesh to render
  134757. * @returns true if it should render otherwise false
  134758. */
  134759. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  134760. /**
  134761. * Returns true if the mesh can be rendered, otherwise false.
  134762. * @param mesh The mesh to render
  134763. * @param material The material used on the mesh
  134764. * @returns true if it can be rendered otherwise false
  134765. */
  134766. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134767. /**
  134768. * Returns true if the mesh should render, otherwise false.
  134769. * @param mesh The mesh to render
  134770. * @returns true if it should render otherwise false
  134771. */
  134772. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  134773. /**
  134774. * Renders the submesh passed in parameter to the generation map.
  134775. */
  134776. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  134777. /**
  134778. * Defines whether the current material of the mesh should be use to render the effect.
  134779. * @param mesh defines the current mesh to render
  134780. */
  134781. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134782. /**
  134783. * Rebuild the required buffers.
  134784. * @hidden Internal use only.
  134785. */
  134786. _rebuild(): void;
  134787. /**
  134788. * Dispose only the render target textures and post process.
  134789. */
  134790. private _disposeTextureAndPostProcesses;
  134791. /**
  134792. * Dispose the highlight layer and free resources.
  134793. */
  134794. dispose(): void;
  134795. /**
  134796. * Gets the class name of the effect layer
  134797. * @returns the string with the class name of the effect layer
  134798. */
  134799. getClassName(): string;
  134800. /**
  134801. * Creates an effect layer from parsed effect layer data
  134802. * @param parsedEffectLayer defines effect layer data
  134803. * @param scene defines the current scene
  134804. * @param rootUrl defines the root URL containing the effect layer information
  134805. * @returns a parsed effect Layer
  134806. */
  134807. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  134808. }
  134809. }
  134810. declare module BABYLON {
  134811. interface AbstractScene {
  134812. /**
  134813. * The list of effect layers (highlights/glow) added to the scene
  134814. * @see http://doc.babylonjs.com/how_to/highlight_layer
  134815. * @see http://doc.babylonjs.com/how_to/glow_layer
  134816. */
  134817. effectLayers: Array<EffectLayer>;
  134818. /**
  134819. * Removes the given effect layer from this scene.
  134820. * @param toRemove defines the effect layer to remove
  134821. * @returns the index of the removed effect layer
  134822. */
  134823. removeEffectLayer(toRemove: EffectLayer): number;
  134824. /**
  134825. * Adds the given effect layer to this scene
  134826. * @param newEffectLayer defines the effect layer to add
  134827. */
  134828. addEffectLayer(newEffectLayer: EffectLayer): void;
  134829. }
  134830. /**
  134831. * Defines the layer scene component responsible to manage any effect layers
  134832. * in a given scene.
  134833. */
  134834. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134835. /**
  134836. * The component name helpfull to identify the component in the list of scene components.
  134837. */
  134838. readonly name: string;
  134839. /**
  134840. * The scene the component belongs to.
  134841. */
  134842. scene: Scene;
  134843. private _engine;
  134844. private _renderEffects;
  134845. private _needStencil;
  134846. private _previousStencilState;
  134847. /**
  134848. * Creates a new instance of the component for the given scene
  134849. * @param scene Defines the scene to register the component in
  134850. */
  134851. constructor(scene: Scene);
  134852. /**
  134853. * Registers the component in a given scene
  134854. */
  134855. register(): void;
  134856. /**
  134857. * Rebuilds the elements related to this component in case of
  134858. * context lost for instance.
  134859. */
  134860. rebuild(): void;
  134861. /**
  134862. * Serializes the component data to the specified json object
  134863. * @param serializationObject The object to serialize to
  134864. */
  134865. serialize(serializationObject: any): void;
  134866. /**
  134867. * Adds all the elements from the container to the scene
  134868. * @param container the container holding the elements
  134869. */
  134870. addFromContainer(container: AbstractScene): void;
  134871. /**
  134872. * Removes all the elements in the container from the scene
  134873. * @param container contains the elements to remove
  134874. * @param dispose if the removed element should be disposed (default: false)
  134875. */
  134876. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134877. /**
  134878. * Disposes the component and the associated ressources.
  134879. */
  134880. dispose(): void;
  134881. private _isReadyForMesh;
  134882. private _renderMainTexture;
  134883. private _setStencil;
  134884. private _setStencilBack;
  134885. private _draw;
  134886. private _drawCamera;
  134887. private _drawRenderingGroup;
  134888. }
  134889. }
  134890. declare module BABYLON {
  134891. /** @hidden */
  134892. export var glowMapMergePixelShader: {
  134893. name: string;
  134894. shader: string;
  134895. };
  134896. }
  134897. declare module BABYLON {
  134898. /** @hidden */
  134899. export var glowMapMergeVertexShader: {
  134900. name: string;
  134901. shader: string;
  134902. };
  134903. }
  134904. declare module BABYLON {
  134905. interface AbstractScene {
  134906. /**
  134907. * Return a the first highlight layer of the scene with a given name.
  134908. * @param name The name of the highlight layer to look for.
  134909. * @return The highlight layer if found otherwise null.
  134910. */
  134911. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134912. }
  134913. /**
  134914. * Glow layer options. This helps customizing the behaviour
  134915. * of the glow layer.
  134916. */
  134917. export interface IGlowLayerOptions {
  134918. /**
  134919. * Multiplication factor apply to the canvas size to compute the render target size
  134920. * used to generated the glowing objects (the smaller the faster).
  134921. */
  134922. mainTextureRatio: number;
  134923. /**
  134924. * Enforces a fixed size texture to ensure resize independant blur.
  134925. */
  134926. mainTextureFixedSize?: number;
  134927. /**
  134928. * How big is the kernel of the blur texture.
  134929. */
  134930. blurKernelSize: number;
  134931. /**
  134932. * The camera attached to the layer.
  134933. */
  134934. camera: Nullable<Camera>;
  134935. /**
  134936. * Enable MSAA by chosing the number of samples.
  134937. */
  134938. mainTextureSamples?: number;
  134939. /**
  134940. * The rendering group to draw the layer in.
  134941. */
  134942. renderingGroupId: number;
  134943. }
  134944. /**
  134945. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134946. *
  134947. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134948. *
  134949. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134950. */
  134951. export class GlowLayer extends EffectLayer {
  134952. /**
  134953. * Effect Name of the layer.
  134954. */
  134955. static readonly EffectName: string;
  134956. /**
  134957. * The default blur kernel size used for the glow.
  134958. */
  134959. static DefaultBlurKernelSize: number;
  134960. /**
  134961. * The default texture size ratio used for the glow.
  134962. */
  134963. static DefaultTextureRatio: number;
  134964. /**
  134965. * Sets the kernel size of the blur.
  134966. */
  134967. set blurKernelSize(value: number);
  134968. /**
  134969. * Gets the kernel size of the blur.
  134970. */
  134971. get blurKernelSize(): number;
  134972. /**
  134973. * Sets the glow intensity.
  134974. */
  134975. set intensity(value: number);
  134976. /**
  134977. * Gets the glow intensity.
  134978. */
  134979. get intensity(): number;
  134980. private _options;
  134981. private _intensity;
  134982. private _horizontalBlurPostprocess1;
  134983. private _verticalBlurPostprocess1;
  134984. private _horizontalBlurPostprocess2;
  134985. private _verticalBlurPostprocess2;
  134986. private _blurTexture1;
  134987. private _blurTexture2;
  134988. private _postProcesses1;
  134989. private _postProcesses2;
  134990. private _includedOnlyMeshes;
  134991. private _excludedMeshes;
  134992. private _meshesUsingTheirOwnMaterials;
  134993. /**
  134994. * Callback used to let the user override the color selection on a per mesh basis
  134995. */
  134996. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134997. /**
  134998. * Callback used to let the user override the texture selection on a per mesh basis
  134999. */
  135000. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135001. /**
  135002. * Instantiates a new glow Layer and references it to the scene.
  135003. * @param name The name of the layer
  135004. * @param scene The scene to use the layer in
  135005. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135006. */
  135007. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135008. /**
  135009. * Get the effect name of the layer.
  135010. * @return The effect name
  135011. */
  135012. getEffectName(): string;
  135013. /**
  135014. * Create the merge effect. This is the shader use to blit the information back
  135015. * to the main canvas at the end of the scene rendering.
  135016. */
  135017. protected _createMergeEffect(): Effect;
  135018. /**
  135019. * Creates the render target textures and post processes used in the glow layer.
  135020. */
  135021. protected _createTextureAndPostProcesses(): void;
  135022. /**
  135023. * Checks for the readiness of the element composing the layer.
  135024. * @param subMesh the mesh to check for
  135025. * @param useInstances specify wether or not to use instances to render the mesh
  135026. * @param emissiveTexture the associated emissive texture used to generate the glow
  135027. * @return true if ready otherwise, false
  135028. */
  135029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135030. /**
  135031. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135032. */
  135033. needStencil(): boolean;
  135034. /**
  135035. * Returns true if the mesh can be rendered, otherwise false.
  135036. * @param mesh The mesh to render
  135037. * @param material The material used on the mesh
  135038. * @returns true if it can be rendered otherwise false
  135039. */
  135040. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135041. /**
  135042. * Implementation specific of rendering the generating effect on the main canvas.
  135043. * @param effect The effect used to render through
  135044. */
  135045. protected _internalRender(effect: Effect): void;
  135046. /**
  135047. * Sets the required values for both the emissive texture and and the main color.
  135048. */
  135049. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135050. /**
  135051. * Returns true if the mesh should render, otherwise false.
  135052. * @param mesh The mesh to render
  135053. * @returns true if it should render otherwise false
  135054. */
  135055. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135056. /**
  135057. * Adds specific effects defines.
  135058. * @param defines The defines to add specifics to.
  135059. */
  135060. protected _addCustomEffectDefines(defines: string[]): void;
  135061. /**
  135062. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135063. * @param mesh The mesh to exclude from the glow layer
  135064. */
  135065. addExcludedMesh(mesh: Mesh): void;
  135066. /**
  135067. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135068. * @param mesh The mesh to remove
  135069. */
  135070. removeExcludedMesh(mesh: Mesh): void;
  135071. /**
  135072. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135073. * @param mesh The mesh to include in the glow layer
  135074. */
  135075. addIncludedOnlyMesh(mesh: Mesh): void;
  135076. /**
  135077. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135078. * @param mesh The mesh to remove
  135079. */
  135080. removeIncludedOnlyMesh(mesh: Mesh): void;
  135081. /**
  135082. * Determine if a given mesh will be used in the glow layer
  135083. * @param mesh The mesh to test
  135084. * @returns true if the mesh will be highlighted by the current glow layer
  135085. */
  135086. hasMesh(mesh: AbstractMesh): boolean;
  135087. /**
  135088. * Defines whether the current material of the mesh should be use to render the effect.
  135089. * @param mesh defines the current mesh to render
  135090. */
  135091. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135092. /**
  135093. * Add a mesh to be rendered through its own material and not with emissive only.
  135094. * @param mesh The mesh for which we need to use its material
  135095. */
  135096. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135097. /**
  135098. * Remove a mesh from being rendered through its own material and not with emissive only.
  135099. * @param mesh The mesh for which we need to not use its material
  135100. */
  135101. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135102. /**
  135103. * Free any resources and references associated to a mesh.
  135104. * Internal use
  135105. * @param mesh The mesh to free.
  135106. * @hidden
  135107. */
  135108. _disposeMesh(mesh: Mesh): void;
  135109. /**
  135110. * Gets the class name of the effect layer
  135111. * @returns the string with the class name of the effect layer
  135112. */
  135113. getClassName(): string;
  135114. /**
  135115. * Serializes this glow layer
  135116. * @returns a serialized glow layer object
  135117. */
  135118. serialize(): any;
  135119. /**
  135120. * Creates a Glow Layer from parsed glow layer data
  135121. * @param parsedGlowLayer defines glow layer data
  135122. * @param scene defines the current scene
  135123. * @param rootUrl defines the root URL containing the glow layer information
  135124. * @returns a parsed Glow Layer
  135125. */
  135126. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135127. }
  135128. }
  135129. declare module BABYLON {
  135130. /** @hidden */
  135131. export var glowBlurPostProcessPixelShader: {
  135132. name: string;
  135133. shader: string;
  135134. };
  135135. }
  135136. declare module BABYLON {
  135137. interface AbstractScene {
  135138. /**
  135139. * Return a the first highlight layer of the scene with a given name.
  135140. * @param name The name of the highlight layer to look for.
  135141. * @return The highlight layer if found otherwise null.
  135142. */
  135143. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135144. }
  135145. /**
  135146. * Highlight layer options. This helps customizing the behaviour
  135147. * of the highlight layer.
  135148. */
  135149. export interface IHighlightLayerOptions {
  135150. /**
  135151. * Multiplication factor apply to the canvas size to compute the render target size
  135152. * used to generated the glowing objects (the smaller the faster).
  135153. */
  135154. mainTextureRatio: number;
  135155. /**
  135156. * Enforces a fixed size texture to ensure resize independant blur.
  135157. */
  135158. mainTextureFixedSize?: number;
  135159. /**
  135160. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135161. * of the picture to blur (the smaller the faster).
  135162. */
  135163. blurTextureSizeRatio: number;
  135164. /**
  135165. * How big in texel of the blur texture is the vertical blur.
  135166. */
  135167. blurVerticalSize: number;
  135168. /**
  135169. * How big in texel of the blur texture is the horizontal blur.
  135170. */
  135171. blurHorizontalSize: number;
  135172. /**
  135173. * Alpha blending mode used to apply the blur. Default is combine.
  135174. */
  135175. alphaBlendingMode: number;
  135176. /**
  135177. * The camera attached to the layer.
  135178. */
  135179. camera: Nullable<Camera>;
  135180. /**
  135181. * Should we display highlight as a solid stroke?
  135182. */
  135183. isStroke?: boolean;
  135184. /**
  135185. * The rendering group to draw the layer in.
  135186. */
  135187. renderingGroupId: number;
  135188. }
  135189. /**
  135190. * The highlight layer Helps adding a glow effect around a mesh.
  135191. *
  135192. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135193. * glowy meshes to your scene.
  135194. *
  135195. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135196. */
  135197. export class HighlightLayer extends EffectLayer {
  135198. name: string;
  135199. /**
  135200. * Effect Name of the highlight layer.
  135201. */
  135202. static readonly EffectName: string;
  135203. /**
  135204. * The neutral color used during the preparation of the glow effect.
  135205. * This is black by default as the blend operation is a blend operation.
  135206. */
  135207. static NeutralColor: Color4;
  135208. /**
  135209. * Stencil value used for glowing meshes.
  135210. */
  135211. static GlowingMeshStencilReference: number;
  135212. /**
  135213. * Stencil value used for the other meshes in the scene.
  135214. */
  135215. static NormalMeshStencilReference: number;
  135216. /**
  135217. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135218. */
  135219. innerGlow: boolean;
  135220. /**
  135221. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135222. */
  135223. outerGlow: boolean;
  135224. /**
  135225. * Specifies the horizontal size of the blur.
  135226. */
  135227. set blurHorizontalSize(value: number);
  135228. /**
  135229. * Specifies the vertical size of the blur.
  135230. */
  135231. set blurVerticalSize(value: number);
  135232. /**
  135233. * Gets the horizontal size of the blur.
  135234. */
  135235. get blurHorizontalSize(): number;
  135236. /**
  135237. * Gets the vertical size of the blur.
  135238. */
  135239. get blurVerticalSize(): number;
  135240. /**
  135241. * An event triggered when the highlight layer is being blurred.
  135242. */
  135243. onBeforeBlurObservable: Observable<HighlightLayer>;
  135244. /**
  135245. * An event triggered when the highlight layer has been blurred.
  135246. */
  135247. onAfterBlurObservable: Observable<HighlightLayer>;
  135248. private _instanceGlowingMeshStencilReference;
  135249. private _options;
  135250. private _downSamplePostprocess;
  135251. private _horizontalBlurPostprocess;
  135252. private _verticalBlurPostprocess;
  135253. private _blurTexture;
  135254. private _meshes;
  135255. private _excludedMeshes;
  135256. /**
  135257. * Instantiates a new highlight Layer and references it to the scene..
  135258. * @param name The name of the layer
  135259. * @param scene The scene to use the layer in
  135260. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135261. */
  135262. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135263. /**
  135264. * Get the effect name of the layer.
  135265. * @return The effect name
  135266. */
  135267. getEffectName(): string;
  135268. /**
  135269. * Create the merge effect. This is the shader use to blit the information back
  135270. * to the main canvas at the end of the scene rendering.
  135271. */
  135272. protected _createMergeEffect(): Effect;
  135273. /**
  135274. * Creates the render target textures and post processes used in the highlight layer.
  135275. */
  135276. protected _createTextureAndPostProcesses(): void;
  135277. /**
  135278. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135279. */
  135280. needStencil(): boolean;
  135281. /**
  135282. * Checks for the readiness of the element composing the layer.
  135283. * @param subMesh the mesh to check for
  135284. * @param useInstances specify wether or not to use instances to render the mesh
  135285. * @param emissiveTexture the associated emissive texture used to generate the glow
  135286. * @return true if ready otherwise, false
  135287. */
  135288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135289. /**
  135290. * Implementation specific of rendering the generating effect on the main canvas.
  135291. * @param effect The effect used to render through
  135292. */
  135293. protected _internalRender(effect: Effect): void;
  135294. /**
  135295. * Returns true if the layer contains information to display, otherwise false.
  135296. */
  135297. shouldRender(): boolean;
  135298. /**
  135299. * Returns true if the mesh should render, otherwise false.
  135300. * @param mesh The mesh to render
  135301. * @returns true if it should render otherwise false
  135302. */
  135303. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135304. /**
  135305. * Adds specific effects defines.
  135306. * @param defines The defines to add specifics to.
  135307. */
  135308. protected _addCustomEffectDefines(defines: string[]): void;
  135309. /**
  135310. * Sets the required values for both the emissive texture and and the main color.
  135311. */
  135312. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135313. /**
  135314. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  135315. * @param mesh The mesh to exclude from the highlight layer
  135316. */
  135317. addExcludedMesh(mesh: Mesh): void;
  135318. /**
  135319. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  135320. * @param mesh The mesh to highlight
  135321. */
  135322. removeExcludedMesh(mesh: Mesh): void;
  135323. /**
  135324. * Determine if a given mesh will be highlighted by the current HighlightLayer
  135325. * @param mesh mesh to test
  135326. * @returns true if the mesh will be highlighted by the current HighlightLayer
  135327. */
  135328. hasMesh(mesh: AbstractMesh): boolean;
  135329. /**
  135330. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  135331. * @param mesh The mesh to highlight
  135332. * @param color The color of the highlight
  135333. * @param glowEmissiveOnly Extract the glow from the emissive texture
  135334. */
  135335. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  135336. /**
  135337. * Remove a mesh from the highlight layer in order to make it stop glowing.
  135338. * @param mesh The mesh to highlight
  135339. */
  135340. removeMesh(mesh: Mesh): void;
  135341. /**
  135342. * Remove all the meshes currently referenced in the highlight layer
  135343. */
  135344. removeAllMeshes(): void;
  135345. /**
  135346. * Force the stencil to the normal expected value for none glowing parts
  135347. */
  135348. private _defaultStencilReference;
  135349. /**
  135350. * Free any resources and references associated to a mesh.
  135351. * Internal use
  135352. * @param mesh The mesh to free.
  135353. * @hidden
  135354. */
  135355. _disposeMesh(mesh: Mesh): void;
  135356. /**
  135357. * Dispose the highlight layer and free resources.
  135358. */
  135359. dispose(): void;
  135360. /**
  135361. * Gets the class name of the effect layer
  135362. * @returns the string with the class name of the effect layer
  135363. */
  135364. getClassName(): string;
  135365. /**
  135366. * Serializes this Highlight layer
  135367. * @returns a serialized Highlight layer object
  135368. */
  135369. serialize(): any;
  135370. /**
  135371. * Creates a Highlight layer from parsed Highlight layer data
  135372. * @param parsedHightlightLayer defines the Highlight layer data
  135373. * @param scene defines the current scene
  135374. * @param rootUrl defines the root URL containing the Highlight layer information
  135375. * @returns a parsed Highlight layer
  135376. */
  135377. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135378. }
  135379. }
  135380. declare module BABYLON {
  135381. interface AbstractScene {
  135382. /**
  135383. * The list of layers (background and foreground) of the scene
  135384. */
  135385. layers: Array<Layer>;
  135386. }
  135387. /**
  135388. * Defines the layer scene component responsible to manage any layers
  135389. * in a given scene.
  135390. */
  135391. export class LayerSceneComponent implements ISceneComponent {
  135392. /**
  135393. * The component name helpfull to identify the component in the list of scene components.
  135394. */
  135395. readonly name: string;
  135396. /**
  135397. * The scene the component belongs to.
  135398. */
  135399. scene: Scene;
  135400. private _engine;
  135401. /**
  135402. * Creates a new instance of the component for the given scene
  135403. * @param scene Defines the scene to register the component in
  135404. */
  135405. constructor(scene: Scene);
  135406. /**
  135407. * Registers the component in a given scene
  135408. */
  135409. register(): void;
  135410. /**
  135411. * Rebuilds the elements related to this component in case of
  135412. * context lost for instance.
  135413. */
  135414. rebuild(): void;
  135415. /**
  135416. * Disposes the component and the associated ressources.
  135417. */
  135418. dispose(): void;
  135419. private _draw;
  135420. private _drawCameraPredicate;
  135421. private _drawCameraBackground;
  135422. private _drawCameraForeground;
  135423. private _drawRenderTargetPredicate;
  135424. private _drawRenderTargetBackground;
  135425. private _drawRenderTargetForeground;
  135426. /**
  135427. * Adds all the elements from the container to the scene
  135428. * @param container the container holding the elements
  135429. */
  135430. addFromContainer(container: AbstractScene): void;
  135431. /**
  135432. * Removes all the elements in the container from the scene
  135433. * @param container contains the elements to remove
  135434. * @param dispose if the removed element should be disposed (default: false)
  135435. */
  135436. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135437. }
  135438. }
  135439. declare module BABYLON {
  135440. /** @hidden */
  135441. export var layerPixelShader: {
  135442. name: string;
  135443. shader: string;
  135444. };
  135445. }
  135446. declare module BABYLON {
  135447. /** @hidden */
  135448. export var layerVertexShader: {
  135449. name: string;
  135450. shader: string;
  135451. };
  135452. }
  135453. declare module BABYLON {
  135454. /**
  135455. * This represents a full screen 2d layer.
  135456. * This can be useful to display a picture in the background of your scene for instance.
  135457. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135458. */
  135459. export class Layer {
  135460. /**
  135461. * Define the name of the layer.
  135462. */
  135463. name: string;
  135464. /**
  135465. * Define the texture the layer should display.
  135466. */
  135467. texture: Nullable<Texture>;
  135468. /**
  135469. * Is the layer in background or foreground.
  135470. */
  135471. isBackground: boolean;
  135472. /**
  135473. * Define the color of the layer (instead of texture).
  135474. */
  135475. color: Color4;
  135476. /**
  135477. * Define the scale of the layer in order to zoom in out of the texture.
  135478. */
  135479. scale: Vector2;
  135480. /**
  135481. * Define an offset for the layer in order to shift the texture.
  135482. */
  135483. offset: Vector2;
  135484. /**
  135485. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135486. */
  135487. alphaBlendingMode: number;
  135488. /**
  135489. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135490. * Alpha test will not mix with the background color in case of transparency.
  135491. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135492. */
  135493. alphaTest: boolean;
  135494. /**
  135495. * Define a mask to restrict the layer to only some of the scene cameras.
  135496. */
  135497. layerMask: number;
  135498. /**
  135499. * Define the list of render target the layer is visible into.
  135500. */
  135501. renderTargetTextures: RenderTargetTexture[];
  135502. /**
  135503. * Define if the layer is only used in renderTarget or if it also
  135504. * renders in the main frame buffer of the canvas.
  135505. */
  135506. renderOnlyInRenderTargetTextures: boolean;
  135507. private _scene;
  135508. private _vertexBuffers;
  135509. private _indexBuffer;
  135510. private _effect;
  135511. private _previousDefines;
  135512. /**
  135513. * An event triggered when the layer is disposed.
  135514. */
  135515. onDisposeObservable: Observable<Layer>;
  135516. private _onDisposeObserver;
  135517. /**
  135518. * Back compatibility with callback before the onDisposeObservable existed.
  135519. * The set callback will be triggered when the layer has been disposed.
  135520. */
  135521. set onDispose(callback: () => void);
  135522. /**
  135523. * An event triggered before rendering the scene
  135524. */
  135525. onBeforeRenderObservable: Observable<Layer>;
  135526. private _onBeforeRenderObserver;
  135527. /**
  135528. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135529. * The set callback will be triggered just before rendering the layer.
  135530. */
  135531. set onBeforeRender(callback: () => void);
  135532. /**
  135533. * An event triggered after rendering the scene
  135534. */
  135535. onAfterRenderObservable: Observable<Layer>;
  135536. private _onAfterRenderObserver;
  135537. /**
  135538. * Back compatibility with callback before the onAfterRenderObservable existed.
  135539. * The set callback will be triggered just after rendering the layer.
  135540. */
  135541. set onAfterRender(callback: () => void);
  135542. /**
  135543. * Instantiates a new layer.
  135544. * This represents a full screen 2d layer.
  135545. * This can be useful to display a picture in the background of your scene for instance.
  135546. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135547. * @param name Define the name of the layer in the scene
  135548. * @param imgUrl Define the url of the texture to display in the layer
  135549. * @param scene Define the scene the layer belongs to
  135550. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135551. * @param color Defines a color for the layer
  135552. */
  135553. constructor(
  135554. /**
  135555. * Define the name of the layer.
  135556. */
  135557. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135558. private _createIndexBuffer;
  135559. /** @hidden */
  135560. _rebuild(): void;
  135561. /**
  135562. * Renders the layer in the scene.
  135563. */
  135564. render(): void;
  135565. /**
  135566. * Disposes and releases the associated ressources.
  135567. */
  135568. dispose(): void;
  135569. }
  135570. }
  135571. declare module BABYLON {
  135572. /** @hidden */
  135573. export var lensFlarePixelShader: {
  135574. name: string;
  135575. shader: string;
  135576. };
  135577. }
  135578. declare module BABYLON {
  135579. /** @hidden */
  135580. export var lensFlareVertexShader: {
  135581. name: string;
  135582. shader: string;
  135583. };
  135584. }
  135585. declare module BABYLON {
  135586. /**
  135587. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135588. * It is usually composed of several `lensFlare`.
  135589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135590. */
  135591. export class LensFlareSystem {
  135592. /**
  135593. * Define the name of the lens flare system
  135594. */
  135595. name: string;
  135596. /**
  135597. * List of lens flares used in this system.
  135598. */
  135599. lensFlares: LensFlare[];
  135600. /**
  135601. * Define a limit from the border the lens flare can be visible.
  135602. */
  135603. borderLimit: number;
  135604. /**
  135605. * Define a viewport border we do not want to see the lens flare in.
  135606. */
  135607. viewportBorder: number;
  135608. /**
  135609. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135610. */
  135611. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135612. /**
  135613. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135614. */
  135615. layerMask: number;
  135616. /**
  135617. * Define the id of the lens flare system in the scene.
  135618. * (equal to name by default)
  135619. */
  135620. id: string;
  135621. private _scene;
  135622. private _emitter;
  135623. private _vertexBuffers;
  135624. private _indexBuffer;
  135625. private _effect;
  135626. private _positionX;
  135627. private _positionY;
  135628. private _isEnabled;
  135629. /** @hidden */
  135630. static _SceneComponentInitialization: (scene: Scene) => void;
  135631. /**
  135632. * Instantiates a lens flare system.
  135633. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135634. * It is usually composed of several `lensFlare`.
  135635. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135636. * @param name Define the name of the lens flare system in the scene
  135637. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135638. * @param scene Define the scene the lens flare system belongs to
  135639. */
  135640. constructor(
  135641. /**
  135642. * Define the name of the lens flare system
  135643. */
  135644. name: string, emitter: any, scene: Scene);
  135645. /**
  135646. * Define if the lens flare system is enabled.
  135647. */
  135648. get isEnabled(): boolean;
  135649. set isEnabled(value: boolean);
  135650. /**
  135651. * Get the scene the effects belongs to.
  135652. * @returns the scene holding the lens flare system
  135653. */
  135654. getScene(): Scene;
  135655. /**
  135656. * Get the emitter of the lens flare system.
  135657. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135658. * @returns the emitter of the lens flare system
  135659. */
  135660. getEmitter(): any;
  135661. /**
  135662. * Set the emitter of the lens flare system.
  135663. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135664. * @param newEmitter Define the new emitter of the system
  135665. */
  135666. setEmitter(newEmitter: any): void;
  135667. /**
  135668. * Get the lens flare system emitter position.
  135669. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135670. * @returns the position
  135671. */
  135672. getEmitterPosition(): Vector3;
  135673. /**
  135674. * @hidden
  135675. */
  135676. computeEffectivePosition(globalViewport: Viewport): boolean;
  135677. /** @hidden */
  135678. _isVisible(): boolean;
  135679. /**
  135680. * @hidden
  135681. */
  135682. render(): boolean;
  135683. /**
  135684. * Dispose and release the lens flare with its associated resources.
  135685. */
  135686. dispose(): void;
  135687. /**
  135688. * Parse a lens flare system from a JSON repressentation
  135689. * @param parsedLensFlareSystem Define the JSON to parse
  135690. * @param scene Define the scene the parsed system should be instantiated in
  135691. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135692. * @returns the parsed system
  135693. */
  135694. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135695. /**
  135696. * Serialize the current Lens Flare System into a JSON representation.
  135697. * @returns the serialized JSON
  135698. */
  135699. serialize(): any;
  135700. }
  135701. }
  135702. declare module BABYLON {
  135703. /**
  135704. * This represents one of the lens effect in a `lensFlareSystem`.
  135705. * It controls one of the indiviual texture used in the effect.
  135706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135707. */
  135708. export class LensFlare {
  135709. /**
  135710. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135711. */
  135712. size: number;
  135713. /**
  135714. * 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.
  135715. */
  135716. position: number;
  135717. /**
  135718. * Define the lens color.
  135719. */
  135720. color: Color3;
  135721. /**
  135722. * Define the lens texture.
  135723. */
  135724. texture: Nullable<Texture>;
  135725. /**
  135726. * Define the alpha mode to render this particular lens.
  135727. */
  135728. alphaMode: number;
  135729. private _system;
  135730. /**
  135731. * Creates a new Lens Flare.
  135732. * This represents one of the lens effect in a `lensFlareSystem`.
  135733. * It controls one of the indiviual texture used in the effect.
  135734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135735. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135736. * @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.
  135737. * @param color Define the lens color
  135738. * @param imgUrl Define the lens texture url
  135739. * @param system Define the `lensFlareSystem` this flare is part of
  135740. * @returns The newly created Lens Flare
  135741. */
  135742. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135743. /**
  135744. * Instantiates a new Lens Flare.
  135745. * This represents one of the lens effect in a `lensFlareSystem`.
  135746. * It controls one of the indiviual texture used in the effect.
  135747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135748. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  135749. * @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.
  135750. * @param color Define the lens color
  135751. * @param imgUrl Define the lens texture url
  135752. * @param system Define the `lensFlareSystem` this flare is part of
  135753. */
  135754. constructor(
  135755. /**
  135756. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135757. */
  135758. size: number,
  135759. /**
  135760. * 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.
  135761. */
  135762. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  135763. /**
  135764. * Dispose and release the lens flare with its associated resources.
  135765. */
  135766. dispose(): void;
  135767. }
  135768. }
  135769. declare module BABYLON {
  135770. interface AbstractScene {
  135771. /**
  135772. * The list of lens flare system added to the scene
  135773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135774. */
  135775. lensFlareSystems: Array<LensFlareSystem>;
  135776. /**
  135777. * Removes the given lens flare system from this scene.
  135778. * @param toRemove The lens flare system to remove
  135779. * @returns The index of the removed lens flare system
  135780. */
  135781. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  135782. /**
  135783. * Adds the given lens flare system to this scene
  135784. * @param newLensFlareSystem The lens flare system to add
  135785. */
  135786. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  135787. /**
  135788. * Gets a lens flare system using its name
  135789. * @param name defines the name to look for
  135790. * @returns the lens flare system or null if not found
  135791. */
  135792. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  135793. /**
  135794. * Gets a lens flare system using its id
  135795. * @param id defines the id to look for
  135796. * @returns the lens flare system or null if not found
  135797. */
  135798. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  135799. }
  135800. /**
  135801. * Defines the lens flare scene component responsible to manage any lens flares
  135802. * in a given scene.
  135803. */
  135804. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  135805. /**
  135806. * The component name helpfull to identify the component in the list of scene components.
  135807. */
  135808. readonly name: string;
  135809. /**
  135810. * The scene the component belongs to.
  135811. */
  135812. scene: Scene;
  135813. /**
  135814. * Creates a new instance of the component for the given scene
  135815. * @param scene Defines the scene to register the component in
  135816. */
  135817. constructor(scene: Scene);
  135818. /**
  135819. * Registers the component in a given scene
  135820. */
  135821. register(): void;
  135822. /**
  135823. * Rebuilds the elements related to this component in case of
  135824. * context lost for instance.
  135825. */
  135826. rebuild(): void;
  135827. /**
  135828. * Adds all the elements from the container to the scene
  135829. * @param container the container holding the elements
  135830. */
  135831. addFromContainer(container: AbstractScene): void;
  135832. /**
  135833. * Removes all the elements in the container from the scene
  135834. * @param container contains the elements to remove
  135835. * @param dispose if the removed element should be disposed (default: false)
  135836. */
  135837. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135838. /**
  135839. * Serializes the component data to the specified json object
  135840. * @param serializationObject The object to serialize to
  135841. */
  135842. serialize(serializationObject: any): void;
  135843. /**
  135844. * Disposes the component and the associated ressources.
  135845. */
  135846. dispose(): void;
  135847. private _draw;
  135848. }
  135849. }
  135850. declare module BABYLON {
  135851. /** @hidden */
  135852. export var depthPixelShader: {
  135853. name: string;
  135854. shader: string;
  135855. };
  135856. }
  135857. declare module BABYLON {
  135858. /** @hidden */
  135859. export var depthVertexShader: {
  135860. name: string;
  135861. shader: string;
  135862. };
  135863. }
  135864. declare module BABYLON {
  135865. /**
  135866. * This represents a depth renderer in Babylon.
  135867. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135868. */
  135869. export class DepthRenderer {
  135870. private _scene;
  135871. private _depthMap;
  135872. private _effect;
  135873. private readonly _storeNonLinearDepth;
  135874. private readonly _clearColor;
  135875. /** Get if the depth renderer is using packed depth or not */
  135876. readonly isPacked: boolean;
  135877. private _cachedDefines;
  135878. private _camera;
  135879. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135880. enabled: boolean;
  135881. /**
  135882. * Specifiess that the depth renderer will only be used within
  135883. * the camera it is created for.
  135884. * This can help forcing its rendering during the camera processing.
  135885. */
  135886. useOnlyInActiveCamera: boolean;
  135887. /** @hidden */
  135888. static _SceneComponentInitialization: (scene: Scene) => void;
  135889. /**
  135890. * Instantiates a depth renderer
  135891. * @param scene The scene the renderer belongs to
  135892. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135893. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135894. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135895. */
  135896. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135897. /**
  135898. * Creates the depth rendering effect and checks if the effect is ready.
  135899. * @param subMesh The submesh to be used to render the depth map of
  135900. * @param useInstances If multiple world instances should be used
  135901. * @returns if the depth renderer is ready to render the depth map
  135902. */
  135903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135904. /**
  135905. * Gets the texture which the depth map will be written to.
  135906. * @returns The depth map texture
  135907. */
  135908. getDepthMap(): RenderTargetTexture;
  135909. /**
  135910. * Disposes of the depth renderer.
  135911. */
  135912. dispose(): void;
  135913. }
  135914. }
  135915. declare module BABYLON {
  135916. /** @hidden */
  135917. export var minmaxReduxPixelShader: {
  135918. name: string;
  135919. shader: string;
  135920. };
  135921. }
  135922. declare module BABYLON {
  135923. /**
  135924. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135925. * and maximum values from all values of the texture.
  135926. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135927. * The source values are read from the red channel of the texture.
  135928. */
  135929. export class MinMaxReducer {
  135930. /**
  135931. * Observable triggered when the computation has been performed
  135932. */
  135933. onAfterReductionPerformed: Observable<{
  135934. min: number;
  135935. max: number;
  135936. }>;
  135937. protected _camera: Camera;
  135938. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135939. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135940. protected _postProcessManager: PostProcessManager;
  135941. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135942. protected _forceFullscreenViewport: boolean;
  135943. /**
  135944. * Creates a min/max reducer
  135945. * @param camera The camera to use for the post processes
  135946. */
  135947. constructor(camera: Camera);
  135948. /**
  135949. * Gets the texture used to read the values from.
  135950. */
  135951. get sourceTexture(): Nullable<RenderTargetTexture>;
  135952. /**
  135953. * Sets the source texture to read the values from.
  135954. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135955. * because in such textures '1' value must not be taken into account to compute the maximum
  135956. * as this value is used to clear the texture.
  135957. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135958. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135959. * @param depthRedux Indicates if the texture is a depth texture or not
  135960. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135961. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135962. */
  135963. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135964. /**
  135965. * Defines the refresh rate of the computation.
  135966. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135967. */
  135968. get refreshRate(): number;
  135969. set refreshRate(value: number);
  135970. protected _activated: boolean;
  135971. /**
  135972. * Gets the activation status of the reducer
  135973. */
  135974. get activated(): boolean;
  135975. /**
  135976. * Activates the reduction computation.
  135977. * When activated, the observers registered in onAfterReductionPerformed are
  135978. * called after the compuation is performed
  135979. */
  135980. activate(): void;
  135981. /**
  135982. * Deactivates the reduction computation.
  135983. */
  135984. deactivate(): void;
  135985. /**
  135986. * Disposes the min/max reducer
  135987. * @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.
  135988. */
  135989. dispose(disposeAll?: boolean): void;
  135990. }
  135991. }
  135992. declare module BABYLON {
  135993. /**
  135994. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135995. */
  135996. export class DepthReducer extends MinMaxReducer {
  135997. private _depthRenderer;
  135998. private _depthRendererId;
  135999. /**
  136000. * Gets the depth renderer used for the computation.
  136001. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136002. */
  136003. get depthRenderer(): Nullable<DepthRenderer>;
  136004. /**
  136005. * Creates a depth reducer
  136006. * @param camera The camera used to render the depth texture
  136007. */
  136008. constructor(camera: Camera);
  136009. /**
  136010. * Sets the depth renderer to use to generate the depth map
  136011. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136012. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136013. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136014. */
  136015. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136016. /** @hidden */
  136017. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136018. /**
  136019. * Activates the reduction computation.
  136020. * When activated, the observers registered in onAfterReductionPerformed are
  136021. * called after the compuation is performed
  136022. */
  136023. activate(): void;
  136024. /**
  136025. * Deactivates the reduction computation.
  136026. */
  136027. deactivate(): void;
  136028. /**
  136029. * Disposes the depth reducer
  136030. * @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.
  136031. */
  136032. dispose(disposeAll?: boolean): void;
  136033. }
  136034. }
  136035. declare module BABYLON {
  136036. /**
  136037. * A CSM implementation allowing casting shadows on large scenes.
  136038. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136039. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136040. */
  136041. export class CascadedShadowGenerator extends ShadowGenerator {
  136042. private static readonly frustumCornersNDCSpace;
  136043. /**
  136044. * Name of the CSM class
  136045. */
  136046. static CLASSNAME: string;
  136047. /**
  136048. * Defines the default number of cascades used by the CSM.
  136049. */
  136050. static readonly DEFAULT_CASCADES_COUNT: number;
  136051. /**
  136052. * Defines the minimum number of cascades used by the CSM.
  136053. */
  136054. static readonly MIN_CASCADES_COUNT: number;
  136055. /**
  136056. * Defines the maximum number of cascades used by the CSM.
  136057. */
  136058. static readonly MAX_CASCADES_COUNT: number;
  136059. protected _validateFilter(filter: number): number;
  136060. /**
  136061. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136062. */
  136063. penumbraDarkness: number;
  136064. private _numCascades;
  136065. /**
  136066. * Gets or set the number of cascades used by the CSM.
  136067. */
  136068. get numCascades(): number;
  136069. set numCascades(value: number);
  136070. /**
  136071. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136072. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136073. */
  136074. stabilizeCascades: boolean;
  136075. private _freezeShadowCastersBoundingInfo;
  136076. private _freezeShadowCastersBoundingInfoObservable;
  136077. /**
  136078. * Enables or disables the shadow casters bounding info computation.
  136079. * If your shadow casters don't move, you can disable this feature.
  136080. * If it is enabled, the bounding box computation is done every frame.
  136081. */
  136082. get freezeShadowCastersBoundingInfo(): boolean;
  136083. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136084. private _scbiMin;
  136085. private _scbiMax;
  136086. protected _computeShadowCastersBoundingInfo(): void;
  136087. protected _shadowCastersBoundingInfo: BoundingInfo;
  136088. /**
  136089. * Gets or sets the shadow casters bounding info.
  136090. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136091. * so that the system won't overwrite the bounds you provide
  136092. */
  136093. get shadowCastersBoundingInfo(): BoundingInfo;
  136094. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136095. protected _breaksAreDirty: boolean;
  136096. protected _minDistance: number;
  136097. protected _maxDistance: number;
  136098. /**
  136099. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136100. *
  136101. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136102. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136103. * @param min minimal distance for the breaks (default to 0.)
  136104. * @param max maximal distance for the breaks (default to 1.)
  136105. */
  136106. setMinMaxDistance(min: number, max: number): void;
  136107. /** Gets the minimal distance used in the cascade break computation */
  136108. get minDistance(): number;
  136109. /** Gets the maximal distance used in the cascade break computation */
  136110. get maxDistance(): number;
  136111. /**
  136112. * Gets the class name of that object
  136113. * @returns "CascadedShadowGenerator"
  136114. */
  136115. getClassName(): string;
  136116. private _cascadeMinExtents;
  136117. private _cascadeMaxExtents;
  136118. /**
  136119. * Gets a cascade minimum extents
  136120. * @param cascadeIndex index of the cascade
  136121. * @returns the minimum cascade extents
  136122. */
  136123. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136124. /**
  136125. * Gets a cascade maximum extents
  136126. * @param cascadeIndex index of the cascade
  136127. * @returns the maximum cascade extents
  136128. */
  136129. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136130. private _cascades;
  136131. private _currentLayer;
  136132. private _viewSpaceFrustumsZ;
  136133. private _viewMatrices;
  136134. private _projectionMatrices;
  136135. private _transformMatrices;
  136136. private _transformMatricesAsArray;
  136137. private _frustumLengths;
  136138. private _lightSizeUVCorrection;
  136139. private _depthCorrection;
  136140. private _frustumCornersWorldSpace;
  136141. private _frustumCenter;
  136142. private _shadowCameraPos;
  136143. private _shadowMaxZ;
  136144. /**
  136145. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136146. * It defaults to camera.maxZ
  136147. */
  136148. get shadowMaxZ(): number;
  136149. /**
  136150. * Sets the shadow max z distance.
  136151. */
  136152. set shadowMaxZ(value: number);
  136153. protected _debug: boolean;
  136154. /**
  136155. * Gets or sets the debug flag.
  136156. * When enabled, the cascades are materialized by different colors on the screen.
  136157. */
  136158. get debug(): boolean;
  136159. set debug(dbg: boolean);
  136160. private _depthClamp;
  136161. /**
  136162. * Gets or sets the depth clamping value.
  136163. *
  136164. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136165. * to account for the shadow casters far away.
  136166. *
  136167. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136168. */
  136169. get depthClamp(): boolean;
  136170. set depthClamp(value: boolean);
  136171. private _cascadeBlendPercentage;
  136172. /**
  136173. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136174. * It defaults to 0.1 (10% blending).
  136175. */
  136176. get cascadeBlendPercentage(): number;
  136177. set cascadeBlendPercentage(value: number);
  136178. private _lambda;
  136179. /**
  136180. * Gets or set the lambda parameter.
  136181. * This parameter is used to split the camera frustum and create the cascades.
  136182. * 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.
  136183. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136184. */
  136185. get lambda(): number;
  136186. set lambda(value: number);
  136187. /**
  136188. * Gets the view matrix corresponding to a given cascade
  136189. * @param cascadeNum cascade to retrieve the view matrix from
  136190. * @returns the cascade view matrix
  136191. */
  136192. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136193. /**
  136194. * Gets the projection matrix corresponding to a given cascade
  136195. * @param cascadeNum cascade to retrieve the projection matrix from
  136196. * @returns the cascade projection matrix
  136197. */
  136198. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136199. /**
  136200. * Gets the transformation matrix corresponding to a given cascade
  136201. * @param cascadeNum cascade to retrieve the transformation matrix from
  136202. * @returns the cascade transformation matrix
  136203. */
  136204. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136205. private _depthRenderer;
  136206. /**
  136207. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136208. *
  136209. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136210. *
  136211. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136212. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136213. * @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
  136214. */
  136215. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136216. private _depthReducer;
  136217. private _autoCalcDepthBounds;
  136218. /**
  136219. * Gets or sets the autoCalcDepthBounds property.
  136220. *
  136221. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136222. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136223. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136224. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136225. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136226. */
  136227. get autoCalcDepthBounds(): boolean;
  136228. set autoCalcDepthBounds(value: boolean);
  136229. /**
  136230. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136231. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136232. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136233. * for setting the refresh rate on the renderer yourself!
  136234. */
  136235. get autoCalcDepthBoundsRefreshRate(): number;
  136236. set autoCalcDepthBoundsRefreshRate(value: number);
  136237. /**
  136238. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136239. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136240. * you change the camera near/far planes!
  136241. */
  136242. splitFrustum(): void;
  136243. private _splitFrustum;
  136244. private _computeMatrices;
  136245. private _computeFrustumInWorldSpace;
  136246. private _computeCascadeFrustum;
  136247. /**
  136248. * Support test.
  136249. */
  136250. static get IsSupported(): boolean;
  136251. /** @hidden */
  136252. static _SceneComponentInitialization: (scene: Scene) => void;
  136253. /**
  136254. * Creates a Cascaded Shadow Generator object.
  136255. * A ShadowGenerator is the required tool to use the shadows.
  136256. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136257. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136258. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136259. * @param light The directional light object generating the shadows.
  136260. * @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.
  136261. */
  136262. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136263. protected _initializeGenerator(): void;
  136264. protected _createTargetRenderTexture(): void;
  136265. protected _initializeShadowMap(): void;
  136266. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136267. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136268. /**
  136269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136270. * @param defines Defines of the material we want to update
  136271. * @param lightIndex Index of the light in the enabled light list of the material
  136272. */
  136273. prepareDefines(defines: any, lightIndex: number): void;
  136274. /**
  136275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136276. * defined in the generator but impacting the effect).
  136277. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136278. * @param effect The effect we are binfing the information for
  136279. */
  136280. bindShadowLight(lightIndex: string, effect: Effect): void;
  136281. /**
  136282. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136283. * (eq to view projection * shadow projection matrices)
  136284. * @returns The transform matrix used to create the shadow map
  136285. */
  136286. getTransformMatrix(): Matrix;
  136287. /**
  136288. * Disposes the ShadowGenerator.
  136289. * Returns nothing.
  136290. */
  136291. dispose(): void;
  136292. /**
  136293. * Serializes the shadow generator setup to a json object.
  136294. * @returns The serialized JSON object
  136295. */
  136296. serialize(): any;
  136297. /**
  136298. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136299. * @param parsedShadowGenerator The JSON object to parse
  136300. * @param scene The scene to create the shadow map for
  136301. * @returns The parsed shadow generator
  136302. */
  136303. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  136304. }
  136305. }
  136306. declare module BABYLON {
  136307. /**
  136308. * Defines the shadow generator component responsible to manage any shadow generators
  136309. * in a given scene.
  136310. */
  136311. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  136312. /**
  136313. * The component name helpfull to identify the component in the list of scene components.
  136314. */
  136315. readonly name: string;
  136316. /**
  136317. * The scene the component belongs to.
  136318. */
  136319. scene: Scene;
  136320. /**
  136321. * Creates a new instance of the component for the given scene
  136322. * @param scene Defines the scene to register the component in
  136323. */
  136324. constructor(scene: Scene);
  136325. /**
  136326. * Registers the component in a given scene
  136327. */
  136328. register(): void;
  136329. /**
  136330. * Rebuilds the elements related to this component in case of
  136331. * context lost for instance.
  136332. */
  136333. rebuild(): void;
  136334. /**
  136335. * Serializes the component data to the specified json object
  136336. * @param serializationObject The object to serialize to
  136337. */
  136338. serialize(serializationObject: any): void;
  136339. /**
  136340. * Adds all the elements from the container to the scene
  136341. * @param container the container holding the elements
  136342. */
  136343. addFromContainer(container: AbstractScene): void;
  136344. /**
  136345. * Removes all the elements in the container from the scene
  136346. * @param container contains the elements to remove
  136347. * @param dispose if the removed element should be disposed (default: false)
  136348. */
  136349. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136350. /**
  136351. * Rebuilds the elements related to this component in case of
  136352. * context lost for instance.
  136353. */
  136354. dispose(): void;
  136355. private _gatherRenderTargets;
  136356. }
  136357. }
  136358. declare module BABYLON {
  136359. /**
  136360. * A point light is a light defined by an unique point in world space.
  136361. * The light is emitted in every direction from this point.
  136362. * A good example of a point light is a standard light bulb.
  136363. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136364. */
  136365. export class PointLight extends ShadowLight {
  136366. private _shadowAngle;
  136367. /**
  136368. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136369. * This specifies what angle the shadow will use to be created.
  136370. *
  136371. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136372. */
  136373. get shadowAngle(): number;
  136374. /**
  136375. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136376. * This specifies what angle the shadow will use to be created.
  136377. *
  136378. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136379. */
  136380. set shadowAngle(value: number);
  136381. /**
  136382. * Gets the direction if it has been set.
  136383. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136384. */
  136385. get direction(): Vector3;
  136386. /**
  136387. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136388. */
  136389. set direction(value: Vector3);
  136390. /**
  136391. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136392. * A PointLight emits the light in every direction.
  136393. * It can cast shadows.
  136394. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136395. * ```javascript
  136396. * var pointLight = new PointLight("pl", camera.position, scene);
  136397. * ```
  136398. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136399. * @param name The light friendly name
  136400. * @param position The position of the point light in the scene
  136401. * @param scene The scene the lights belongs to
  136402. */
  136403. constructor(name: string, position: Vector3, scene: Scene);
  136404. /**
  136405. * Returns the string "PointLight"
  136406. * @returns the class name
  136407. */
  136408. getClassName(): string;
  136409. /**
  136410. * Returns the integer 0.
  136411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136412. */
  136413. getTypeID(): number;
  136414. /**
  136415. * Specifies wether or not the shadowmap should be a cube texture.
  136416. * @returns true if the shadowmap needs to be a cube texture.
  136417. */
  136418. needCube(): boolean;
  136419. /**
  136420. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136423. */
  136424. getShadowDirection(faceIndex?: number): Vector3;
  136425. /**
  136426. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136427. * - fov = PI / 2
  136428. * - aspect ratio : 1.0
  136429. * - z-near and far equal to the active camera minZ and maxZ.
  136430. * Returns the PointLight.
  136431. */
  136432. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136433. protected _buildUniformLayout(): void;
  136434. /**
  136435. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136436. * @param effect The effect to update
  136437. * @param lightIndex The index of the light in the effect to update
  136438. * @returns The point light
  136439. */
  136440. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136441. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136442. /**
  136443. * Prepares the list of defines specific to the light type.
  136444. * @param defines the list of defines
  136445. * @param lightIndex defines the index of the light for the effect
  136446. */
  136447. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136448. }
  136449. }
  136450. declare module BABYLON {
  136451. /**
  136452. * Header information of HDR texture files.
  136453. */
  136454. export interface HDRInfo {
  136455. /**
  136456. * The height of the texture in pixels.
  136457. */
  136458. height: number;
  136459. /**
  136460. * The width of the texture in pixels.
  136461. */
  136462. width: number;
  136463. /**
  136464. * The index of the beginning of the data in the binary file.
  136465. */
  136466. dataPosition: number;
  136467. }
  136468. /**
  136469. * This groups tools to convert HDR texture to native colors array.
  136470. */
  136471. export class HDRTools {
  136472. private static Ldexp;
  136473. private static Rgbe2float;
  136474. private static readStringLine;
  136475. /**
  136476. * Reads header information from an RGBE texture stored in a native array.
  136477. * More information on this format are available here:
  136478. * https://en.wikipedia.org/wiki/RGBE_image_format
  136479. *
  136480. * @param uint8array The binary file stored in native array.
  136481. * @return The header information.
  136482. */
  136483. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136484. /**
  136485. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136486. * This RGBE texture needs to store the information as a panorama.
  136487. *
  136488. * More information on this format are available here:
  136489. * https://en.wikipedia.org/wiki/RGBE_image_format
  136490. *
  136491. * @param buffer The binary file stored in an array buffer.
  136492. * @param size The expected size of the extracted cubemap.
  136493. * @return The Cube Map information.
  136494. */
  136495. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136496. /**
  136497. * Returns the pixels data extracted from an RGBE texture.
  136498. * This pixels will be stored left to right up to down in the R G B order in one array.
  136499. *
  136500. * More information on this format are available here:
  136501. * https://en.wikipedia.org/wiki/RGBE_image_format
  136502. *
  136503. * @param uint8array The binary file stored in an array buffer.
  136504. * @param hdrInfo The header information of the file.
  136505. * @return The pixels data in RGB right to left up to down order.
  136506. */
  136507. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136508. private static RGBE_ReadPixels_RLE;
  136509. }
  136510. }
  136511. declare module BABYLON {
  136512. /**
  136513. * Effect Render Options
  136514. */
  136515. export interface IEffectRendererOptions {
  136516. /**
  136517. * Defines the vertices positions.
  136518. */
  136519. positions?: number[];
  136520. /**
  136521. * Defines the indices.
  136522. */
  136523. indices?: number[];
  136524. }
  136525. /**
  136526. * Helper class to render one or more effects.
  136527. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136528. */
  136529. export class EffectRenderer {
  136530. private engine;
  136531. private static _DefaultOptions;
  136532. private _vertexBuffers;
  136533. private _indexBuffer;
  136534. private _fullscreenViewport;
  136535. /**
  136536. * Creates an effect renderer
  136537. * @param engine the engine to use for rendering
  136538. * @param options defines the options of the effect renderer
  136539. */
  136540. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136541. /**
  136542. * Sets the current viewport in normalized coordinates 0-1
  136543. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136544. */
  136545. setViewport(viewport?: Viewport): void;
  136546. /**
  136547. * Binds the embedded attributes buffer to the effect.
  136548. * @param effect Defines the effect to bind the attributes for
  136549. */
  136550. bindBuffers(effect: Effect): void;
  136551. /**
  136552. * Sets the current effect wrapper to use during draw.
  136553. * The effect needs to be ready before calling this api.
  136554. * This also sets the default full screen position attribute.
  136555. * @param effectWrapper Defines the effect to draw with
  136556. */
  136557. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136558. /**
  136559. * Restores engine states
  136560. */
  136561. restoreStates(): void;
  136562. /**
  136563. * Draws a full screen quad.
  136564. */
  136565. draw(): void;
  136566. private isRenderTargetTexture;
  136567. /**
  136568. * renders one or more effects to a specified texture
  136569. * @param effectWrapper the effect to renderer
  136570. * @param outputTexture texture to draw to, if null it will render to the screen.
  136571. */
  136572. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136573. /**
  136574. * Disposes of the effect renderer
  136575. */
  136576. dispose(): void;
  136577. }
  136578. /**
  136579. * Options to create an EffectWrapper
  136580. */
  136581. interface EffectWrapperCreationOptions {
  136582. /**
  136583. * Engine to use to create the effect
  136584. */
  136585. engine: ThinEngine;
  136586. /**
  136587. * Fragment shader for the effect
  136588. */
  136589. fragmentShader: string;
  136590. /**
  136591. * Use the shader store instead of direct source code
  136592. */
  136593. useShaderStore?: boolean;
  136594. /**
  136595. * Vertex shader for the effect
  136596. */
  136597. vertexShader?: string;
  136598. /**
  136599. * Attributes to use in the shader
  136600. */
  136601. attributeNames?: Array<string>;
  136602. /**
  136603. * Uniforms to use in the shader
  136604. */
  136605. uniformNames?: Array<string>;
  136606. /**
  136607. * Texture sampler names to use in the shader
  136608. */
  136609. samplerNames?: Array<string>;
  136610. /**
  136611. * Defines to use in the shader
  136612. */
  136613. defines?: Array<string>;
  136614. /**
  136615. * Callback when effect is compiled
  136616. */
  136617. onCompiled?: Nullable<(effect: Effect) => void>;
  136618. /**
  136619. * The friendly name of the effect displayed in Spector.
  136620. */
  136621. name?: string;
  136622. }
  136623. /**
  136624. * Wraps an effect to be used for rendering
  136625. */
  136626. export class EffectWrapper {
  136627. /**
  136628. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136629. */
  136630. onApplyObservable: Observable<{}>;
  136631. /**
  136632. * The underlying effect
  136633. */
  136634. effect: Effect;
  136635. /**
  136636. * Creates an effect to be renderer
  136637. * @param creationOptions options to create the effect
  136638. */
  136639. constructor(creationOptions: EffectWrapperCreationOptions);
  136640. /**
  136641. * Disposes of the effect wrapper
  136642. */
  136643. dispose(): void;
  136644. }
  136645. }
  136646. declare module BABYLON {
  136647. /** @hidden */
  136648. export var hdrFilteringVertexShader: {
  136649. name: string;
  136650. shader: string;
  136651. };
  136652. }
  136653. declare module BABYLON {
  136654. /** @hidden */
  136655. export var hdrFilteringPixelShader: {
  136656. name: string;
  136657. shader: string;
  136658. };
  136659. }
  136660. declare module BABYLON {
  136661. /**
  136662. * Options for texture filtering
  136663. */
  136664. interface IHDRFilteringOptions {
  136665. /**
  136666. * Scales pixel intensity for the input HDR map.
  136667. */
  136668. hdrScale?: number;
  136669. /**
  136670. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136671. */
  136672. quality?: number;
  136673. }
  136674. /**
  136675. * Filters HDR maps to get correct renderings of PBR reflections
  136676. */
  136677. export class HDRFiltering {
  136678. private _engine;
  136679. private _effectRenderer;
  136680. private _effectWrapper;
  136681. private _lodGenerationOffset;
  136682. private _lodGenerationScale;
  136683. /**
  136684. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136685. * you care about baking speed.
  136686. */
  136687. quality: number;
  136688. /**
  136689. * Scales pixel intensity for the input HDR map.
  136690. */
  136691. hdrScale: number;
  136692. /**
  136693. * Instantiates HDR filter for reflection maps
  136694. *
  136695. * @param engine Thin engine
  136696. * @param options Options
  136697. */
  136698. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136699. private _createRenderTarget;
  136700. private _prefilterInternal;
  136701. private _createEffect;
  136702. /**
  136703. * Get a value indicating if the filter is ready to be used
  136704. * @param texture Texture to filter
  136705. * @returns true if the filter is ready
  136706. */
  136707. isReady(texture: BaseTexture): boolean;
  136708. /**
  136709. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136710. * Prefiltering will be invoked at the end of next rendering pass.
  136711. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136712. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136713. * @param texture Texture to filter
  136714. * @param onFinished Callback when filtering is done
  136715. * @return Promise called when prefiltering is done
  136716. */
  136717. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136718. }
  136719. }
  136720. declare module BABYLON {
  136721. /**
  136722. * This represents a texture coming from an HDR input.
  136723. *
  136724. * The only supported format is currently panorama picture stored in RGBE format.
  136725. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136726. */
  136727. export class HDRCubeTexture extends BaseTexture {
  136728. private static _facesMapping;
  136729. private _generateHarmonics;
  136730. private _noMipmap;
  136731. private _prefilterOnLoad;
  136732. private _textureMatrix;
  136733. private _size;
  136734. private _onLoad;
  136735. private _onError;
  136736. /**
  136737. * The texture URL.
  136738. */
  136739. url: string;
  136740. /**
  136741. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136742. */
  136743. coordinatesMode: number;
  136744. protected _isBlocking: boolean;
  136745. /**
  136746. * Sets wether or not the texture is blocking during loading.
  136747. */
  136748. set isBlocking(value: boolean);
  136749. /**
  136750. * Gets wether or not the texture is blocking during loading.
  136751. */
  136752. get isBlocking(): boolean;
  136753. protected _rotationY: number;
  136754. /**
  136755. * Sets texture matrix rotation angle around Y axis in radians.
  136756. */
  136757. set rotationY(value: number);
  136758. /**
  136759. * Gets texture matrix rotation angle around Y axis radians.
  136760. */
  136761. get rotationY(): number;
  136762. /**
  136763. * Gets or sets the center of the bounding box associated with the cube texture
  136764. * It must define where the camera used to render the texture was set
  136765. */
  136766. boundingBoxPosition: Vector3;
  136767. private _boundingBoxSize;
  136768. /**
  136769. * Gets or sets the size of the bounding box associated with the cube texture
  136770. * When defined, the cubemap will switch to local mode
  136771. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  136772. * @example https://www.babylonjs-playground.com/#RNASML
  136773. */
  136774. set boundingBoxSize(value: Vector3);
  136775. get boundingBoxSize(): Vector3;
  136776. /**
  136777. * Instantiates an HDRTexture from the following parameters.
  136778. *
  136779. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  136780. * @param sceneOrEngine The scene or engine the texture will be used in
  136781. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136782. * @param noMipmap Forces to not generate the mipmap if true
  136783. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  136784. * @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)
  136785. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  136786. */
  136787. 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>);
  136788. /**
  136789. * Get the current class name of the texture useful for serialization or dynamic coding.
  136790. * @returns "HDRCubeTexture"
  136791. */
  136792. getClassName(): string;
  136793. /**
  136794. * Occurs when the file is raw .hdr file.
  136795. */
  136796. private loadTexture;
  136797. clone(): HDRCubeTexture;
  136798. delayLoad(): void;
  136799. /**
  136800. * Get the texture reflection matrix used to rotate/transform the reflection.
  136801. * @returns the reflection matrix
  136802. */
  136803. getReflectionTextureMatrix(): Matrix;
  136804. /**
  136805. * Set the texture reflection matrix used to rotate/transform the reflection.
  136806. * @param value Define the reflection matrix to set
  136807. */
  136808. setReflectionTextureMatrix(value: Matrix): void;
  136809. /**
  136810. * Parses a JSON representation of an HDR Texture in order to create the texture
  136811. * @param parsedTexture Define the JSON representation
  136812. * @param scene Define the scene the texture should be created in
  136813. * @param rootUrl Define the root url in case we need to load relative dependencies
  136814. * @returns the newly created texture after parsing
  136815. */
  136816. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  136817. serialize(): any;
  136818. }
  136819. }
  136820. declare module BABYLON {
  136821. /**
  136822. * Class used to control physics engine
  136823. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136824. */
  136825. export class PhysicsEngine implements IPhysicsEngine {
  136826. private _physicsPlugin;
  136827. /**
  136828. * Global value used to control the smallest number supported by the simulation
  136829. */
  136830. static Epsilon: number;
  136831. private _impostors;
  136832. private _joints;
  136833. private _subTimeStep;
  136834. /**
  136835. * Gets the gravity vector used by the simulation
  136836. */
  136837. gravity: Vector3;
  136838. /**
  136839. * Factory used to create the default physics plugin.
  136840. * @returns The default physics plugin
  136841. */
  136842. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136843. /**
  136844. * Creates a new Physics Engine
  136845. * @param gravity defines the gravity vector used by the simulation
  136846. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136847. */
  136848. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136849. /**
  136850. * Sets the gravity vector used by the simulation
  136851. * @param gravity defines the gravity vector to use
  136852. */
  136853. setGravity(gravity: Vector3): void;
  136854. /**
  136855. * Set the time step of the physics engine.
  136856. * Default is 1/60.
  136857. * To slow it down, enter 1/600 for example.
  136858. * To speed it up, 1/30
  136859. * @param newTimeStep defines the new timestep to apply to this world.
  136860. */
  136861. setTimeStep(newTimeStep?: number): void;
  136862. /**
  136863. * Get the time step of the physics engine.
  136864. * @returns the current time step
  136865. */
  136866. getTimeStep(): number;
  136867. /**
  136868. * Set the sub time step of the physics engine.
  136869. * Default is 0 meaning there is no sub steps
  136870. * To increase physics resolution precision, set a small value (like 1 ms)
  136871. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136872. */
  136873. setSubTimeStep(subTimeStep?: number): void;
  136874. /**
  136875. * Get the sub time step of the physics engine.
  136876. * @returns the current sub time step
  136877. */
  136878. getSubTimeStep(): number;
  136879. /**
  136880. * Release all resources
  136881. */
  136882. dispose(): void;
  136883. /**
  136884. * Gets the name of the current physics plugin
  136885. * @returns the name of the plugin
  136886. */
  136887. getPhysicsPluginName(): string;
  136888. /**
  136889. * Adding a new impostor for the impostor tracking.
  136890. * This will be done by the impostor itself.
  136891. * @param impostor the impostor to add
  136892. */
  136893. addImpostor(impostor: PhysicsImpostor): void;
  136894. /**
  136895. * Remove an impostor from the engine.
  136896. * This impostor and its mesh will not longer be updated by the physics engine.
  136897. * @param impostor the impostor to remove
  136898. */
  136899. removeImpostor(impostor: PhysicsImpostor): void;
  136900. /**
  136901. * Add a joint to the physics engine
  136902. * @param mainImpostor defines the main impostor to which the joint is added.
  136903. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136904. * @param joint defines the joint that will connect both impostors.
  136905. */
  136906. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136907. /**
  136908. * Removes a joint from the simulation
  136909. * @param mainImpostor defines the impostor used with the joint
  136910. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136911. * @param joint defines the joint to remove
  136912. */
  136913. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136914. /**
  136915. * Called by the scene. No need to call it.
  136916. * @param delta defines the timespam between frames
  136917. */
  136918. _step(delta: number): void;
  136919. /**
  136920. * Gets the current plugin used to run the simulation
  136921. * @returns current plugin
  136922. */
  136923. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136924. /**
  136925. * Gets the list of physic impostors
  136926. * @returns an array of PhysicsImpostor
  136927. */
  136928. getImpostors(): Array<PhysicsImpostor>;
  136929. /**
  136930. * Gets the impostor for a physics enabled object
  136931. * @param object defines the object impersonated by the impostor
  136932. * @returns the PhysicsImpostor or null if not found
  136933. */
  136934. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136935. /**
  136936. * Gets the impostor for a physics body object
  136937. * @param body defines physics body used by the impostor
  136938. * @returns the PhysicsImpostor or null if not found
  136939. */
  136940. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136941. /**
  136942. * Does a raycast in the physics world
  136943. * @param from when should the ray start?
  136944. * @param to when should the ray end?
  136945. * @returns PhysicsRaycastResult
  136946. */
  136947. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136948. }
  136949. }
  136950. declare module BABYLON {
  136951. /** @hidden */
  136952. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136953. private _useDeltaForWorldStep;
  136954. world: any;
  136955. name: string;
  136956. private _physicsMaterials;
  136957. private _fixedTimeStep;
  136958. private _cannonRaycastResult;
  136959. private _raycastResult;
  136960. private _physicsBodysToRemoveAfterStep;
  136961. private _firstFrame;
  136962. BJSCANNON: any;
  136963. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136964. setGravity(gravity: Vector3): void;
  136965. setTimeStep(timeStep: number): void;
  136966. getTimeStep(): number;
  136967. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136968. private _removeMarkedPhysicsBodiesFromWorld;
  136969. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136970. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136971. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136972. private _processChildMeshes;
  136973. removePhysicsBody(impostor: PhysicsImpostor): void;
  136974. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136975. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136976. private _addMaterial;
  136977. private _checkWithEpsilon;
  136978. private _createShape;
  136979. private _createHeightmap;
  136980. private _minus90X;
  136981. private _plus90X;
  136982. private _tmpPosition;
  136983. private _tmpDeltaPosition;
  136984. private _tmpUnityRotation;
  136985. private _updatePhysicsBodyTransformation;
  136986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136988. isSupported(): boolean;
  136989. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136990. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136991. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136993. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136994. getBodyMass(impostor: PhysicsImpostor): number;
  136995. getBodyFriction(impostor: PhysicsImpostor): number;
  136996. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136997. getBodyRestitution(impostor: PhysicsImpostor): number;
  136998. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136999. sleepBody(impostor: PhysicsImpostor): void;
  137000. wakeUpBody(impostor: PhysicsImpostor): void;
  137001. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137002. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137003. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137004. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137005. getRadius(impostor: PhysicsImpostor): number;
  137006. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137007. dispose(): void;
  137008. private _extendNamespace;
  137009. /**
  137010. * Does a raycast in the physics world
  137011. * @param from when should the ray start?
  137012. * @param to when should the ray end?
  137013. * @returns PhysicsRaycastResult
  137014. */
  137015. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137016. }
  137017. }
  137018. declare module BABYLON {
  137019. /** @hidden */
  137020. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137021. private _useDeltaForWorldStep;
  137022. world: any;
  137023. name: string;
  137024. BJSOIMO: any;
  137025. private _raycastResult;
  137026. private _fixedTimeStep;
  137027. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137028. setGravity(gravity: Vector3): void;
  137029. setTimeStep(timeStep: number): void;
  137030. getTimeStep(): number;
  137031. private _tmpImpostorsArray;
  137032. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137033. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137034. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137035. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137036. private _tmpPositionVector;
  137037. removePhysicsBody(impostor: PhysicsImpostor): void;
  137038. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137039. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137040. isSupported(): boolean;
  137041. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137042. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137043. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137044. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137045. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137046. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137047. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137048. getBodyMass(impostor: PhysicsImpostor): number;
  137049. getBodyFriction(impostor: PhysicsImpostor): number;
  137050. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137051. getBodyRestitution(impostor: PhysicsImpostor): number;
  137052. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137053. sleepBody(impostor: PhysicsImpostor): void;
  137054. wakeUpBody(impostor: PhysicsImpostor): void;
  137055. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137056. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137058. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137059. getRadius(impostor: PhysicsImpostor): number;
  137060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137061. dispose(): void;
  137062. /**
  137063. * Does a raycast in the physics world
  137064. * @param from when should the ray start?
  137065. * @param to when should the ray end?
  137066. * @returns PhysicsRaycastResult
  137067. */
  137068. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137069. }
  137070. }
  137071. declare module BABYLON {
  137072. /**
  137073. * Class containing static functions to help procedurally build meshes
  137074. */
  137075. export class RibbonBuilder {
  137076. /**
  137077. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137078. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137079. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137080. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137081. * * 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
  137082. * * 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
  137083. * * 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
  137084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137087. * * 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
  137088. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137089. * * 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
  137090. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137092. * @param name defines the name of the mesh
  137093. * @param options defines the options used to create the mesh
  137094. * @param scene defines the hosting scene
  137095. * @returns the ribbon mesh
  137096. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137098. */
  137099. static CreateRibbon(name: string, options: {
  137100. pathArray: Vector3[][];
  137101. closeArray?: boolean;
  137102. closePath?: boolean;
  137103. offset?: number;
  137104. updatable?: boolean;
  137105. sideOrientation?: number;
  137106. frontUVs?: Vector4;
  137107. backUVs?: Vector4;
  137108. instance?: Mesh;
  137109. invertUV?: boolean;
  137110. uvs?: Vector2[];
  137111. colors?: Color4[];
  137112. }, scene?: Nullable<Scene>): Mesh;
  137113. }
  137114. }
  137115. declare module BABYLON {
  137116. /**
  137117. * Class containing static functions to help procedurally build meshes
  137118. */
  137119. export class ShapeBuilder {
  137120. /**
  137121. * 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.
  137122. * * 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.
  137123. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137124. * * 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.
  137125. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137126. * * 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
  137127. * * 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
  137128. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137133. * @param name defines the name of the mesh
  137134. * @param options defines the options used to create the mesh
  137135. * @param scene defines the hosting scene
  137136. * @returns the extruded shape mesh
  137137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137139. */
  137140. static ExtrudeShape(name: string, options: {
  137141. shape: Vector3[];
  137142. path: Vector3[];
  137143. scale?: number;
  137144. rotation?: number;
  137145. cap?: number;
  137146. updatable?: boolean;
  137147. sideOrientation?: number;
  137148. frontUVs?: Vector4;
  137149. backUVs?: Vector4;
  137150. instance?: Mesh;
  137151. invertUV?: boolean;
  137152. }, scene?: Nullable<Scene>): Mesh;
  137153. /**
  137154. * Creates an custom extruded shape mesh.
  137155. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137156. * * 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.
  137157. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137158. * * 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
  137159. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137160. * * 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
  137161. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137162. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137163. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137164. * * 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
  137165. * * 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
  137166. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137171. * @param name defines the name of the mesh
  137172. * @param options defines the options used to create the mesh
  137173. * @param scene defines the hosting scene
  137174. * @returns the custom extruded shape mesh
  137175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137178. */
  137179. static ExtrudeShapeCustom(name: string, options: {
  137180. shape: Vector3[];
  137181. path: Vector3[];
  137182. scaleFunction?: any;
  137183. rotationFunction?: any;
  137184. ribbonCloseArray?: boolean;
  137185. ribbonClosePath?: boolean;
  137186. cap?: number;
  137187. updatable?: boolean;
  137188. sideOrientation?: number;
  137189. frontUVs?: Vector4;
  137190. backUVs?: Vector4;
  137191. instance?: Mesh;
  137192. invertUV?: boolean;
  137193. }, scene?: Nullable<Scene>): Mesh;
  137194. private static _ExtrudeShapeGeneric;
  137195. }
  137196. }
  137197. declare module BABYLON {
  137198. /**
  137199. * AmmoJS Physics plugin
  137200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137201. * @see https://github.com/kripken/ammo.js/
  137202. */
  137203. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137204. private _useDeltaForWorldStep;
  137205. /**
  137206. * Reference to the Ammo library
  137207. */
  137208. bjsAMMO: any;
  137209. /**
  137210. * Created ammoJS world which physics bodies are added to
  137211. */
  137212. world: any;
  137213. /**
  137214. * Name of the plugin
  137215. */
  137216. name: string;
  137217. private _timeStep;
  137218. private _fixedTimeStep;
  137219. private _maxSteps;
  137220. private _tmpQuaternion;
  137221. private _tmpAmmoTransform;
  137222. private _tmpAmmoQuaternion;
  137223. private _tmpAmmoConcreteContactResultCallback;
  137224. private _collisionConfiguration;
  137225. private _dispatcher;
  137226. private _overlappingPairCache;
  137227. private _solver;
  137228. private _softBodySolver;
  137229. private _tmpAmmoVectorA;
  137230. private _tmpAmmoVectorB;
  137231. private _tmpAmmoVectorC;
  137232. private _tmpAmmoVectorD;
  137233. private _tmpContactCallbackResult;
  137234. private _tmpAmmoVectorRCA;
  137235. private _tmpAmmoVectorRCB;
  137236. private _raycastResult;
  137237. private static readonly DISABLE_COLLISION_FLAG;
  137238. private static readonly KINEMATIC_FLAG;
  137239. private static readonly DISABLE_DEACTIVATION_FLAG;
  137240. /**
  137241. * Initializes the ammoJS plugin
  137242. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137243. * @param ammoInjection can be used to inject your own ammo reference
  137244. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137245. */
  137246. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137247. /**
  137248. * Sets the gravity of the physics world (m/(s^2))
  137249. * @param gravity Gravity to set
  137250. */
  137251. setGravity(gravity: Vector3): void;
  137252. /**
  137253. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137254. * @param timeStep timestep to use in seconds
  137255. */
  137256. setTimeStep(timeStep: number): void;
  137257. /**
  137258. * 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)
  137259. * @param fixedTimeStep fixedTimeStep to use in seconds
  137260. */
  137261. setFixedTimeStep(fixedTimeStep: number): void;
  137262. /**
  137263. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137264. * @param maxSteps the maximum number of steps by the physics engine per frame
  137265. */
  137266. setMaxSteps(maxSteps: number): void;
  137267. /**
  137268. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137269. * @returns the current timestep in seconds
  137270. */
  137271. getTimeStep(): number;
  137272. /**
  137273. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137274. */
  137275. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137276. private _isImpostorInContact;
  137277. private _isImpostorPairInContact;
  137278. private _stepSimulation;
  137279. /**
  137280. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137281. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137282. * After the step the babylon meshes are set to the position of the physics imposters
  137283. * @param delta amount of time to step forward
  137284. * @param impostors array of imposters to update before/after the step
  137285. */
  137286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137287. /**
  137288. * Update babylon mesh to match physics world object
  137289. * @param impostor imposter to match
  137290. */
  137291. private _afterSoftStep;
  137292. /**
  137293. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137294. * @param impostor imposter to match
  137295. */
  137296. private _ropeStep;
  137297. /**
  137298. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137299. * @param impostor imposter to match
  137300. */
  137301. private _softbodyOrClothStep;
  137302. private _tmpMatrix;
  137303. /**
  137304. * Applies an impulse on the imposter
  137305. * @param impostor imposter to apply impulse to
  137306. * @param force amount of force to be applied to the imposter
  137307. * @param contactPoint the location to apply the impulse on the imposter
  137308. */
  137309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137310. /**
  137311. * Applies a force on the imposter
  137312. * @param impostor imposter to apply force
  137313. * @param force amount of force to be applied to the imposter
  137314. * @param contactPoint the location to apply the force on the imposter
  137315. */
  137316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137317. /**
  137318. * Creates a physics body using the plugin
  137319. * @param impostor the imposter to create the physics body on
  137320. */
  137321. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137322. /**
  137323. * Removes the physics body from the imposter and disposes of the body's memory
  137324. * @param impostor imposter to remove the physics body from
  137325. */
  137326. removePhysicsBody(impostor: PhysicsImpostor): void;
  137327. /**
  137328. * Generates a joint
  137329. * @param impostorJoint the imposter joint to create the joint with
  137330. */
  137331. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137332. /**
  137333. * Removes a joint
  137334. * @param impostorJoint the imposter joint to remove the joint from
  137335. */
  137336. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137337. private _addMeshVerts;
  137338. /**
  137339. * Initialise the soft body vertices to match its object's (mesh) vertices
  137340. * Softbody vertices (nodes) are in world space and to match this
  137341. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  137342. * @param impostor to create the softbody for
  137343. */
  137344. private _softVertexData;
  137345. /**
  137346. * Create an impostor's soft body
  137347. * @param impostor to create the softbody for
  137348. */
  137349. private _createSoftbody;
  137350. /**
  137351. * Create cloth for an impostor
  137352. * @param impostor to create the softbody for
  137353. */
  137354. private _createCloth;
  137355. /**
  137356. * Create rope for an impostor
  137357. * @param impostor to create the softbody for
  137358. */
  137359. private _createRope;
  137360. /**
  137361. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137362. * @param impostor to create the custom physics shape for
  137363. */
  137364. private _createCustom;
  137365. private _addHullVerts;
  137366. private _createShape;
  137367. /**
  137368. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137369. * @param impostor imposter containing the physics body and babylon object
  137370. */
  137371. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137372. /**
  137373. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137374. * @param impostor imposter containing the physics body and babylon object
  137375. * @param newPosition new position
  137376. * @param newRotation new rotation
  137377. */
  137378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137379. /**
  137380. * If this plugin is supported
  137381. * @returns true if its supported
  137382. */
  137383. isSupported(): boolean;
  137384. /**
  137385. * Sets the linear velocity of the physics body
  137386. * @param impostor imposter to set the velocity on
  137387. * @param velocity velocity to set
  137388. */
  137389. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137390. /**
  137391. * Sets the angular velocity of the physics body
  137392. * @param impostor imposter to set the velocity on
  137393. * @param velocity velocity to set
  137394. */
  137395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137396. /**
  137397. * gets the linear velocity
  137398. * @param impostor imposter to get linear velocity from
  137399. * @returns linear velocity
  137400. */
  137401. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137402. /**
  137403. * gets the angular velocity
  137404. * @param impostor imposter to get angular velocity from
  137405. * @returns angular velocity
  137406. */
  137407. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137408. /**
  137409. * Sets the mass of physics body
  137410. * @param impostor imposter to set the mass on
  137411. * @param mass mass to set
  137412. */
  137413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137414. /**
  137415. * Gets the mass of the physics body
  137416. * @param impostor imposter to get the mass from
  137417. * @returns mass
  137418. */
  137419. getBodyMass(impostor: PhysicsImpostor): number;
  137420. /**
  137421. * Gets friction of the impostor
  137422. * @param impostor impostor to get friction from
  137423. * @returns friction value
  137424. */
  137425. getBodyFriction(impostor: PhysicsImpostor): number;
  137426. /**
  137427. * Sets friction of the impostor
  137428. * @param impostor impostor to set friction on
  137429. * @param friction friction value
  137430. */
  137431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137432. /**
  137433. * Gets restitution of the impostor
  137434. * @param impostor impostor to get restitution from
  137435. * @returns restitution value
  137436. */
  137437. getBodyRestitution(impostor: PhysicsImpostor): number;
  137438. /**
  137439. * Sets resitution of the impostor
  137440. * @param impostor impostor to set resitution on
  137441. * @param restitution resitution value
  137442. */
  137443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137444. /**
  137445. * Gets pressure inside the impostor
  137446. * @param impostor impostor to get pressure from
  137447. * @returns pressure value
  137448. */
  137449. getBodyPressure(impostor: PhysicsImpostor): number;
  137450. /**
  137451. * Sets pressure inside a soft body impostor
  137452. * Cloth and rope must remain 0 pressure
  137453. * @param impostor impostor to set pressure on
  137454. * @param pressure pressure value
  137455. */
  137456. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137457. /**
  137458. * Gets stiffness of the impostor
  137459. * @param impostor impostor to get stiffness from
  137460. * @returns pressure value
  137461. */
  137462. getBodyStiffness(impostor: PhysicsImpostor): number;
  137463. /**
  137464. * Sets stiffness of the impostor
  137465. * @param impostor impostor to set stiffness on
  137466. * @param stiffness stiffness value from 0 to 1
  137467. */
  137468. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137469. /**
  137470. * Gets velocityIterations of the impostor
  137471. * @param impostor impostor to get velocity iterations from
  137472. * @returns velocityIterations value
  137473. */
  137474. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137475. /**
  137476. * Sets velocityIterations of the impostor
  137477. * @param impostor impostor to set velocity iterations on
  137478. * @param velocityIterations velocityIterations value
  137479. */
  137480. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137481. /**
  137482. * Gets positionIterations of the impostor
  137483. * @param impostor impostor to get position iterations from
  137484. * @returns positionIterations value
  137485. */
  137486. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137487. /**
  137488. * Sets positionIterations of the impostor
  137489. * @param impostor impostor to set position on
  137490. * @param positionIterations positionIterations value
  137491. */
  137492. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137493. /**
  137494. * Append an anchor to a cloth object
  137495. * @param impostor is the cloth impostor to add anchor to
  137496. * @param otherImpostor is the rigid impostor to anchor to
  137497. * @param width ratio across width from 0 to 1
  137498. * @param height ratio up height from 0 to 1
  137499. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137500. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137501. */
  137502. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137503. /**
  137504. * Append an hook to a rope object
  137505. * @param impostor is the rope impostor to add hook to
  137506. * @param otherImpostor is the rigid impostor to hook to
  137507. * @param length ratio along the rope from 0 to 1
  137508. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137509. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137510. */
  137511. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137512. /**
  137513. * Sleeps the physics body and stops it from being active
  137514. * @param impostor impostor to sleep
  137515. */
  137516. sleepBody(impostor: PhysicsImpostor): void;
  137517. /**
  137518. * Activates the physics body
  137519. * @param impostor impostor to activate
  137520. */
  137521. wakeUpBody(impostor: PhysicsImpostor): void;
  137522. /**
  137523. * Updates the distance parameters of the joint
  137524. * @param joint joint to update
  137525. * @param maxDistance maximum distance of the joint
  137526. * @param minDistance minimum distance of the joint
  137527. */
  137528. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137529. /**
  137530. * Sets a motor on the joint
  137531. * @param joint joint to set motor on
  137532. * @param speed speed of the motor
  137533. * @param maxForce maximum force of the motor
  137534. * @param motorIndex index of the motor
  137535. */
  137536. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137537. /**
  137538. * Sets the motors limit
  137539. * @param joint joint to set limit on
  137540. * @param upperLimit upper limit
  137541. * @param lowerLimit lower limit
  137542. */
  137543. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137544. /**
  137545. * Syncs the position and rotation of a mesh with the impostor
  137546. * @param mesh mesh to sync
  137547. * @param impostor impostor to update the mesh with
  137548. */
  137549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137550. /**
  137551. * Gets the radius of the impostor
  137552. * @param impostor impostor to get radius from
  137553. * @returns the radius
  137554. */
  137555. getRadius(impostor: PhysicsImpostor): number;
  137556. /**
  137557. * Gets the box size of the impostor
  137558. * @param impostor impostor to get box size from
  137559. * @param result the resulting box size
  137560. */
  137561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137562. /**
  137563. * Disposes of the impostor
  137564. */
  137565. dispose(): void;
  137566. /**
  137567. * Does a raycast in the physics world
  137568. * @param from when should the ray start?
  137569. * @param to when should the ray end?
  137570. * @returns PhysicsRaycastResult
  137571. */
  137572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137573. }
  137574. }
  137575. declare module BABYLON {
  137576. interface AbstractScene {
  137577. /**
  137578. * The list of reflection probes added to the scene
  137579. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137580. */
  137581. reflectionProbes: Array<ReflectionProbe>;
  137582. /**
  137583. * Removes the given reflection probe from this scene.
  137584. * @param toRemove The reflection probe to remove
  137585. * @returns The index of the removed reflection probe
  137586. */
  137587. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137588. /**
  137589. * Adds the given reflection probe to this scene.
  137590. * @param newReflectionProbe The reflection probe to add
  137591. */
  137592. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137593. }
  137594. /**
  137595. * Class used to generate realtime reflection / refraction cube textures
  137596. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137597. */
  137598. export class ReflectionProbe {
  137599. /** defines the name of the probe */
  137600. name: string;
  137601. private _scene;
  137602. private _renderTargetTexture;
  137603. private _projectionMatrix;
  137604. private _viewMatrix;
  137605. private _target;
  137606. private _add;
  137607. private _attachedMesh;
  137608. private _invertYAxis;
  137609. /** Gets or sets probe position (center of the cube map) */
  137610. position: Vector3;
  137611. /**
  137612. * Creates a new reflection probe
  137613. * @param name defines the name of the probe
  137614. * @param size defines the texture resolution (for each face)
  137615. * @param scene defines the hosting scene
  137616. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137617. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137618. */
  137619. constructor(
  137620. /** defines the name of the probe */
  137621. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137622. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137623. get samples(): number;
  137624. set samples(value: number);
  137625. /** Gets or sets the refresh rate to use (on every frame by default) */
  137626. get refreshRate(): number;
  137627. set refreshRate(value: number);
  137628. /**
  137629. * Gets the hosting scene
  137630. * @returns a Scene
  137631. */
  137632. getScene(): Scene;
  137633. /** Gets the internal CubeTexture used to render to */
  137634. get cubeTexture(): RenderTargetTexture;
  137635. /** Gets the list of meshes to render */
  137636. get renderList(): Nullable<AbstractMesh[]>;
  137637. /**
  137638. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137639. * @param mesh defines the mesh to attach to
  137640. */
  137641. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137642. /**
  137643. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137644. * @param renderingGroupId The rendering group id corresponding to its index
  137645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137646. */
  137647. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137648. /**
  137649. * Clean all associated resources
  137650. */
  137651. dispose(): void;
  137652. /**
  137653. * Converts the reflection probe information to a readable string for debug purpose.
  137654. * @param fullDetails Supports for multiple levels of logging within scene loading
  137655. * @returns the human readable reflection probe info
  137656. */
  137657. toString(fullDetails?: boolean): string;
  137658. /**
  137659. * Get the class name of the relfection probe.
  137660. * @returns "ReflectionProbe"
  137661. */
  137662. getClassName(): string;
  137663. /**
  137664. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137665. * @returns The JSON representation of the texture
  137666. */
  137667. serialize(): any;
  137668. /**
  137669. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137670. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137671. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137672. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137673. * @returns The parsed reflection probe if successful
  137674. */
  137675. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137676. }
  137677. }
  137678. declare module BABYLON {
  137679. /** @hidden */
  137680. export var _BabylonLoaderRegistered: boolean;
  137681. /**
  137682. * Helps setting up some configuration for the babylon file loader.
  137683. */
  137684. export class BabylonFileLoaderConfiguration {
  137685. /**
  137686. * The loader does not allow injecting custom physix engine into the plugins.
  137687. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137688. * So you could set this variable to your engine import to make it work.
  137689. */
  137690. static LoaderInjectedPhysicsEngine: any;
  137691. }
  137692. }
  137693. declare module BABYLON {
  137694. /**
  137695. * The Physically based simple base material of BJS.
  137696. *
  137697. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137698. * It is used as the base class for both the specGloss and metalRough conventions.
  137699. */
  137700. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137701. /**
  137702. * Number of Simultaneous lights allowed on the material.
  137703. */
  137704. maxSimultaneousLights: number;
  137705. /**
  137706. * If sets to true, disables all the lights affecting the material.
  137707. */
  137708. disableLighting: boolean;
  137709. /**
  137710. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137711. */
  137712. environmentTexture: BaseTexture;
  137713. /**
  137714. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137715. */
  137716. invertNormalMapX: boolean;
  137717. /**
  137718. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137719. */
  137720. invertNormalMapY: boolean;
  137721. /**
  137722. * Normal map used in the model.
  137723. */
  137724. normalTexture: BaseTexture;
  137725. /**
  137726. * Emissivie color used to self-illuminate the model.
  137727. */
  137728. emissiveColor: Color3;
  137729. /**
  137730. * Emissivie texture used to self-illuminate the model.
  137731. */
  137732. emissiveTexture: BaseTexture;
  137733. /**
  137734. * Occlusion Channel Strenght.
  137735. */
  137736. occlusionStrength: number;
  137737. /**
  137738. * Occlusion Texture of the material (adding extra occlusion effects).
  137739. */
  137740. occlusionTexture: BaseTexture;
  137741. /**
  137742. * Defines the alpha limits in alpha test mode.
  137743. */
  137744. alphaCutOff: number;
  137745. /**
  137746. * Gets the current double sided mode.
  137747. */
  137748. get doubleSided(): boolean;
  137749. /**
  137750. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137751. */
  137752. set doubleSided(value: boolean);
  137753. /**
  137754. * Stores the pre-calculated light information of a mesh in a texture.
  137755. */
  137756. lightmapTexture: BaseTexture;
  137757. /**
  137758. * If true, the light map contains occlusion information instead of lighting info.
  137759. */
  137760. useLightmapAsShadowmap: boolean;
  137761. /**
  137762. * Instantiates a new PBRMaterial instance.
  137763. *
  137764. * @param name The material name
  137765. * @param scene The scene the material will be use in.
  137766. */
  137767. constructor(name: string, scene: Scene);
  137768. getClassName(): string;
  137769. }
  137770. }
  137771. declare module BABYLON {
  137772. /**
  137773. * The PBR material of BJS following the metal roughness convention.
  137774. *
  137775. * This fits to the PBR convention in the GLTF definition:
  137776. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  137777. */
  137778. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  137779. /**
  137780. * The base color has two different interpretations depending on the value of metalness.
  137781. * When the material is a metal, the base color is the specific measured reflectance value
  137782. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  137783. * of the material.
  137784. */
  137785. baseColor: Color3;
  137786. /**
  137787. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  137788. * well as opacity information in the alpha channel.
  137789. */
  137790. baseTexture: BaseTexture;
  137791. /**
  137792. * Specifies the metallic scalar value of the material.
  137793. * Can also be used to scale the metalness values of the metallic texture.
  137794. */
  137795. metallic: number;
  137796. /**
  137797. * Specifies the roughness scalar value of the material.
  137798. * Can also be used to scale the roughness values of the metallic texture.
  137799. */
  137800. roughness: number;
  137801. /**
  137802. * Texture containing both the metallic value in the B channel and the
  137803. * roughness value in the G channel to keep better precision.
  137804. */
  137805. metallicRoughnessTexture: BaseTexture;
  137806. /**
  137807. * Instantiates a new PBRMetalRoughnessMaterial instance.
  137808. *
  137809. * @param name The material name
  137810. * @param scene The scene the material will be use in.
  137811. */
  137812. constructor(name: string, scene: Scene);
  137813. /**
  137814. * Return the currrent class name of the material.
  137815. */
  137816. getClassName(): string;
  137817. /**
  137818. * Makes a duplicate of the current material.
  137819. * @param name - name to use for the new material.
  137820. */
  137821. clone(name: string): PBRMetallicRoughnessMaterial;
  137822. /**
  137823. * Serialize the material to a parsable JSON object.
  137824. */
  137825. serialize(): any;
  137826. /**
  137827. * Parses a JSON object correponding to the serialize function.
  137828. */
  137829. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  137830. }
  137831. }
  137832. declare module BABYLON {
  137833. /**
  137834. * The PBR material of BJS following the specular glossiness convention.
  137835. *
  137836. * This fits to the PBR convention in the GLTF definition:
  137837. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137838. */
  137839. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137840. /**
  137841. * Specifies the diffuse color of the material.
  137842. */
  137843. diffuseColor: Color3;
  137844. /**
  137845. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137846. * channel.
  137847. */
  137848. diffuseTexture: BaseTexture;
  137849. /**
  137850. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137851. */
  137852. specularColor: Color3;
  137853. /**
  137854. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137855. */
  137856. glossiness: number;
  137857. /**
  137858. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137859. */
  137860. specularGlossinessTexture: BaseTexture;
  137861. /**
  137862. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137863. *
  137864. * @param name The material name
  137865. * @param scene The scene the material will be use in.
  137866. */
  137867. constructor(name: string, scene: Scene);
  137868. /**
  137869. * Return the currrent class name of the material.
  137870. */
  137871. getClassName(): string;
  137872. /**
  137873. * Makes a duplicate of the current material.
  137874. * @param name - name to use for the new material.
  137875. */
  137876. clone(name: string): PBRSpecularGlossinessMaterial;
  137877. /**
  137878. * Serialize the material to a parsable JSON object.
  137879. */
  137880. serialize(): any;
  137881. /**
  137882. * Parses a JSON object correponding to the serialize function.
  137883. */
  137884. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137885. }
  137886. }
  137887. declare module BABYLON {
  137888. /**
  137889. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137890. * It can help converting any input color in a desired output one. This can then be used to create effects
  137891. * from sepia, black and white to sixties or futuristic rendering...
  137892. *
  137893. * The only supported format is currently 3dl.
  137894. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137895. */
  137896. export class ColorGradingTexture extends BaseTexture {
  137897. /**
  137898. * The texture URL.
  137899. */
  137900. url: string;
  137901. /**
  137902. * Empty line regex stored for GC.
  137903. */
  137904. private static _noneEmptyLineRegex;
  137905. private _textureMatrix;
  137906. private _onLoad;
  137907. /**
  137908. * Instantiates a ColorGradingTexture from the following parameters.
  137909. *
  137910. * @param url The location of the color gradind data (currently only supporting 3dl)
  137911. * @param sceneOrEngine The scene or engine the texture will be used in
  137912. * @param onLoad defines a callback triggered when the texture has been loaded
  137913. */
  137914. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137915. /**
  137916. * Fires the onload event from the constructor if requested.
  137917. */
  137918. private _triggerOnLoad;
  137919. /**
  137920. * Returns the texture matrix used in most of the material.
  137921. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137922. */
  137923. getTextureMatrix(): Matrix;
  137924. /**
  137925. * Occurs when the file being loaded is a .3dl LUT file.
  137926. */
  137927. private load3dlTexture;
  137928. /**
  137929. * Starts the loading process of the texture.
  137930. */
  137931. private loadTexture;
  137932. /**
  137933. * Clones the color gradind texture.
  137934. */
  137935. clone(): ColorGradingTexture;
  137936. /**
  137937. * Called during delayed load for textures.
  137938. */
  137939. delayLoad(): void;
  137940. /**
  137941. * Parses a color grading texture serialized by Babylon.
  137942. * @param parsedTexture The texture information being parsedTexture
  137943. * @param scene The scene to load the texture in
  137944. * @param rootUrl The root url of the data assets to load
  137945. * @return A color gradind texture
  137946. */
  137947. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137948. /**
  137949. * Serializes the LUT texture to json format.
  137950. */
  137951. serialize(): any;
  137952. }
  137953. }
  137954. declare module BABYLON {
  137955. /**
  137956. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137957. */
  137958. export class EquiRectangularCubeTexture extends BaseTexture {
  137959. /** The six faces of the cube. */
  137960. private static _FacesMapping;
  137961. private _noMipmap;
  137962. private _onLoad;
  137963. private _onError;
  137964. /** The size of the cubemap. */
  137965. private _size;
  137966. /** The buffer of the image. */
  137967. private _buffer;
  137968. /** The width of the input image. */
  137969. private _width;
  137970. /** The height of the input image. */
  137971. private _height;
  137972. /** The URL to the image. */
  137973. url: string;
  137974. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137975. coordinatesMode: number;
  137976. /**
  137977. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137978. * @param url The location of the image
  137979. * @param scene The scene the texture will be used in
  137980. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137981. * @param noMipmap Forces to not generate the mipmap if true
  137982. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137983. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137984. * @param onLoad — defines a callback called when texture is loaded
  137985. * @param onError — defines a callback called if there is an error
  137986. */
  137987. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137988. /**
  137989. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137990. */
  137991. private loadImage;
  137992. /**
  137993. * Convert the image buffer into a cubemap and create a CubeTexture.
  137994. */
  137995. private loadTexture;
  137996. /**
  137997. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137998. * @param buffer The ArrayBuffer that should be converted.
  137999. * @returns The buffer as Float32Array.
  138000. */
  138001. private getFloat32ArrayFromArrayBuffer;
  138002. /**
  138003. * Get the current class name of the texture useful for serialization or dynamic coding.
  138004. * @returns "EquiRectangularCubeTexture"
  138005. */
  138006. getClassName(): string;
  138007. /**
  138008. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138009. * @returns A clone of the current EquiRectangularCubeTexture.
  138010. */
  138011. clone(): EquiRectangularCubeTexture;
  138012. }
  138013. }
  138014. declare module BABYLON {
  138015. /**
  138016. * Defines the options related to the creation of an HtmlElementTexture
  138017. */
  138018. export interface IHtmlElementTextureOptions {
  138019. /**
  138020. * Defines wether mip maps should be created or not.
  138021. */
  138022. generateMipMaps?: boolean;
  138023. /**
  138024. * Defines the sampling mode of the texture.
  138025. */
  138026. samplingMode?: number;
  138027. /**
  138028. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138029. */
  138030. engine: Nullable<ThinEngine>;
  138031. /**
  138032. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138033. */
  138034. scene: Nullable<Scene>;
  138035. }
  138036. /**
  138037. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138038. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138039. * is automatically managed.
  138040. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138041. * in your application.
  138042. *
  138043. * As the update is not automatic, you need to call them manually.
  138044. */
  138045. export class HtmlElementTexture extends BaseTexture {
  138046. /**
  138047. * The texture URL.
  138048. */
  138049. element: HTMLVideoElement | HTMLCanvasElement;
  138050. private static readonly DefaultOptions;
  138051. private _textureMatrix;
  138052. private _isVideo;
  138053. private _generateMipMaps;
  138054. private _samplingMode;
  138055. /**
  138056. * Instantiates a HtmlElementTexture from the following parameters.
  138057. *
  138058. * @param name Defines the name of the texture
  138059. * @param element Defines the video or canvas the texture is filled with
  138060. * @param options Defines the other none mandatory texture creation options
  138061. */
  138062. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138063. private _createInternalTexture;
  138064. /**
  138065. * Returns the texture matrix used in most of the material.
  138066. */
  138067. getTextureMatrix(): Matrix;
  138068. /**
  138069. * Updates the content of the texture.
  138070. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138071. */
  138072. update(invertY?: Nullable<boolean>): void;
  138073. }
  138074. }
  138075. declare module BABYLON {
  138076. /**
  138077. * Based on jsTGALoader - Javascript loader for TGA file
  138078. * By Vincent Thibault
  138079. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138080. */
  138081. export class TGATools {
  138082. private static _TYPE_INDEXED;
  138083. private static _TYPE_RGB;
  138084. private static _TYPE_GREY;
  138085. private static _TYPE_RLE_INDEXED;
  138086. private static _TYPE_RLE_RGB;
  138087. private static _TYPE_RLE_GREY;
  138088. private static _ORIGIN_MASK;
  138089. private static _ORIGIN_SHIFT;
  138090. private static _ORIGIN_BL;
  138091. private static _ORIGIN_BR;
  138092. private static _ORIGIN_UL;
  138093. private static _ORIGIN_UR;
  138094. /**
  138095. * Gets the header of a TGA file
  138096. * @param data defines the TGA data
  138097. * @returns the header
  138098. */
  138099. static GetTGAHeader(data: Uint8Array): any;
  138100. /**
  138101. * Uploads TGA content to a Babylon Texture
  138102. * @hidden
  138103. */
  138104. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138105. /** @hidden */
  138106. 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;
  138107. /** @hidden */
  138108. 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;
  138109. /** @hidden */
  138110. 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;
  138111. /** @hidden */
  138112. 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;
  138113. /** @hidden */
  138114. 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;
  138115. /** @hidden */
  138116. 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;
  138117. }
  138118. }
  138119. declare module BABYLON {
  138120. /**
  138121. * Implementation of the TGA Texture Loader.
  138122. * @hidden
  138123. */
  138124. export class _TGATextureLoader implements IInternalTextureLoader {
  138125. /**
  138126. * Defines wether the loader supports cascade loading the different faces.
  138127. */
  138128. readonly supportCascades: boolean;
  138129. /**
  138130. * This returns if the loader support the current file information.
  138131. * @param extension defines the file extension of the file being loaded
  138132. * @returns true if the loader can load the specified file
  138133. */
  138134. canLoad(extension: string): boolean;
  138135. /**
  138136. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138137. * @param data contains the texture data
  138138. * @param texture defines the BabylonJS internal texture
  138139. * @param createPolynomials will be true if polynomials have been requested
  138140. * @param onLoad defines the callback to trigger once the texture is ready
  138141. * @param onError defines the callback to trigger in case of error
  138142. */
  138143. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138144. /**
  138145. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138146. * @param data contains the texture data
  138147. * @param texture defines the BabylonJS internal texture
  138148. * @param callback defines the method to call once ready to upload
  138149. */
  138150. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138151. }
  138152. }
  138153. declare module BABYLON {
  138154. /**
  138155. * Info about the .basis files
  138156. */
  138157. class BasisFileInfo {
  138158. /**
  138159. * If the file has alpha
  138160. */
  138161. hasAlpha: boolean;
  138162. /**
  138163. * Info about each image of the basis file
  138164. */
  138165. images: Array<{
  138166. levels: Array<{
  138167. width: number;
  138168. height: number;
  138169. transcodedPixels: ArrayBufferView;
  138170. }>;
  138171. }>;
  138172. }
  138173. /**
  138174. * Result of transcoding a basis file
  138175. */
  138176. class TranscodeResult {
  138177. /**
  138178. * Info about the .basis file
  138179. */
  138180. fileInfo: BasisFileInfo;
  138181. /**
  138182. * Format to use when loading the file
  138183. */
  138184. format: number;
  138185. }
  138186. /**
  138187. * Configuration options for the Basis transcoder
  138188. */
  138189. export class BasisTranscodeConfiguration {
  138190. /**
  138191. * Supported compression formats used to determine the supported output format of the transcoder
  138192. */
  138193. supportedCompressionFormats?: {
  138194. /**
  138195. * etc1 compression format
  138196. */
  138197. etc1?: boolean;
  138198. /**
  138199. * s3tc compression format
  138200. */
  138201. s3tc?: boolean;
  138202. /**
  138203. * pvrtc compression format
  138204. */
  138205. pvrtc?: boolean;
  138206. /**
  138207. * etc2 compression format
  138208. */
  138209. etc2?: boolean;
  138210. };
  138211. /**
  138212. * If mipmap levels should be loaded for transcoded images (Default: true)
  138213. */
  138214. loadMipmapLevels?: boolean;
  138215. /**
  138216. * Index of a single image to load (Default: all images)
  138217. */
  138218. loadSingleImage?: number;
  138219. }
  138220. /**
  138221. * Used to load .Basis files
  138222. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138223. */
  138224. export class BasisTools {
  138225. private static _IgnoreSupportedFormats;
  138226. /**
  138227. * URL to use when loading the basis transcoder
  138228. */
  138229. static JSModuleURL: string;
  138230. /**
  138231. * URL to use when loading the wasm module for the transcoder
  138232. */
  138233. static WasmModuleURL: string;
  138234. /**
  138235. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138236. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138237. * @returns internal format corresponding to the Basis format
  138238. */
  138239. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138240. private static _WorkerPromise;
  138241. private static _Worker;
  138242. private static _actionId;
  138243. private static _CreateWorkerAsync;
  138244. /**
  138245. * Transcodes a loaded image file to compressed pixel data
  138246. * @param data image data to transcode
  138247. * @param config configuration options for the transcoding
  138248. * @returns a promise resulting in the transcoded image
  138249. */
  138250. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138251. /**
  138252. * Loads a texture from the transcode result
  138253. * @param texture texture load to
  138254. * @param transcodeResult the result of transcoding the basis file to load from
  138255. */
  138256. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138257. }
  138258. }
  138259. declare module BABYLON {
  138260. /**
  138261. * Loader for .basis file format
  138262. */
  138263. export class _BasisTextureLoader implements IInternalTextureLoader {
  138264. /**
  138265. * Defines whether the loader supports cascade loading the different faces.
  138266. */
  138267. readonly supportCascades: boolean;
  138268. /**
  138269. * This returns if the loader support the current file information.
  138270. * @param extension defines the file extension of the file being loaded
  138271. * @returns true if the loader can load the specified file
  138272. */
  138273. canLoad(extension: string): boolean;
  138274. /**
  138275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138276. * @param data contains the texture data
  138277. * @param texture defines the BabylonJS internal texture
  138278. * @param createPolynomials will be true if polynomials have been requested
  138279. * @param onLoad defines the callback to trigger once the texture is ready
  138280. * @param onError defines the callback to trigger in case of error
  138281. */
  138282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138283. /**
  138284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138285. * @param data contains the texture data
  138286. * @param texture defines the BabylonJS internal texture
  138287. * @param callback defines the method to call once ready to upload
  138288. */
  138289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138290. }
  138291. }
  138292. declare module BABYLON {
  138293. /**
  138294. * Defines the basic options interface of a TexturePacker Frame
  138295. */
  138296. export interface ITexturePackerFrame {
  138297. /**
  138298. * The frame ID
  138299. */
  138300. id: number;
  138301. /**
  138302. * The frames Scale
  138303. */
  138304. scale: Vector2;
  138305. /**
  138306. * The Frames offset
  138307. */
  138308. offset: Vector2;
  138309. }
  138310. /**
  138311. * This is a support class for frame Data on texture packer sets.
  138312. */
  138313. export class TexturePackerFrame implements ITexturePackerFrame {
  138314. /**
  138315. * The frame ID
  138316. */
  138317. id: number;
  138318. /**
  138319. * The frames Scale
  138320. */
  138321. scale: Vector2;
  138322. /**
  138323. * The Frames offset
  138324. */
  138325. offset: Vector2;
  138326. /**
  138327. * Initializes a texture package frame.
  138328. * @param id The numerical frame identifier
  138329. * @param scale Scalar Vector2 for UV frame
  138330. * @param offset Vector2 for the frame position in UV units.
  138331. * @returns TexturePackerFrame
  138332. */
  138333. constructor(id: number, scale: Vector2, offset: Vector2);
  138334. }
  138335. }
  138336. declare module BABYLON {
  138337. /**
  138338. * Defines the basic options interface of a TexturePacker
  138339. */
  138340. export interface ITexturePackerOptions {
  138341. /**
  138342. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  138343. */
  138344. map?: string[];
  138345. /**
  138346. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138347. */
  138348. uvsIn?: string;
  138349. /**
  138350. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138351. */
  138352. uvsOut?: string;
  138353. /**
  138354. * number representing the layout style. Defaults to LAYOUT_STRIP
  138355. */
  138356. layout?: number;
  138357. /**
  138358. * number of columns if using custom column count layout(2). This defaults to 4.
  138359. */
  138360. colnum?: number;
  138361. /**
  138362. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138363. */
  138364. updateInputMeshes?: boolean;
  138365. /**
  138366. * boolean flag to dispose all the source textures. Defaults to true.
  138367. */
  138368. disposeSources?: boolean;
  138369. /**
  138370. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138371. */
  138372. fillBlanks?: boolean;
  138373. /**
  138374. * string value representing the context fill style color. Defaults to 'black'.
  138375. */
  138376. customFillColor?: string;
  138377. /**
  138378. * Width and Height Value of each Frame in the TexturePacker Sets
  138379. */
  138380. frameSize?: number;
  138381. /**
  138382. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138383. */
  138384. paddingRatio?: number;
  138385. /**
  138386. * Number that declares the fill method for the padding gutter.
  138387. */
  138388. paddingMode?: number;
  138389. /**
  138390. * If in SUBUV_COLOR padding mode what color to use.
  138391. */
  138392. paddingColor?: Color3 | Color4;
  138393. }
  138394. /**
  138395. * Defines the basic interface of a TexturePacker JSON File
  138396. */
  138397. export interface ITexturePackerJSON {
  138398. /**
  138399. * The frame ID
  138400. */
  138401. name: string;
  138402. /**
  138403. * The base64 channel data
  138404. */
  138405. sets: any;
  138406. /**
  138407. * The options of the Packer
  138408. */
  138409. options: ITexturePackerOptions;
  138410. /**
  138411. * The frame data of the Packer
  138412. */
  138413. frames: Array<number>;
  138414. }
  138415. /**
  138416. * This is a support class that generates a series of packed texture sets.
  138417. * @see https://doc.babylonjs.com/babylon101/materials
  138418. */
  138419. export class TexturePacker {
  138420. /** Packer Layout Constant 0 */
  138421. static readonly LAYOUT_STRIP: number;
  138422. /** Packer Layout Constant 1 */
  138423. static readonly LAYOUT_POWER2: number;
  138424. /** Packer Layout Constant 2 */
  138425. static readonly LAYOUT_COLNUM: number;
  138426. /** Packer Layout Constant 0 */
  138427. static readonly SUBUV_WRAP: number;
  138428. /** Packer Layout Constant 1 */
  138429. static readonly SUBUV_EXTEND: number;
  138430. /** Packer Layout Constant 2 */
  138431. static readonly SUBUV_COLOR: number;
  138432. /** The Name of the Texture Package */
  138433. name: string;
  138434. /** The scene scope of the TexturePacker */
  138435. scene: Scene;
  138436. /** The Meshes to target */
  138437. meshes: AbstractMesh[];
  138438. /** Arguments passed with the Constructor */
  138439. options: ITexturePackerOptions;
  138440. /** The promise that is started upon initialization */
  138441. promise: Nullable<Promise<TexturePacker | string>>;
  138442. /** The Container object for the channel sets that are generated */
  138443. sets: object;
  138444. /** The Container array for the frames that are generated */
  138445. frames: TexturePackerFrame[];
  138446. /** The expected number of textures the system is parsing. */
  138447. private _expecting;
  138448. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138449. private _paddingValue;
  138450. /**
  138451. * Initializes a texture package series from an array of meshes or a single mesh.
  138452. * @param name The name of the package
  138453. * @param meshes The target meshes to compose the package from
  138454. * @param options The arguments that texture packer should follow while building.
  138455. * @param scene The scene which the textures are scoped to.
  138456. * @returns TexturePacker
  138457. */
  138458. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138459. /**
  138460. * Starts the package process
  138461. * @param resolve The promises resolution function
  138462. * @returns TexturePacker
  138463. */
  138464. private _createFrames;
  138465. /**
  138466. * Calculates the Size of the Channel Sets
  138467. * @returns Vector2
  138468. */
  138469. private _calculateSize;
  138470. /**
  138471. * Calculates the UV data for the frames.
  138472. * @param baseSize the base frameSize
  138473. * @param padding the base frame padding
  138474. * @param dtSize size of the Dynamic Texture for that channel
  138475. * @param dtUnits is 1/dtSize
  138476. * @param update flag to update the input meshes
  138477. */
  138478. private _calculateMeshUVFrames;
  138479. /**
  138480. * Calculates the frames Offset.
  138481. * @param index of the frame
  138482. * @returns Vector2
  138483. */
  138484. private _getFrameOffset;
  138485. /**
  138486. * Updates a Mesh to the frame data
  138487. * @param mesh that is the target
  138488. * @param frameID or the frame index
  138489. */
  138490. private _updateMeshUV;
  138491. /**
  138492. * Updates a Meshes materials to use the texture packer channels
  138493. * @param m is the mesh to target
  138494. * @param force all channels on the packer to be set.
  138495. */
  138496. private _updateTextureReferences;
  138497. /**
  138498. * Public method to set a Mesh to a frame
  138499. * @param m that is the target
  138500. * @param frameID or the frame index
  138501. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138502. */
  138503. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138504. /**
  138505. * Starts the async promise to compile the texture packer.
  138506. * @returns Promise<void>
  138507. */
  138508. processAsync(): Promise<void>;
  138509. /**
  138510. * Disposes all textures associated with this packer
  138511. */
  138512. dispose(): void;
  138513. /**
  138514. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138515. * @param imageType is the image type to use.
  138516. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138517. */
  138518. download(imageType?: string, quality?: number): void;
  138519. /**
  138520. * Public method to load a texturePacker JSON file.
  138521. * @param data of the JSON file in string format.
  138522. */
  138523. updateFromJSON(data: string): void;
  138524. }
  138525. }
  138526. declare module BABYLON {
  138527. /**
  138528. * 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.
  138529. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138530. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138531. */
  138532. export class CustomProceduralTexture extends ProceduralTexture {
  138533. private _animate;
  138534. private _time;
  138535. private _config;
  138536. private _texturePath;
  138537. /**
  138538. * Instantiates a new Custom Procedural Texture.
  138539. * 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.
  138540. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138541. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138542. * @param name Define the name of the texture
  138543. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138544. * @param size Define the size of the texture to create
  138545. * @param scene Define the scene the texture belongs to
  138546. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138547. * @param generateMipMaps Define if the texture should creates mip maps or not
  138548. */
  138549. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138550. private _loadJson;
  138551. /**
  138552. * Is the texture ready to be used ? (rendered at least once)
  138553. * @returns true if ready, otherwise, false.
  138554. */
  138555. isReady(): boolean;
  138556. /**
  138557. * Render the texture to its associated render target.
  138558. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138559. */
  138560. render(useCameraPostProcess?: boolean): void;
  138561. /**
  138562. * Update the list of dependant textures samplers in the shader.
  138563. */
  138564. updateTextures(): void;
  138565. /**
  138566. * Update the uniform values of the procedural texture in the shader.
  138567. */
  138568. updateShaderUniforms(): void;
  138569. /**
  138570. * Define if the texture animates or not.
  138571. */
  138572. get animate(): boolean;
  138573. set animate(value: boolean);
  138574. }
  138575. }
  138576. declare module BABYLON {
  138577. /** @hidden */
  138578. export var noisePixelShader: {
  138579. name: string;
  138580. shader: string;
  138581. };
  138582. }
  138583. declare module BABYLON {
  138584. /**
  138585. * Class used to generate noise procedural textures
  138586. */
  138587. export class NoiseProceduralTexture extends ProceduralTexture {
  138588. private _time;
  138589. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138590. brightness: number;
  138591. /** Defines the number of octaves to process */
  138592. octaves: number;
  138593. /** Defines the level of persistence (0.8 by default) */
  138594. persistence: number;
  138595. /** Gets or sets animation speed factor (default is 1) */
  138596. animationSpeedFactor: number;
  138597. /**
  138598. * Creates a new NoiseProceduralTexture
  138599. * @param name defines the name fo the texture
  138600. * @param size defines the size of the texture (default is 256)
  138601. * @param scene defines the hosting scene
  138602. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138603. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138604. */
  138605. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138606. private _updateShaderUniforms;
  138607. protected _getDefines(): string;
  138608. /** Generate the current state of the procedural texture */
  138609. render(useCameraPostProcess?: boolean): void;
  138610. /**
  138611. * Serializes this noise procedural texture
  138612. * @returns a serialized noise procedural texture object
  138613. */
  138614. serialize(): any;
  138615. /**
  138616. * Clone the texture.
  138617. * @returns the cloned texture
  138618. */
  138619. clone(): NoiseProceduralTexture;
  138620. /**
  138621. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138622. * @param parsedTexture defines parsed texture data
  138623. * @param scene defines the current scene
  138624. * @param rootUrl defines the root URL containing noise procedural texture information
  138625. * @returns a parsed NoiseProceduralTexture
  138626. */
  138627. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138628. }
  138629. }
  138630. declare module BABYLON {
  138631. /**
  138632. * Raw cube texture where the raw buffers are passed in
  138633. */
  138634. export class RawCubeTexture extends CubeTexture {
  138635. /**
  138636. * Creates a cube texture where the raw buffers are passed in.
  138637. * @param scene defines the scene the texture is attached to
  138638. * @param data defines the array of data to use to create each face
  138639. * @param size defines the size of the textures
  138640. * @param format defines the format of the data
  138641. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138642. * @param generateMipMaps defines if the engine should generate the mip levels
  138643. * @param invertY defines if data must be stored with Y axis inverted
  138644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138645. * @param compression defines the compression used (null by default)
  138646. */
  138647. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138648. /**
  138649. * Updates the raw cube texture.
  138650. * @param data defines the data to store
  138651. * @param format defines the data format
  138652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138653. * @param invertY defines if data must be stored with Y axis inverted
  138654. * @param compression defines the compression used (null by default)
  138655. * @param level defines which level of the texture to update
  138656. */
  138657. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138658. /**
  138659. * Updates a raw cube texture with RGBD encoded data.
  138660. * @param data defines the array of data [mipmap][face] to use to create each face
  138661. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138664. * @returns a promsie that resolves when the operation is complete
  138665. */
  138666. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138667. /**
  138668. * Clones the raw cube texture.
  138669. * @return a new cube texture
  138670. */
  138671. clone(): CubeTexture;
  138672. /** @hidden */
  138673. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138674. }
  138675. }
  138676. declare module BABYLON {
  138677. /**
  138678. * Class used to store 2D array textures containing user data
  138679. */
  138680. export class RawTexture2DArray extends Texture {
  138681. /** Gets or sets the texture format to use */
  138682. format: number;
  138683. /**
  138684. * Create a new RawTexture2DArray
  138685. * @param data defines the data of the texture
  138686. * @param width defines the width of the texture
  138687. * @param height defines the height of the texture
  138688. * @param depth defines the number of layers of the texture
  138689. * @param format defines the texture format to use
  138690. * @param scene defines the hosting scene
  138691. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138692. * @param invertY defines if texture must be stored with Y axis inverted
  138693. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138695. */
  138696. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138697. /** Gets or sets the texture format to use */
  138698. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138699. /**
  138700. * Update the texture with new data
  138701. * @param data defines the data to store in the texture
  138702. */
  138703. update(data: ArrayBufferView): void;
  138704. }
  138705. }
  138706. declare module BABYLON {
  138707. /**
  138708. * Class used to store 3D textures containing user data
  138709. */
  138710. export class RawTexture3D extends Texture {
  138711. /** Gets or sets the texture format to use */
  138712. format: number;
  138713. /**
  138714. * Create a new RawTexture3D
  138715. * @param data defines the data of the texture
  138716. * @param width defines the width of the texture
  138717. * @param height defines the height of the texture
  138718. * @param depth defines the depth of the texture
  138719. * @param format defines the texture format to use
  138720. * @param scene defines the hosting scene
  138721. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138722. * @param invertY defines if texture must be stored with Y axis inverted
  138723. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138724. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138725. */
  138726. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138727. /** Gets or sets the texture format to use */
  138728. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138729. /**
  138730. * Update the texture with new data
  138731. * @param data defines the data to store in the texture
  138732. */
  138733. update(data: ArrayBufferView): void;
  138734. }
  138735. }
  138736. declare module BABYLON {
  138737. /**
  138738. * Creates a refraction texture used by refraction channel of the standard material.
  138739. * It is like a mirror but to see through a material.
  138740. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138741. */
  138742. export class RefractionTexture extends RenderTargetTexture {
  138743. /**
  138744. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138745. * 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.
  138746. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138747. */
  138748. refractionPlane: Plane;
  138749. /**
  138750. * Define how deep under the surface we should see.
  138751. */
  138752. depth: number;
  138753. /**
  138754. * Creates a refraction texture used by refraction channel of the standard material.
  138755. * It is like a mirror but to see through a material.
  138756. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138757. * @param name Define the texture name
  138758. * @param size Define the size of the underlying texture
  138759. * @param scene Define the scene the refraction belongs to
  138760. * @param generateMipMaps Define if we need to generate mips level for the refraction
  138761. */
  138762. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  138763. /**
  138764. * Clone the refraction texture.
  138765. * @returns the cloned texture
  138766. */
  138767. clone(): RefractionTexture;
  138768. /**
  138769. * Serialize the texture to a JSON representation you could use in Parse later on
  138770. * @returns the serialized JSON representation
  138771. */
  138772. serialize(): any;
  138773. }
  138774. }
  138775. declare module BABYLON {
  138776. /**
  138777. * Block used to add support for vertex skinning (bones)
  138778. */
  138779. export class BonesBlock extends NodeMaterialBlock {
  138780. /**
  138781. * Creates a new BonesBlock
  138782. * @param name defines the block name
  138783. */
  138784. constructor(name: string);
  138785. /**
  138786. * Initialize the block and prepare the context for build
  138787. * @param state defines the state that will be used for the build
  138788. */
  138789. initialize(state: NodeMaterialBuildState): void;
  138790. /**
  138791. * Gets the current class name
  138792. * @returns the class name
  138793. */
  138794. getClassName(): string;
  138795. /**
  138796. * Gets the matrix indices input component
  138797. */
  138798. get matricesIndices(): NodeMaterialConnectionPoint;
  138799. /**
  138800. * Gets the matrix weights input component
  138801. */
  138802. get matricesWeights(): NodeMaterialConnectionPoint;
  138803. /**
  138804. * Gets the extra matrix indices input component
  138805. */
  138806. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  138807. /**
  138808. * Gets the extra matrix weights input component
  138809. */
  138810. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  138811. /**
  138812. * Gets the world input component
  138813. */
  138814. get world(): NodeMaterialConnectionPoint;
  138815. /**
  138816. * Gets the output component
  138817. */
  138818. get output(): NodeMaterialConnectionPoint;
  138819. autoConfigure(material: NodeMaterial): void;
  138820. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  138821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138823. protected _buildBlock(state: NodeMaterialBuildState): this;
  138824. }
  138825. }
  138826. declare module BABYLON {
  138827. /**
  138828. * Block used to add support for instances
  138829. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  138830. */
  138831. export class InstancesBlock extends NodeMaterialBlock {
  138832. /**
  138833. * Creates a new InstancesBlock
  138834. * @param name defines the block name
  138835. */
  138836. constructor(name: string);
  138837. /**
  138838. * Gets the current class name
  138839. * @returns the class name
  138840. */
  138841. getClassName(): string;
  138842. /**
  138843. * Gets the first world row input component
  138844. */
  138845. get world0(): NodeMaterialConnectionPoint;
  138846. /**
  138847. * Gets the second world row input component
  138848. */
  138849. get world1(): NodeMaterialConnectionPoint;
  138850. /**
  138851. * Gets the third world row input component
  138852. */
  138853. get world2(): NodeMaterialConnectionPoint;
  138854. /**
  138855. * Gets the forth world row input component
  138856. */
  138857. get world3(): NodeMaterialConnectionPoint;
  138858. /**
  138859. * Gets the world input component
  138860. */
  138861. get world(): NodeMaterialConnectionPoint;
  138862. /**
  138863. * Gets the output component
  138864. */
  138865. get output(): NodeMaterialConnectionPoint;
  138866. /**
  138867. * Gets the isntanceID component
  138868. */
  138869. get instanceID(): NodeMaterialConnectionPoint;
  138870. autoConfigure(material: NodeMaterial): void;
  138871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138872. protected _buildBlock(state: NodeMaterialBuildState): this;
  138873. }
  138874. }
  138875. declare module BABYLON {
  138876. /**
  138877. * Block used to add morph targets support to vertex shader
  138878. */
  138879. export class MorphTargetsBlock extends NodeMaterialBlock {
  138880. private _repeatableContentAnchor;
  138881. /**
  138882. * Create a new MorphTargetsBlock
  138883. * @param name defines the block name
  138884. */
  138885. constructor(name: string);
  138886. /**
  138887. * Gets the current class name
  138888. * @returns the class name
  138889. */
  138890. getClassName(): string;
  138891. /**
  138892. * Gets the position input component
  138893. */
  138894. get position(): NodeMaterialConnectionPoint;
  138895. /**
  138896. * Gets the normal input component
  138897. */
  138898. get normal(): NodeMaterialConnectionPoint;
  138899. /**
  138900. * Gets the tangent input component
  138901. */
  138902. get tangent(): NodeMaterialConnectionPoint;
  138903. /**
  138904. * Gets the tangent input component
  138905. */
  138906. get uv(): NodeMaterialConnectionPoint;
  138907. /**
  138908. * Gets the position output component
  138909. */
  138910. get positionOutput(): NodeMaterialConnectionPoint;
  138911. /**
  138912. * Gets the normal output component
  138913. */
  138914. get normalOutput(): NodeMaterialConnectionPoint;
  138915. /**
  138916. * Gets the tangent output component
  138917. */
  138918. get tangentOutput(): NodeMaterialConnectionPoint;
  138919. /**
  138920. * Gets the tangent output component
  138921. */
  138922. get uvOutput(): NodeMaterialConnectionPoint;
  138923. initialize(state: NodeMaterialBuildState): void;
  138924. autoConfigure(material: NodeMaterial): void;
  138925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138927. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138928. protected _buildBlock(state: NodeMaterialBuildState): this;
  138929. }
  138930. }
  138931. declare module BABYLON {
  138932. /**
  138933. * Block used to get data information from a light
  138934. */
  138935. export class LightInformationBlock extends NodeMaterialBlock {
  138936. private _lightDataUniformName;
  138937. private _lightColorUniformName;
  138938. private _lightTypeDefineName;
  138939. /**
  138940. * Gets or sets the light associated with this block
  138941. */
  138942. light: Nullable<Light>;
  138943. /**
  138944. * Creates a new LightInformationBlock
  138945. * @param name defines the block name
  138946. */
  138947. constructor(name: string);
  138948. /**
  138949. * Gets the current class name
  138950. * @returns the class name
  138951. */
  138952. getClassName(): string;
  138953. /**
  138954. * Gets the world position input component
  138955. */
  138956. get worldPosition(): NodeMaterialConnectionPoint;
  138957. /**
  138958. * Gets the direction output component
  138959. */
  138960. get direction(): NodeMaterialConnectionPoint;
  138961. /**
  138962. * Gets the direction output component
  138963. */
  138964. get color(): NodeMaterialConnectionPoint;
  138965. /**
  138966. * Gets the direction output component
  138967. */
  138968. get intensity(): NodeMaterialConnectionPoint;
  138969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138971. protected _buildBlock(state: NodeMaterialBuildState): this;
  138972. serialize(): any;
  138973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138974. }
  138975. }
  138976. declare module BABYLON {
  138977. /**
  138978. * Block used to add image processing support to fragment shader
  138979. */
  138980. export class ImageProcessingBlock extends NodeMaterialBlock {
  138981. /**
  138982. * Create a new ImageProcessingBlock
  138983. * @param name defines the block name
  138984. */
  138985. constructor(name: string);
  138986. /**
  138987. * Gets the current class name
  138988. * @returns the class name
  138989. */
  138990. getClassName(): string;
  138991. /**
  138992. * Gets the color input component
  138993. */
  138994. get color(): NodeMaterialConnectionPoint;
  138995. /**
  138996. * Gets the output component
  138997. */
  138998. get output(): NodeMaterialConnectionPoint;
  138999. /**
  139000. * Initialize the block and prepare the context for build
  139001. * @param state defines the state that will be used for the build
  139002. */
  139003. initialize(state: NodeMaterialBuildState): void;
  139004. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139007. protected _buildBlock(state: NodeMaterialBuildState): this;
  139008. }
  139009. }
  139010. declare module BABYLON {
  139011. /**
  139012. * Block used to pertub normals based on a normal map
  139013. */
  139014. export class PerturbNormalBlock extends NodeMaterialBlock {
  139015. private _tangentSpaceParameterName;
  139016. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139017. invertX: boolean;
  139018. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139019. invertY: boolean;
  139020. /**
  139021. * Create a new PerturbNormalBlock
  139022. * @param name defines the block name
  139023. */
  139024. constructor(name: string);
  139025. /**
  139026. * Gets the current class name
  139027. * @returns the class name
  139028. */
  139029. getClassName(): string;
  139030. /**
  139031. * Gets the world position input component
  139032. */
  139033. get worldPosition(): NodeMaterialConnectionPoint;
  139034. /**
  139035. * Gets the world normal input component
  139036. */
  139037. get worldNormal(): NodeMaterialConnectionPoint;
  139038. /**
  139039. * Gets the world tangent input component
  139040. */
  139041. get worldTangent(): NodeMaterialConnectionPoint;
  139042. /**
  139043. * Gets the uv input component
  139044. */
  139045. get uv(): NodeMaterialConnectionPoint;
  139046. /**
  139047. * Gets the normal map color input component
  139048. */
  139049. get normalMapColor(): NodeMaterialConnectionPoint;
  139050. /**
  139051. * Gets the strength input component
  139052. */
  139053. get strength(): NodeMaterialConnectionPoint;
  139054. /**
  139055. * Gets the output component
  139056. */
  139057. get output(): NodeMaterialConnectionPoint;
  139058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139060. autoConfigure(material: NodeMaterial): void;
  139061. protected _buildBlock(state: NodeMaterialBuildState): this;
  139062. protected _dumpPropertiesCode(): string;
  139063. serialize(): any;
  139064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /**
  139069. * Block used to discard a pixel if a value is smaller than a cutoff
  139070. */
  139071. export class DiscardBlock extends NodeMaterialBlock {
  139072. /**
  139073. * Create a new DiscardBlock
  139074. * @param name defines the block name
  139075. */
  139076. constructor(name: string);
  139077. /**
  139078. * Gets the current class name
  139079. * @returns the class name
  139080. */
  139081. getClassName(): string;
  139082. /**
  139083. * Gets the color input component
  139084. */
  139085. get value(): NodeMaterialConnectionPoint;
  139086. /**
  139087. * Gets the cutoff input component
  139088. */
  139089. get cutoff(): NodeMaterialConnectionPoint;
  139090. protected _buildBlock(state: NodeMaterialBuildState): this;
  139091. }
  139092. }
  139093. declare module BABYLON {
  139094. /**
  139095. * Block used to test if the fragment shader is front facing
  139096. */
  139097. export class FrontFacingBlock extends NodeMaterialBlock {
  139098. /**
  139099. * Creates a new FrontFacingBlock
  139100. * @param name defines the block name
  139101. */
  139102. constructor(name: string);
  139103. /**
  139104. * Gets the current class name
  139105. * @returns the class name
  139106. */
  139107. getClassName(): string;
  139108. /**
  139109. * Gets the output component
  139110. */
  139111. get output(): NodeMaterialConnectionPoint;
  139112. protected _buildBlock(state: NodeMaterialBuildState): this;
  139113. }
  139114. }
  139115. declare module BABYLON {
  139116. /**
  139117. * Block used to get the derivative value on x and y of a given input
  139118. */
  139119. export class DerivativeBlock extends NodeMaterialBlock {
  139120. /**
  139121. * Create a new DerivativeBlock
  139122. * @param name defines the block name
  139123. */
  139124. constructor(name: string);
  139125. /**
  139126. * Gets the current class name
  139127. * @returns the class name
  139128. */
  139129. getClassName(): string;
  139130. /**
  139131. * Gets the input component
  139132. */
  139133. get input(): NodeMaterialConnectionPoint;
  139134. /**
  139135. * Gets the derivative output on x
  139136. */
  139137. get dx(): NodeMaterialConnectionPoint;
  139138. /**
  139139. * Gets the derivative output on y
  139140. */
  139141. get dy(): NodeMaterialConnectionPoint;
  139142. protected _buildBlock(state: NodeMaterialBuildState): this;
  139143. }
  139144. }
  139145. declare module BABYLON {
  139146. /**
  139147. * Block used to make gl_FragCoord available
  139148. */
  139149. export class FragCoordBlock extends NodeMaterialBlock {
  139150. /**
  139151. * Creates a new FragCoordBlock
  139152. * @param name defines the block name
  139153. */
  139154. constructor(name: string);
  139155. /**
  139156. * Gets the current class name
  139157. * @returns the class name
  139158. */
  139159. getClassName(): string;
  139160. /**
  139161. * Gets the xy component
  139162. */
  139163. get xy(): NodeMaterialConnectionPoint;
  139164. /**
  139165. * Gets the xyz component
  139166. */
  139167. get xyz(): NodeMaterialConnectionPoint;
  139168. /**
  139169. * Gets the xyzw component
  139170. */
  139171. get xyzw(): NodeMaterialConnectionPoint;
  139172. /**
  139173. * Gets the x component
  139174. */
  139175. get x(): NodeMaterialConnectionPoint;
  139176. /**
  139177. * Gets the y component
  139178. */
  139179. get y(): NodeMaterialConnectionPoint;
  139180. /**
  139181. * Gets the z component
  139182. */
  139183. get z(): NodeMaterialConnectionPoint;
  139184. /**
  139185. * Gets the w component
  139186. */
  139187. get output(): NodeMaterialConnectionPoint;
  139188. protected writeOutputs(state: NodeMaterialBuildState): string;
  139189. protected _buildBlock(state: NodeMaterialBuildState): this;
  139190. }
  139191. }
  139192. declare module BABYLON {
  139193. /**
  139194. * Block used to get the screen sizes
  139195. */
  139196. export class ScreenSizeBlock extends NodeMaterialBlock {
  139197. private _varName;
  139198. private _scene;
  139199. /**
  139200. * Creates a new ScreenSizeBlock
  139201. * @param name defines the block name
  139202. */
  139203. constructor(name: string);
  139204. /**
  139205. * Gets the current class name
  139206. * @returns the class name
  139207. */
  139208. getClassName(): string;
  139209. /**
  139210. * Gets the xy component
  139211. */
  139212. get xy(): NodeMaterialConnectionPoint;
  139213. /**
  139214. * Gets the x component
  139215. */
  139216. get x(): NodeMaterialConnectionPoint;
  139217. /**
  139218. * Gets the y component
  139219. */
  139220. get y(): NodeMaterialConnectionPoint;
  139221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139222. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139223. protected _buildBlock(state: NodeMaterialBuildState): this;
  139224. }
  139225. }
  139226. declare module BABYLON {
  139227. /**
  139228. * Block used to add support for scene fog
  139229. */
  139230. export class FogBlock extends NodeMaterialBlock {
  139231. private _fogDistanceName;
  139232. private _fogParameters;
  139233. /**
  139234. * Create a new FogBlock
  139235. * @param name defines the block name
  139236. */
  139237. constructor(name: string);
  139238. /**
  139239. * Gets the current class name
  139240. * @returns the class name
  139241. */
  139242. getClassName(): string;
  139243. /**
  139244. * Gets the world position input component
  139245. */
  139246. get worldPosition(): NodeMaterialConnectionPoint;
  139247. /**
  139248. * Gets the view input component
  139249. */
  139250. get view(): NodeMaterialConnectionPoint;
  139251. /**
  139252. * Gets the color input component
  139253. */
  139254. get input(): NodeMaterialConnectionPoint;
  139255. /**
  139256. * Gets the fog color input component
  139257. */
  139258. get fogColor(): NodeMaterialConnectionPoint;
  139259. /**
  139260. * Gets the output component
  139261. */
  139262. get output(): NodeMaterialConnectionPoint;
  139263. autoConfigure(material: NodeMaterial): void;
  139264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139266. protected _buildBlock(state: NodeMaterialBuildState): this;
  139267. }
  139268. }
  139269. declare module BABYLON {
  139270. /**
  139271. * Block used to add light in the fragment shader
  139272. */
  139273. export class LightBlock extends NodeMaterialBlock {
  139274. private _lightId;
  139275. /**
  139276. * Gets or sets the light associated with this block
  139277. */
  139278. light: Nullable<Light>;
  139279. /**
  139280. * Create a new LightBlock
  139281. * @param name defines the block name
  139282. */
  139283. constructor(name: string);
  139284. /**
  139285. * Gets the current class name
  139286. * @returns the class name
  139287. */
  139288. getClassName(): string;
  139289. /**
  139290. * Gets the world position input component
  139291. */
  139292. get worldPosition(): NodeMaterialConnectionPoint;
  139293. /**
  139294. * Gets the world normal input component
  139295. */
  139296. get worldNormal(): NodeMaterialConnectionPoint;
  139297. /**
  139298. * Gets the camera (or eye) position component
  139299. */
  139300. get cameraPosition(): NodeMaterialConnectionPoint;
  139301. /**
  139302. * Gets the glossiness component
  139303. */
  139304. get glossiness(): NodeMaterialConnectionPoint;
  139305. /**
  139306. * Gets the glossinness power component
  139307. */
  139308. get glossPower(): NodeMaterialConnectionPoint;
  139309. /**
  139310. * Gets the diffuse color component
  139311. */
  139312. get diffuseColor(): NodeMaterialConnectionPoint;
  139313. /**
  139314. * Gets the specular color component
  139315. */
  139316. get specularColor(): NodeMaterialConnectionPoint;
  139317. /**
  139318. * Gets the diffuse output component
  139319. */
  139320. get diffuseOutput(): NodeMaterialConnectionPoint;
  139321. /**
  139322. * Gets the specular output component
  139323. */
  139324. get specularOutput(): NodeMaterialConnectionPoint;
  139325. /**
  139326. * Gets the shadow output component
  139327. */
  139328. get shadow(): NodeMaterialConnectionPoint;
  139329. autoConfigure(material: NodeMaterial): void;
  139330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139331. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  139332. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139333. private _injectVertexCode;
  139334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139335. serialize(): any;
  139336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139337. }
  139338. }
  139339. declare module BABYLON {
  139340. /**
  139341. * Block used to read a reflection texture from a sampler
  139342. */
  139343. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  139344. /**
  139345. * Create a new ReflectionTextureBlock
  139346. * @param name defines the block name
  139347. */
  139348. constructor(name: string);
  139349. /**
  139350. * Gets the current class name
  139351. * @returns the class name
  139352. */
  139353. getClassName(): string;
  139354. /**
  139355. * Gets the world position input component
  139356. */
  139357. get position(): NodeMaterialConnectionPoint;
  139358. /**
  139359. * Gets the world position input component
  139360. */
  139361. get worldPosition(): NodeMaterialConnectionPoint;
  139362. /**
  139363. * Gets the world normal input component
  139364. */
  139365. get worldNormal(): NodeMaterialConnectionPoint;
  139366. /**
  139367. * Gets the world input component
  139368. */
  139369. get world(): NodeMaterialConnectionPoint;
  139370. /**
  139371. * Gets the camera (or eye) position component
  139372. */
  139373. get cameraPosition(): NodeMaterialConnectionPoint;
  139374. /**
  139375. * Gets the view input component
  139376. */
  139377. get view(): NodeMaterialConnectionPoint;
  139378. /**
  139379. * Gets the rgb output component
  139380. */
  139381. get rgb(): NodeMaterialConnectionPoint;
  139382. /**
  139383. * Gets the r output component
  139384. */
  139385. get r(): NodeMaterialConnectionPoint;
  139386. /**
  139387. * Gets the g output component
  139388. */
  139389. get g(): NodeMaterialConnectionPoint;
  139390. /**
  139391. * Gets the b output component
  139392. */
  139393. get b(): NodeMaterialConnectionPoint;
  139394. autoConfigure(material: NodeMaterial): void;
  139395. protected _buildBlock(state: NodeMaterialBuildState): this;
  139396. }
  139397. }
  139398. declare module BABYLON {
  139399. /**
  139400. * Block used to add 2 vectors
  139401. */
  139402. export class AddBlock extends NodeMaterialBlock {
  139403. /**
  139404. * Creates a new AddBlock
  139405. * @param name defines the block name
  139406. */
  139407. constructor(name: string);
  139408. /**
  139409. * Gets the current class name
  139410. * @returns the class name
  139411. */
  139412. getClassName(): string;
  139413. /**
  139414. * Gets the left operand input component
  139415. */
  139416. get left(): NodeMaterialConnectionPoint;
  139417. /**
  139418. * Gets the right operand input component
  139419. */
  139420. get right(): NodeMaterialConnectionPoint;
  139421. /**
  139422. * Gets the output component
  139423. */
  139424. get output(): NodeMaterialConnectionPoint;
  139425. protected _buildBlock(state: NodeMaterialBuildState): this;
  139426. }
  139427. }
  139428. declare module BABYLON {
  139429. /**
  139430. * Block used to scale a vector by a float
  139431. */
  139432. export class ScaleBlock extends NodeMaterialBlock {
  139433. /**
  139434. * Creates a new ScaleBlock
  139435. * @param name defines the block name
  139436. */
  139437. constructor(name: string);
  139438. /**
  139439. * Gets the current class name
  139440. * @returns the class name
  139441. */
  139442. getClassName(): string;
  139443. /**
  139444. * Gets the input component
  139445. */
  139446. get input(): NodeMaterialConnectionPoint;
  139447. /**
  139448. * Gets the factor input component
  139449. */
  139450. get factor(): NodeMaterialConnectionPoint;
  139451. /**
  139452. * Gets the output component
  139453. */
  139454. get output(): NodeMaterialConnectionPoint;
  139455. protected _buildBlock(state: NodeMaterialBuildState): this;
  139456. }
  139457. }
  139458. declare module BABYLON {
  139459. /**
  139460. * Block used to clamp a float
  139461. */
  139462. export class ClampBlock extends NodeMaterialBlock {
  139463. /** Gets or sets the minimum range */
  139464. minimum: number;
  139465. /** Gets or sets the maximum range */
  139466. maximum: number;
  139467. /**
  139468. * Creates a new ClampBlock
  139469. * @param name defines the block name
  139470. */
  139471. constructor(name: string);
  139472. /**
  139473. * Gets the current class name
  139474. * @returns the class name
  139475. */
  139476. getClassName(): string;
  139477. /**
  139478. * Gets the value input component
  139479. */
  139480. get value(): NodeMaterialConnectionPoint;
  139481. /**
  139482. * Gets the output component
  139483. */
  139484. get output(): NodeMaterialConnectionPoint;
  139485. protected _buildBlock(state: NodeMaterialBuildState): this;
  139486. protected _dumpPropertiesCode(): string;
  139487. serialize(): any;
  139488. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139489. }
  139490. }
  139491. declare module BABYLON {
  139492. /**
  139493. * Block used to apply a cross product between 2 vectors
  139494. */
  139495. export class CrossBlock extends NodeMaterialBlock {
  139496. /**
  139497. * Creates a new CrossBlock
  139498. * @param name defines the block name
  139499. */
  139500. constructor(name: string);
  139501. /**
  139502. * Gets the current class name
  139503. * @returns the class name
  139504. */
  139505. getClassName(): string;
  139506. /**
  139507. * Gets the left operand input component
  139508. */
  139509. get left(): NodeMaterialConnectionPoint;
  139510. /**
  139511. * Gets the right operand input component
  139512. */
  139513. get right(): NodeMaterialConnectionPoint;
  139514. /**
  139515. * Gets the output component
  139516. */
  139517. get output(): NodeMaterialConnectionPoint;
  139518. protected _buildBlock(state: NodeMaterialBuildState): this;
  139519. }
  139520. }
  139521. declare module BABYLON {
  139522. /**
  139523. * Block used to apply a dot product between 2 vectors
  139524. */
  139525. export class DotBlock extends NodeMaterialBlock {
  139526. /**
  139527. * Creates a new DotBlock
  139528. * @param name defines the block name
  139529. */
  139530. constructor(name: string);
  139531. /**
  139532. * Gets the current class name
  139533. * @returns the class name
  139534. */
  139535. getClassName(): string;
  139536. /**
  139537. * Gets the left operand input component
  139538. */
  139539. get left(): NodeMaterialConnectionPoint;
  139540. /**
  139541. * Gets the right operand input component
  139542. */
  139543. get right(): NodeMaterialConnectionPoint;
  139544. /**
  139545. * Gets the output component
  139546. */
  139547. get output(): NodeMaterialConnectionPoint;
  139548. protected _buildBlock(state: NodeMaterialBuildState): this;
  139549. }
  139550. }
  139551. declare module BABYLON {
  139552. /**
  139553. * Block used to normalize a vector
  139554. */
  139555. export class NormalizeBlock extends NodeMaterialBlock {
  139556. /**
  139557. * Creates a new NormalizeBlock
  139558. * @param name defines the block name
  139559. */
  139560. constructor(name: string);
  139561. /**
  139562. * Gets the current class name
  139563. * @returns the class name
  139564. */
  139565. getClassName(): string;
  139566. /**
  139567. * Gets the input component
  139568. */
  139569. get input(): NodeMaterialConnectionPoint;
  139570. /**
  139571. * Gets the output component
  139572. */
  139573. get output(): NodeMaterialConnectionPoint;
  139574. protected _buildBlock(state: NodeMaterialBuildState): this;
  139575. }
  139576. }
  139577. declare module BABYLON {
  139578. /**
  139579. * Operations supported by the Trigonometry block
  139580. */
  139581. export enum TrigonometryBlockOperations {
  139582. /** Cos */
  139583. Cos = 0,
  139584. /** Sin */
  139585. Sin = 1,
  139586. /** Abs */
  139587. Abs = 2,
  139588. /** Exp */
  139589. Exp = 3,
  139590. /** Exp2 */
  139591. Exp2 = 4,
  139592. /** Round */
  139593. Round = 5,
  139594. /** Floor */
  139595. Floor = 6,
  139596. /** Ceiling */
  139597. Ceiling = 7,
  139598. /** Square root */
  139599. Sqrt = 8,
  139600. /** Log */
  139601. Log = 9,
  139602. /** Tangent */
  139603. Tan = 10,
  139604. /** Arc tangent */
  139605. ArcTan = 11,
  139606. /** Arc cosinus */
  139607. ArcCos = 12,
  139608. /** Arc sinus */
  139609. ArcSin = 13,
  139610. /** Fraction */
  139611. Fract = 14,
  139612. /** Sign */
  139613. Sign = 15,
  139614. /** To radians (from degrees) */
  139615. Radians = 16,
  139616. /** To degrees (from radians) */
  139617. Degrees = 17
  139618. }
  139619. /**
  139620. * Block used to apply trigonometry operation to floats
  139621. */
  139622. export class TrigonometryBlock extends NodeMaterialBlock {
  139623. /**
  139624. * Gets or sets the operation applied by the block
  139625. */
  139626. operation: TrigonometryBlockOperations;
  139627. /**
  139628. * Creates a new TrigonometryBlock
  139629. * @param name defines the block name
  139630. */
  139631. constructor(name: string);
  139632. /**
  139633. * Gets the current class name
  139634. * @returns the class name
  139635. */
  139636. getClassName(): string;
  139637. /**
  139638. * Gets the input component
  139639. */
  139640. get input(): NodeMaterialConnectionPoint;
  139641. /**
  139642. * Gets the output component
  139643. */
  139644. get output(): NodeMaterialConnectionPoint;
  139645. protected _buildBlock(state: NodeMaterialBuildState): this;
  139646. serialize(): any;
  139647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139648. protected _dumpPropertiesCode(): string;
  139649. }
  139650. }
  139651. declare module BABYLON {
  139652. /**
  139653. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139654. */
  139655. export class ColorMergerBlock extends NodeMaterialBlock {
  139656. /**
  139657. * Create a new ColorMergerBlock
  139658. * @param name defines the block name
  139659. */
  139660. constructor(name: string);
  139661. /**
  139662. * Gets the current class name
  139663. * @returns the class name
  139664. */
  139665. getClassName(): string;
  139666. /**
  139667. * Gets the rgb component (input)
  139668. */
  139669. get rgbIn(): NodeMaterialConnectionPoint;
  139670. /**
  139671. * Gets the r component (input)
  139672. */
  139673. get r(): NodeMaterialConnectionPoint;
  139674. /**
  139675. * Gets the g component (input)
  139676. */
  139677. get g(): NodeMaterialConnectionPoint;
  139678. /**
  139679. * Gets the b component (input)
  139680. */
  139681. get b(): NodeMaterialConnectionPoint;
  139682. /**
  139683. * Gets the a component (input)
  139684. */
  139685. get a(): NodeMaterialConnectionPoint;
  139686. /**
  139687. * Gets the rgba component (output)
  139688. */
  139689. get rgba(): NodeMaterialConnectionPoint;
  139690. /**
  139691. * Gets the rgb component (output)
  139692. */
  139693. get rgbOut(): NodeMaterialConnectionPoint;
  139694. /**
  139695. * Gets the rgb component (output)
  139696. * @deprecated Please use rgbOut instead.
  139697. */
  139698. get rgb(): NodeMaterialConnectionPoint;
  139699. protected _buildBlock(state: NodeMaterialBuildState): this;
  139700. }
  139701. }
  139702. declare module BABYLON {
  139703. /**
  139704. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139705. */
  139706. export class VectorSplitterBlock extends NodeMaterialBlock {
  139707. /**
  139708. * Create a new VectorSplitterBlock
  139709. * @param name defines the block name
  139710. */
  139711. constructor(name: string);
  139712. /**
  139713. * Gets the current class name
  139714. * @returns the class name
  139715. */
  139716. getClassName(): string;
  139717. /**
  139718. * Gets the xyzw component (input)
  139719. */
  139720. get xyzw(): NodeMaterialConnectionPoint;
  139721. /**
  139722. * Gets the xyz component (input)
  139723. */
  139724. get xyzIn(): NodeMaterialConnectionPoint;
  139725. /**
  139726. * Gets the xy component (input)
  139727. */
  139728. get xyIn(): NodeMaterialConnectionPoint;
  139729. /**
  139730. * Gets the xyz component (output)
  139731. */
  139732. get xyzOut(): NodeMaterialConnectionPoint;
  139733. /**
  139734. * Gets the xy component (output)
  139735. */
  139736. get xyOut(): NodeMaterialConnectionPoint;
  139737. /**
  139738. * Gets the x component (output)
  139739. */
  139740. get x(): NodeMaterialConnectionPoint;
  139741. /**
  139742. * Gets the y component (output)
  139743. */
  139744. get y(): NodeMaterialConnectionPoint;
  139745. /**
  139746. * Gets the z component (output)
  139747. */
  139748. get z(): NodeMaterialConnectionPoint;
  139749. /**
  139750. * Gets the w component (output)
  139751. */
  139752. get w(): NodeMaterialConnectionPoint;
  139753. protected _inputRename(name: string): string;
  139754. protected _outputRename(name: string): string;
  139755. protected _buildBlock(state: NodeMaterialBuildState): this;
  139756. }
  139757. }
  139758. declare module BABYLON {
  139759. /**
  139760. * Block used to lerp between 2 values
  139761. */
  139762. export class LerpBlock extends NodeMaterialBlock {
  139763. /**
  139764. * Creates a new LerpBlock
  139765. * @param name defines the block name
  139766. */
  139767. constructor(name: string);
  139768. /**
  139769. * Gets the current class name
  139770. * @returns the class name
  139771. */
  139772. getClassName(): string;
  139773. /**
  139774. * Gets the left operand input component
  139775. */
  139776. get left(): NodeMaterialConnectionPoint;
  139777. /**
  139778. * Gets the right operand input component
  139779. */
  139780. get right(): NodeMaterialConnectionPoint;
  139781. /**
  139782. * Gets the gradient operand input component
  139783. */
  139784. get gradient(): NodeMaterialConnectionPoint;
  139785. /**
  139786. * Gets the output component
  139787. */
  139788. get output(): NodeMaterialConnectionPoint;
  139789. protected _buildBlock(state: NodeMaterialBuildState): this;
  139790. }
  139791. }
  139792. declare module BABYLON {
  139793. /**
  139794. * Block used to divide 2 vectors
  139795. */
  139796. export class DivideBlock extends NodeMaterialBlock {
  139797. /**
  139798. * Creates a new DivideBlock
  139799. * @param name defines the block name
  139800. */
  139801. constructor(name: string);
  139802. /**
  139803. * Gets the current class name
  139804. * @returns the class name
  139805. */
  139806. getClassName(): string;
  139807. /**
  139808. * Gets the left operand input component
  139809. */
  139810. get left(): NodeMaterialConnectionPoint;
  139811. /**
  139812. * Gets the right operand input component
  139813. */
  139814. get right(): NodeMaterialConnectionPoint;
  139815. /**
  139816. * Gets the output component
  139817. */
  139818. get output(): NodeMaterialConnectionPoint;
  139819. protected _buildBlock(state: NodeMaterialBuildState): this;
  139820. }
  139821. }
  139822. declare module BABYLON {
  139823. /**
  139824. * Block used to subtract 2 vectors
  139825. */
  139826. export class SubtractBlock extends NodeMaterialBlock {
  139827. /**
  139828. * Creates a new SubtractBlock
  139829. * @param name defines the block name
  139830. */
  139831. constructor(name: string);
  139832. /**
  139833. * Gets the current class name
  139834. * @returns the class name
  139835. */
  139836. getClassName(): string;
  139837. /**
  139838. * Gets the left operand input component
  139839. */
  139840. get left(): NodeMaterialConnectionPoint;
  139841. /**
  139842. * Gets the right operand input component
  139843. */
  139844. get right(): NodeMaterialConnectionPoint;
  139845. /**
  139846. * Gets the output component
  139847. */
  139848. get output(): NodeMaterialConnectionPoint;
  139849. protected _buildBlock(state: NodeMaterialBuildState): this;
  139850. }
  139851. }
  139852. declare module BABYLON {
  139853. /**
  139854. * Block used to step a value
  139855. */
  139856. export class StepBlock extends NodeMaterialBlock {
  139857. /**
  139858. * Creates a new StepBlock
  139859. * @param name defines the block name
  139860. */
  139861. constructor(name: string);
  139862. /**
  139863. * Gets the current class name
  139864. * @returns the class name
  139865. */
  139866. getClassName(): string;
  139867. /**
  139868. * Gets the value operand input component
  139869. */
  139870. get value(): NodeMaterialConnectionPoint;
  139871. /**
  139872. * Gets the edge operand input component
  139873. */
  139874. get edge(): NodeMaterialConnectionPoint;
  139875. /**
  139876. * Gets the output component
  139877. */
  139878. get output(): NodeMaterialConnectionPoint;
  139879. protected _buildBlock(state: NodeMaterialBuildState): this;
  139880. }
  139881. }
  139882. declare module BABYLON {
  139883. /**
  139884. * Block used to get the opposite (1 - x) of a value
  139885. */
  139886. export class OneMinusBlock extends NodeMaterialBlock {
  139887. /**
  139888. * Creates a new OneMinusBlock
  139889. * @param name defines the block name
  139890. */
  139891. constructor(name: string);
  139892. /**
  139893. * Gets the current class name
  139894. * @returns the class name
  139895. */
  139896. getClassName(): string;
  139897. /**
  139898. * Gets the input component
  139899. */
  139900. get input(): NodeMaterialConnectionPoint;
  139901. /**
  139902. * Gets the output component
  139903. */
  139904. get output(): NodeMaterialConnectionPoint;
  139905. protected _buildBlock(state: NodeMaterialBuildState): this;
  139906. }
  139907. }
  139908. declare module BABYLON {
  139909. /**
  139910. * Block used to get the view direction
  139911. */
  139912. export class ViewDirectionBlock extends NodeMaterialBlock {
  139913. /**
  139914. * Creates a new ViewDirectionBlock
  139915. * @param name defines the block name
  139916. */
  139917. constructor(name: string);
  139918. /**
  139919. * Gets the current class name
  139920. * @returns the class name
  139921. */
  139922. getClassName(): string;
  139923. /**
  139924. * Gets the world position component
  139925. */
  139926. get worldPosition(): NodeMaterialConnectionPoint;
  139927. /**
  139928. * Gets the camera position component
  139929. */
  139930. get cameraPosition(): NodeMaterialConnectionPoint;
  139931. /**
  139932. * Gets the output component
  139933. */
  139934. get output(): NodeMaterialConnectionPoint;
  139935. autoConfigure(material: NodeMaterial): void;
  139936. protected _buildBlock(state: NodeMaterialBuildState): this;
  139937. }
  139938. }
  139939. declare module BABYLON {
  139940. /**
  139941. * Block used to compute fresnel value
  139942. */
  139943. export class FresnelBlock extends NodeMaterialBlock {
  139944. /**
  139945. * Create a new FresnelBlock
  139946. * @param name defines the block name
  139947. */
  139948. constructor(name: string);
  139949. /**
  139950. * Gets the current class name
  139951. * @returns the class name
  139952. */
  139953. getClassName(): string;
  139954. /**
  139955. * Gets the world normal input component
  139956. */
  139957. get worldNormal(): NodeMaterialConnectionPoint;
  139958. /**
  139959. * Gets the view direction input component
  139960. */
  139961. get viewDirection(): NodeMaterialConnectionPoint;
  139962. /**
  139963. * Gets the bias input component
  139964. */
  139965. get bias(): NodeMaterialConnectionPoint;
  139966. /**
  139967. * Gets the camera (or eye) position component
  139968. */
  139969. get power(): NodeMaterialConnectionPoint;
  139970. /**
  139971. * Gets the fresnel output component
  139972. */
  139973. get fresnel(): NodeMaterialConnectionPoint;
  139974. autoConfigure(material: NodeMaterial): void;
  139975. protected _buildBlock(state: NodeMaterialBuildState): this;
  139976. }
  139977. }
  139978. declare module BABYLON {
  139979. /**
  139980. * Block used to get the max of 2 values
  139981. */
  139982. export class MaxBlock extends NodeMaterialBlock {
  139983. /**
  139984. * Creates a new MaxBlock
  139985. * @param name defines the block name
  139986. */
  139987. constructor(name: string);
  139988. /**
  139989. * Gets the current class name
  139990. * @returns the class name
  139991. */
  139992. getClassName(): string;
  139993. /**
  139994. * Gets the left operand input component
  139995. */
  139996. get left(): NodeMaterialConnectionPoint;
  139997. /**
  139998. * Gets the right operand input component
  139999. */
  140000. get right(): NodeMaterialConnectionPoint;
  140001. /**
  140002. * Gets the output component
  140003. */
  140004. get output(): NodeMaterialConnectionPoint;
  140005. protected _buildBlock(state: NodeMaterialBuildState): this;
  140006. }
  140007. }
  140008. declare module BABYLON {
  140009. /**
  140010. * Block used to get the min of 2 values
  140011. */
  140012. export class MinBlock extends NodeMaterialBlock {
  140013. /**
  140014. * Creates a new MinBlock
  140015. * @param name defines the block name
  140016. */
  140017. constructor(name: string);
  140018. /**
  140019. * Gets the current class name
  140020. * @returns the class name
  140021. */
  140022. getClassName(): string;
  140023. /**
  140024. * Gets the left operand input component
  140025. */
  140026. get left(): NodeMaterialConnectionPoint;
  140027. /**
  140028. * Gets the right operand input component
  140029. */
  140030. get right(): NodeMaterialConnectionPoint;
  140031. /**
  140032. * Gets the output component
  140033. */
  140034. get output(): NodeMaterialConnectionPoint;
  140035. protected _buildBlock(state: NodeMaterialBuildState): this;
  140036. }
  140037. }
  140038. declare module BABYLON {
  140039. /**
  140040. * Block used to get the distance between 2 values
  140041. */
  140042. export class DistanceBlock extends NodeMaterialBlock {
  140043. /**
  140044. * Creates a new DistanceBlock
  140045. * @param name defines the block name
  140046. */
  140047. constructor(name: string);
  140048. /**
  140049. * Gets the current class name
  140050. * @returns the class name
  140051. */
  140052. getClassName(): string;
  140053. /**
  140054. * Gets the left operand input component
  140055. */
  140056. get left(): NodeMaterialConnectionPoint;
  140057. /**
  140058. * Gets the right operand input component
  140059. */
  140060. get right(): NodeMaterialConnectionPoint;
  140061. /**
  140062. * Gets the output component
  140063. */
  140064. get output(): NodeMaterialConnectionPoint;
  140065. protected _buildBlock(state: NodeMaterialBuildState): this;
  140066. }
  140067. }
  140068. declare module BABYLON {
  140069. /**
  140070. * Block used to get the length of a vector
  140071. */
  140072. export class LengthBlock extends NodeMaterialBlock {
  140073. /**
  140074. * Creates a new LengthBlock
  140075. * @param name defines the block name
  140076. */
  140077. constructor(name: string);
  140078. /**
  140079. * Gets the current class name
  140080. * @returns the class name
  140081. */
  140082. getClassName(): string;
  140083. /**
  140084. * Gets the value input component
  140085. */
  140086. get value(): NodeMaterialConnectionPoint;
  140087. /**
  140088. * Gets the output component
  140089. */
  140090. get output(): NodeMaterialConnectionPoint;
  140091. protected _buildBlock(state: NodeMaterialBuildState): this;
  140092. }
  140093. }
  140094. declare module BABYLON {
  140095. /**
  140096. * Block used to get negative version of a value (i.e. x * -1)
  140097. */
  140098. export class NegateBlock extends NodeMaterialBlock {
  140099. /**
  140100. * Creates a new NegateBlock
  140101. * @param name defines the block name
  140102. */
  140103. constructor(name: string);
  140104. /**
  140105. * Gets the current class name
  140106. * @returns the class name
  140107. */
  140108. getClassName(): string;
  140109. /**
  140110. * Gets the value input component
  140111. */
  140112. get value(): NodeMaterialConnectionPoint;
  140113. /**
  140114. * Gets the output component
  140115. */
  140116. get output(): NodeMaterialConnectionPoint;
  140117. protected _buildBlock(state: NodeMaterialBuildState): this;
  140118. }
  140119. }
  140120. declare module BABYLON {
  140121. /**
  140122. * Block used to get the value of the first parameter raised to the power of the second
  140123. */
  140124. export class PowBlock extends NodeMaterialBlock {
  140125. /**
  140126. * Creates a new PowBlock
  140127. * @param name defines the block name
  140128. */
  140129. constructor(name: string);
  140130. /**
  140131. * Gets the current class name
  140132. * @returns the class name
  140133. */
  140134. getClassName(): string;
  140135. /**
  140136. * Gets the value operand input component
  140137. */
  140138. get value(): NodeMaterialConnectionPoint;
  140139. /**
  140140. * Gets the power operand input component
  140141. */
  140142. get power(): NodeMaterialConnectionPoint;
  140143. /**
  140144. * Gets the output component
  140145. */
  140146. get output(): NodeMaterialConnectionPoint;
  140147. protected _buildBlock(state: NodeMaterialBuildState): this;
  140148. }
  140149. }
  140150. declare module BABYLON {
  140151. /**
  140152. * Block used to get a random number
  140153. */
  140154. export class RandomNumberBlock extends NodeMaterialBlock {
  140155. /**
  140156. * Creates a new RandomNumberBlock
  140157. * @param name defines the block name
  140158. */
  140159. constructor(name: string);
  140160. /**
  140161. * Gets the current class name
  140162. * @returns the class name
  140163. */
  140164. getClassName(): string;
  140165. /**
  140166. * Gets the seed input component
  140167. */
  140168. get seed(): NodeMaterialConnectionPoint;
  140169. /**
  140170. * Gets the output component
  140171. */
  140172. get output(): NodeMaterialConnectionPoint;
  140173. protected _buildBlock(state: NodeMaterialBuildState): this;
  140174. }
  140175. }
  140176. declare module BABYLON {
  140177. /**
  140178. * Block used to compute arc tangent of 2 values
  140179. */
  140180. export class ArcTan2Block extends NodeMaterialBlock {
  140181. /**
  140182. * Creates a new ArcTan2Block
  140183. * @param name defines the block name
  140184. */
  140185. constructor(name: string);
  140186. /**
  140187. * Gets the current class name
  140188. * @returns the class name
  140189. */
  140190. getClassName(): string;
  140191. /**
  140192. * Gets the x operand input component
  140193. */
  140194. get x(): NodeMaterialConnectionPoint;
  140195. /**
  140196. * Gets the y operand input component
  140197. */
  140198. get y(): NodeMaterialConnectionPoint;
  140199. /**
  140200. * Gets the output component
  140201. */
  140202. get output(): NodeMaterialConnectionPoint;
  140203. protected _buildBlock(state: NodeMaterialBuildState): this;
  140204. }
  140205. }
  140206. declare module BABYLON {
  140207. /**
  140208. * Block used to smooth step a value
  140209. */
  140210. export class SmoothStepBlock extends NodeMaterialBlock {
  140211. /**
  140212. * Creates a new SmoothStepBlock
  140213. * @param name defines the block name
  140214. */
  140215. constructor(name: string);
  140216. /**
  140217. * Gets the current class name
  140218. * @returns the class name
  140219. */
  140220. getClassName(): string;
  140221. /**
  140222. * Gets the value operand input component
  140223. */
  140224. get value(): NodeMaterialConnectionPoint;
  140225. /**
  140226. * Gets the first edge operand input component
  140227. */
  140228. get edge0(): NodeMaterialConnectionPoint;
  140229. /**
  140230. * Gets the second edge operand input component
  140231. */
  140232. get edge1(): NodeMaterialConnectionPoint;
  140233. /**
  140234. * Gets the output component
  140235. */
  140236. get output(): NodeMaterialConnectionPoint;
  140237. protected _buildBlock(state: NodeMaterialBuildState): this;
  140238. }
  140239. }
  140240. declare module BABYLON {
  140241. /**
  140242. * Block used to get the reciprocal (1 / x) of a value
  140243. */
  140244. export class ReciprocalBlock extends NodeMaterialBlock {
  140245. /**
  140246. * Creates a new ReciprocalBlock
  140247. * @param name defines the block name
  140248. */
  140249. constructor(name: string);
  140250. /**
  140251. * Gets the current class name
  140252. * @returns the class name
  140253. */
  140254. getClassName(): string;
  140255. /**
  140256. * Gets the input component
  140257. */
  140258. get input(): NodeMaterialConnectionPoint;
  140259. /**
  140260. * Gets the output component
  140261. */
  140262. get output(): NodeMaterialConnectionPoint;
  140263. protected _buildBlock(state: NodeMaterialBuildState): this;
  140264. }
  140265. }
  140266. declare module BABYLON {
  140267. /**
  140268. * Block used to replace a color by another one
  140269. */
  140270. export class ReplaceColorBlock extends NodeMaterialBlock {
  140271. /**
  140272. * Creates a new ReplaceColorBlock
  140273. * @param name defines the block name
  140274. */
  140275. constructor(name: string);
  140276. /**
  140277. * Gets the current class name
  140278. * @returns the class name
  140279. */
  140280. getClassName(): string;
  140281. /**
  140282. * Gets the value input component
  140283. */
  140284. get value(): NodeMaterialConnectionPoint;
  140285. /**
  140286. * Gets the reference input component
  140287. */
  140288. get reference(): NodeMaterialConnectionPoint;
  140289. /**
  140290. * Gets the distance input component
  140291. */
  140292. get distance(): NodeMaterialConnectionPoint;
  140293. /**
  140294. * Gets the replacement input component
  140295. */
  140296. get replacement(): NodeMaterialConnectionPoint;
  140297. /**
  140298. * Gets the output component
  140299. */
  140300. get output(): NodeMaterialConnectionPoint;
  140301. protected _buildBlock(state: NodeMaterialBuildState): this;
  140302. }
  140303. }
  140304. declare module BABYLON {
  140305. /**
  140306. * Block used to posterize a value
  140307. * @see https://en.wikipedia.org/wiki/Posterization
  140308. */
  140309. export class PosterizeBlock extends NodeMaterialBlock {
  140310. /**
  140311. * Creates a new PosterizeBlock
  140312. * @param name defines the block name
  140313. */
  140314. constructor(name: string);
  140315. /**
  140316. * Gets the current class name
  140317. * @returns the class name
  140318. */
  140319. getClassName(): string;
  140320. /**
  140321. * Gets the value input component
  140322. */
  140323. get value(): NodeMaterialConnectionPoint;
  140324. /**
  140325. * Gets the steps input component
  140326. */
  140327. get steps(): NodeMaterialConnectionPoint;
  140328. /**
  140329. * Gets the output component
  140330. */
  140331. get output(): NodeMaterialConnectionPoint;
  140332. protected _buildBlock(state: NodeMaterialBuildState): this;
  140333. }
  140334. }
  140335. declare module BABYLON {
  140336. /**
  140337. * Operations supported by the Wave block
  140338. */
  140339. export enum WaveBlockKind {
  140340. /** SawTooth */
  140341. SawTooth = 0,
  140342. /** Square */
  140343. Square = 1,
  140344. /** Triangle */
  140345. Triangle = 2
  140346. }
  140347. /**
  140348. * Block used to apply wave operation to floats
  140349. */
  140350. export class WaveBlock extends NodeMaterialBlock {
  140351. /**
  140352. * Gets or sets the kibnd of wave to be applied by the block
  140353. */
  140354. kind: WaveBlockKind;
  140355. /**
  140356. * Creates a new WaveBlock
  140357. * @param name defines the block name
  140358. */
  140359. constructor(name: string);
  140360. /**
  140361. * Gets the current class name
  140362. * @returns the class name
  140363. */
  140364. getClassName(): string;
  140365. /**
  140366. * Gets the input component
  140367. */
  140368. get input(): NodeMaterialConnectionPoint;
  140369. /**
  140370. * Gets the output component
  140371. */
  140372. get output(): NodeMaterialConnectionPoint;
  140373. protected _buildBlock(state: NodeMaterialBuildState): this;
  140374. serialize(): any;
  140375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140376. }
  140377. }
  140378. declare module BABYLON {
  140379. /**
  140380. * Class used to store a color step for the GradientBlock
  140381. */
  140382. export class GradientBlockColorStep {
  140383. /**
  140384. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140385. */
  140386. step: number;
  140387. /**
  140388. * Gets or sets the color associated with this step
  140389. */
  140390. color: Color3;
  140391. /**
  140392. * Creates a new GradientBlockColorStep
  140393. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140394. * @param color defines the color associated with this step
  140395. */
  140396. constructor(
  140397. /**
  140398. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140399. */
  140400. step: number,
  140401. /**
  140402. * Gets or sets the color associated with this step
  140403. */
  140404. color: Color3);
  140405. }
  140406. /**
  140407. * Block used to return a color from a gradient based on an input value between 0 and 1
  140408. */
  140409. export class GradientBlock extends NodeMaterialBlock {
  140410. /**
  140411. * Gets or sets the list of color steps
  140412. */
  140413. colorSteps: GradientBlockColorStep[];
  140414. /**
  140415. * Creates a new GradientBlock
  140416. * @param name defines the block name
  140417. */
  140418. constructor(name: string);
  140419. /**
  140420. * Gets the current class name
  140421. * @returns the class name
  140422. */
  140423. getClassName(): string;
  140424. /**
  140425. * Gets the gradient input component
  140426. */
  140427. get gradient(): NodeMaterialConnectionPoint;
  140428. /**
  140429. * Gets the output component
  140430. */
  140431. get output(): NodeMaterialConnectionPoint;
  140432. private _writeColorConstant;
  140433. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140434. serialize(): any;
  140435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140436. protected _dumpPropertiesCode(): string;
  140437. }
  140438. }
  140439. declare module BABYLON {
  140440. /**
  140441. * Block used to normalize lerp between 2 values
  140442. */
  140443. export class NLerpBlock extends NodeMaterialBlock {
  140444. /**
  140445. * Creates a new NLerpBlock
  140446. * @param name defines the block name
  140447. */
  140448. constructor(name: string);
  140449. /**
  140450. * Gets the current class name
  140451. * @returns the class name
  140452. */
  140453. getClassName(): string;
  140454. /**
  140455. * Gets the left operand input component
  140456. */
  140457. get left(): NodeMaterialConnectionPoint;
  140458. /**
  140459. * Gets the right operand input component
  140460. */
  140461. get right(): NodeMaterialConnectionPoint;
  140462. /**
  140463. * Gets the gradient operand input component
  140464. */
  140465. get gradient(): NodeMaterialConnectionPoint;
  140466. /**
  140467. * Gets the output component
  140468. */
  140469. get output(): NodeMaterialConnectionPoint;
  140470. protected _buildBlock(state: NodeMaterialBuildState): this;
  140471. }
  140472. }
  140473. declare module BABYLON {
  140474. /**
  140475. * block used to Generate a Worley Noise 3D Noise Pattern
  140476. */
  140477. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140478. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140479. manhattanDistance: boolean;
  140480. /**
  140481. * Creates a new WorleyNoise3DBlock
  140482. * @param name defines the block name
  140483. */
  140484. constructor(name: string);
  140485. /**
  140486. * Gets the current class name
  140487. * @returns the class name
  140488. */
  140489. getClassName(): string;
  140490. /**
  140491. * Gets the seed input component
  140492. */
  140493. get seed(): NodeMaterialConnectionPoint;
  140494. /**
  140495. * Gets the jitter input component
  140496. */
  140497. get jitter(): NodeMaterialConnectionPoint;
  140498. /**
  140499. * Gets the output component
  140500. */
  140501. get output(): NodeMaterialConnectionPoint;
  140502. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140503. /**
  140504. * Exposes the properties to the UI?
  140505. */
  140506. protected _dumpPropertiesCode(): string;
  140507. /**
  140508. * Exposes the properties to the Seralize?
  140509. */
  140510. serialize(): any;
  140511. /**
  140512. * Exposes the properties to the deseralize?
  140513. */
  140514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140515. }
  140516. }
  140517. declare module BABYLON {
  140518. /**
  140519. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140520. */
  140521. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140522. /**
  140523. * Creates a new SimplexPerlin3DBlock
  140524. * @param name defines the block name
  140525. */
  140526. constructor(name: string);
  140527. /**
  140528. * Gets the current class name
  140529. * @returns the class name
  140530. */
  140531. getClassName(): string;
  140532. /**
  140533. * Gets the seed operand input component
  140534. */
  140535. get seed(): NodeMaterialConnectionPoint;
  140536. /**
  140537. * Gets the output component
  140538. */
  140539. get output(): NodeMaterialConnectionPoint;
  140540. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140541. }
  140542. }
  140543. declare module BABYLON {
  140544. /**
  140545. * Block used to blend normals
  140546. */
  140547. export class NormalBlendBlock extends NodeMaterialBlock {
  140548. /**
  140549. * Creates a new NormalBlendBlock
  140550. * @param name defines the block name
  140551. */
  140552. constructor(name: string);
  140553. /**
  140554. * Gets the current class name
  140555. * @returns the class name
  140556. */
  140557. getClassName(): string;
  140558. /**
  140559. * Gets the first input component
  140560. */
  140561. get normalMap0(): NodeMaterialConnectionPoint;
  140562. /**
  140563. * Gets the second input component
  140564. */
  140565. get normalMap1(): NodeMaterialConnectionPoint;
  140566. /**
  140567. * Gets the output component
  140568. */
  140569. get output(): NodeMaterialConnectionPoint;
  140570. protected _buildBlock(state: NodeMaterialBuildState): this;
  140571. }
  140572. }
  140573. declare module BABYLON {
  140574. /**
  140575. * Block used to rotate a 2d vector by a given angle
  140576. */
  140577. export class Rotate2dBlock extends NodeMaterialBlock {
  140578. /**
  140579. * Creates a new Rotate2dBlock
  140580. * @param name defines the block name
  140581. */
  140582. constructor(name: string);
  140583. /**
  140584. * Gets the current class name
  140585. * @returns the class name
  140586. */
  140587. getClassName(): string;
  140588. /**
  140589. * Gets the input vector
  140590. */
  140591. get input(): NodeMaterialConnectionPoint;
  140592. /**
  140593. * Gets the input angle
  140594. */
  140595. get angle(): NodeMaterialConnectionPoint;
  140596. /**
  140597. * Gets the output component
  140598. */
  140599. get output(): NodeMaterialConnectionPoint;
  140600. autoConfigure(material: NodeMaterial): void;
  140601. protected _buildBlock(state: NodeMaterialBuildState): this;
  140602. }
  140603. }
  140604. declare module BABYLON {
  140605. /**
  140606. * Block used to get the reflected vector from a direction and a normal
  140607. */
  140608. export class ReflectBlock extends NodeMaterialBlock {
  140609. /**
  140610. * Creates a new ReflectBlock
  140611. * @param name defines the block name
  140612. */
  140613. constructor(name: string);
  140614. /**
  140615. * Gets the current class name
  140616. * @returns the class name
  140617. */
  140618. getClassName(): string;
  140619. /**
  140620. * Gets the incident component
  140621. */
  140622. get incident(): NodeMaterialConnectionPoint;
  140623. /**
  140624. * Gets the normal component
  140625. */
  140626. get normal(): NodeMaterialConnectionPoint;
  140627. /**
  140628. * Gets the output component
  140629. */
  140630. get output(): NodeMaterialConnectionPoint;
  140631. protected _buildBlock(state: NodeMaterialBuildState): this;
  140632. }
  140633. }
  140634. declare module BABYLON {
  140635. /**
  140636. * Block used to get the refracted vector from a direction and a normal
  140637. */
  140638. export class RefractBlock extends NodeMaterialBlock {
  140639. /**
  140640. * Creates a new RefractBlock
  140641. * @param name defines the block name
  140642. */
  140643. constructor(name: string);
  140644. /**
  140645. * Gets the current class name
  140646. * @returns the class name
  140647. */
  140648. getClassName(): string;
  140649. /**
  140650. * Gets the incident component
  140651. */
  140652. get incident(): NodeMaterialConnectionPoint;
  140653. /**
  140654. * Gets the normal component
  140655. */
  140656. get normal(): NodeMaterialConnectionPoint;
  140657. /**
  140658. * Gets the index of refraction component
  140659. */
  140660. get ior(): NodeMaterialConnectionPoint;
  140661. /**
  140662. * Gets the output component
  140663. */
  140664. get output(): NodeMaterialConnectionPoint;
  140665. protected _buildBlock(state: NodeMaterialBuildState): this;
  140666. }
  140667. }
  140668. declare module BABYLON {
  140669. /**
  140670. * Block used to desaturate a color
  140671. */
  140672. export class DesaturateBlock extends NodeMaterialBlock {
  140673. /**
  140674. * Creates a new DesaturateBlock
  140675. * @param name defines the block name
  140676. */
  140677. constructor(name: string);
  140678. /**
  140679. * Gets the current class name
  140680. * @returns the class name
  140681. */
  140682. getClassName(): string;
  140683. /**
  140684. * Gets the color operand input component
  140685. */
  140686. get color(): NodeMaterialConnectionPoint;
  140687. /**
  140688. * Gets the level operand input component
  140689. */
  140690. get level(): NodeMaterialConnectionPoint;
  140691. /**
  140692. * Gets the output component
  140693. */
  140694. get output(): NodeMaterialConnectionPoint;
  140695. protected _buildBlock(state: NodeMaterialBuildState): this;
  140696. }
  140697. }
  140698. declare module BABYLON {
  140699. /**
  140700. * Block used to implement the ambient occlusion module of the PBR material
  140701. */
  140702. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140703. /**
  140704. * Create a new AmbientOcclusionBlock
  140705. * @param name defines the block name
  140706. */
  140707. constructor(name: string);
  140708. /**
  140709. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140710. */
  140711. useAmbientInGrayScale: boolean;
  140712. /**
  140713. * Initialize the block and prepare the context for build
  140714. * @param state defines the state that will be used for the build
  140715. */
  140716. initialize(state: NodeMaterialBuildState): void;
  140717. /**
  140718. * Gets the current class name
  140719. * @returns the class name
  140720. */
  140721. getClassName(): string;
  140722. /**
  140723. * Gets the texture input component
  140724. */
  140725. get texture(): NodeMaterialConnectionPoint;
  140726. /**
  140727. * Gets the texture intensity component
  140728. */
  140729. get intensity(): NodeMaterialConnectionPoint;
  140730. /**
  140731. * Gets the direct light intensity input component
  140732. */
  140733. get directLightIntensity(): NodeMaterialConnectionPoint;
  140734. /**
  140735. * Gets the ambient occlusion object output component
  140736. */
  140737. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140738. /**
  140739. * Gets the main code of the block (fragment side)
  140740. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  140741. * @returns the shader code
  140742. */
  140743. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  140744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140745. protected _buildBlock(state: NodeMaterialBuildState): this;
  140746. protected _dumpPropertiesCode(): string;
  140747. serialize(): any;
  140748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140749. }
  140750. }
  140751. declare module BABYLON {
  140752. /**
  140753. * Block used to implement the reflection module of the PBR material
  140754. */
  140755. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  140756. /** @hidden */
  140757. _defineLODReflectionAlpha: string;
  140758. /** @hidden */
  140759. _defineLinearSpecularReflection: string;
  140760. private _vEnvironmentIrradianceName;
  140761. /** @hidden */
  140762. _vReflectionMicrosurfaceInfosName: string;
  140763. /** @hidden */
  140764. _vReflectionInfosName: string;
  140765. /** @hidden */
  140766. _vReflectionFilteringInfoName: string;
  140767. private _scene;
  140768. /**
  140769. * The three properties below are set by the main PBR block prior to calling methods of this class.
  140770. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140771. * It's less burden on the user side in the editor part.
  140772. */
  140773. /** @hidden */
  140774. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140775. /** @hidden */
  140776. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140777. /** @hidden */
  140778. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  140779. /**
  140780. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  140781. * diffuse part of the IBL.
  140782. */
  140783. useSphericalHarmonics: boolean;
  140784. /**
  140785. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  140786. */
  140787. forceIrradianceInFragment: boolean;
  140788. /**
  140789. * Create a new ReflectionBlock
  140790. * @param name defines the block name
  140791. */
  140792. constructor(name: string);
  140793. /**
  140794. * Gets the current class name
  140795. * @returns the class name
  140796. */
  140797. getClassName(): string;
  140798. /**
  140799. * Gets the position input component
  140800. */
  140801. get position(): NodeMaterialConnectionPoint;
  140802. /**
  140803. * Gets the world position input component
  140804. */
  140805. get worldPosition(): NodeMaterialConnectionPoint;
  140806. /**
  140807. * Gets the world normal input component
  140808. */
  140809. get worldNormal(): NodeMaterialConnectionPoint;
  140810. /**
  140811. * Gets the world input component
  140812. */
  140813. get world(): NodeMaterialConnectionPoint;
  140814. /**
  140815. * Gets the camera (or eye) position component
  140816. */
  140817. get cameraPosition(): NodeMaterialConnectionPoint;
  140818. /**
  140819. * Gets the view input component
  140820. */
  140821. get view(): NodeMaterialConnectionPoint;
  140822. /**
  140823. * Gets the color input component
  140824. */
  140825. get color(): NodeMaterialConnectionPoint;
  140826. /**
  140827. * Gets the reflection object output component
  140828. */
  140829. get reflection(): NodeMaterialConnectionPoint;
  140830. /**
  140831. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  140832. */
  140833. get hasTexture(): boolean;
  140834. /**
  140835. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140836. */
  140837. get reflectionColor(): string;
  140838. protected _getTexture(): Nullable<BaseTexture>;
  140839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140841. /**
  140842. * Gets the code to inject in the vertex shader
  140843. * @param state current state of the node material building
  140844. * @returns the shader code
  140845. */
  140846. handleVertexSide(state: NodeMaterialBuildState): string;
  140847. /**
  140848. * Gets the main code of the block (fragment side)
  140849. * @param state current state of the node material building
  140850. * @param normalVarName name of the existing variable corresponding to the normal
  140851. * @returns the shader code
  140852. */
  140853. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140854. protected _buildBlock(state: NodeMaterialBuildState): this;
  140855. protected _dumpPropertiesCode(): string;
  140856. serialize(): any;
  140857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140858. }
  140859. }
  140860. declare module BABYLON {
  140861. /**
  140862. * Block used to implement the sheen module of the PBR material
  140863. */
  140864. export class SheenBlock extends NodeMaterialBlock {
  140865. /**
  140866. * Create a new SheenBlock
  140867. * @param name defines the block name
  140868. */
  140869. constructor(name: string);
  140870. /**
  140871. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140872. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140873. * making it easier to setup and tweak the effect
  140874. */
  140875. albedoScaling: boolean;
  140876. /**
  140877. * Defines if the sheen is linked to the sheen color.
  140878. */
  140879. linkSheenWithAlbedo: boolean;
  140880. /**
  140881. * Initialize the block and prepare the context for build
  140882. * @param state defines the state that will be used for the build
  140883. */
  140884. initialize(state: NodeMaterialBuildState): void;
  140885. /**
  140886. * Gets the current class name
  140887. * @returns the class name
  140888. */
  140889. getClassName(): string;
  140890. /**
  140891. * Gets the intensity input component
  140892. */
  140893. get intensity(): NodeMaterialConnectionPoint;
  140894. /**
  140895. * Gets the color input component
  140896. */
  140897. get color(): NodeMaterialConnectionPoint;
  140898. /**
  140899. * Gets the roughness input component
  140900. */
  140901. get roughness(): NodeMaterialConnectionPoint;
  140902. /**
  140903. * Gets the sheen object output component
  140904. */
  140905. get sheen(): NodeMaterialConnectionPoint;
  140906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140907. /**
  140908. * Gets the main code of the block (fragment side)
  140909. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140910. * @returns the shader code
  140911. */
  140912. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140913. protected _buildBlock(state: NodeMaterialBuildState): this;
  140914. protected _dumpPropertiesCode(): string;
  140915. serialize(): any;
  140916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140917. }
  140918. }
  140919. declare module BABYLON {
  140920. /**
  140921. * Block used to implement the reflectivity module of the PBR material
  140922. */
  140923. export class ReflectivityBlock extends NodeMaterialBlock {
  140924. private _metallicReflectanceColor;
  140925. private _metallicF0Factor;
  140926. /** @hidden */
  140927. _vMetallicReflectanceFactorsName: string;
  140928. /**
  140929. * The property below is set by the main PBR block prior to calling methods of this class.
  140930. */
  140931. /** @hidden */
  140932. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140933. /**
  140934. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140935. */
  140936. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140937. /**
  140938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140939. */
  140940. useMetallnessFromMetallicTextureBlue: boolean;
  140941. /**
  140942. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140943. */
  140944. useRoughnessFromMetallicTextureAlpha: boolean;
  140945. /**
  140946. * Specifies if the metallic texture contains the roughness information in its green channel.
  140947. */
  140948. useRoughnessFromMetallicTextureGreen: boolean;
  140949. /**
  140950. * Create a new ReflectivityBlock
  140951. * @param name defines the block name
  140952. */
  140953. constructor(name: string);
  140954. /**
  140955. * Initialize the block and prepare the context for build
  140956. * @param state defines the state that will be used for the build
  140957. */
  140958. initialize(state: NodeMaterialBuildState): void;
  140959. /**
  140960. * Gets the current class name
  140961. * @returns the class name
  140962. */
  140963. getClassName(): string;
  140964. /**
  140965. * Gets the metallic input component
  140966. */
  140967. get metallic(): NodeMaterialConnectionPoint;
  140968. /**
  140969. * Gets the roughness input component
  140970. */
  140971. get roughness(): NodeMaterialConnectionPoint;
  140972. /**
  140973. * Gets the texture input component
  140974. */
  140975. get texture(): NodeMaterialConnectionPoint;
  140976. /**
  140977. * Gets the reflectivity object output component
  140978. */
  140979. get reflectivity(): NodeMaterialConnectionPoint;
  140980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140981. /**
  140982. * Gets the main code of the block (fragment side)
  140983. * @param state current state of the node material building
  140984. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140985. * @returns the shader code
  140986. */
  140987. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140989. protected _buildBlock(state: NodeMaterialBuildState): this;
  140990. protected _dumpPropertiesCode(): string;
  140991. serialize(): any;
  140992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140993. }
  140994. }
  140995. declare module BABYLON {
  140996. /**
  140997. * Block used to implement the anisotropy module of the PBR material
  140998. */
  140999. export class AnisotropyBlock extends NodeMaterialBlock {
  141000. /**
  141001. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141002. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141003. * It's less burden on the user side in the editor part.
  141004. */
  141005. /** @hidden */
  141006. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141007. /** @hidden */
  141008. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141009. /**
  141010. * Create a new AnisotropyBlock
  141011. * @param name defines the block name
  141012. */
  141013. constructor(name: string);
  141014. /**
  141015. * Initialize the block and prepare the context for build
  141016. * @param state defines the state that will be used for the build
  141017. */
  141018. initialize(state: NodeMaterialBuildState): void;
  141019. /**
  141020. * Gets the current class name
  141021. * @returns the class name
  141022. */
  141023. getClassName(): string;
  141024. /**
  141025. * Gets the intensity input component
  141026. */
  141027. get intensity(): NodeMaterialConnectionPoint;
  141028. /**
  141029. * Gets the direction input component
  141030. */
  141031. get direction(): NodeMaterialConnectionPoint;
  141032. /**
  141033. * Gets the texture input component
  141034. */
  141035. get texture(): NodeMaterialConnectionPoint;
  141036. /**
  141037. * Gets the uv input component
  141038. */
  141039. get uv(): NodeMaterialConnectionPoint;
  141040. /**
  141041. * Gets the worldTangent input component
  141042. */
  141043. get worldTangent(): NodeMaterialConnectionPoint;
  141044. /**
  141045. * Gets the anisotropy object output component
  141046. */
  141047. get anisotropy(): NodeMaterialConnectionPoint;
  141048. private _generateTBNSpace;
  141049. /**
  141050. * Gets the main code of the block (fragment side)
  141051. * @param state current state of the node material building
  141052. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141053. * @returns the shader code
  141054. */
  141055. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141057. protected _buildBlock(state: NodeMaterialBuildState): this;
  141058. }
  141059. }
  141060. declare module BABYLON {
  141061. /**
  141062. * Block used to implement the clear coat module of the PBR material
  141063. */
  141064. export class ClearCoatBlock extends NodeMaterialBlock {
  141065. private _scene;
  141066. /**
  141067. * Create a new ClearCoatBlock
  141068. * @param name defines the block name
  141069. */
  141070. constructor(name: string);
  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. /**
  141077. * Gets the current class name
  141078. * @returns the class name
  141079. */
  141080. getClassName(): string;
  141081. /**
  141082. * Gets the intensity input component
  141083. */
  141084. get intensity(): NodeMaterialConnectionPoint;
  141085. /**
  141086. * Gets the roughness input component
  141087. */
  141088. get roughness(): NodeMaterialConnectionPoint;
  141089. /**
  141090. * Gets the ior input component
  141091. */
  141092. get ior(): NodeMaterialConnectionPoint;
  141093. /**
  141094. * Gets the texture input component
  141095. */
  141096. get texture(): NodeMaterialConnectionPoint;
  141097. /**
  141098. * Gets the bump texture input component
  141099. */
  141100. get bumpTexture(): NodeMaterialConnectionPoint;
  141101. /**
  141102. * Gets the uv input component
  141103. */
  141104. get uv(): NodeMaterialConnectionPoint;
  141105. /**
  141106. * Gets the tint color input component
  141107. */
  141108. get tintColor(): NodeMaterialConnectionPoint;
  141109. /**
  141110. * Gets the tint "at distance" input component
  141111. */
  141112. get tintAtDistance(): NodeMaterialConnectionPoint;
  141113. /**
  141114. * Gets the tint thickness input component
  141115. */
  141116. get tintThickness(): NodeMaterialConnectionPoint;
  141117. /**
  141118. * Gets the world tangent input component
  141119. */
  141120. get worldTangent(): NodeMaterialConnectionPoint;
  141121. /**
  141122. * Gets the clear coat object output component
  141123. */
  141124. get clearcoat(): NodeMaterialConnectionPoint;
  141125. autoConfigure(material: NodeMaterial): void;
  141126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141127. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141128. private _generateTBNSpace;
  141129. /**
  141130. * Gets the main code of the block (fragment side)
  141131. * @param state current state of the node material building
  141132. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141133. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141134. * @param worldPosVarName name of the variable holding the world position
  141135. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141136. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141137. * @param worldNormalVarName name of the variable holding the world normal
  141138. * @returns the shader code
  141139. */
  141140. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141141. protected _buildBlock(state: NodeMaterialBuildState): this;
  141142. }
  141143. }
  141144. declare module BABYLON {
  141145. /**
  141146. * Block used to implement the sub surface module of the PBR material
  141147. */
  141148. export class SubSurfaceBlock extends NodeMaterialBlock {
  141149. /**
  141150. * Create a new SubSurfaceBlock
  141151. * @param name defines the block name
  141152. */
  141153. constructor(name: string);
  141154. /**
  141155. * Stores the intensity of the different subsurface effects in the thickness texture.
  141156. * * the green channel is the translucency intensity.
  141157. * * the blue channel is the scattering intensity.
  141158. * * the alpha channel is the refraction intensity.
  141159. */
  141160. useMaskFromThicknessTexture: boolean;
  141161. /**
  141162. * Initialize the block and prepare the context for build
  141163. * @param state defines the state that will be used for the build
  141164. */
  141165. initialize(state: NodeMaterialBuildState): void;
  141166. /**
  141167. * Gets the current class name
  141168. * @returns the class name
  141169. */
  141170. getClassName(): string;
  141171. /**
  141172. * Gets the min thickness input component
  141173. */
  141174. get minThickness(): NodeMaterialConnectionPoint;
  141175. /**
  141176. * Gets the max thickness input component
  141177. */
  141178. get maxThickness(): NodeMaterialConnectionPoint;
  141179. /**
  141180. * Gets the thickness texture component
  141181. */
  141182. get thicknessTexture(): NodeMaterialConnectionPoint;
  141183. /**
  141184. * Gets the tint color input component
  141185. */
  141186. get tintColor(): NodeMaterialConnectionPoint;
  141187. /**
  141188. * Gets the translucency intensity input component
  141189. */
  141190. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141191. /**
  141192. * Gets the translucency diffusion distance input component
  141193. */
  141194. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141195. /**
  141196. * Gets the refraction object parameters
  141197. */
  141198. get refraction(): NodeMaterialConnectionPoint;
  141199. /**
  141200. * Gets the sub surface object output component
  141201. */
  141202. get subsurface(): NodeMaterialConnectionPoint;
  141203. autoConfigure(material: NodeMaterial): void;
  141204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141205. /**
  141206. * Gets the main code of the block (fragment side)
  141207. * @param state current state of the node material building
  141208. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141209. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141210. * @param worldPosVarName name of the variable holding the world position
  141211. * @returns the shader code
  141212. */
  141213. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141214. protected _buildBlock(state: NodeMaterialBuildState): this;
  141215. }
  141216. }
  141217. declare module BABYLON {
  141218. /**
  141219. * Block used to implement the PBR metallic/roughness model
  141220. */
  141221. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141222. /**
  141223. * Gets or sets the light associated with this block
  141224. */
  141225. light: Nullable<Light>;
  141226. private _lightId;
  141227. private _scene;
  141228. private _environmentBRDFTexture;
  141229. private _environmentBrdfSamplerName;
  141230. private _vNormalWName;
  141231. private _invertNormalName;
  141232. /**
  141233. * Create a new ReflectionBlock
  141234. * @param name defines the block name
  141235. */
  141236. constructor(name: string);
  141237. /**
  141238. * Intensity of the direct lights e.g. the four lights available in your scene.
  141239. * This impacts both the direct diffuse and specular highlights.
  141240. */
  141241. directIntensity: number;
  141242. /**
  141243. * Intensity of the environment e.g. how much the environment will light the object
  141244. * either through harmonics for rough material or through the refelction for shiny ones.
  141245. */
  141246. environmentIntensity: number;
  141247. /**
  141248. * This is a special control allowing the reduction of the specular highlights coming from the
  141249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141250. */
  141251. specularIntensity: number;
  141252. /**
  141253. * Defines the falloff type used in this material.
  141254. * It by default is Physical.
  141255. */
  141256. lightFalloff: number;
  141257. /**
  141258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141259. */
  141260. useAlphaFromAlbedoTexture: boolean;
  141261. /**
  141262. * Specifies that alpha test should be used
  141263. */
  141264. useAlphaTest: boolean;
  141265. /**
  141266. * Defines the alpha limits in alpha test mode.
  141267. */
  141268. alphaTestCutoff: number;
  141269. /**
  141270. * Specifies that alpha blending should be used
  141271. */
  141272. useAlphaBlending: boolean;
  141273. /**
  141274. * Defines if the alpha value should be determined via the rgb values.
  141275. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141276. */
  141277. opacityRGB: boolean;
  141278. /**
  141279. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141280. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141281. */
  141282. useRadianceOverAlpha: boolean;
  141283. /**
  141284. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141285. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141286. */
  141287. useSpecularOverAlpha: boolean;
  141288. /**
  141289. * Enables specular anti aliasing in the PBR shader.
  141290. * It will both interacts on the Geometry for analytical and IBL lighting.
  141291. * It also prefilter the roughness map based on the bump values.
  141292. */
  141293. enableSpecularAntiAliasing: boolean;
  141294. /**
  141295. * Enables realtime filtering on the texture.
  141296. */
  141297. realTimeFiltering: boolean;
  141298. /**
  141299. * Quality switch for realtime filtering
  141300. */
  141301. realTimeFilteringQuality: number;
  141302. /**
  141303. * Defines if the material uses energy conservation.
  141304. */
  141305. useEnergyConservation: boolean;
  141306. /**
  141307. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  141308. * too much the area relying on ambient texture to define their ambient occlusion.
  141309. */
  141310. useRadianceOcclusion: boolean;
  141311. /**
  141312. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  141313. * makes the reflect vector face the model (under horizon).
  141314. */
  141315. useHorizonOcclusion: boolean;
  141316. /**
  141317. * If set to true, no lighting calculations will be applied.
  141318. */
  141319. unlit: boolean;
  141320. /**
  141321. * Force normal to face away from face.
  141322. */
  141323. forceNormalForward: boolean;
  141324. /**
  141325. * Defines the material debug mode.
  141326. * It helps seeing only some components of the material while troubleshooting.
  141327. */
  141328. debugMode: number;
  141329. /**
  141330. * Specify from where on screen the debug mode should start.
  141331. * The value goes from -1 (full screen) to 1 (not visible)
  141332. * It helps with side by side comparison against the final render
  141333. * This defaults to 0
  141334. */
  141335. debugLimit: number;
  141336. /**
  141337. * As the default viewing range might not be enough (if the ambient is really small for instance)
  141338. * You can use the factor to better multiply the final value.
  141339. */
  141340. debugFactor: number;
  141341. /**
  141342. * Initialize the block and prepare the context for build
  141343. * @param state defines the state that will be used for the build
  141344. */
  141345. initialize(state: NodeMaterialBuildState): void;
  141346. /**
  141347. * Gets the current class name
  141348. * @returns the class name
  141349. */
  141350. getClassName(): string;
  141351. /**
  141352. * Gets the world position input component
  141353. */
  141354. get worldPosition(): NodeMaterialConnectionPoint;
  141355. /**
  141356. * Gets the world normal input component
  141357. */
  141358. get worldNormal(): NodeMaterialConnectionPoint;
  141359. /**
  141360. * Gets the perturbed normal input component
  141361. */
  141362. get perturbedNormal(): NodeMaterialConnectionPoint;
  141363. /**
  141364. * Gets the camera position input component
  141365. */
  141366. get cameraPosition(): NodeMaterialConnectionPoint;
  141367. /**
  141368. * Gets the base color input component
  141369. */
  141370. get baseColor(): NodeMaterialConnectionPoint;
  141371. /**
  141372. * Gets the opacity texture input component
  141373. */
  141374. get opacityTexture(): NodeMaterialConnectionPoint;
  141375. /**
  141376. * Gets the ambient color input component
  141377. */
  141378. get ambientColor(): NodeMaterialConnectionPoint;
  141379. /**
  141380. * Gets the reflectivity object parameters
  141381. */
  141382. get reflectivity(): NodeMaterialConnectionPoint;
  141383. /**
  141384. * Gets the ambient occlusion object parameters
  141385. */
  141386. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141387. /**
  141388. * Gets the reflection object parameters
  141389. */
  141390. get reflection(): NodeMaterialConnectionPoint;
  141391. /**
  141392. * Gets the sheen object parameters
  141393. */
  141394. get sheen(): NodeMaterialConnectionPoint;
  141395. /**
  141396. * Gets the clear coat object parameters
  141397. */
  141398. get clearcoat(): NodeMaterialConnectionPoint;
  141399. /**
  141400. * Gets the sub surface object parameters
  141401. */
  141402. get subsurface(): NodeMaterialConnectionPoint;
  141403. /**
  141404. * Gets the anisotropy object parameters
  141405. */
  141406. get anisotropy(): NodeMaterialConnectionPoint;
  141407. /**
  141408. * Gets the ambient output component
  141409. */
  141410. get ambient(): NodeMaterialConnectionPoint;
  141411. /**
  141412. * Gets the diffuse output component
  141413. */
  141414. get diffuse(): NodeMaterialConnectionPoint;
  141415. /**
  141416. * Gets the specular output component
  141417. */
  141418. get specular(): NodeMaterialConnectionPoint;
  141419. /**
  141420. * Gets the sheen output component
  141421. */
  141422. get sheenDir(): NodeMaterialConnectionPoint;
  141423. /**
  141424. * Gets the clear coat output component
  141425. */
  141426. get clearcoatDir(): NodeMaterialConnectionPoint;
  141427. /**
  141428. * Gets the indirect diffuse output component
  141429. */
  141430. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141431. /**
  141432. * Gets the indirect specular output component
  141433. */
  141434. get specularIndirect(): NodeMaterialConnectionPoint;
  141435. /**
  141436. * Gets the indirect sheen output component
  141437. */
  141438. get sheenIndirect(): NodeMaterialConnectionPoint;
  141439. /**
  141440. * Gets the indirect clear coat output component
  141441. */
  141442. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141443. /**
  141444. * Gets the refraction output component
  141445. */
  141446. get refraction(): NodeMaterialConnectionPoint;
  141447. /**
  141448. * Gets the global lighting output component
  141449. */
  141450. get lighting(): NodeMaterialConnectionPoint;
  141451. /**
  141452. * Gets the shadow output component
  141453. */
  141454. get shadow(): NodeMaterialConnectionPoint;
  141455. /**
  141456. * Gets the alpha output component
  141457. */
  141458. get alpha(): NodeMaterialConnectionPoint;
  141459. autoConfigure(material: NodeMaterial): void;
  141460. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141461. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141462. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141463. private _injectVertexCode;
  141464. /**
  141465. * Gets the code corresponding to the albedo/opacity module
  141466. * @returns the shader code
  141467. */
  141468. getAlbedoOpacityCode(): string;
  141469. protected _buildBlock(state: NodeMaterialBuildState): this;
  141470. protected _dumpPropertiesCode(): string;
  141471. serialize(): any;
  141472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141473. }
  141474. }
  141475. declare module BABYLON {
  141476. /**
  141477. * Block used to compute value of one parameter modulo another
  141478. */
  141479. export class ModBlock extends NodeMaterialBlock {
  141480. /**
  141481. * Creates a new ModBlock
  141482. * @param name defines the block name
  141483. */
  141484. constructor(name: string);
  141485. /**
  141486. * Gets the current class name
  141487. * @returns the class name
  141488. */
  141489. getClassName(): string;
  141490. /**
  141491. * Gets the left operand input component
  141492. */
  141493. get left(): NodeMaterialConnectionPoint;
  141494. /**
  141495. * Gets the right operand input component
  141496. */
  141497. get right(): NodeMaterialConnectionPoint;
  141498. /**
  141499. * Gets the output component
  141500. */
  141501. get output(): NodeMaterialConnectionPoint;
  141502. protected _buildBlock(state: NodeMaterialBuildState): this;
  141503. }
  141504. }
  141505. declare module BABYLON {
  141506. /**
  141507. * Helper class to push actions to a pool of workers.
  141508. */
  141509. export class WorkerPool implements IDisposable {
  141510. private _workerInfos;
  141511. private _pendingActions;
  141512. /**
  141513. * Constructor
  141514. * @param workers Array of workers to use for actions
  141515. */
  141516. constructor(workers: Array<Worker>);
  141517. /**
  141518. * Terminates all workers and clears any pending actions.
  141519. */
  141520. dispose(): void;
  141521. /**
  141522. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141523. * pended until a worker has completed its action.
  141524. * @param action The action to perform. Call onComplete when the action is complete.
  141525. */
  141526. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141527. private _execute;
  141528. }
  141529. }
  141530. declare module BABYLON {
  141531. /**
  141532. * Configuration for Draco compression
  141533. */
  141534. export interface IDracoCompressionConfiguration {
  141535. /**
  141536. * Configuration for the decoder.
  141537. */
  141538. decoder: {
  141539. /**
  141540. * The url to the WebAssembly module.
  141541. */
  141542. wasmUrl?: string;
  141543. /**
  141544. * The url to the WebAssembly binary.
  141545. */
  141546. wasmBinaryUrl?: string;
  141547. /**
  141548. * The url to the fallback JavaScript module.
  141549. */
  141550. fallbackUrl?: string;
  141551. };
  141552. }
  141553. /**
  141554. * Draco compression (https://google.github.io/draco/)
  141555. *
  141556. * This class wraps the Draco module.
  141557. *
  141558. * **Encoder**
  141559. *
  141560. * The encoder is not currently implemented.
  141561. *
  141562. * **Decoder**
  141563. *
  141564. * 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.
  141565. *
  141566. * To update the configuration, use the following code:
  141567. * ```javascript
  141568. * DracoCompression.Configuration = {
  141569. * decoder: {
  141570. * wasmUrl: "<url to the WebAssembly library>",
  141571. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141572. * fallbackUrl: "<url to the fallback JavaScript library>",
  141573. * }
  141574. * };
  141575. * ```
  141576. *
  141577. * 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.
  141578. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141579. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141580. *
  141581. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141582. * ```javascript
  141583. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141584. * ```
  141585. *
  141586. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141587. */
  141588. export class DracoCompression implements IDisposable {
  141589. private _workerPoolPromise?;
  141590. private _decoderModulePromise?;
  141591. /**
  141592. * The configuration. Defaults to the following urls:
  141593. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141594. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141595. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141596. */
  141597. static Configuration: IDracoCompressionConfiguration;
  141598. /**
  141599. * Returns true if the decoder configuration is available.
  141600. */
  141601. static get DecoderAvailable(): boolean;
  141602. /**
  141603. * Default number of workers to create when creating the draco compression object.
  141604. */
  141605. static DefaultNumWorkers: number;
  141606. private static GetDefaultNumWorkers;
  141607. private static _Default;
  141608. /**
  141609. * Default instance for the draco compression object.
  141610. */
  141611. static get Default(): DracoCompression;
  141612. /**
  141613. * Constructor
  141614. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141615. */
  141616. constructor(numWorkers?: number);
  141617. /**
  141618. * Stop all async operations and release resources.
  141619. */
  141620. dispose(): void;
  141621. /**
  141622. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141623. * @returns a promise that resolves when ready
  141624. */
  141625. whenReadyAsync(): Promise<void>;
  141626. /**
  141627. * Decode Draco compressed mesh data to vertex data.
  141628. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141629. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141630. * @returns A promise that resolves with the decoded vertex data
  141631. */
  141632. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141633. [kind: string]: number;
  141634. }): Promise<VertexData>;
  141635. }
  141636. }
  141637. declare module BABYLON {
  141638. /**
  141639. * Class for building Constructive Solid Geometry
  141640. */
  141641. export class CSG {
  141642. private polygons;
  141643. /**
  141644. * The world matrix
  141645. */
  141646. matrix: Matrix;
  141647. /**
  141648. * Stores the position
  141649. */
  141650. position: Vector3;
  141651. /**
  141652. * Stores the rotation
  141653. */
  141654. rotation: Vector3;
  141655. /**
  141656. * Stores the rotation quaternion
  141657. */
  141658. rotationQuaternion: Nullable<Quaternion>;
  141659. /**
  141660. * Stores the scaling vector
  141661. */
  141662. scaling: Vector3;
  141663. /**
  141664. * Convert the Mesh to CSG
  141665. * @param mesh The Mesh to convert to CSG
  141666. * @returns A new CSG from the Mesh
  141667. */
  141668. static FromMesh(mesh: Mesh): CSG;
  141669. /**
  141670. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141671. * @param polygons Polygons used to construct a CSG solid
  141672. */
  141673. private static FromPolygons;
  141674. /**
  141675. * Clones, or makes a deep copy, of the CSG
  141676. * @returns A new CSG
  141677. */
  141678. clone(): CSG;
  141679. /**
  141680. * Unions this CSG with another CSG
  141681. * @param csg The CSG to union against this CSG
  141682. * @returns The unioned CSG
  141683. */
  141684. union(csg: CSG): CSG;
  141685. /**
  141686. * Unions this CSG with another CSG in place
  141687. * @param csg The CSG to union against this CSG
  141688. */
  141689. unionInPlace(csg: CSG): void;
  141690. /**
  141691. * Subtracts this CSG with another CSG
  141692. * @param csg The CSG to subtract against this CSG
  141693. * @returns A new CSG
  141694. */
  141695. subtract(csg: CSG): CSG;
  141696. /**
  141697. * Subtracts this CSG with another CSG in place
  141698. * @param csg The CSG to subtact against this CSG
  141699. */
  141700. subtractInPlace(csg: CSG): void;
  141701. /**
  141702. * Intersect this CSG with another CSG
  141703. * @param csg The CSG to intersect against this CSG
  141704. * @returns A new CSG
  141705. */
  141706. intersect(csg: CSG): CSG;
  141707. /**
  141708. * Intersects this CSG with another CSG in place
  141709. * @param csg The CSG to intersect against this CSG
  141710. */
  141711. intersectInPlace(csg: CSG): void;
  141712. /**
  141713. * Return a new CSG solid with solid and empty space switched. This solid is
  141714. * not modified.
  141715. * @returns A new CSG solid with solid and empty space switched
  141716. */
  141717. inverse(): CSG;
  141718. /**
  141719. * Inverses the CSG in place
  141720. */
  141721. inverseInPlace(): void;
  141722. /**
  141723. * This is used to keep meshes transformations so they can be restored
  141724. * when we build back a Babylon Mesh
  141725. * NB : All CSG operations are performed in world coordinates
  141726. * @param csg The CSG to copy the transform attributes from
  141727. * @returns This CSG
  141728. */
  141729. copyTransformAttributes(csg: CSG): CSG;
  141730. /**
  141731. * Build Raw mesh from CSG
  141732. * Coordinates here are in world space
  141733. * @param name The name of the mesh geometry
  141734. * @param scene The Scene
  141735. * @param keepSubMeshes Specifies if the submeshes should be kept
  141736. * @returns A new Mesh
  141737. */
  141738. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141739. /**
  141740. * Build Mesh from CSG taking material and transforms into account
  141741. * @param name The name of the Mesh
  141742. * @param material The material of the Mesh
  141743. * @param scene The Scene
  141744. * @param keepSubMeshes Specifies if submeshes should be kept
  141745. * @returns The new Mesh
  141746. */
  141747. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141748. }
  141749. }
  141750. declare module BABYLON {
  141751. /**
  141752. * Class used to create a trail following a mesh
  141753. */
  141754. export class TrailMesh extends Mesh {
  141755. private _generator;
  141756. private _autoStart;
  141757. private _running;
  141758. private _diameter;
  141759. private _length;
  141760. private _sectionPolygonPointsCount;
  141761. private _sectionVectors;
  141762. private _sectionNormalVectors;
  141763. private _beforeRenderObserver;
  141764. /**
  141765. * @constructor
  141766. * @param name The value used by scene.getMeshByName() to do a lookup.
  141767. * @param generator The mesh or transform node to generate a trail.
  141768. * @param scene The scene to add this mesh to.
  141769. * @param diameter Diameter of trailing mesh. Default is 1.
  141770. * @param length Length of trailing mesh. Default is 60.
  141771. * @param autoStart Automatically start trailing mesh. Default true.
  141772. */
  141773. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  141774. /**
  141775. * "TrailMesh"
  141776. * @returns "TrailMesh"
  141777. */
  141778. getClassName(): string;
  141779. private _createMesh;
  141780. /**
  141781. * Start trailing mesh.
  141782. */
  141783. start(): void;
  141784. /**
  141785. * Stop trailing mesh.
  141786. */
  141787. stop(): void;
  141788. /**
  141789. * Update trailing mesh geometry.
  141790. */
  141791. update(): void;
  141792. /**
  141793. * Returns a new TrailMesh object.
  141794. * @param name is a string, the name given to the new mesh
  141795. * @param newGenerator use new generator object for cloned trail mesh
  141796. * @returns a new mesh
  141797. */
  141798. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  141799. /**
  141800. * Serializes this trail mesh
  141801. * @param serializationObject object to write serialization to
  141802. */
  141803. serialize(serializationObject: any): void;
  141804. /**
  141805. * Parses a serialized trail mesh
  141806. * @param parsedMesh the serialized mesh
  141807. * @param scene the scene to create the trail mesh in
  141808. * @returns the created trail mesh
  141809. */
  141810. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  141811. }
  141812. }
  141813. declare module BABYLON {
  141814. /**
  141815. * Class containing static functions to help procedurally build meshes
  141816. */
  141817. export class TiledBoxBuilder {
  141818. /**
  141819. * Creates a box mesh
  141820. * 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)
  141821. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141825. * @param name defines the name of the mesh
  141826. * @param options defines the options used to create the mesh
  141827. * @param scene defines the hosting scene
  141828. * @returns the box mesh
  141829. */
  141830. static CreateTiledBox(name: string, options: {
  141831. pattern?: number;
  141832. width?: number;
  141833. height?: number;
  141834. depth?: number;
  141835. tileSize?: number;
  141836. tileWidth?: number;
  141837. tileHeight?: number;
  141838. alignHorizontal?: number;
  141839. alignVertical?: number;
  141840. faceUV?: Vector4[];
  141841. faceColors?: Color4[];
  141842. sideOrientation?: number;
  141843. updatable?: boolean;
  141844. }, scene?: Nullable<Scene>): Mesh;
  141845. }
  141846. }
  141847. declare module BABYLON {
  141848. /**
  141849. * Class containing static functions to help procedurally build meshes
  141850. */
  141851. export class TorusKnotBuilder {
  141852. /**
  141853. * Creates a torus knot mesh
  141854. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141855. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141856. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141857. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141861. * @param name defines the name of the mesh
  141862. * @param options defines the options used to create the mesh
  141863. * @param scene defines the hosting scene
  141864. * @returns the torus knot mesh
  141865. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141866. */
  141867. static CreateTorusKnot(name: string, options: {
  141868. radius?: number;
  141869. tube?: number;
  141870. radialSegments?: number;
  141871. tubularSegments?: number;
  141872. p?: number;
  141873. q?: number;
  141874. updatable?: boolean;
  141875. sideOrientation?: number;
  141876. frontUVs?: Vector4;
  141877. backUVs?: Vector4;
  141878. }, scene: any): Mesh;
  141879. }
  141880. }
  141881. declare module BABYLON {
  141882. /**
  141883. * Polygon
  141884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141885. */
  141886. export class Polygon {
  141887. /**
  141888. * Creates a rectangle
  141889. * @param xmin bottom X coord
  141890. * @param ymin bottom Y coord
  141891. * @param xmax top X coord
  141892. * @param ymax top Y coord
  141893. * @returns points that make the resulting rectation
  141894. */
  141895. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141896. /**
  141897. * Creates a circle
  141898. * @param radius radius of circle
  141899. * @param cx scale in x
  141900. * @param cy scale in y
  141901. * @param numberOfSides number of sides that make up the circle
  141902. * @returns points that make the resulting circle
  141903. */
  141904. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141905. /**
  141906. * Creates a polygon from input string
  141907. * @param input Input polygon data
  141908. * @returns the parsed points
  141909. */
  141910. static Parse(input: string): Vector2[];
  141911. /**
  141912. * Starts building a polygon from x and y coordinates
  141913. * @param x x coordinate
  141914. * @param y y coordinate
  141915. * @returns the started path2
  141916. */
  141917. static StartingAt(x: number, y: number): Path2;
  141918. }
  141919. /**
  141920. * Builds a polygon
  141921. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141922. */
  141923. export class PolygonMeshBuilder {
  141924. private _points;
  141925. private _outlinepoints;
  141926. private _holes;
  141927. private _name;
  141928. private _scene;
  141929. private _epoints;
  141930. private _eholes;
  141931. private _addToepoint;
  141932. /**
  141933. * Babylon reference to the earcut plugin.
  141934. */
  141935. bjsEarcut: any;
  141936. /**
  141937. * Creates a PolygonMeshBuilder
  141938. * @param name name of the builder
  141939. * @param contours Path of the polygon
  141940. * @param scene scene to add to when creating the mesh
  141941. * @param earcutInjection can be used to inject your own earcut reference
  141942. */
  141943. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141944. /**
  141945. * Adds a whole within the polygon
  141946. * @param hole Array of points defining the hole
  141947. * @returns this
  141948. */
  141949. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141950. /**
  141951. * Creates the polygon
  141952. * @param updatable If the mesh should be updatable
  141953. * @param depth The depth of the mesh created
  141954. * @returns the created mesh
  141955. */
  141956. build(updatable?: boolean, depth?: number): Mesh;
  141957. /**
  141958. * Creates the polygon
  141959. * @param depth The depth of the mesh created
  141960. * @returns the created VertexData
  141961. */
  141962. buildVertexData(depth?: number): VertexData;
  141963. /**
  141964. * Adds a side to the polygon
  141965. * @param positions points that make the polygon
  141966. * @param normals normals of the polygon
  141967. * @param uvs uvs of the polygon
  141968. * @param indices indices of the polygon
  141969. * @param bounds bounds of the polygon
  141970. * @param points points of the polygon
  141971. * @param depth depth of the polygon
  141972. * @param flip flip of the polygon
  141973. */
  141974. private addSide;
  141975. }
  141976. }
  141977. declare module BABYLON {
  141978. /**
  141979. * Class containing static functions to help procedurally build meshes
  141980. */
  141981. export class PolygonBuilder {
  141982. /**
  141983. * Creates a polygon mesh
  141984. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141985. * * 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
  141986. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141989. * * Remember you can only change the shape positions, not their number when updating a polygon
  141990. * @param name defines the name of the mesh
  141991. * @param options defines the options used to create the mesh
  141992. * @param scene defines the hosting scene
  141993. * @param earcutInjection can be used to inject your own earcut reference
  141994. * @returns the polygon mesh
  141995. */
  141996. static CreatePolygon(name: string, options: {
  141997. shape: Vector3[];
  141998. holes?: Vector3[][];
  141999. depth?: number;
  142000. faceUV?: Vector4[];
  142001. faceColors?: Color4[];
  142002. updatable?: boolean;
  142003. sideOrientation?: number;
  142004. frontUVs?: Vector4;
  142005. backUVs?: Vector4;
  142006. wrap?: boolean;
  142007. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142008. /**
  142009. * Creates an extruded polygon mesh, with depth in the Y direction.
  142010. * * 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)
  142011. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142012. * @param name defines the name of the mesh
  142013. * @param options defines the options used to create the mesh
  142014. * @param scene defines the hosting scene
  142015. * @param earcutInjection can be used to inject your own earcut reference
  142016. * @returns the polygon mesh
  142017. */
  142018. static ExtrudePolygon(name: string, options: {
  142019. shape: Vector3[];
  142020. holes?: Vector3[][];
  142021. depth?: number;
  142022. faceUV?: Vector4[];
  142023. faceColors?: Color4[];
  142024. updatable?: boolean;
  142025. sideOrientation?: number;
  142026. frontUVs?: Vector4;
  142027. backUVs?: Vector4;
  142028. wrap?: boolean;
  142029. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142030. }
  142031. }
  142032. declare module BABYLON {
  142033. /**
  142034. * Class containing static functions to help procedurally build meshes
  142035. */
  142036. export class LatheBuilder {
  142037. /**
  142038. * Creates lathe mesh.
  142039. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142040. * * 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
  142041. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142042. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142043. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142044. * * 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
  142045. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142046. * * 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
  142047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142051. * @param name defines the name of the mesh
  142052. * @param options defines the options used to create the mesh
  142053. * @param scene defines the hosting scene
  142054. * @returns the lathe mesh
  142055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142056. */
  142057. static CreateLathe(name: string, options: {
  142058. shape: Vector3[];
  142059. radius?: number;
  142060. tessellation?: number;
  142061. clip?: number;
  142062. arc?: number;
  142063. closed?: boolean;
  142064. updatable?: boolean;
  142065. sideOrientation?: number;
  142066. frontUVs?: Vector4;
  142067. backUVs?: Vector4;
  142068. cap?: number;
  142069. invertUV?: boolean;
  142070. }, scene?: Nullable<Scene>): Mesh;
  142071. }
  142072. }
  142073. declare module BABYLON {
  142074. /**
  142075. * Class containing static functions to help procedurally build meshes
  142076. */
  142077. export class TiledPlaneBuilder {
  142078. /**
  142079. * Creates a tiled plane mesh
  142080. * * The parameter `pattern` will, depending on value, do nothing or
  142081. * * * flip (reflect about central vertical) alternate tiles across and up
  142082. * * * flip every tile on alternate rows
  142083. * * * rotate (180 degs) alternate tiles across and up
  142084. * * * rotate every tile on alternate rows
  142085. * * * flip and rotate alternate tiles across and up
  142086. * * * flip and rotate every tile on alternate rows
  142087. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142088. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142091. * * 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)
  142092. * * 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)
  142093. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142094. * @param name defines the name of the mesh
  142095. * @param options defines the options used to create the mesh
  142096. * @param scene defines the hosting scene
  142097. * @returns the box mesh
  142098. */
  142099. static CreateTiledPlane(name: string, options: {
  142100. pattern?: number;
  142101. tileSize?: number;
  142102. tileWidth?: number;
  142103. tileHeight?: number;
  142104. size?: number;
  142105. width?: number;
  142106. height?: number;
  142107. alignHorizontal?: number;
  142108. alignVertical?: number;
  142109. sideOrientation?: number;
  142110. frontUVs?: Vector4;
  142111. backUVs?: Vector4;
  142112. updatable?: boolean;
  142113. }, scene?: Nullable<Scene>): Mesh;
  142114. }
  142115. }
  142116. declare module BABYLON {
  142117. /**
  142118. * Class containing static functions to help procedurally build meshes
  142119. */
  142120. export class TubeBuilder {
  142121. /**
  142122. * Creates a tube mesh.
  142123. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142124. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142125. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142126. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142127. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142128. * * 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)
  142129. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142130. * * 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
  142131. * * 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
  142132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142136. * @param name defines the name of the mesh
  142137. * @param options defines the options used to create the mesh
  142138. * @param scene defines the hosting scene
  142139. * @returns the tube mesh
  142140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142141. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142142. */
  142143. static CreateTube(name: string, options: {
  142144. path: Vector3[];
  142145. radius?: number;
  142146. tessellation?: number;
  142147. radiusFunction?: {
  142148. (i: number, distance: number): number;
  142149. };
  142150. cap?: number;
  142151. arc?: number;
  142152. updatable?: boolean;
  142153. sideOrientation?: number;
  142154. frontUVs?: Vector4;
  142155. backUVs?: Vector4;
  142156. instance?: Mesh;
  142157. invertUV?: boolean;
  142158. }, scene?: Nullable<Scene>): Mesh;
  142159. }
  142160. }
  142161. declare module BABYLON {
  142162. /**
  142163. * Class containing static functions to help procedurally build meshes
  142164. */
  142165. export class IcoSphereBuilder {
  142166. /**
  142167. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142168. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142169. * * 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`)
  142170. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142171. * * 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
  142172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142175. * @param name defines the name of the mesh
  142176. * @param options defines the options used to create the mesh
  142177. * @param scene defines the hosting scene
  142178. * @returns the icosahedron mesh
  142179. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142180. */
  142181. static CreateIcoSphere(name: string, options: {
  142182. radius?: number;
  142183. radiusX?: number;
  142184. radiusY?: number;
  142185. radiusZ?: number;
  142186. flat?: boolean;
  142187. subdivisions?: number;
  142188. sideOrientation?: number;
  142189. frontUVs?: Vector4;
  142190. backUVs?: Vector4;
  142191. updatable?: boolean;
  142192. }, scene?: Nullable<Scene>): Mesh;
  142193. }
  142194. }
  142195. declare module BABYLON {
  142196. /**
  142197. * Class containing static functions to help procedurally build meshes
  142198. */
  142199. export class DecalBuilder {
  142200. /**
  142201. * Creates a decal mesh.
  142202. * 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
  142203. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142204. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142205. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142206. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142207. * @param name defines the name of the mesh
  142208. * @param sourceMesh defines the mesh where the decal must be applied
  142209. * @param options defines the options used to create the mesh
  142210. * @param scene defines the hosting scene
  142211. * @returns the decal mesh
  142212. * @see https://doc.babylonjs.com/how_to/decals
  142213. */
  142214. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142215. position?: Vector3;
  142216. normal?: Vector3;
  142217. size?: Vector3;
  142218. angle?: number;
  142219. }): Mesh;
  142220. }
  142221. }
  142222. declare module BABYLON {
  142223. /**
  142224. * Class containing static functions to help procedurally build meshes
  142225. */
  142226. export class MeshBuilder {
  142227. /**
  142228. * Creates a box mesh
  142229. * * The parameter `size` sets the size (float) of each box side (default 1)
  142230. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142231. * * 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)
  142232. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142236. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142237. * @param name defines the name of the mesh
  142238. * @param options defines the options used to create the mesh
  142239. * @param scene defines the hosting scene
  142240. * @returns the box mesh
  142241. */
  142242. static CreateBox(name: string, options: {
  142243. size?: number;
  142244. width?: number;
  142245. height?: number;
  142246. depth?: number;
  142247. faceUV?: Vector4[];
  142248. faceColors?: Color4[];
  142249. sideOrientation?: number;
  142250. frontUVs?: Vector4;
  142251. backUVs?: Vector4;
  142252. wrap?: boolean;
  142253. topBaseAt?: number;
  142254. bottomBaseAt?: number;
  142255. updatable?: boolean;
  142256. }, scene?: Nullable<Scene>): Mesh;
  142257. /**
  142258. * Creates a tiled box mesh
  142259. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142261. * @param name defines the name of the mesh
  142262. * @param options defines the options used to create the mesh
  142263. * @param scene defines the hosting scene
  142264. * @returns the tiled box mesh
  142265. */
  142266. static CreateTiledBox(name: string, options: {
  142267. pattern?: number;
  142268. size?: number;
  142269. width?: number;
  142270. height?: number;
  142271. depth: number;
  142272. tileSize?: number;
  142273. tileWidth?: number;
  142274. tileHeight?: number;
  142275. faceUV?: Vector4[];
  142276. faceColors?: Color4[];
  142277. alignHorizontal?: number;
  142278. alignVertical?: number;
  142279. sideOrientation?: number;
  142280. updatable?: boolean;
  142281. }, scene?: Nullable<Scene>): Mesh;
  142282. /**
  142283. * Creates a sphere mesh
  142284. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142285. * * 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`)
  142286. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142287. * * 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
  142288. * * 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)
  142289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142292. * @param name defines the name of the mesh
  142293. * @param options defines the options used to create the mesh
  142294. * @param scene defines the hosting scene
  142295. * @returns the sphere mesh
  142296. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  142297. */
  142298. static CreateSphere(name: string, options: {
  142299. segments?: number;
  142300. diameter?: number;
  142301. diameterX?: number;
  142302. diameterY?: number;
  142303. diameterZ?: number;
  142304. arc?: number;
  142305. slice?: number;
  142306. sideOrientation?: number;
  142307. frontUVs?: Vector4;
  142308. backUVs?: Vector4;
  142309. updatable?: boolean;
  142310. }, scene?: Nullable<Scene>): Mesh;
  142311. /**
  142312. * Creates a plane polygonal mesh. By default, this is a disc
  142313. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  142314. * * 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
  142315. * * 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
  142316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142319. * @param name defines the name of the mesh
  142320. * @param options defines the options used to create the mesh
  142321. * @param scene defines the hosting scene
  142322. * @returns the plane polygonal mesh
  142323. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  142324. */
  142325. static CreateDisc(name: string, options: {
  142326. radius?: number;
  142327. tessellation?: number;
  142328. arc?: number;
  142329. updatable?: boolean;
  142330. sideOrientation?: number;
  142331. frontUVs?: Vector4;
  142332. backUVs?: Vector4;
  142333. }, scene?: Nullable<Scene>): Mesh;
  142334. /**
  142335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142337. * * 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`)
  142338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142339. * * 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
  142340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142343. * @param name defines the name of the mesh
  142344. * @param options defines the options used to create the mesh
  142345. * @param scene defines the hosting scene
  142346. * @returns the icosahedron mesh
  142347. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142348. */
  142349. static CreateIcoSphere(name: string, options: {
  142350. radius?: number;
  142351. radiusX?: number;
  142352. radiusY?: number;
  142353. radiusZ?: number;
  142354. flat?: boolean;
  142355. subdivisions?: number;
  142356. sideOrientation?: number;
  142357. frontUVs?: Vector4;
  142358. backUVs?: Vector4;
  142359. updatable?: boolean;
  142360. }, scene?: Nullable<Scene>): Mesh;
  142361. /**
  142362. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142363. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142364. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142365. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142366. * * 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
  142367. * * 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
  142368. * * 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
  142369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142372. * * 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
  142373. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142374. * * 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
  142375. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142377. * @param name defines the name of the mesh
  142378. * @param options defines the options used to create the mesh
  142379. * @param scene defines the hosting scene
  142380. * @returns the ribbon mesh
  142381. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142383. */
  142384. static CreateRibbon(name: string, options: {
  142385. pathArray: Vector3[][];
  142386. closeArray?: boolean;
  142387. closePath?: boolean;
  142388. offset?: number;
  142389. updatable?: boolean;
  142390. sideOrientation?: number;
  142391. frontUVs?: Vector4;
  142392. backUVs?: Vector4;
  142393. instance?: Mesh;
  142394. invertUV?: boolean;
  142395. uvs?: Vector2[];
  142396. colors?: Color4[];
  142397. }, scene?: Nullable<Scene>): Mesh;
  142398. /**
  142399. * Creates a cylinder or a cone mesh
  142400. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142401. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142402. * * 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.
  142403. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142404. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142405. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142406. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142407. * * 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).
  142408. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142409. * * 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).
  142410. * * 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
  142411. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142412. * * 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
  142413. * * 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.
  142414. * * If `enclose` is false, a ring surface is one element.
  142415. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142416. * * 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
  142417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142420. * @param name defines the name of the mesh
  142421. * @param options defines the options used to create the mesh
  142422. * @param scene defines the hosting scene
  142423. * @returns the cylinder mesh
  142424. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142425. */
  142426. static CreateCylinder(name: string, options: {
  142427. height?: number;
  142428. diameterTop?: number;
  142429. diameterBottom?: number;
  142430. diameter?: number;
  142431. tessellation?: number;
  142432. subdivisions?: number;
  142433. arc?: number;
  142434. faceColors?: Color4[];
  142435. faceUV?: Vector4[];
  142436. updatable?: boolean;
  142437. hasRings?: boolean;
  142438. enclose?: boolean;
  142439. cap?: number;
  142440. sideOrientation?: number;
  142441. frontUVs?: Vector4;
  142442. backUVs?: Vector4;
  142443. }, scene?: Nullable<Scene>): Mesh;
  142444. /**
  142445. * Creates a torus mesh
  142446. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142447. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142448. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142452. * @param name defines the name of the mesh
  142453. * @param options defines the options used to create the mesh
  142454. * @param scene defines the hosting scene
  142455. * @returns the torus mesh
  142456. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142457. */
  142458. static CreateTorus(name: string, options: {
  142459. diameter?: number;
  142460. thickness?: number;
  142461. tessellation?: number;
  142462. updatable?: boolean;
  142463. sideOrientation?: number;
  142464. frontUVs?: Vector4;
  142465. backUVs?: Vector4;
  142466. }, scene?: Nullable<Scene>): Mesh;
  142467. /**
  142468. * Creates a torus knot mesh
  142469. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142470. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142471. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142472. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142476. * @param name defines the name of the mesh
  142477. * @param options defines the options used to create the mesh
  142478. * @param scene defines the hosting scene
  142479. * @returns the torus knot mesh
  142480. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142481. */
  142482. static CreateTorusKnot(name: string, options: {
  142483. radius?: number;
  142484. tube?: number;
  142485. radialSegments?: number;
  142486. tubularSegments?: number;
  142487. p?: number;
  142488. q?: number;
  142489. updatable?: boolean;
  142490. sideOrientation?: number;
  142491. frontUVs?: Vector4;
  142492. backUVs?: Vector4;
  142493. }, scene?: Nullable<Scene>): Mesh;
  142494. /**
  142495. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142496. * * 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
  142497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142498. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142499. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142500. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142501. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142502. * * 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
  142503. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142506. * @param name defines the name of the new line system
  142507. * @param options defines the options used to create the line system
  142508. * @param scene defines the hosting scene
  142509. * @returns a new line system mesh
  142510. */
  142511. static CreateLineSystem(name: string, options: {
  142512. lines: Vector3[][];
  142513. updatable?: boolean;
  142514. instance?: Nullable<LinesMesh>;
  142515. colors?: Nullable<Color4[][]>;
  142516. useVertexAlpha?: boolean;
  142517. }, scene: Nullable<Scene>): LinesMesh;
  142518. /**
  142519. * Creates a line mesh
  142520. * 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
  142521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142522. * * The parameter `points` is an array successive Vector3
  142523. * * 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
  142524. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142525. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142526. * * When updating an instance, remember that only point positions can change, not the number of points
  142527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142529. * @param name defines the name of the new line system
  142530. * @param options defines the options used to create the line system
  142531. * @param scene defines the hosting scene
  142532. * @returns a new line mesh
  142533. */
  142534. static CreateLines(name: string, options: {
  142535. points: Vector3[];
  142536. updatable?: boolean;
  142537. instance?: Nullable<LinesMesh>;
  142538. colors?: Color4[];
  142539. useVertexAlpha?: boolean;
  142540. }, scene?: Nullable<Scene>): LinesMesh;
  142541. /**
  142542. * Creates a dashed line mesh
  142543. * * 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
  142544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142545. * * The parameter `points` is an array successive Vector3
  142546. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142547. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142548. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142549. * * 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
  142550. * * When updating an instance, remember that only point positions can change, not the number of points
  142551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142552. * @param name defines the name of the mesh
  142553. * @param options defines the options used to create the mesh
  142554. * @param scene defines the hosting scene
  142555. * @returns the dashed line mesh
  142556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142557. */
  142558. static CreateDashedLines(name: string, options: {
  142559. points: Vector3[];
  142560. dashSize?: number;
  142561. gapSize?: number;
  142562. dashNb?: number;
  142563. updatable?: boolean;
  142564. instance?: LinesMesh;
  142565. }, scene?: Nullable<Scene>): LinesMesh;
  142566. /**
  142567. * 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.
  142568. * * 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.
  142569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142570. * * 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.
  142571. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142572. * * 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
  142573. * * 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
  142574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142579. * @param name defines the name of the mesh
  142580. * @param options defines the options used to create the mesh
  142581. * @param scene defines the hosting scene
  142582. * @returns the extruded shape mesh
  142583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142585. */
  142586. static ExtrudeShape(name: string, options: {
  142587. shape: Vector3[];
  142588. path: Vector3[];
  142589. scale?: number;
  142590. rotation?: number;
  142591. cap?: number;
  142592. updatable?: boolean;
  142593. sideOrientation?: number;
  142594. frontUVs?: Vector4;
  142595. backUVs?: Vector4;
  142596. instance?: Mesh;
  142597. invertUV?: boolean;
  142598. }, scene?: Nullable<Scene>): Mesh;
  142599. /**
  142600. * Creates an custom extruded shape mesh.
  142601. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142602. * * 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.
  142603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142604. * * 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
  142605. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142606. * * 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
  142607. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142608. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142609. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142610. * * 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
  142611. * * 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
  142612. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142617. * @param name defines the name of the mesh
  142618. * @param options defines the options used to create the mesh
  142619. * @param scene defines the hosting scene
  142620. * @returns the custom extruded shape mesh
  142621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142622. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142624. */
  142625. static ExtrudeShapeCustom(name: string, options: {
  142626. shape: Vector3[];
  142627. path: Vector3[];
  142628. scaleFunction?: any;
  142629. rotationFunction?: any;
  142630. ribbonCloseArray?: boolean;
  142631. ribbonClosePath?: boolean;
  142632. cap?: number;
  142633. updatable?: boolean;
  142634. sideOrientation?: number;
  142635. frontUVs?: Vector4;
  142636. backUVs?: Vector4;
  142637. instance?: Mesh;
  142638. invertUV?: boolean;
  142639. }, scene?: Nullable<Scene>): Mesh;
  142640. /**
  142641. * Creates lathe mesh.
  142642. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142643. * * 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
  142644. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142645. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142646. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142647. * * 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
  142648. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142649. * * 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
  142650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142654. * @param name defines the name of the mesh
  142655. * @param options defines the options used to create the mesh
  142656. * @param scene defines the hosting scene
  142657. * @returns the lathe mesh
  142658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142659. */
  142660. static CreateLathe(name: string, options: {
  142661. shape: Vector3[];
  142662. radius?: number;
  142663. tessellation?: number;
  142664. clip?: number;
  142665. arc?: number;
  142666. closed?: boolean;
  142667. updatable?: boolean;
  142668. sideOrientation?: number;
  142669. frontUVs?: Vector4;
  142670. backUVs?: Vector4;
  142671. cap?: number;
  142672. invertUV?: boolean;
  142673. }, scene?: Nullable<Scene>): Mesh;
  142674. /**
  142675. * Creates a tiled plane mesh
  142676. * * You can set a limited pattern arrangement with the tiles
  142677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142680. * @param name defines the name of the mesh
  142681. * @param options defines the options used to create the mesh
  142682. * @param scene defines the hosting scene
  142683. * @returns the plane mesh
  142684. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142685. */
  142686. static CreateTiledPlane(name: string, options: {
  142687. pattern?: number;
  142688. tileSize?: number;
  142689. tileWidth?: number;
  142690. tileHeight?: number;
  142691. size?: number;
  142692. width?: number;
  142693. height?: number;
  142694. alignHorizontal?: number;
  142695. alignVertical?: number;
  142696. sideOrientation?: number;
  142697. frontUVs?: Vector4;
  142698. backUVs?: Vector4;
  142699. updatable?: boolean;
  142700. }, scene?: Nullable<Scene>): Mesh;
  142701. /**
  142702. * Creates a plane mesh
  142703. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142704. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142705. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142709. * @param name defines the name of the mesh
  142710. * @param options defines the options used to create the mesh
  142711. * @param scene defines the hosting scene
  142712. * @returns the plane mesh
  142713. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142714. */
  142715. static CreatePlane(name: string, options: {
  142716. size?: number;
  142717. width?: number;
  142718. height?: number;
  142719. sideOrientation?: number;
  142720. frontUVs?: Vector4;
  142721. backUVs?: Vector4;
  142722. updatable?: boolean;
  142723. sourcePlane?: Plane;
  142724. }, scene?: Nullable<Scene>): Mesh;
  142725. /**
  142726. * Creates a ground mesh
  142727. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142728. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142730. * @param name defines the name of the mesh
  142731. * @param options defines the options used to create the mesh
  142732. * @param scene defines the hosting scene
  142733. * @returns the ground mesh
  142734. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142735. */
  142736. static CreateGround(name: string, options: {
  142737. width?: number;
  142738. height?: number;
  142739. subdivisions?: number;
  142740. subdivisionsX?: number;
  142741. subdivisionsY?: number;
  142742. updatable?: boolean;
  142743. }, scene?: Nullable<Scene>): Mesh;
  142744. /**
  142745. * Creates a tiled ground mesh
  142746. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  142747. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  142748. * * 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
  142749. * * 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
  142750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142751. * @param name defines the name of the mesh
  142752. * @param options defines the options used to create the mesh
  142753. * @param scene defines the hosting scene
  142754. * @returns the tiled ground mesh
  142755. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  142756. */
  142757. static CreateTiledGround(name: string, options: {
  142758. xmin: number;
  142759. zmin: number;
  142760. xmax: number;
  142761. zmax: number;
  142762. subdivisions?: {
  142763. w: number;
  142764. h: number;
  142765. };
  142766. precision?: {
  142767. w: number;
  142768. h: number;
  142769. };
  142770. updatable?: boolean;
  142771. }, scene?: Nullable<Scene>): Mesh;
  142772. /**
  142773. * Creates a ground mesh from a height map
  142774. * * The parameter `url` sets the URL of the height map image resource.
  142775. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  142776. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  142777. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  142778. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  142779. * * 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.
  142780. * * 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).
  142781. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  142782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142783. * @param name defines the name of the mesh
  142784. * @param url defines the url to the height map
  142785. * @param options defines the options used to create the mesh
  142786. * @param scene defines the hosting scene
  142787. * @returns the ground mesh
  142788. * @see https://doc.babylonjs.com/babylon101/height_map
  142789. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  142790. */
  142791. static CreateGroundFromHeightMap(name: string, url: string, options: {
  142792. width?: number;
  142793. height?: number;
  142794. subdivisions?: number;
  142795. minHeight?: number;
  142796. maxHeight?: number;
  142797. colorFilter?: Color3;
  142798. alphaFilter?: number;
  142799. updatable?: boolean;
  142800. onReady?: (mesh: GroundMesh) => void;
  142801. }, scene?: Nullable<Scene>): GroundMesh;
  142802. /**
  142803. * Creates a polygon mesh
  142804. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142805. * * 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
  142806. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142809. * * Remember you can only change the shape positions, not their number when updating a polygon
  142810. * @param name defines the name of the mesh
  142811. * @param options defines the options used to create the mesh
  142812. * @param scene defines the hosting scene
  142813. * @param earcutInjection can be used to inject your own earcut reference
  142814. * @returns the polygon mesh
  142815. */
  142816. static CreatePolygon(name: string, options: {
  142817. shape: Vector3[];
  142818. holes?: Vector3[][];
  142819. depth?: number;
  142820. faceUV?: Vector4[];
  142821. faceColors?: Color4[];
  142822. updatable?: boolean;
  142823. sideOrientation?: number;
  142824. frontUVs?: Vector4;
  142825. backUVs?: Vector4;
  142826. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142827. /**
  142828. * Creates an extruded polygon mesh, with depth in the Y direction.
  142829. * * 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)
  142830. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142831. * @param name defines the name of the mesh
  142832. * @param options defines the options used to create the mesh
  142833. * @param scene defines the hosting scene
  142834. * @param earcutInjection can be used to inject your own earcut reference
  142835. * @returns the polygon mesh
  142836. */
  142837. static ExtrudePolygon(name: string, options: {
  142838. shape: Vector3[];
  142839. holes?: Vector3[][];
  142840. depth?: number;
  142841. faceUV?: Vector4[];
  142842. faceColors?: Color4[];
  142843. updatable?: boolean;
  142844. sideOrientation?: number;
  142845. frontUVs?: Vector4;
  142846. backUVs?: Vector4;
  142847. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142848. /**
  142849. * Creates a tube mesh.
  142850. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142851. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142852. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142853. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142854. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142855. * * 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)
  142856. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142857. * * 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
  142858. * * 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
  142859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142863. * @param name defines the name of the mesh
  142864. * @param options defines the options used to create the mesh
  142865. * @param scene defines the hosting scene
  142866. * @returns the tube mesh
  142867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142868. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142869. */
  142870. static CreateTube(name: string, options: {
  142871. path: Vector3[];
  142872. radius?: number;
  142873. tessellation?: number;
  142874. radiusFunction?: {
  142875. (i: number, distance: number): number;
  142876. };
  142877. cap?: number;
  142878. arc?: number;
  142879. updatable?: boolean;
  142880. sideOrientation?: number;
  142881. frontUVs?: Vector4;
  142882. backUVs?: Vector4;
  142883. instance?: Mesh;
  142884. invertUV?: boolean;
  142885. }, scene?: Nullable<Scene>): Mesh;
  142886. /**
  142887. * Creates a polyhedron mesh
  142888. * * 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
  142889. * * The parameter `size` (positive float, default 1) sets the polygon size
  142890. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142891. * * 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`
  142892. * * 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
  142893. * * 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)`)
  142894. * * 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
  142895. * * 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
  142896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142899. * @param name defines the name of the mesh
  142900. * @param options defines the options used to create the mesh
  142901. * @param scene defines the hosting scene
  142902. * @returns the polyhedron mesh
  142903. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142904. */
  142905. static CreatePolyhedron(name: string, options: {
  142906. type?: number;
  142907. size?: number;
  142908. sizeX?: number;
  142909. sizeY?: number;
  142910. sizeZ?: number;
  142911. custom?: any;
  142912. faceUV?: Vector4[];
  142913. faceColors?: Color4[];
  142914. flat?: boolean;
  142915. updatable?: boolean;
  142916. sideOrientation?: number;
  142917. frontUVs?: Vector4;
  142918. backUVs?: Vector4;
  142919. }, scene?: Nullable<Scene>): Mesh;
  142920. /**
  142921. * Creates a decal mesh.
  142922. * 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
  142923. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142924. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142925. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142926. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142927. * @param name defines the name of the mesh
  142928. * @param sourceMesh defines the mesh where the decal must be applied
  142929. * @param options defines the options used to create the mesh
  142930. * @param scene defines the hosting scene
  142931. * @returns the decal mesh
  142932. * @see https://doc.babylonjs.com/how_to/decals
  142933. */
  142934. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142935. position?: Vector3;
  142936. normal?: Vector3;
  142937. size?: Vector3;
  142938. angle?: number;
  142939. }): Mesh;
  142940. }
  142941. }
  142942. declare module BABYLON {
  142943. /**
  142944. * A simplifier interface for future simplification implementations
  142945. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142946. */
  142947. export interface ISimplifier {
  142948. /**
  142949. * Simplification of a given mesh according to the given settings.
  142950. * Since this requires computation, it is assumed that the function runs async.
  142951. * @param settings The settings of the simplification, including quality and distance
  142952. * @param successCallback A callback that will be called after the mesh was simplified.
  142953. * @param errorCallback in case of an error, this callback will be called. optional.
  142954. */
  142955. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142956. }
  142957. /**
  142958. * Expected simplification settings.
  142959. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142960. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142961. */
  142962. export interface ISimplificationSettings {
  142963. /**
  142964. * Gets or sets the expected quality
  142965. */
  142966. quality: number;
  142967. /**
  142968. * Gets or sets the distance when this optimized version should be used
  142969. */
  142970. distance: number;
  142971. /**
  142972. * Gets an already optimized mesh
  142973. */
  142974. optimizeMesh?: boolean;
  142975. }
  142976. /**
  142977. * Class used to specify simplification options
  142978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142979. */
  142980. export class SimplificationSettings implements ISimplificationSettings {
  142981. /** expected quality */
  142982. quality: number;
  142983. /** distance when this optimized version should be used */
  142984. distance: number;
  142985. /** already optimized mesh */
  142986. optimizeMesh?: boolean | undefined;
  142987. /**
  142988. * Creates a SimplificationSettings
  142989. * @param quality expected quality
  142990. * @param distance distance when this optimized version should be used
  142991. * @param optimizeMesh already optimized mesh
  142992. */
  142993. constructor(
  142994. /** expected quality */
  142995. quality: number,
  142996. /** distance when this optimized version should be used */
  142997. distance: number,
  142998. /** already optimized mesh */
  142999. optimizeMesh?: boolean | undefined);
  143000. }
  143001. /**
  143002. * Interface used to define a simplification task
  143003. */
  143004. export interface ISimplificationTask {
  143005. /**
  143006. * Array of settings
  143007. */
  143008. settings: Array<ISimplificationSettings>;
  143009. /**
  143010. * Simplification type
  143011. */
  143012. simplificationType: SimplificationType;
  143013. /**
  143014. * Mesh to simplify
  143015. */
  143016. mesh: Mesh;
  143017. /**
  143018. * Callback called on success
  143019. */
  143020. successCallback?: () => void;
  143021. /**
  143022. * Defines if parallel processing can be used
  143023. */
  143024. parallelProcessing: boolean;
  143025. }
  143026. /**
  143027. * Queue used to order the simplification tasks
  143028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143029. */
  143030. export class SimplificationQueue {
  143031. private _simplificationArray;
  143032. /**
  143033. * Gets a boolean indicating that the process is still running
  143034. */
  143035. running: boolean;
  143036. /**
  143037. * Creates a new queue
  143038. */
  143039. constructor();
  143040. /**
  143041. * Adds a new simplification task
  143042. * @param task defines a task to add
  143043. */
  143044. addTask(task: ISimplificationTask): void;
  143045. /**
  143046. * Execute next task
  143047. */
  143048. executeNext(): void;
  143049. /**
  143050. * Execute a simplification task
  143051. * @param task defines the task to run
  143052. */
  143053. runSimplification(task: ISimplificationTask): void;
  143054. private getSimplifier;
  143055. }
  143056. /**
  143057. * The implemented types of simplification
  143058. * At the moment only Quadratic Error Decimation is implemented
  143059. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143060. */
  143061. export enum SimplificationType {
  143062. /** Quadratic error decimation */
  143063. QUADRATIC = 0
  143064. }
  143065. /**
  143066. * An implementation of the Quadratic Error simplification algorithm.
  143067. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143068. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143069. * @author RaananW
  143070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143071. */
  143072. export class QuadraticErrorSimplification implements ISimplifier {
  143073. private _mesh;
  143074. private triangles;
  143075. private vertices;
  143076. private references;
  143077. private _reconstructedMesh;
  143078. /** Gets or sets the number pf sync interations */
  143079. syncIterations: number;
  143080. /** Gets or sets the aggressiveness of the simplifier */
  143081. aggressiveness: number;
  143082. /** Gets or sets the number of allowed iterations for decimation */
  143083. decimationIterations: number;
  143084. /** Gets or sets the espilon to use for bounding box computation */
  143085. boundingBoxEpsilon: number;
  143086. /**
  143087. * Creates a new QuadraticErrorSimplification
  143088. * @param _mesh defines the target mesh
  143089. */
  143090. constructor(_mesh: Mesh);
  143091. /**
  143092. * Simplification of a given mesh according to the given settings.
  143093. * Since this requires computation, it is assumed that the function runs async.
  143094. * @param settings The settings of the simplification, including quality and distance
  143095. * @param successCallback A callback that will be called after the mesh was simplified.
  143096. */
  143097. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143098. private runDecimation;
  143099. private initWithMesh;
  143100. private init;
  143101. private reconstructMesh;
  143102. private initDecimatedMesh;
  143103. private isFlipped;
  143104. private updateTriangles;
  143105. private identifyBorder;
  143106. private updateMesh;
  143107. private vertexError;
  143108. private calculateError;
  143109. }
  143110. }
  143111. declare module BABYLON {
  143112. interface Scene {
  143113. /** @hidden (Backing field) */
  143114. _simplificationQueue: SimplificationQueue;
  143115. /**
  143116. * Gets or sets the simplification queue attached to the scene
  143117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143118. */
  143119. simplificationQueue: SimplificationQueue;
  143120. }
  143121. interface Mesh {
  143122. /**
  143123. * Simplify the mesh according to the given array of settings.
  143124. * Function will return immediately and will simplify async
  143125. * @param settings a collection of simplification settings
  143126. * @param parallelProcessing should all levels calculate parallel or one after the other
  143127. * @param simplificationType the type of simplification to run
  143128. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143129. * @returns the current mesh
  143130. */
  143131. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143132. }
  143133. /**
  143134. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143135. * created in a scene
  143136. */
  143137. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143138. /**
  143139. * The component name helpfull to identify the component in the list of scene components.
  143140. */
  143141. readonly name: string;
  143142. /**
  143143. * The scene the component belongs to.
  143144. */
  143145. scene: Scene;
  143146. /**
  143147. * Creates a new instance of the component for the given scene
  143148. * @param scene Defines the scene to register the component in
  143149. */
  143150. constructor(scene: Scene);
  143151. /**
  143152. * Registers the component in a given scene
  143153. */
  143154. register(): void;
  143155. /**
  143156. * Rebuilds the elements related to this component in case of
  143157. * context lost for instance.
  143158. */
  143159. rebuild(): void;
  143160. /**
  143161. * Disposes the component and the associated ressources
  143162. */
  143163. dispose(): void;
  143164. private _beforeCameraUpdate;
  143165. }
  143166. }
  143167. declare module BABYLON {
  143168. interface Mesh {
  143169. /**
  143170. * Creates a new thin instance
  143171. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143172. * @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
  143173. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143174. */
  143175. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143176. /**
  143177. * Adds the transformation (matrix) of the current mesh as a thin instance
  143178. * @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
  143179. * @returns the thin instance index number
  143180. */
  143181. thinInstanceAddSelf(refresh: boolean): number;
  143182. /**
  143183. * Registers a custom attribute to be used with thin instances
  143184. * @param kind name of the attribute
  143185. * @param stride size in floats of the attribute
  143186. */
  143187. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143188. /**
  143189. * Sets the matrix of a thin instance
  143190. * @param index index of the thin instance
  143191. * @param matrix matrix to set
  143192. * @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
  143193. */
  143194. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143195. /**
  143196. * Sets the value of a custom attribute for a thin instance
  143197. * @param kind name of the attribute
  143198. * @param index index of the thin instance
  143199. * @param value value to set
  143200. * @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
  143201. */
  143202. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143203. /**
  143204. * 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.
  143205. */
  143206. thinInstanceCount: number;
  143207. /**
  143208. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143209. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143210. * @param buffer buffer to set
  143211. * @param stride size in floats of each value of the buffer
  143212. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143213. */
  143214. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143215. /**
  143216. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143217. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143218. */
  143219. thinInstanceBufferUpdated(kind: string): void;
  143220. /**
  143221. * Refreshes the bounding info, taking into account all the thin instances defined
  143222. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143223. */
  143224. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143225. /** @hidden */
  143226. _thinInstanceInitializeUserStorage(): void;
  143227. /** @hidden */
  143228. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143229. /** @hidden */
  143230. _userThinInstanceBuffersStorage: {
  143231. data: {
  143232. [key: string]: Float32Array;
  143233. };
  143234. sizes: {
  143235. [key: string]: number;
  143236. };
  143237. vertexBuffers: {
  143238. [key: string]: Nullable<VertexBuffer>;
  143239. };
  143240. strides: {
  143241. [key: string]: number;
  143242. };
  143243. };
  143244. }
  143245. }
  143246. declare module BABYLON {
  143247. /**
  143248. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143249. */
  143250. export interface INavigationEnginePlugin {
  143251. /**
  143252. * plugin name
  143253. */
  143254. name: string;
  143255. /**
  143256. * Creates a navigation mesh
  143257. * @param meshes array of all the geometry used to compute the navigatio mesh
  143258. * @param parameters bunch of parameters used to filter geometry
  143259. */
  143260. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143261. /**
  143262. * Create a navigation mesh debug mesh
  143263. * @param scene is where the mesh will be added
  143264. * @returns debug display mesh
  143265. */
  143266. createDebugNavMesh(scene: Scene): Mesh;
  143267. /**
  143268. * Get a navigation mesh constrained position, closest to the parameter position
  143269. * @param position world position
  143270. * @returns the closest point to position constrained by the navigation mesh
  143271. */
  143272. getClosestPoint(position: Vector3): Vector3;
  143273. /**
  143274. * Get a navigation mesh constrained position, closest to the parameter position
  143275. * @param position world position
  143276. * @param result output the closest point to position constrained by the navigation mesh
  143277. */
  143278. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143279. /**
  143280. * Get a navigation mesh constrained position, within a particular radius
  143281. * @param position world position
  143282. * @param maxRadius the maximum distance to the constrained world position
  143283. * @returns the closest point to position constrained by the navigation mesh
  143284. */
  143285. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143286. /**
  143287. * Get a navigation mesh constrained position, within a particular radius
  143288. * @param position world position
  143289. * @param maxRadius the maximum distance to the constrained world position
  143290. * @param result output the closest point to position constrained by the navigation mesh
  143291. */
  143292. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143293. /**
  143294. * Compute the final position from a segment made of destination-position
  143295. * @param position world position
  143296. * @param destination world position
  143297. * @returns the resulting point along the navmesh
  143298. */
  143299. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143300. /**
  143301. * Compute the final position from a segment made of destination-position
  143302. * @param position world position
  143303. * @param destination world position
  143304. * @param result output the resulting point along the navmesh
  143305. */
  143306. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143307. /**
  143308. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143309. * @param start world position
  143310. * @param end world position
  143311. * @returns array containing world position composing the path
  143312. */
  143313. computePath(start: Vector3, end: Vector3): Vector3[];
  143314. /**
  143315. * If this plugin is supported
  143316. * @returns true if plugin is supported
  143317. */
  143318. isSupported(): boolean;
  143319. /**
  143320. * Create a new Crowd so you can add agents
  143321. * @param maxAgents the maximum agent count in the crowd
  143322. * @param maxAgentRadius the maximum radius an agent can have
  143323. * @param scene to attach the crowd to
  143324. * @returns the crowd you can add agents to
  143325. */
  143326. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143327. /**
  143328. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143329. * The queries will try to find a solution within those bounds
  143330. * default is (1,1,1)
  143331. * @param extent x,y,z value that define the extent around the queries point of reference
  143332. */
  143333. setDefaultQueryExtent(extent: Vector3): void;
  143334. /**
  143335. * Get the Bounding box extent specified by setDefaultQueryExtent
  143336. * @returns the box extent values
  143337. */
  143338. getDefaultQueryExtent(): Vector3;
  143339. /**
  143340. * build the navmesh from a previously saved state using getNavmeshData
  143341. * @param data the Uint8Array returned by getNavmeshData
  143342. */
  143343. buildFromNavmeshData(data: Uint8Array): void;
  143344. /**
  143345. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143346. * @returns data the Uint8Array that can be saved and reused
  143347. */
  143348. getNavmeshData(): Uint8Array;
  143349. /**
  143350. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143351. * @param result output the box extent values
  143352. */
  143353. getDefaultQueryExtentToRef(result: Vector3): void;
  143354. /**
  143355. * Release all resources
  143356. */
  143357. dispose(): void;
  143358. }
  143359. /**
  143360. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143361. */
  143362. export interface ICrowd {
  143363. /**
  143364. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143365. * You can attach anything to that node. The node position is updated in the scene update tick.
  143366. * @param pos world position that will be constrained by the navigation mesh
  143367. * @param parameters agent parameters
  143368. * @param transform hooked to the agent that will be update by the scene
  143369. * @returns agent index
  143370. */
  143371. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143372. /**
  143373. * Returns the agent position in world space
  143374. * @param index agent index returned by addAgent
  143375. * @returns world space position
  143376. */
  143377. getAgentPosition(index: number): Vector3;
  143378. /**
  143379. * Gets the agent position result in world space
  143380. * @param index agent index returned by addAgent
  143381. * @param result output world space position
  143382. */
  143383. getAgentPositionToRef(index: number, result: Vector3): void;
  143384. /**
  143385. * Gets the agent velocity in world space
  143386. * @param index agent index returned by addAgent
  143387. * @returns world space velocity
  143388. */
  143389. getAgentVelocity(index: number): Vector3;
  143390. /**
  143391. * Gets the agent velocity result in world space
  143392. * @param index agent index returned by addAgent
  143393. * @param result output world space velocity
  143394. */
  143395. getAgentVelocityToRef(index: number, result: Vector3): void;
  143396. /**
  143397. * remove a particular agent previously created
  143398. * @param index agent index returned by addAgent
  143399. */
  143400. removeAgent(index: number): void;
  143401. /**
  143402. * get the list of all agents attached to this crowd
  143403. * @returns list of agent indices
  143404. */
  143405. getAgents(): number[];
  143406. /**
  143407. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143408. * @param deltaTime in seconds
  143409. */
  143410. update(deltaTime: number): void;
  143411. /**
  143412. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143413. * @param index agent index returned by addAgent
  143414. * @param destination targeted world position
  143415. */
  143416. agentGoto(index: number, destination: Vector3): void;
  143417. /**
  143418. * Teleport the agent to a new position
  143419. * @param index agent index returned by addAgent
  143420. * @param destination targeted world position
  143421. */
  143422. agentTeleport(index: number, destination: Vector3): void;
  143423. /**
  143424. * Update agent parameters
  143425. * @param index agent index returned by addAgent
  143426. * @param parameters agent parameters
  143427. */
  143428. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143429. /**
  143430. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143431. * The queries will try to find a solution within those bounds
  143432. * default is (1,1,1)
  143433. * @param extent x,y,z value that define the extent around the queries point of reference
  143434. */
  143435. setDefaultQueryExtent(extent: Vector3): void;
  143436. /**
  143437. * Get the Bounding box extent specified by setDefaultQueryExtent
  143438. * @returns the box extent values
  143439. */
  143440. getDefaultQueryExtent(): Vector3;
  143441. /**
  143442. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143443. * @param result output the box extent values
  143444. */
  143445. getDefaultQueryExtentToRef(result: Vector3): void;
  143446. /**
  143447. * Release all resources
  143448. */
  143449. dispose(): void;
  143450. }
  143451. /**
  143452. * Configures an agent
  143453. */
  143454. export interface IAgentParameters {
  143455. /**
  143456. * Agent radius. [Limit: >= 0]
  143457. */
  143458. radius: number;
  143459. /**
  143460. * Agent height. [Limit: > 0]
  143461. */
  143462. height: number;
  143463. /**
  143464. * Maximum allowed acceleration. [Limit: >= 0]
  143465. */
  143466. maxAcceleration: number;
  143467. /**
  143468. * Maximum allowed speed. [Limit: >= 0]
  143469. */
  143470. maxSpeed: number;
  143471. /**
  143472. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143473. */
  143474. collisionQueryRange: number;
  143475. /**
  143476. * The path visibility optimization range. [Limit: > 0]
  143477. */
  143478. pathOptimizationRange: number;
  143479. /**
  143480. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143481. */
  143482. separationWeight: number;
  143483. }
  143484. /**
  143485. * Configures the navigation mesh creation
  143486. */
  143487. export interface INavMeshParameters {
  143488. /**
  143489. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143490. */
  143491. cs: number;
  143492. /**
  143493. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143494. */
  143495. ch: number;
  143496. /**
  143497. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143498. */
  143499. walkableSlopeAngle: number;
  143500. /**
  143501. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143502. * be considered walkable. [Limit: >= 3] [Units: vx]
  143503. */
  143504. walkableHeight: number;
  143505. /**
  143506. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143507. */
  143508. walkableClimb: number;
  143509. /**
  143510. * The distance to erode/shrink the walkable area of the heightfield away from
  143511. * obstructions. [Limit: >=0] [Units: vx]
  143512. */
  143513. walkableRadius: number;
  143514. /**
  143515. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143516. */
  143517. maxEdgeLen: number;
  143518. /**
  143519. * The maximum distance a simplfied contour's border edges should deviate
  143520. * the original raw contour. [Limit: >=0] [Units: vx]
  143521. */
  143522. maxSimplificationError: number;
  143523. /**
  143524. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143525. */
  143526. minRegionArea: number;
  143527. /**
  143528. * Any regions with a span count smaller than this value will, if possible,
  143529. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143530. */
  143531. mergeRegionArea: number;
  143532. /**
  143533. * The maximum number of vertices allowed for polygons generated during the
  143534. * contour to polygon conversion process. [Limit: >= 3]
  143535. */
  143536. maxVertsPerPoly: number;
  143537. /**
  143538. * Sets the sampling distance to use when generating the detail mesh.
  143539. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143540. */
  143541. detailSampleDist: number;
  143542. /**
  143543. * The maximum distance the detail mesh surface should deviate from heightfield
  143544. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143545. */
  143546. detailSampleMaxError: number;
  143547. }
  143548. }
  143549. declare module BABYLON {
  143550. /**
  143551. * RecastJS navigation plugin
  143552. */
  143553. export class RecastJSPlugin implements INavigationEnginePlugin {
  143554. /**
  143555. * Reference to the Recast library
  143556. */
  143557. bjsRECAST: any;
  143558. /**
  143559. * plugin name
  143560. */
  143561. name: string;
  143562. /**
  143563. * the first navmesh created. We might extend this to support multiple navmeshes
  143564. */
  143565. navMesh: any;
  143566. /**
  143567. * Initializes the recastJS plugin
  143568. * @param recastInjection can be used to inject your own recast reference
  143569. */
  143570. constructor(recastInjection?: any);
  143571. /**
  143572. * Creates a navigation mesh
  143573. * @param meshes array of all the geometry used to compute the navigatio mesh
  143574. * @param parameters bunch of parameters used to filter geometry
  143575. */
  143576. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143577. /**
  143578. * Create a navigation mesh debug mesh
  143579. * @param scene is where the mesh will be added
  143580. * @returns debug display mesh
  143581. */
  143582. createDebugNavMesh(scene: Scene): Mesh;
  143583. /**
  143584. * Get a navigation mesh constrained position, closest to the parameter position
  143585. * @param position world position
  143586. * @returns the closest point to position constrained by the navigation mesh
  143587. */
  143588. getClosestPoint(position: Vector3): Vector3;
  143589. /**
  143590. * Get a navigation mesh constrained position, closest to the parameter position
  143591. * @param position world position
  143592. * @param result output the closest point to position constrained by the navigation mesh
  143593. */
  143594. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143595. /**
  143596. * Get a navigation mesh constrained position, within a particular radius
  143597. * @param position world position
  143598. * @param maxRadius the maximum distance to the constrained world position
  143599. * @returns the closest point to position constrained by the navigation mesh
  143600. */
  143601. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143602. /**
  143603. * Get a navigation mesh constrained position, within a particular radius
  143604. * @param position world position
  143605. * @param maxRadius the maximum distance to the constrained world position
  143606. * @param result output the closest point to position constrained by the navigation mesh
  143607. */
  143608. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143609. /**
  143610. * Compute the final position from a segment made of destination-position
  143611. * @param position world position
  143612. * @param destination world position
  143613. * @returns the resulting point along the navmesh
  143614. */
  143615. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143616. /**
  143617. * Compute the final position from a segment made of destination-position
  143618. * @param position world position
  143619. * @param destination world position
  143620. * @param result output the resulting point along the navmesh
  143621. */
  143622. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143623. /**
  143624. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143625. * @param start world position
  143626. * @param end world position
  143627. * @returns array containing world position composing the path
  143628. */
  143629. computePath(start: Vector3, end: Vector3): Vector3[];
  143630. /**
  143631. * Create a new Crowd so you can add agents
  143632. * @param maxAgents the maximum agent count in the crowd
  143633. * @param maxAgentRadius the maximum radius an agent can have
  143634. * @param scene to attach the crowd to
  143635. * @returns the crowd you can add agents to
  143636. */
  143637. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143638. /**
  143639. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143640. * The queries will try to find a solution within those bounds
  143641. * default is (1,1,1)
  143642. * @param extent x,y,z value that define the extent around the queries point of reference
  143643. */
  143644. setDefaultQueryExtent(extent: Vector3): void;
  143645. /**
  143646. * Get the Bounding box extent specified by setDefaultQueryExtent
  143647. * @returns the box extent values
  143648. */
  143649. getDefaultQueryExtent(): Vector3;
  143650. /**
  143651. * build the navmesh from a previously saved state using getNavmeshData
  143652. * @param data the Uint8Array returned by getNavmeshData
  143653. */
  143654. buildFromNavmeshData(data: Uint8Array): void;
  143655. /**
  143656. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143657. * @returns data the Uint8Array that can be saved and reused
  143658. */
  143659. getNavmeshData(): Uint8Array;
  143660. /**
  143661. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143662. * @param result output the box extent values
  143663. */
  143664. getDefaultQueryExtentToRef(result: Vector3): void;
  143665. /**
  143666. * Disposes
  143667. */
  143668. dispose(): void;
  143669. /**
  143670. * If this plugin is supported
  143671. * @returns true if plugin is supported
  143672. */
  143673. isSupported(): boolean;
  143674. }
  143675. /**
  143676. * Recast detour crowd implementation
  143677. */
  143678. export class RecastJSCrowd implements ICrowd {
  143679. /**
  143680. * Recast/detour plugin
  143681. */
  143682. bjsRECASTPlugin: RecastJSPlugin;
  143683. /**
  143684. * Link to the detour crowd
  143685. */
  143686. recastCrowd: any;
  143687. /**
  143688. * One transform per agent
  143689. */
  143690. transforms: TransformNode[];
  143691. /**
  143692. * All agents created
  143693. */
  143694. agents: number[];
  143695. /**
  143696. * Link to the scene is kept to unregister the crowd from the scene
  143697. */
  143698. private _scene;
  143699. /**
  143700. * Observer for crowd updates
  143701. */
  143702. private _onBeforeAnimationsObserver;
  143703. /**
  143704. * Constructor
  143705. * @param plugin recastJS plugin
  143706. * @param maxAgents the maximum agent count in the crowd
  143707. * @param maxAgentRadius the maximum radius an agent can have
  143708. * @param scene to attach the crowd to
  143709. * @returns the crowd you can add agents to
  143710. */
  143711. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143712. /**
  143713. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143714. * You can attach anything to that node. The node position is updated in the scene update tick.
  143715. * @param pos world position that will be constrained by the navigation mesh
  143716. * @param parameters agent parameters
  143717. * @param transform hooked to the agent that will be update by the scene
  143718. * @returns agent index
  143719. */
  143720. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143721. /**
  143722. * Returns the agent position in world space
  143723. * @param index agent index returned by addAgent
  143724. * @returns world space position
  143725. */
  143726. getAgentPosition(index: number): Vector3;
  143727. /**
  143728. * Returns the agent position result in world space
  143729. * @param index agent index returned by addAgent
  143730. * @param result output world space position
  143731. */
  143732. getAgentPositionToRef(index: number, result: Vector3): void;
  143733. /**
  143734. * Returns the agent velocity in world space
  143735. * @param index agent index returned by addAgent
  143736. * @returns world space velocity
  143737. */
  143738. getAgentVelocity(index: number): Vector3;
  143739. /**
  143740. * Returns the agent velocity result in world space
  143741. * @param index agent index returned by addAgent
  143742. * @param result output world space velocity
  143743. */
  143744. getAgentVelocityToRef(index: number, result: Vector3): void;
  143745. /**
  143746. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143747. * @param index agent index returned by addAgent
  143748. * @param destination targeted world position
  143749. */
  143750. agentGoto(index: number, destination: Vector3): void;
  143751. /**
  143752. * Teleport the agent to a new position
  143753. * @param index agent index returned by addAgent
  143754. * @param destination targeted world position
  143755. */
  143756. agentTeleport(index: number, destination: Vector3): void;
  143757. /**
  143758. * Update agent parameters
  143759. * @param index agent index returned by addAgent
  143760. * @param parameters agent parameters
  143761. */
  143762. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143763. /**
  143764. * remove a particular agent previously created
  143765. * @param index agent index returned by addAgent
  143766. */
  143767. removeAgent(index: number): void;
  143768. /**
  143769. * get the list of all agents attached to this crowd
  143770. * @returns list of agent indices
  143771. */
  143772. getAgents(): number[];
  143773. /**
  143774. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143775. * @param deltaTime in seconds
  143776. */
  143777. update(deltaTime: number): void;
  143778. /**
  143779. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143780. * The queries will try to find a solution within those bounds
  143781. * default is (1,1,1)
  143782. * @param extent x,y,z value that define the extent around the queries point of reference
  143783. */
  143784. setDefaultQueryExtent(extent: Vector3): void;
  143785. /**
  143786. * Get the Bounding box extent specified by setDefaultQueryExtent
  143787. * @returns the box extent values
  143788. */
  143789. getDefaultQueryExtent(): Vector3;
  143790. /**
  143791. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143792. * @param result output the box extent values
  143793. */
  143794. getDefaultQueryExtentToRef(result: Vector3): void;
  143795. /**
  143796. * Release all resources
  143797. */
  143798. dispose(): void;
  143799. }
  143800. }
  143801. declare module BABYLON {
  143802. /**
  143803. * Class used to enable access to IndexedDB
  143804. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  143805. */
  143806. export class Database implements IOfflineProvider {
  143807. private _callbackManifestChecked;
  143808. private _currentSceneUrl;
  143809. private _db;
  143810. private _enableSceneOffline;
  143811. private _enableTexturesOffline;
  143812. private _manifestVersionFound;
  143813. private _mustUpdateRessources;
  143814. private _hasReachedQuota;
  143815. private _isSupported;
  143816. private _idbFactory;
  143817. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  143818. private static IsUASupportingBlobStorage;
  143819. /**
  143820. * Gets a boolean indicating if Database storate is enabled (off by default)
  143821. */
  143822. static IDBStorageEnabled: boolean;
  143823. /**
  143824. * Gets a boolean indicating if scene must be saved in the database
  143825. */
  143826. get enableSceneOffline(): boolean;
  143827. /**
  143828. * Gets a boolean indicating if textures must be saved in the database
  143829. */
  143830. get enableTexturesOffline(): boolean;
  143831. /**
  143832. * Creates a new Database
  143833. * @param urlToScene defines the url to load the scene
  143834. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143835. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143836. */
  143837. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143838. private static _ParseURL;
  143839. private static _ReturnFullUrlLocation;
  143840. private _checkManifestFile;
  143841. /**
  143842. * Open the database and make it available
  143843. * @param successCallback defines the callback to call on success
  143844. * @param errorCallback defines the callback to call on error
  143845. */
  143846. open(successCallback: () => void, errorCallback: () => void): void;
  143847. /**
  143848. * Loads an image from the database
  143849. * @param url defines the url to load from
  143850. * @param image defines the target DOM image
  143851. */
  143852. loadImage(url: string, image: HTMLImageElement): void;
  143853. private _loadImageFromDBAsync;
  143854. private _saveImageIntoDBAsync;
  143855. private _checkVersionFromDB;
  143856. private _loadVersionFromDBAsync;
  143857. private _saveVersionIntoDBAsync;
  143858. /**
  143859. * Loads a file from database
  143860. * @param url defines the URL to load from
  143861. * @param sceneLoaded defines a callback to call on success
  143862. * @param progressCallBack defines a callback to call when progress changed
  143863. * @param errorCallback defines a callback to call on error
  143864. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143865. */
  143866. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143867. private _loadFileAsync;
  143868. private _saveFileAsync;
  143869. /**
  143870. * Validates if xhr data is correct
  143871. * @param xhr defines the request to validate
  143872. * @param dataType defines the expected data type
  143873. * @returns true if data is correct
  143874. */
  143875. private static _ValidateXHRData;
  143876. }
  143877. }
  143878. declare module BABYLON {
  143879. /** @hidden */
  143880. export var gpuUpdateParticlesPixelShader: {
  143881. name: string;
  143882. shader: string;
  143883. };
  143884. }
  143885. declare module BABYLON {
  143886. /** @hidden */
  143887. export var gpuUpdateParticlesVertexShader: {
  143888. name: string;
  143889. shader: string;
  143890. };
  143891. }
  143892. declare module BABYLON {
  143893. /** @hidden */
  143894. export var clipPlaneFragmentDeclaration2: {
  143895. name: string;
  143896. shader: string;
  143897. };
  143898. }
  143899. declare module BABYLON {
  143900. /** @hidden */
  143901. export var gpuRenderParticlesPixelShader: {
  143902. name: string;
  143903. shader: string;
  143904. };
  143905. }
  143906. declare module BABYLON {
  143907. /** @hidden */
  143908. export var clipPlaneVertexDeclaration2: {
  143909. name: string;
  143910. shader: string;
  143911. };
  143912. }
  143913. declare module BABYLON {
  143914. /** @hidden */
  143915. export var gpuRenderParticlesVertexShader: {
  143916. name: string;
  143917. shader: string;
  143918. };
  143919. }
  143920. declare module BABYLON {
  143921. /**
  143922. * This represents a GPU particle system in Babylon
  143923. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143924. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143925. */
  143926. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143927. /**
  143928. * The layer mask we are rendering the particles through.
  143929. */
  143930. layerMask: number;
  143931. private _capacity;
  143932. private _activeCount;
  143933. private _currentActiveCount;
  143934. private _accumulatedCount;
  143935. private _renderEffect;
  143936. private _updateEffect;
  143937. private _buffer0;
  143938. private _buffer1;
  143939. private _spriteBuffer;
  143940. private _updateVAO;
  143941. private _renderVAO;
  143942. private _targetIndex;
  143943. private _sourceBuffer;
  143944. private _targetBuffer;
  143945. private _engine;
  143946. private _currentRenderId;
  143947. private _started;
  143948. private _stopped;
  143949. private _timeDelta;
  143950. private _randomTexture;
  143951. private _randomTexture2;
  143952. private _attributesStrideSize;
  143953. private _updateEffectOptions;
  143954. private _randomTextureSize;
  143955. private _actualFrame;
  143956. private _customEffect;
  143957. private readonly _rawTextureWidth;
  143958. /**
  143959. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143960. */
  143961. static get IsSupported(): boolean;
  143962. /**
  143963. * An event triggered when the system is disposed.
  143964. */
  143965. onDisposeObservable: Observable<IParticleSystem>;
  143966. /**
  143967. * Gets the maximum number of particles active at the same time.
  143968. * @returns The max number of active particles.
  143969. */
  143970. getCapacity(): number;
  143971. /**
  143972. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143973. * to override the particles.
  143974. */
  143975. forceDepthWrite: boolean;
  143976. /**
  143977. * Gets or set the number of active particles
  143978. */
  143979. get activeParticleCount(): number;
  143980. set activeParticleCount(value: number);
  143981. private _preWarmDone;
  143982. /**
  143983. * Specifies if the particles are updated in emitter local space or world space.
  143984. */
  143985. isLocal: boolean;
  143986. /**
  143987. * Is this system ready to be used/rendered
  143988. * @return true if the system is ready
  143989. */
  143990. isReady(): boolean;
  143991. /**
  143992. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143993. * @returns True if it has been started, otherwise false.
  143994. */
  143995. isStarted(): boolean;
  143996. /**
  143997. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143998. * @returns True if it has been stopped, otherwise false.
  143999. */
  144000. isStopped(): boolean;
  144001. /**
  144002. * Gets a boolean indicating that the system is stopping
  144003. * @returns true if the system is currently stopping
  144004. */
  144005. isStopping(): boolean;
  144006. /**
  144007. * Gets the number of particles active at the same time.
  144008. * @returns The number of active particles.
  144009. */
  144010. getActiveCount(): number;
  144011. /**
  144012. * Starts the particle system and begins to emit
  144013. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144014. */
  144015. start(delay?: number): void;
  144016. /**
  144017. * Stops the particle system.
  144018. */
  144019. stop(): void;
  144020. /**
  144021. * Remove all active particles
  144022. */
  144023. reset(): void;
  144024. /**
  144025. * Returns the string "GPUParticleSystem"
  144026. * @returns a string containing the class name
  144027. */
  144028. getClassName(): string;
  144029. /**
  144030. * Gets the custom effect used to render the particles
  144031. * @param blendMode Blend mode for which the effect should be retrieved
  144032. * @returns The effect
  144033. */
  144034. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144035. /**
  144036. * Sets the custom effect used to render the particles
  144037. * @param effect The effect to set
  144038. * @param blendMode Blend mode for which the effect should be set
  144039. */
  144040. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144041. /** @hidden */
  144042. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144043. /**
  144044. * Observable that will be called just before the particles are drawn
  144045. */
  144046. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144047. /**
  144048. * Gets the name of the particle vertex shader
  144049. */
  144050. get vertexShaderName(): string;
  144051. private _colorGradientsTexture;
  144052. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144053. /**
  144054. * Adds a new color gradient
  144055. * @param gradient defines the gradient to use (between 0 and 1)
  144056. * @param color1 defines the color to affect to the specified gradient
  144057. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144058. * @returns the current particle system
  144059. */
  144060. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144061. private _refreshColorGradient;
  144062. /** Force the system to rebuild all gradients that need to be resync */
  144063. forceRefreshGradients(): void;
  144064. /**
  144065. * Remove a specific color gradient
  144066. * @param gradient defines the gradient to remove
  144067. * @returns the current particle system
  144068. */
  144069. removeColorGradient(gradient: number): GPUParticleSystem;
  144070. private _angularSpeedGradientsTexture;
  144071. private _sizeGradientsTexture;
  144072. private _velocityGradientsTexture;
  144073. private _limitVelocityGradientsTexture;
  144074. private _dragGradientsTexture;
  144075. private _addFactorGradient;
  144076. /**
  144077. * Adds a new size gradient
  144078. * @param gradient defines the gradient to use (between 0 and 1)
  144079. * @param factor defines the size factor to affect to the specified gradient
  144080. * @returns the current particle system
  144081. */
  144082. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144083. /**
  144084. * Remove a specific size gradient
  144085. * @param gradient defines the gradient to remove
  144086. * @returns the current particle system
  144087. */
  144088. removeSizeGradient(gradient: number): GPUParticleSystem;
  144089. private _refreshFactorGradient;
  144090. /**
  144091. * Adds a new angular speed gradient
  144092. * @param gradient defines the gradient to use (between 0 and 1)
  144093. * @param factor defines the angular speed to affect to the specified gradient
  144094. * @returns the current particle system
  144095. */
  144096. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144097. /**
  144098. * Remove a specific angular speed gradient
  144099. * @param gradient defines the gradient to remove
  144100. * @returns the current particle system
  144101. */
  144102. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144103. /**
  144104. * Adds a new velocity gradient
  144105. * @param gradient defines the gradient to use (between 0 and 1)
  144106. * @param factor defines the velocity to affect to the specified gradient
  144107. * @returns the current particle system
  144108. */
  144109. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144110. /**
  144111. * Remove a specific velocity gradient
  144112. * @param gradient defines the gradient to remove
  144113. * @returns the current particle system
  144114. */
  144115. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144116. /**
  144117. * Adds a new limit velocity gradient
  144118. * @param gradient defines the gradient to use (between 0 and 1)
  144119. * @param factor defines the limit velocity value to affect to the specified gradient
  144120. * @returns the current particle system
  144121. */
  144122. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144123. /**
  144124. * Remove a specific limit velocity gradient
  144125. * @param gradient defines the gradient to remove
  144126. * @returns the current particle system
  144127. */
  144128. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144129. /**
  144130. * Adds a new drag gradient
  144131. * @param gradient defines the gradient to use (between 0 and 1)
  144132. * @param factor defines the drag value to affect to the specified gradient
  144133. * @returns the current particle system
  144134. */
  144135. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144136. /**
  144137. * Remove a specific drag gradient
  144138. * @param gradient defines the gradient to remove
  144139. * @returns the current particle system
  144140. */
  144141. removeDragGradient(gradient: number): GPUParticleSystem;
  144142. /**
  144143. * Not supported by GPUParticleSystem
  144144. * @param gradient defines the gradient to use (between 0 and 1)
  144145. * @param factor defines the emit rate value to affect to the specified gradient
  144146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144147. * @returns the current particle system
  144148. */
  144149. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144150. /**
  144151. * Not supported by GPUParticleSystem
  144152. * @param gradient defines the gradient to remove
  144153. * @returns the current particle system
  144154. */
  144155. removeEmitRateGradient(gradient: number): IParticleSystem;
  144156. /**
  144157. * Not supported by GPUParticleSystem
  144158. * @param gradient defines the gradient to use (between 0 and 1)
  144159. * @param factor defines the start size value to affect to the specified gradient
  144160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144161. * @returns the current particle system
  144162. */
  144163. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144164. /**
  144165. * Not supported by GPUParticleSystem
  144166. * @param gradient defines the gradient to remove
  144167. * @returns the current particle system
  144168. */
  144169. removeStartSizeGradient(gradient: number): IParticleSystem;
  144170. /**
  144171. * Not supported by GPUParticleSystem
  144172. * @param gradient defines the gradient to use (between 0 and 1)
  144173. * @param min defines the color remap minimal range
  144174. * @param max defines the color remap maximal range
  144175. * @returns the current particle system
  144176. */
  144177. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144178. /**
  144179. * Not supported by GPUParticleSystem
  144180. * @param gradient defines the gradient to remove
  144181. * @returns the current particle system
  144182. */
  144183. removeColorRemapGradient(): IParticleSystem;
  144184. /**
  144185. * Not supported by GPUParticleSystem
  144186. * @param gradient defines the gradient to use (between 0 and 1)
  144187. * @param min defines the alpha remap minimal range
  144188. * @param max defines the alpha remap maximal range
  144189. * @returns the current particle system
  144190. */
  144191. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144192. /**
  144193. * Not supported by GPUParticleSystem
  144194. * @param gradient defines the gradient to remove
  144195. * @returns the current particle system
  144196. */
  144197. removeAlphaRemapGradient(): IParticleSystem;
  144198. /**
  144199. * Not supported by GPUParticleSystem
  144200. * @param gradient defines the gradient to use (between 0 and 1)
  144201. * @param color defines the color to affect to the specified gradient
  144202. * @returns the current particle system
  144203. */
  144204. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144205. /**
  144206. * Not supported by GPUParticleSystem
  144207. * @param gradient defines the gradient to remove
  144208. * @returns the current particle system
  144209. */
  144210. removeRampGradient(): IParticleSystem;
  144211. /**
  144212. * Not supported by GPUParticleSystem
  144213. * @returns the list of ramp gradients
  144214. */
  144215. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144216. /**
  144217. * Not supported by GPUParticleSystem
  144218. * Gets or sets a boolean indicating that ramp gradients must be used
  144219. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144220. */
  144221. get useRampGradients(): boolean;
  144222. set useRampGradients(value: boolean);
  144223. /**
  144224. * Not supported by GPUParticleSystem
  144225. * @param gradient defines the gradient to use (between 0 and 1)
  144226. * @param factor defines the life time factor to affect to the specified gradient
  144227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144228. * @returns the current particle system
  144229. */
  144230. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144231. /**
  144232. * Not supported by GPUParticleSystem
  144233. * @param gradient defines the gradient to remove
  144234. * @returns the current particle system
  144235. */
  144236. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144237. /**
  144238. * Instantiates a GPU particle system.
  144239. * 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.
  144240. * @param name The name of the particle system
  144241. * @param options The options used to create the system
  144242. * @param scene The scene the particle system belongs to
  144243. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144244. * @param customEffect a custom effect used to change the way particles are rendered by default
  144245. */
  144246. constructor(name: string, options: Partial<{
  144247. capacity: number;
  144248. randomTextureSize: number;
  144249. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144250. protected _reset(): void;
  144251. private _createUpdateVAO;
  144252. private _createRenderVAO;
  144253. private _initialize;
  144254. /** @hidden */
  144255. _recreateUpdateEffect(): void;
  144256. private _getEffect;
  144257. /**
  144258. * Fill the defines array according to the current settings of the particle system
  144259. * @param defines Array to be updated
  144260. * @param blendMode blend mode to take into account when updating the array
  144261. */
  144262. fillDefines(defines: Array<string>, blendMode?: number): void;
  144263. /**
  144264. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144265. * @param uniforms Uniforms array to fill
  144266. * @param attributes Attributes array to fill
  144267. * @param samplers Samplers array to fill
  144268. */
  144269. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144270. /** @hidden */
  144271. _recreateRenderEffect(): Effect;
  144272. /**
  144273. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144274. * @param preWarm defines if we are in the pre-warmimg phase
  144275. */
  144276. animate(preWarm?: boolean): void;
  144277. private _createFactorGradientTexture;
  144278. private _createSizeGradientTexture;
  144279. private _createAngularSpeedGradientTexture;
  144280. private _createVelocityGradientTexture;
  144281. private _createLimitVelocityGradientTexture;
  144282. private _createDragGradientTexture;
  144283. private _createColorGradientTexture;
  144284. /**
  144285. * Renders the particle system in its current state
  144286. * @param preWarm defines if the system should only update the particles but not render them
  144287. * @returns the current number of particles
  144288. */
  144289. render(preWarm?: boolean): number;
  144290. /**
  144291. * Rebuilds the particle system
  144292. */
  144293. rebuild(): void;
  144294. private _releaseBuffers;
  144295. private _releaseVAOs;
  144296. /**
  144297. * Disposes the particle system and free the associated resources
  144298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  144299. */
  144300. dispose(disposeTexture?: boolean): void;
  144301. /**
  144302. * Clones the particle system.
  144303. * @param name The name of the cloned object
  144304. * @param newEmitter The new emitter to use
  144305. * @returns the cloned particle system
  144306. */
  144307. clone(name: string, newEmitter: any): GPUParticleSystem;
  144308. /**
  144309. * Serializes the particle system to a JSON object
  144310. * @param serializeTexture defines if the texture must be serialized as well
  144311. * @returns the JSON object
  144312. */
  144313. serialize(serializeTexture?: boolean): any;
  144314. /**
  144315. * Parses a JSON object to create a GPU particle system.
  144316. * @param parsedParticleSystem The JSON object to parse
  144317. * @param scene The scene to create the particle system in
  144318. * @param rootUrl The root url to use to load external dependencies like texture
  144319. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  144320. * @returns the parsed GPU particle system
  144321. */
  144322. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  144323. }
  144324. }
  144325. declare module BABYLON {
  144326. /**
  144327. * Represents a set of particle systems working together to create a specific effect
  144328. */
  144329. export class ParticleSystemSet implements IDisposable {
  144330. /**
  144331. * Gets or sets base Assets URL
  144332. */
  144333. static BaseAssetsUrl: string;
  144334. private _emitterCreationOptions;
  144335. private _emitterNode;
  144336. /**
  144337. * Gets the particle system list
  144338. */
  144339. systems: IParticleSystem[];
  144340. /**
  144341. * Gets the emitter node used with this set
  144342. */
  144343. get emitterNode(): Nullable<TransformNode>;
  144344. /**
  144345. * Creates a new emitter mesh as a sphere
  144346. * @param options defines the options used to create the sphere
  144347. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  144348. * @param scene defines the hosting scene
  144349. */
  144350. setEmitterAsSphere(options: {
  144351. diameter: number;
  144352. segments: number;
  144353. color: Color3;
  144354. }, renderingGroupId: number, scene: Scene): void;
  144355. /**
  144356. * Starts all particle systems of the set
  144357. * @param emitter defines an optional mesh to use as emitter for the particle systems
  144358. */
  144359. start(emitter?: AbstractMesh): void;
  144360. /**
  144361. * Release all associated resources
  144362. */
  144363. dispose(): void;
  144364. /**
  144365. * Serialize the set into a JSON compatible object
  144366. * @param serializeTexture defines if the texture must be serialized as well
  144367. * @returns a JSON compatible representation of the set
  144368. */
  144369. serialize(serializeTexture?: boolean): any;
  144370. /**
  144371. * Parse a new ParticleSystemSet from a serialized source
  144372. * @param data defines a JSON compatible representation of the set
  144373. * @param scene defines the hosting scene
  144374. * @param gpu defines if we want GPU particles or CPU particles
  144375. * @returns a new ParticleSystemSet
  144376. */
  144377. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144378. }
  144379. }
  144380. declare module BABYLON {
  144381. /**
  144382. * This class is made for on one-liner static method to help creating particle system set.
  144383. */
  144384. export class ParticleHelper {
  144385. /**
  144386. * Gets or sets base Assets URL
  144387. */
  144388. static BaseAssetsUrl: string;
  144389. /** Define the Url to load snippets */
  144390. static SnippetUrl: string;
  144391. /**
  144392. * Create a default particle system that you can tweak
  144393. * @param emitter defines the emitter to use
  144394. * @param capacity defines the system capacity (default is 500 particles)
  144395. * @param scene defines the hosting scene
  144396. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144397. * @returns the new Particle system
  144398. */
  144399. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144400. /**
  144401. * This is the main static method (one-liner) of this helper to create different particle systems
  144402. * @param type This string represents the type to the particle system to create
  144403. * @param scene The scene where the particle system should live
  144404. * @param gpu If the system will use gpu
  144405. * @returns the ParticleSystemSet created
  144406. */
  144407. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144408. /**
  144409. * Static function used to export a particle system to a ParticleSystemSet variable.
  144410. * Please note that the emitter shape is not exported
  144411. * @param systems defines the particle systems to export
  144412. * @returns the created particle system set
  144413. */
  144414. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144415. /**
  144416. * Creates a particle system from a snippet saved in a remote file
  144417. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144418. * @param url defines the url to load from
  144419. * @param scene defines the hosting scene
  144420. * @param gpu If the system will use gpu
  144421. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144422. * @returns a promise that will resolve to the new particle system
  144423. */
  144424. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144425. /**
  144426. * Creates a particle system from a snippet saved by the particle system editor
  144427. * @param snippetId defines the snippet to load
  144428. * @param scene defines the hosting scene
  144429. * @param gpu If the system will use gpu
  144430. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144431. * @returns a promise that will resolve to the new particle system
  144432. */
  144433. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144434. }
  144435. }
  144436. declare module BABYLON {
  144437. interface Engine {
  144438. /**
  144439. * Create an effect to use with particle systems.
  144440. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144441. * the particle system for which you want to create a custom effect in the last parameter
  144442. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144443. * @param uniformsNames defines a list of attribute names
  144444. * @param samplers defines an array of string used to represent textures
  144445. * @param defines defines the string containing the defines to use to compile the shaders
  144446. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144447. * @param onCompiled defines a function to call when the effect creation is successful
  144448. * @param onError defines a function to call when the effect creation has failed
  144449. * @param particleSystem the particle system you want to create the effect for
  144450. * @returns the new Effect
  144451. */
  144452. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144453. }
  144454. interface Mesh {
  144455. /**
  144456. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144457. * @returns an array of IParticleSystem
  144458. */
  144459. getEmittedParticleSystems(): IParticleSystem[];
  144460. /**
  144461. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144462. * @returns an array of IParticleSystem
  144463. */
  144464. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144465. }
  144466. }
  144467. declare module BABYLON {
  144468. /** Defines the 4 color options */
  144469. export enum PointColor {
  144470. /** color value */
  144471. Color = 2,
  144472. /** uv value */
  144473. UV = 1,
  144474. /** random value */
  144475. Random = 0,
  144476. /** stated value */
  144477. Stated = 3
  144478. }
  144479. /**
  144480. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144481. * 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.
  144482. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144483. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144484. *
  144485. * Full documentation here : TO BE ENTERED
  144486. */
  144487. export class PointsCloudSystem implements IDisposable {
  144488. /**
  144489. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144490. * Example : var p = SPS.particles[i];
  144491. */
  144492. particles: CloudPoint[];
  144493. /**
  144494. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144495. */
  144496. nbParticles: number;
  144497. /**
  144498. * This a counter for your own usage. It's not set by any SPS functions.
  144499. */
  144500. counter: number;
  144501. /**
  144502. * The PCS name. This name is also given to the underlying mesh.
  144503. */
  144504. name: string;
  144505. /**
  144506. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144507. */
  144508. mesh: Mesh;
  144509. /**
  144510. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144511. * Please read :
  144512. */
  144513. vars: any;
  144514. /**
  144515. * @hidden
  144516. */
  144517. _size: number;
  144518. private _scene;
  144519. private _promises;
  144520. private _positions;
  144521. private _indices;
  144522. private _normals;
  144523. private _colors;
  144524. private _uvs;
  144525. private _indices32;
  144526. private _positions32;
  144527. private _colors32;
  144528. private _uvs32;
  144529. private _updatable;
  144530. private _isVisibilityBoxLocked;
  144531. private _alwaysVisible;
  144532. private _groups;
  144533. private _groupCounter;
  144534. private _computeParticleColor;
  144535. private _computeParticleTexture;
  144536. private _computeParticleRotation;
  144537. private _computeBoundingBox;
  144538. private _isReady;
  144539. /**
  144540. * Creates a PCS (Points Cloud System) object
  144541. * @param name (String) is the PCS name, this will be the underlying mesh name
  144542. * @param pointSize (number) is the size for each point
  144543. * @param scene (Scene) is the scene in which the PCS is added
  144544. * @param options defines the options of the PCS e.g.
  144545. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144546. */
  144547. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144548. updatable?: boolean;
  144549. });
  144550. /**
  144551. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144552. * If no points were added to the PCS, the returned mesh is just a single point.
  144553. * @returns a promise for the created mesh
  144554. */
  144555. buildMeshAsync(): Promise<Mesh>;
  144556. /**
  144557. * @hidden
  144558. */
  144559. private _buildMesh;
  144560. private _addParticle;
  144561. private _randomUnitVector;
  144562. private _getColorIndicesForCoord;
  144563. private _setPointsColorOrUV;
  144564. private _colorFromTexture;
  144565. private _calculateDensity;
  144566. /**
  144567. * Adds points to the PCS in random positions within a unit sphere
  144568. * @param nb (positive integer) the number of particles to be created from this model
  144569. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144570. * @returns the number of groups in the system
  144571. */
  144572. addPoints(nb: number, pointFunction?: any): number;
  144573. /**
  144574. * Adds points to the PCS from the surface of the model shape
  144575. * @param mesh is any Mesh object that will be used as a surface model for the points
  144576. * @param nb (positive integer) the number of particles to be created from this model
  144577. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144578. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144579. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144580. * @returns the number of groups in the system
  144581. */
  144582. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144583. /**
  144584. * Adds points to the PCS inside the model shape
  144585. * @param mesh is any Mesh object that will be used as a surface model for the points
  144586. * @param nb (positive integer) the number of particles to be created from this model
  144587. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144588. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144589. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144590. * @returns the number of groups in the system
  144591. */
  144592. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144593. /**
  144594. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144595. * This method calls `updateParticle()` for each particle of the SPS.
  144596. * For an animated SPS, it is usually called within the render loop.
  144597. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144598. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144599. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144600. * @returns the PCS.
  144601. */
  144602. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144603. /**
  144604. * Disposes the PCS.
  144605. */
  144606. dispose(): void;
  144607. /**
  144608. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144609. * doc :
  144610. * @returns the PCS.
  144611. */
  144612. refreshVisibleSize(): PointsCloudSystem;
  144613. /**
  144614. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144615. * @param size the size (float) of the visibility box
  144616. * note : this doesn't lock the PCS mesh bounding box.
  144617. * doc :
  144618. */
  144619. setVisibilityBox(size: number): void;
  144620. /**
  144621. * Gets whether the PCS is always visible or not
  144622. * doc :
  144623. */
  144624. get isAlwaysVisible(): boolean;
  144625. /**
  144626. * Sets the PCS as always visible or not
  144627. * doc :
  144628. */
  144629. set isAlwaysVisible(val: boolean);
  144630. /**
  144631. * Tells to `setParticles()` to compute the particle rotations or not
  144632. * Default value : false. The PCS is faster when it's set to false
  144633. * Note : particle rotations are only applied to parent particles
  144634. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144635. */
  144636. set computeParticleRotation(val: boolean);
  144637. /**
  144638. * Tells to `setParticles()` to compute the particle colors or not.
  144639. * Default value : true. The PCS is faster when it's set to false.
  144640. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144641. */
  144642. set computeParticleColor(val: boolean);
  144643. set computeParticleTexture(val: boolean);
  144644. /**
  144645. * Gets if `setParticles()` computes the particle colors or not.
  144646. * Default value : false. The PCS is faster when it's set to false.
  144647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144648. */
  144649. get computeParticleColor(): boolean;
  144650. /**
  144651. * Gets if `setParticles()` computes the particle textures or not.
  144652. * Default value : false. The PCS is faster when it's set to false.
  144653. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144654. */
  144655. get computeParticleTexture(): boolean;
  144656. /**
  144657. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144658. */
  144659. set computeBoundingBox(val: boolean);
  144660. /**
  144661. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144662. */
  144663. get computeBoundingBox(): boolean;
  144664. /**
  144665. * This function does nothing. It may be overwritten to set all the particle first values.
  144666. * The PCS doesn't call this function, you may have to call it by your own.
  144667. * doc :
  144668. */
  144669. initParticles(): void;
  144670. /**
  144671. * This function does nothing. It may be overwritten to recycle a particle
  144672. * The PCS doesn't call this function, you can to call it
  144673. * doc :
  144674. * @param particle The particle to recycle
  144675. * @returns the recycled particle
  144676. */
  144677. recycleParticle(particle: CloudPoint): CloudPoint;
  144678. /**
  144679. * Updates a particle : this function should be overwritten by the user.
  144680. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144681. * doc :
  144682. * @example : just set a particle position or velocity and recycle conditions
  144683. * @param particle The particle to update
  144684. * @returns the updated particle
  144685. */
  144686. updateParticle(particle: CloudPoint): CloudPoint;
  144687. /**
  144688. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144689. * This does nothing and may be overwritten by the user.
  144690. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144691. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144692. * @param update the boolean update value actually passed to setParticles()
  144693. */
  144694. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144695. /**
  144696. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144697. * This will be passed three parameters.
  144698. * This does nothing and may be overwritten by the user.
  144699. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144700. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144701. * @param update the boolean update value actually passed to setParticles()
  144702. */
  144703. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144704. }
  144705. }
  144706. declare module BABYLON {
  144707. /**
  144708. * Represents one particle of a points cloud system.
  144709. */
  144710. export class CloudPoint {
  144711. /**
  144712. * particle global index
  144713. */
  144714. idx: number;
  144715. /**
  144716. * The color of the particle
  144717. */
  144718. color: Nullable<Color4>;
  144719. /**
  144720. * The world space position of the particle.
  144721. */
  144722. position: Vector3;
  144723. /**
  144724. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144725. */
  144726. rotation: Vector3;
  144727. /**
  144728. * The world space rotation quaternion of the particle.
  144729. */
  144730. rotationQuaternion: Nullable<Quaternion>;
  144731. /**
  144732. * The uv of the particle.
  144733. */
  144734. uv: Nullable<Vector2>;
  144735. /**
  144736. * The current speed of the particle.
  144737. */
  144738. velocity: Vector3;
  144739. /**
  144740. * The pivot point in the particle local space.
  144741. */
  144742. pivot: Vector3;
  144743. /**
  144744. * Must the particle be translated from its pivot point in its local space ?
  144745. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  144746. * Default : false
  144747. */
  144748. translateFromPivot: boolean;
  144749. /**
  144750. * Index of this particle in the global "positions" array (Internal use)
  144751. * @hidden
  144752. */
  144753. _pos: number;
  144754. /**
  144755. * @hidden Index of this particle in the global "indices" array (Internal use)
  144756. */
  144757. _ind: number;
  144758. /**
  144759. * Group this particle belongs to
  144760. */
  144761. _group: PointsGroup;
  144762. /**
  144763. * Group id of this particle
  144764. */
  144765. groupId: number;
  144766. /**
  144767. * Index of the particle in its group id (Internal use)
  144768. */
  144769. idxInGroup: number;
  144770. /**
  144771. * @hidden Particle BoundingInfo object (Internal use)
  144772. */
  144773. _boundingInfo: BoundingInfo;
  144774. /**
  144775. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  144776. */
  144777. _pcs: PointsCloudSystem;
  144778. /**
  144779. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  144780. */
  144781. _stillInvisible: boolean;
  144782. /**
  144783. * @hidden Last computed particle rotation matrix
  144784. */
  144785. _rotationMatrix: number[];
  144786. /**
  144787. * Parent particle Id, if any.
  144788. * Default null.
  144789. */
  144790. parentId: Nullable<number>;
  144791. /**
  144792. * @hidden Internal global position in the PCS.
  144793. */
  144794. _globalPosition: Vector3;
  144795. /**
  144796. * Creates a Point Cloud object.
  144797. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  144798. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  144799. * @param group (PointsGroup) is the group the particle belongs to
  144800. * @param groupId (integer) is the group identifier in the PCS.
  144801. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  144802. * @param pcs defines the PCS it is associated to
  144803. */
  144804. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  144805. /**
  144806. * get point size
  144807. */
  144808. get size(): Vector3;
  144809. /**
  144810. * Set point size
  144811. */
  144812. set size(scale: Vector3);
  144813. /**
  144814. * Legacy support, changed quaternion to rotationQuaternion
  144815. */
  144816. get quaternion(): Nullable<Quaternion>;
  144817. /**
  144818. * Legacy support, changed quaternion to rotationQuaternion
  144819. */
  144820. set quaternion(q: Nullable<Quaternion>);
  144821. /**
  144822. * Returns a boolean. True if the particle intersects a mesh, else false
  144823. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  144824. * @param target is the object (point or mesh) what the intersection is computed against
  144825. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  144826. * @returns true if it intersects
  144827. */
  144828. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  144829. /**
  144830. * get the rotation matrix of the particle
  144831. * @hidden
  144832. */
  144833. getRotationMatrix(m: Matrix): void;
  144834. }
  144835. /**
  144836. * Represents a group of points in a points cloud system
  144837. * * PCS internal tool, don't use it manually.
  144838. */
  144839. export class PointsGroup {
  144840. /**
  144841. * The group id
  144842. * @hidden
  144843. */
  144844. groupID: number;
  144845. /**
  144846. * image data for group (internal use)
  144847. * @hidden
  144848. */
  144849. _groupImageData: Nullable<ArrayBufferView>;
  144850. /**
  144851. * Image Width (internal use)
  144852. * @hidden
  144853. */
  144854. _groupImgWidth: number;
  144855. /**
  144856. * Image Height (internal use)
  144857. * @hidden
  144858. */
  144859. _groupImgHeight: number;
  144860. /**
  144861. * Custom position function (internal use)
  144862. * @hidden
  144863. */
  144864. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144865. /**
  144866. * density per facet for surface points
  144867. * @hidden
  144868. */
  144869. _groupDensity: number[];
  144870. /**
  144871. * Only when points are colored by texture carries pointer to texture list array
  144872. * @hidden
  144873. */
  144874. _textureNb: number;
  144875. /**
  144876. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144877. * PCS internal tool, don't use it manually.
  144878. * @hidden
  144879. */
  144880. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144881. }
  144882. }
  144883. declare module BABYLON {
  144884. interface Scene {
  144885. /** @hidden (Backing field) */
  144886. _physicsEngine: Nullable<IPhysicsEngine>;
  144887. /** @hidden */
  144888. _physicsTimeAccumulator: number;
  144889. /**
  144890. * Gets the current physics engine
  144891. * @returns a IPhysicsEngine or null if none attached
  144892. */
  144893. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144894. /**
  144895. * Enables physics to the current scene
  144896. * @param gravity defines the scene's gravity for the physics engine
  144897. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144898. * @return a boolean indicating if the physics engine was initialized
  144899. */
  144900. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144901. /**
  144902. * Disables and disposes the physics engine associated with the scene
  144903. */
  144904. disablePhysicsEngine(): void;
  144905. /**
  144906. * Gets a boolean indicating if there is an active physics engine
  144907. * @returns a boolean indicating if there is an active physics engine
  144908. */
  144909. isPhysicsEnabled(): boolean;
  144910. /**
  144911. * Deletes a physics compound impostor
  144912. * @param compound defines the compound to delete
  144913. */
  144914. deleteCompoundImpostor(compound: any): void;
  144915. /**
  144916. * An event triggered when physic simulation is about to be run
  144917. */
  144918. onBeforePhysicsObservable: Observable<Scene>;
  144919. /**
  144920. * An event triggered when physic simulation has been done
  144921. */
  144922. onAfterPhysicsObservable: Observable<Scene>;
  144923. }
  144924. interface AbstractMesh {
  144925. /** @hidden */
  144926. _physicsImpostor: Nullable<PhysicsImpostor>;
  144927. /**
  144928. * Gets or sets impostor used for physic simulation
  144929. * @see http://doc.babylonjs.com/features/physics_engine
  144930. */
  144931. physicsImpostor: Nullable<PhysicsImpostor>;
  144932. /**
  144933. * Gets the current physics impostor
  144934. * @see http://doc.babylonjs.com/features/physics_engine
  144935. * @returns a physics impostor or null
  144936. */
  144937. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144938. /** Apply a physic impulse to the mesh
  144939. * @param force defines the force to apply
  144940. * @param contactPoint defines where to apply the force
  144941. * @returns the current mesh
  144942. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144943. */
  144944. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144945. /**
  144946. * Creates a physic joint between two meshes
  144947. * @param otherMesh defines the other mesh to use
  144948. * @param pivot1 defines the pivot to use on this mesh
  144949. * @param pivot2 defines the pivot to use on the other mesh
  144950. * @param options defines additional options (can be plugin dependent)
  144951. * @returns the current mesh
  144952. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144953. */
  144954. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144955. /** @hidden */
  144956. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144957. }
  144958. /**
  144959. * Defines the physics engine scene component responsible to manage a physics engine
  144960. */
  144961. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144962. /**
  144963. * The component name helpful to identify the component in the list of scene components.
  144964. */
  144965. readonly name: string;
  144966. /**
  144967. * The scene the component belongs to.
  144968. */
  144969. scene: Scene;
  144970. /**
  144971. * Creates a new instance of the component for the given scene
  144972. * @param scene Defines the scene to register the component in
  144973. */
  144974. constructor(scene: Scene);
  144975. /**
  144976. * Registers the component in a given scene
  144977. */
  144978. register(): void;
  144979. /**
  144980. * Rebuilds the elements related to this component in case of
  144981. * context lost for instance.
  144982. */
  144983. rebuild(): void;
  144984. /**
  144985. * Disposes the component and the associated ressources
  144986. */
  144987. dispose(): void;
  144988. }
  144989. }
  144990. declare module BABYLON {
  144991. /**
  144992. * A helper for physics simulations
  144993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144994. */
  144995. export class PhysicsHelper {
  144996. private _scene;
  144997. private _physicsEngine;
  144998. /**
  144999. * Initializes the Physics helper
  145000. * @param scene Babylon.js scene
  145001. */
  145002. constructor(scene: Scene);
  145003. /**
  145004. * Applies a radial explosion impulse
  145005. * @param origin the origin of the explosion
  145006. * @param radiusOrEventOptions the radius or the options of radial explosion
  145007. * @param strength the explosion strength
  145008. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145009. * @returns A physics radial explosion event, or null
  145010. */
  145011. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145012. /**
  145013. * Applies a radial explosion force
  145014. * @param origin the origin of the explosion
  145015. * @param radiusOrEventOptions the radius or the options of radial explosion
  145016. * @param strength the explosion strength
  145017. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145018. * @returns A physics radial explosion event, or null
  145019. */
  145020. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145021. /**
  145022. * Creates a gravitational field
  145023. * @param origin the origin of the explosion
  145024. * @param radiusOrEventOptions the radius or the options of radial explosion
  145025. * @param strength the explosion strength
  145026. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145027. * @returns A physics gravitational field event, or null
  145028. */
  145029. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145030. /**
  145031. * Creates a physics updraft event
  145032. * @param origin the origin of the updraft
  145033. * @param radiusOrEventOptions the radius or the options of the updraft
  145034. * @param strength the strength of the updraft
  145035. * @param height the height of the updraft
  145036. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145037. * @returns A physics updraft event, or null
  145038. */
  145039. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145040. /**
  145041. * Creates a physics vortex event
  145042. * @param origin the of the vortex
  145043. * @param radiusOrEventOptions the radius or the options of the vortex
  145044. * @param strength the strength of the vortex
  145045. * @param height the height of the vortex
  145046. * @returns a Physics vortex event, or null
  145047. * A physics vortex event or null
  145048. */
  145049. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145050. }
  145051. /**
  145052. * Represents a physics radial explosion event
  145053. */
  145054. class PhysicsRadialExplosionEvent {
  145055. private _scene;
  145056. private _options;
  145057. private _sphere;
  145058. private _dataFetched;
  145059. /**
  145060. * Initializes a radial explosioin event
  145061. * @param _scene BabylonJS scene
  145062. * @param _options The options for the vortex event
  145063. */
  145064. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145065. /**
  145066. * Returns the data related to the radial explosion event (sphere).
  145067. * @returns The radial explosion event data
  145068. */
  145069. getData(): PhysicsRadialExplosionEventData;
  145070. /**
  145071. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145072. * @param impostor A physics imposter
  145073. * @param origin the origin of the explosion
  145074. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145075. */
  145076. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145077. /**
  145078. * Triggers affecterd impostors callbacks
  145079. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145080. */
  145081. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145082. /**
  145083. * Disposes the sphere.
  145084. * @param force Specifies if the sphere should be disposed by force
  145085. */
  145086. dispose(force?: boolean): void;
  145087. /*** Helpers ***/
  145088. private _prepareSphere;
  145089. private _intersectsWithSphere;
  145090. }
  145091. /**
  145092. * Represents a gravitational field event
  145093. */
  145094. class PhysicsGravitationalFieldEvent {
  145095. private _physicsHelper;
  145096. private _scene;
  145097. private _origin;
  145098. private _options;
  145099. private _tickCallback;
  145100. private _sphere;
  145101. private _dataFetched;
  145102. /**
  145103. * Initializes the physics gravitational field event
  145104. * @param _physicsHelper A physics helper
  145105. * @param _scene BabylonJS scene
  145106. * @param _origin The origin position of the gravitational field event
  145107. * @param _options The options for the vortex event
  145108. */
  145109. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145110. /**
  145111. * Returns the data related to the gravitational field event (sphere).
  145112. * @returns A gravitational field event
  145113. */
  145114. getData(): PhysicsGravitationalFieldEventData;
  145115. /**
  145116. * Enables the gravitational field.
  145117. */
  145118. enable(): void;
  145119. /**
  145120. * Disables the gravitational field.
  145121. */
  145122. disable(): void;
  145123. /**
  145124. * Disposes the sphere.
  145125. * @param force The force to dispose from the gravitational field event
  145126. */
  145127. dispose(force?: boolean): void;
  145128. private _tick;
  145129. }
  145130. /**
  145131. * Represents a physics updraft event
  145132. */
  145133. class PhysicsUpdraftEvent {
  145134. private _scene;
  145135. private _origin;
  145136. private _options;
  145137. private _physicsEngine;
  145138. private _originTop;
  145139. private _originDirection;
  145140. private _tickCallback;
  145141. private _cylinder;
  145142. private _cylinderPosition;
  145143. private _dataFetched;
  145144. /**
  145145. * Initializes the physics updraft event
  145146. * @param _scene BabylonJS scene
  145147. * @param _origin The origin position of the updraft
  145148. * @param _options The options for the updraft event
  145149. */
  145150. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145151. /**
  145152. * Returns the data related to the updraft event (cylinder).
  145153. * @returns A physics updraft event
  145154. */
  145155. getData(): PhysicsUpdraftEventData;
  145156. /**
  145157. * Enables the updraft.
  145158. */
  145159. enable(): void;
  145160. /**
  145161. * Disables the updraft.
  145162. */
  145163. disable(): void;
  145164. /**
  145165. * Disposes the cylinder.
  145166. * @param force Specifies if the updraft should be disposed by force
  145167. */
  145168. dispose(force?: boolean): void;
  145169. private getImpostorHitData;
  145170. private _tick;
  145171. /*** Helpers ***/
  145172. private _prepareCylinder;
  145173. private _intersectsWithCylinder;
  145174. }
  145175. /**
  145176. * Represents a physics vortex event
  145177. */
  145178. class PhysicsVortexEvent {
  145179. private _scene;
  145180. private _origin;
  145181. private _options;
  145182. private _physicsEngine;
  145183. private _originTop;
  145184. private _tickCallback;
  145185. private _cylinder;
  145186. private _cylinderPosition;
  145187. private _dataFetched;
  145188. /**
  145189. * Initializes the physics vortex event
  145190. * @param _scene The BabylonJS scene
  145191. * @param _origin The origin position of the vortex
  145192. * @param _options The options for the vortex event
  145193. */
  145194. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145195. /**
  145196. * Returns the data related to the vortex event (cylinder).
  145197. * @returns The physics vortex event data
  145198. */
  145199. getData(): PhysicsVortexEventData;
  145200. /**
  145201. * Enables the vortex.
  145202. */
  145203. enable(): void;
  145204. /**
  145205. * Disables the cortex.
  145206. */
  145207. disable(): void;
  145208. /**
  145209. * Disposes the sphere.
  145210. * @param force
  145211. */
  145212. dispose(force?: boolean): void;
  145213. private getImpostorHitData;
  145214. private _tick;
  145215. /*** Helpers ***/
  145216. private _prepareCylinder;
  145217. private _intersectsWithCylinder;
  145218. }
  145219. /**
  145220. * Options fot the radial explosion event
  145221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145222. */
  145223. export class PhysicsRadialExplosionEventOptions {
  145224. /**
  145225. * The radius of the sphere for the radial explosion.
  145226. */
  145227. radius: number;
  145228. /**
  145229. * The strenth of the explosion.
  145230. */
  145231. strength: number;
  145232. /**
  145233. * The strenght of the force in correspondence to the distance of the affected object
  145234. */
  145235. falloff: PhysicsRadialImpulseFalloff;
  145236. /**
  145237. * Sphere options for the radial explosion.
  145238. */
  145239. sphere: {
  145240. segments: number;
  145241. diameter: number;
  145242. };
  145243. /**
  145244. * Sphere options for the radial explosion.
  145245. */
  145246. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145247. }
  145248. /**
  145249. * Options fot the updraft event
  145250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145251. */
  145252. export class PhysicsUpdraftEventOptions {
  145253. /**
  145254. * The radius of the cylinder for the vortex
  145255. */
  145256. radius: number;
  145257. /**
  145258. * The strenth of the updraft.
  145259. */
  145260. strength: number;
  145261. /**
  145262. * The height of the cylinder for the updraft.
  145263. */
  145264. height: number;
  145265. /**
  145266. * The mode for the the updraft.
  145267. */
  145268. updraftMode: PhysicsUpdraftMode;
  145269. }
  145270. /**
  145271. * Options fot the vortex event
  145272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145273. */
  145274. export class PhysicsVortexEventOptions {
  145275. /**
  145276. * The radius of the cylinder for the vortex
  145277. */
  145278. radius: number;
  145279. /**
  145280. * The strenth of the vortex.
  145281. */
  145282. strength: number;
  145283. /**
  145284. * The height of the cylinder for the vortex.
  145285. */
  145286. height: number;
  145287. /**
  145288. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145289. */
  145290. centripetalForceThreshold: number;
  145291. /**
  145292. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145293. */
  145294. centripetalForceMultiplier: number;
  145295. /**
  145296. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  145297. */
  145298. centrifugalForceMultiplier: number;
  145299. /**
  145300. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  145301. */
  145302. updraftForceMultiplier: number;
  145303. }
  145304. /**
  145305. * The strenght of the force in correspondence to the distance of the affected object
  145306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145307. */
  145308. export enum PhysicsRadialImpulseFalloff {
  145309. /** Defines that impulse is constant in strength across it's whole radius */
  145310. Constant = 0,
  145311. /** Defines that impulse gets weaker if it's further from the origin */
  145312. Linear = 1
  145313. }
  145314. /**
  145315. * The strength of the force in correspondence to the distance of the affected object
  145316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145317. */
  145318. export enum PhysicsUpdraftMode {
  145319. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  145320. Center = 0,
  145321. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  145322. Perpendicular = 1
  145323. }
  145324. /**
  145325. * Interface for a physics hit data
  145326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145327. */
  145328. export interface PhysicsHitData {
  145329. /**
  145330. * The force applied at the contact point
  145331. */
  145332. force: Vector3;
  145333. /**
  145334. * The contact point
  145335. */
  145336. contactPoint: Vector3;
  145337. /**
  145338. * The distance from the origin to the contact point
  145339. */
  145340. distanceFromOrigin: number;
  145341. }
  145342. /**
  145343. * Interface for radial explosion event data
  145344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145345. */
  145346. export interface PhysicsRadialExplosionEventData {
  145347. /**
  145348. * A sphere used for the radial explosion event
  145349. */
  145350. sphere: Mesh;
  145351. }
  145352. /**
  145353. * Interface for gravitational field event data
  145354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145355. */
  145356. export interface PhysicsGravitationalFieldEventData {
  145357. /**
  145358. * A sphere mesh used for the gravitational field event
  145359. */
  145360. sphere: Mesh;
  145361. }
  145362. /**
  145363. * Interface for updraft event data
  145364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145365. */
  145366. export interface PhysicsUpdraftEventData {
  145367. /**
  145368. * A cylinder used for the updraft event
  145369. */
  145370. cylinder: Mesh;
  145371. }
  145372. /**
  145373. * Interface for vortex event data
  145374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145375. */
  145376. export interface PhysicsVortexEventData {
  145377. /**
  145378. * A cylinder used for the vortex event
  145379. */
  145380. cylinder: Mesh;
  145381. }
  145382. /**
  145383. * Interface for an affected physics impostor
  145384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145385. */
  145386. export interface PhysicsAffectedImpostorWithData {
  145387. /**
  145388. * The impostor affected by the effect
  145389. */
  145390. impostor: PhysicsImpostor;
  145391. /**
  145392. * The data about the hit/horce from the explosion
  145393. */
  145394. hitData: PhysicsHitData;
  145395. }
  145396. }
  145397. declare module BABYLON {
  145398. /** @hidden */
  145399. export var blackAndWhitePixelShader: {
  145400. name: string;
  145401. shader: string;
  145402. };
  145403. }
  145404. declare module BABYLON {
  145405. /**
  145406. * Post process used to render in black and white
  145407. */
  145408. export class BlackAndWhitePostProcess extends PostProcess {
  145409. /**
  145410. * Linear about to convert he result to black and white (default: 1)
  145411. */
  145412. degree: number;
  145413. /**
  145414. * Creates a black and white post process
  145415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145416. * @param name The name of the effect.
  145417. * @param options The required width/height ratio to downsize to before computing the render pass.
  145418. * @param camera The camera to apply the render pass to.
  145419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145420. * @param engine The engine which the post process will be applied. (default: current engine)
  145421. * @param reusable If the post process can be reused on the same frame. (default: false)
  145422. */
  145423. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145424. }
  145425. }
  145426. declare module BABYLON {
  145427. /**
  145428. * This represents a set of one or more post processes in Babylon.
  145429. * A post process can be used to apply a shader to a texture after it is rendered.
  145430. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145431. */
  145432. export class PostProcessRenderEffect {
  145433. private _postProcesses;
  145434. private _getPostProcesses;
  145435. private _singleInstance;
  145436. private _cameras;
  145437. private _indicesForCamera;
  145438. /**
  145439. * Name of the effect
  145440. * @hidden
  145441. */
  145442. _name: string;
  145443. /**
  145444. * Instantiates a post process render effect.
  145445. * A post process can be used to apply a shader to a texture after it is rendered.
  145446. * @param engine The engine the effect is tied to
  145447. * @param name The name of the effect
  145448. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145449. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145450. */
  145451. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145452. /**
  145453. * Checks if all the post processes in the effect are supported.
  145454. */
  145455. get isSupported(): boolean;
  145456. /**
  145457. * Updates the current state of the effect
  145458. * @hidden
  145459. */
  145460. _update(): void;
  145461. /**
  145462. * Attaches the effect on cameras
  145463. * @param cameras The camera to attach to.
  145464. * @hidden
  145465. */
  145466. _attachCameras(cameras: Camera): void;
  145467. /**
  145468. * Attaches the effect on cameras
  145469. * @param cameras The camera to attach to.
  145470. * @hidden
  145471. */
  145472. _attachCameras(cameras: Camera[]): void;
  145473. /**
  145474. * Detaches the effect on cameras
  145475. * @param cameras The camera to detatch from.
  145476. * @hidden
  145477. */
  145478. _detachCameras(cameras: Camera): void;
  145479. /**
  145480. * Detatches the effect on cameras
  145481. * @param cameras The camera to detatch from.
  145482. * @hidden
  145483. */
  145484. _detachCameras(cameras: Camera[]): void;
  145485. /**
  145486. * Enables the effect on given cameras
  145487. * @param cameras The camera to enable.
  145488. * @hidden
  145489. */
  145490. _enable(cameras: Camera): void;
  145491. /**
  145492. * Enables the effect on given cameras
  145493. * @param cameras The camera to enable.
  145494. * @hidden
  145495. */
  145496. _enable(cameras: Nullable<Camera[]>): void;
  145497. /**
  145498. * Disables the effect on the given cameras
  145499. * @param cameras The camera to disable.
  145500. * @hidden
  145501. */
  145502. _disable(cameras: Camera): void;
  145503. /**
  145504. * Disables the effect on the given cameras
  145505. * @param cameras The camera to disable.
  145506. * @hidden
  145507. */
  145508. _disable(cameras: Nullable<Camera[]>): void;
  145509. /**
  145510. * Gets a list of the post processes contained in the effect.
  145511. * @param camera The camera to get the post processes on.
  145512. * @returns The list of the post processes in the effect.
  145513. */
  145514. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145515. }
  145516. }
  145517. declare module BABYLON {
  145518. /** @hidden */
  145519. export var extractHighlightsPixelShader: {
  145520. name: string;
  145521. shader: string;
  145522. };
  145523. }
  145524. declare module BABYLON {
  145525. /**
  145526. * 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.
  145527. */
  145528. export class ExtractHighlightsPostProcess extends PostProcess {
  145529. /**
  145530. * The luminance threshold, pixels below this value will be set to black.
  145531. */
  145532. threshold: number;
  145533. /** @hidden */
  145534. _exposure: number;
  145535. /**
  145536. * Post process which has the input texture to be used when performing highlight extraction
  145537. * @hidden
  145538. */
  145539. _inputPostProcess: Nullable<PostProcess>;
  145540. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145541. }
  145542. }
  145543. declare module BABYLON {
  145544. /** @hidden */
  145545. export var bloomMergePixelShader: {
  145546. name: string;
  145547. shader: string;
  145548. };
  145549. }
  145550. declare module BABYLON {
  145551. /**
  145552. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145553. */
  145554. export class BloomMergePostProcess extends PostProcess {
  145555. /** Weight of the bloom to be added to the original input. */
  145556. weight: number;
  145557. /**
  145558. * Creates a new instance of @see BloomMergePostProcess
  145559. * @param name The name of the effect.
  145560. * @param originalFromInput Post process which's input will be used for the merge.
  145561. * @param blurred Blurred highlights post process which's output will be used.
  145562. * @param weight Weight of the bloom to be added to the original input.
  145563. * @param options The required width/height ratio to downsize to before computing the render pass.
  145564. * @param camera The camera to apply the render pass to.
  145565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145566. * @param engine The engine which the post process will be applied. (default: current engine)
  145567. * @param reusable If the post process can be reused on the same frame. (default: false)
  145568. * @param textureType Type of textures used when performing the post process. (default: 0)
  145569. * @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)
  145570. */
  145571. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145572. /** Weight of the bloom to be added to the original input. */
  145573. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145574. }
  145575. }
  145576. declare module BABYLON {
  145577. /**
  145578. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145579. */
  145580. export class BloomEffect extends PostProcessRenderEffect {
  145581. private bloomScale;
  145582. /**
  145583. * @hidden Internal
  145584. */
  145585. _effects: Array<PostProcess>;
  145586. /**
  145587. * @hidden Internal
  145588. */
  145589. _downscale: ExtractHighlightsPostProcess;
  145590. private _blurX;
  145591. private _blurY;
  145592. private _merge;
  145593. /**
  145594. * The luminance threshold to find bright areas of the image to bloom.
  145595. */
  145596. get threshold(): number;
  145597. set threshold(value: number);
  145598. /**
  145599. * The strength of the bloom.
  145600. */
  145601. get weight(): number;
  145602. set weight(value: number);
  145603. /**
  145604. * Specifies the size of the bloom blur kernel, relative to the final output size
  145605. */
  145606. get kernel(): number;
  145607. set kernel(value: number);
  145608. /**
  145609. * Creates a new instance of @see BloomEffect
  145610. * @param scene The scene the effect belongs to.
  145611. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145612. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145613. * @param bloomWeight The the strength of bloom.
  145614. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145615. * @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)
  145616. */
  145617. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145618. /**
  145619. * Disposes each of the internal effects for a given camera.
  145620. * @param camera The camera to dispose the effect on.
  145621. */
  145622. disposeEffects(camera: Camera): void;
  145623. /**
  145624. * @hidden Internal
  145625. */
  145626. _updateEffects(): void;
  145627. /**
  145628. * Internal
  145629. * @returns if all the contained post processes are ready.
  145630. * @hidden
  145631. */
  145632. _isReady(): boolean;
  145633. }
  145634. }
  145635. declare module BABYLON {
  145636. /** @hidden */
  145637. export var chromaticAberrationPixelShader: {
  145638. name: string;
  145639. shader: string;
  145640. };
  145641. }
  145642. declare module BABYLON {
  145643. /**
  145644. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145645. */
  145646. export class ChromaticAberrationPostProcess extends PostProcess {
  145647. /**
  145648. * The amount of seperation of rgb channels (default: 30)
  145649. */
  145650. aberrationAmount: number;
  145651. /**
  145652. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145653. */
  145654. radialIntensity: number;
  145655. /**
  145656. * 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))
  145657. */
  145658. direction: Vector2;
  145659. /**
  145660. * 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))
  145661. */
  145662. centerPosition: Vector2;
  145663. /**
  145664. * Creates a new instance ChromaticAberrationPostProcess
  145665. * @param name The name of the effect.
  145666. * @param screenWidth The width of the screen to apply the effect on.
  145667. * @param screenHeight The height of the screen to apply the effect on.
  145668. * @param options The required width/height ratio to downsize to before computing the render pass.
  145669. * @param camera The camera to apply the render pass to.
  145670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145671. * @param engine The engine which the post process will be applied. (default: current engine)
  145672. * @param reusable If the post process can be reused on the same frame. (default: false)
  145673. * @param textureType Type of textures used when performing the post process. (default: 0)
  145674. * @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)
  145675. */
  145676. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145677. }
  145678. }
  145679. declare module BABYLON {
  145680. /** @hidden */
  145681. export var circleOfConfusionPixelShader: {
  145682. name: string;
  145683. shader: string;
  145684. };
  145685. }
  145686. declare module BABYLON {
  145687. /**
  145688. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145689. */
  145690. export class CircleOfConfusionPostProcess extends PostProcess {
  145691. /**
  145692. * 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.
  145693. */
  145694. lensSize: number;
  145695. /**
  145696. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145697. */
  145698. fStop: number;
  145699. /**
  145700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145701. */
  145702. focusDistance: number;
  145703. /**
  145704. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145705. */
  145706. focalLength: number;
  145707. private _depthTexture;
  145708. /**
  145709. * Creates a new instance CircleOfConfusionPostProcess
  145710. * @param name The name of the effect.
  145711. * @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.
  145712. * @param options The required width/height ratio to downsize to before computing the render pass.
  145713. * @param camera The camera to apply the render pass to.
  145714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145715. * @param engine The engine which the post process will be applied. (default: current engine)
  145716. * @param reusable If the post process can be reused on the same frame. (default: false)
  145717. * @param textureType Type of textures used when performing the post process. (default: 0)
  145718. * @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)
  145719. */
  145720. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145721. /**
  145722. * 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.
  145723. */
  145724. set depthTexture(value: RenderTargetTexture);
  145725. }
  145726. }
  145727. declare module BABYLON {
  145728. /** @hidden */
  145729. export var colorCorrectionPixelShader: {
  145730. name: string;
  145731. shader: string;
  145732. };
  145733. }
  145734. declare module BABYLON {
  145735. /**
  145736. *
  145737. * This post-process allows the modification of rendered colors by using
  145738. * a 'look-up table' (LUT). This effect is also called Color Grading.
  145739. *
  145740. * The object needs to be provided an url to a texture containing the color
  145741. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  145742. * Use an image editing software to tweak the LUT to match your needs.
  145743. *
  145744. * For an example of a color LUT, see here:
  145745. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  145746. * For explanations on color grading, see here:
  145747. * @see http://udn.epicgames.com/Three/ColorGrading.html
  145748. *
  145749. */
  145750. export class ColorCorrectionPostProcess extends PostProcess {
  145751. private _colorTableTexture;
  145752. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145753. }
  145754. }
  145755. declare module BABYLON {
  145756. /** @hidden */
  145757. export var convolutionPixelShader: {
  145758. name: string;
  145759. shader: string;
  145760. };
  145761. }
  145762. declare module BABYLON {
  145763. /**
  145764. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  145765. * input texture to perform effects such as edge detection or sharpening
  145766. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145767. */
  145768. export class ConvolutionPostProcess extends PostProcess {
  145769. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145770. kernel: number[];
  145771. /**
  145772. * Creates a new instance ConvolutionPostProcess
  145773. * @param name The name of the effect.
  145774. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  145775. * @param options The required width/height ratio to downsize to before computing the render pass.
  145776. * @param camera The camera to apply the render pass to.
  145777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145778. * @param engine The engine which the post process will be applied. (default: current engine)
  145779. * @param reusable If the post process can be reused on the same frame. (default: false)
  145780. * @param textureType Type of textures used when performing the post process. (default: 0)
  145781. */
  145782. constructor(name: string,
  145783. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145784. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145785. /**
  145786. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145787. */
  145788. static EdgeDetect0Kernel: number[];
  145789. /**
  145790. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145791. */
  145792. static EdgeDetect1Kernel: number[];
  145793. /**
  145794. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145795. */
  145796. static EdgeDetect2Kernel: number[];
  145797. /**
  145798. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145799. */
  145800. static SharpenKernel: number[];
  145801. /**
  145802. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145803. */
  145804. static EmbossKernel: number[];
  145805. /**
  145806. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145807. */
  145808. static GaussianKernel: number[];
  145809. }
  145810. }
  145811. declare module BABYLON {
  145812. /**
  145813. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  145814. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  145815. * based on samples that have a large difference in distance than the center pixel.
  145816. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  145817. */
  145818. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  145819. direction: Vector2;
  145820. /**
  145821. * Creates a new instance CircleOfConfusionPostProcess
  145822. * @param name The name of the effect.
  145823. * @param scene The scene the effect belongs to.
  145824. * @param direction The direction the blur should be applied.
  145825. * @param kernel The size of the kernel used to blur.
  145826. * @param options The required width/height ratio to downsize to before computing the render pass.
  145827. * @param camera The camera to apply the render pass to.
  145828. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  145829. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  145830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145831. * @param engine The engine which the post process will be applied. (default: current engine)
  145832. * @param reusable If the post process can be reused on the same frame. (default: false)
  145833. * @param textureType Type of textures used when performing the post process. (default: 0)
  145834. * @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)
  145835. */
  145836. 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);
  145837. }
  145838. }
  145839. declare module BABYLON {
  145840. /** @hidden */
  145841. export var depthOfFieldMergePixelShader: {
  145842. name: string;
  145843. shader: string;
  145844. };
  145845. }
  145846. declare module BABYLON {
  145847. /**
  145848. * Options to be set when merging outputs from the default pipeline.
  145849. */
  145850. export class DepthOfFieldMergePostProcessOptions {
  145851. /**
  145852. * The original image to merge on top of
  145853. */
  145854. originalFromInput: PostProcess;
  145855. /**
  145856. * Parameters to perform the merge of the depth of field effect
  145857. */
  145858. depthOfField?: {
  145859. circleOfConfusion: PostProcess;
  145860. blurSteps: Array<PostProcess>;
  145861. };
  145862. /**
  145863. * Parameters to perform the merge of bloom effect
  145864. */
  145865. bloom?: {
  145866. blurred: PostProcess;
  145867. weight: number;
  145868. };
  145869. }
  145870. /**
  145871. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145872. */
  145873. export class DepthOfFieldMergePostProcess extends PostProcess {
  145874. private blurSteps;
  145875. /**
  145876. * Creates a new instance of DepthOfFieldMergePostProcess
  145877. * @param name The name of the effect.
  145878. * @param originalFromInput Post process which's input will be used for the merge.
  145879. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145880. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145881. * @param options The required width/height ratio to downsize to before computing the render pass.
  145882. * @param camera The camera to apply the render pass to.
  145883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145884. * @param engine The engine which the post process will be applied. (default: current engine)
  145885. * @param reusable If the post process can be reused on the same frame. (default: false)
  145886. * @param textureType Type of textures used when performing the post process. (default: 0)
  145887. * @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)
  145888. */
  145889. 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);
  145890. /**
  145891. * Updates the effect with the current post process compile time values and recompiles the shader.
  145892. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145893. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145894. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145895. * @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
  145896. * @param onCompiled Called when the shader has been compiled.
  145897. * @param onError Called if there is an error when compiling a shader.
  145898. */
  145899. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145900. }
  145901. }
  145902. declare module BABYLON {
  145903. /**
  145904. * Specifies the level of max blur that should be applied when using the depth of field effect
  145905. */
  145906. export enum DepthOfFieldEffectBlurLevel {
  145907. /**
  145908. * Subtle blur
  145909. */
  145910. Low = 0,
  145911. /**
  145912. * Medium blur
  145913. */
  145914. Medium = 1,
  145915. /**
  145916. * Large blur
  145917. */
  145918. High = 2
  145919. }
  145920. /**
  145921. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145922. */
  145923. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145924. private _circleOfConfusion;
  145925. /**
  145926. * @hidden Internal, blurs from high to low
  145927. */
  145928. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145929. private _depthOfFieldBlurY;
  145930. private _dofMerge;
  145931. /**
  145932. * @hidden Internal post processes in depth of field effect
  145933. */
  145934. _effects: Array<PostProcess>;
  145935. /**
  145936. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145937. */
  145938. set focalLength(value: number);
  145939. get focalLength(): number;
  145940. /**
  145941. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145942. */
  145943. set fStop(value: number);
  145944. get fStop(): number;
  145945. /**
  145946. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145947. */
  145948. set focusDistance(value: number);
  145949. get focusDistance(): number;
  145950. /**
  145951. * 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.
  145952. */
  145953. set lensSize(value: number);
  145954. get lensSize(): number;
  145955. /**
  145956. * Creates a new instance DepthOfFieldEffect
  145957. * @param scene The scene the effect belongs to.
  145958. * @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.
  145959. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145960. * @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)
  145961. */
  145962. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145963. /**
  145964. * Get the current class name of the current effet
  145965. * @returns "DepthOfFieldEffect"
  145966. */
  145967. getClassName(): string;
  145968. /**
  145969. * 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.
  145970. */
  145971. set depthTexture(value: RenderTargetTexture);
  145972. /**
  145973. * Disposes each of the internal effects for a given camera.
  145974. * @param camera The camera to dispose the effect on.
  145975. */
  145976. disposeEffects(camera: Camera): void;
  145977. /**
  145978. * @hidden Internal
  145979. */
  145980. _updateEffects(): void;
  145981. /**
  145982. * Internal
  145983. * @returns if all the contained post processes are ready.
  145984. * @hidden
  145985. */
  145986. _isReady(): boolean;
  145987. }
  145988. }
  145989. declare module BABYLON {
  145990. /** @hidden */
  145991. export var displayPassPixelShader: {
  145992. name: string;
  145993. shader: string;
  145994. };
  145995. }
  145996. declare module BABYLON {
  145997. /**
  145998. * DisplayPassPostProcess which produces an output the same as it's input
  145999. */
  146000. export class DisplayPassPostProcess extends PostProcess {
  146001. /**
  146002. * Creates the DisplayPassPostProcess
  146003. * @param name The name of the effect.
  146004. * @param options The required width/height ratio to downsize to before computing the render pass.
  146005. * @param camera The camera to apply the render pass to.
  146006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146007. * @param engine The engine which the post process will be applied. (default: current engine)
  146008. * @param reusable If the post process can be reused on the same frame. (default: false)
  146009. */
  146010. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146011. }
  146012. }
  146013. declare module BABYLON {
  146014. /** @hidden */
  146015. export var filterPixelShader: {
  146016. name: string;
  146017. shader: string;
  146018. };
  146019. }
  146020. declare module BABYLON {
  146021. /**
  146022. * Applies a kernel filter to the image
  146023. */
  146024. export class FilterPostProcess extends PostProcess {
  146025. /** The matrix to be applied to the image */
  146026. kernelMatrix: Matrix;
  146027. /**
  146028. *
  146029. * @param name The name of the effect.
  146030. * @param kernelMatrix The matrix to be applied to the image
  146031. * @param options The required width/height ratio to downsize to before computing the render pass.
  146032. * @param camera The camera to apply the render pass to.
  146033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146034. * @param engine The engine which the post process will be applied. (default: current engine)
  146035. * @param reusable If the post process can be reused on the same frame. (default: false)
  146036. */
  146037. constructor(name: string,
  146038. /** The matrix to be applied to the image */
  146039. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146040. }
  146041. }
  146042. declare module BABYLON {
  146043. /** @hidden */
  146044. export var fxaaPixelShader: {
  146045. name: string;
  146046. shader: string;
  146047. };
  146048. }
  146049. declare module BABYLON {
  146050. /** @hidden */
  146051. export var fxaaVertexShader: {
  146052. name: string;
  146053. shader: string;
  146054. };
  146055. }
  146056. declare module BABYLON {
  146057. /**
  146058. * Fxaa post process
  146059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146060. */
  146061. export class FxaaPostProcess extends PostProcess {
  146062. /** @hidden */
  146063. texelWidth: number;
  146064. /** @hidden */
  146065. texelHeight: number;
  146066. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146067. private _getDefines;
  146068. }
  146069. }
  146070. declare module BABYLON {
  146071. /** @hidden */
  146072. export var grainPixelShader: {
  146073. name: string;
  146074. shader: string;
  146075. };
  146076. }
  146077. declare module BABYLON {
  146078. /**
  146079. * The GrainPostProcess adds noise to the image at mid luminance levels
  146080. */
  146081. export class GrainPostProcess extends PostProcess {
  146082. /**
  146083. * The intensity of the grain added (default: 30)
  146084. */
  146085. intensity: number;
  146086. /**
  146087. * If the grain should be randomized on every frame
  146088. */
  146089. animated: boolean;
  146090. /**
  146091. * Creates a new instance of @see GrainPostProcess
  146092. * @param name The name of the effect.
  146093. * @param options The required width/height ratio to downsize to before computing the render pass.
  146094. * @param camera The camera to apply the render pass to.
  146095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146096. * @param engine The engine which the post process will be applied. (default: current engine)
  146097. * @param reusable If the post process can be reused on the same frame. (default: false)
  146098. * @param textureType Type of textures used when performing the post process. (default: 0)
  146099. * @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)
  146100. */
  146101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146102. }
  146103. }
  146104. declare module BABYLON {
  146105. /** @hidden */
  146106. export var highlightsPixelShader: {
  146107. name: string;
  146108. shader: string;
  146109. };
  146110. }
  146111. declare module BABYLON {
  146112. /**
  146113. * Extracts highlights from the image
  146114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146115. */
  146116. export class HighlightsPostProcess extends PostProcess {
  146117. /**
  146118. * Extracts highlights from the image
  146119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146120. * @param name The name of the effect.
  146121. * @param options The required width/height ratio to downsize to before computing the render pass.
  146122. * @param camera The camera to apply the render pass to.
  146123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146124. * @param engine The engine which the post process will be applied. (default: current engine)
  146125. * @param reusable If the post process can be reused on the same frame. (default: false)
  146126. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146127. */
  146128. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146129. }
  146130. }
  146131. declare module BABYLON {
  146132. /** @hidden */
  146133. export var mrtFragmentDeclaration: {
  146134. name: string;
  146135. shader: string;
  146136. };
  146137. }
  146138. declare module BABYLON {
  146139. /** @hidden */
  146140. export var geometryPixelShader: {
  146141. name: string;
  146142. shader: string;
  146143. };
  146144. }
  146145. declare module BABYLON {
  146146. /** @hidden */
  146147. export var geometryVertexShader: {
  146148. name: string;
  146149. shader: string;
  146150. };
  146151. }
  146152. declare module BABYLON {
  146153. /** @hidden */
  146154. interface ISavedTransformationMatrix {
  146155. world: Matrix;
  146156. viewProjection: Matrix;
  146157. }
  146158. /**
  146159. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146160. */
  146161. export class GeometryBufferRenderer {
  146162. /**
  146163. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146164. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146165. */
  146166. static readonly POSITION_TEXTURE_TYPE: number;
  146167. /**
  146168. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146169. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146170. */
  146171. static readonly VELOCITY_TEXTURE_TYPE: number;
  146172. /**
  146173. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146174. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146175. */
  146176. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146177. /**
  146178. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146179. * in order to compute objects velocities when enableVelocity is set to "true"
  146180. * @hidden
  146181. */
  146182. _previousTransformationMatrices: {
  146183. [index: number]: ISavedTransformationMatrix;
  146184. };
  146185. /**
  146186. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146187. * in order to compute objects velocities when enableVelocity is set to "true"
  146188. * @hidden
  146189. */
  146190. _previousBonesTransformationMatrices: {
  146191. [index: number]: Float32Array;
  146192. };
  146193. /**
  146194. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146195. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146196. */
  146197. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146198. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146199. renderTransparentMeshes: boolean;
  146200. private _scene;
  146201. private _multiRenderTarget;
  146202. private _ratio;
  146203. private _enablePosition;
  146204. private _enableVelocity;
  146205. private _enableReflectivity;
  146206. private _positionIndex;
  146207. private _velocityIndex;
  146208. private _reflectivityIndex;
  146209. protected _effect: Effect;
  146210. protected _cachedDefines: string;
  146211. /**
  146212. * Set the render list (meshes to be rendered) used in the G buffer.
  146213. */
  146214. set renderList(meshes: Mesh[]);
  146215. /**
  146216. * Gets wether or not G buffer are supported by the running hardware.
  146217. * This requires draw buffer supports
  146218. */
  146219. get isSupported(): boolean;
  146220. /**
  146221. * Returns the index of the given texture type in the G-Buffer textures array
  146222. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146223. * @returns the index of the given texture type in the G-Buffer textures array
  146224. */
  146225. getTextureIndex(textureType: number): number;
  146226. /**
  146227. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146228. */
  146229. get enablePosition(): boolean;
  146230. /**
  146231. * Sets whether or not objects positions are enabled for the G buffer.
  146232. */
  146233. set enablePosition(enable: boolean);
  146234. /**
  146235. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146236. */
  146237. get enableVelocity(): boolean;
  146238. /**
  146239. * Sets wether or not objects velocities are enabled for the G buffer.
  146240. */
  146241. set enableVelocity(enable: boolean);
  146242. /**
  146243. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146244. */
  146245. get enableReflectivity(): boolean;
  146246. /**
  146247. * Sets wether or not objects roughness are enabled for the G buffer.
  146248. */
  146249. set enableReflectivity(enable: boolean);
  146250. /**
  146251. * Gets the scene associated with the buffer.
  146252. */
  146253. get scene(): Scene;
  146254. /**
  146255. * Gets the ratio used by the buffer during its creation.
  146256. * How big is the buffer related to the main canvas.
  146257. */
  146258. get ratio(): number;
  146259. /** @hidden */
  146260. static _SceneComponentInitialization: (scene: Scene) => void;
  146261. /**
  146262. * Creates a new G Buffer for the scene
  146263. * @param scene The scene the buffer belongs to
  146264. * @param ratio How big is the buffer related to the main canvas.
  146265. */
  146266. constructor(scene: Scene, ratio?: number);
  146267. /**
  146268. * Checks wether everything is ready to render a submesh to the G buffer.
  146269. * @param subMesh the submesh to check readiness for
  146270. * @param useInstances is the mesh drawn using instance or not
  146271. * @returns true if ready otherwise false
  146272. */
  146273. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146274. /**
  146275. * Gets the current underlying G Buffer.
  146276. * @returns the buffer
  146277. */
  146278. getGBuffer(): MultiRenderTarget;
  146279. /**
  146280. * Gets the number of samples used to render the buffer (anti aliasing).
  146281. */
  146282. get samples(): number;
  146283. /**
  146284. * Sets the number of samples used to render the buffer (anti aliasing).
  146285. */
  146286. set samples(value: number);
  146287. /**
  146288. * Disposes the renderer and frees up associated resources.
  146289. */
  146290. dispose(): void;
  146291. protected _createRenderTargets(): void;
  146292. private _copyBonesTransformationMatrices;
  146293. }
  146294. }
  146295. declare module BABYLON {
  146296. interface Scene {
  146297. /** @hidden (Backing field) */
  146298. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146299. /**
  146300. * Gets or Sets the current geometry buffer associated to the scene.
  146301. */
  146302. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146303. /**
  146304. * Enables a GeometryBufferRender and associates it with the scene
  146305. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  146306. * @returns the GeometryBufferRenderer
  146307. */
  146308. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  146309. /**
  146310. * Disables the GeometryBufferRender associated with the scene
  146311. */
  146312. disableGeometryBufferRenderer(): void;
  146313. }
  146314. /**
  146315. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  146316. * in several rendering techniques.
  146317. */
  146318. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  146319. /**
  146320. * The component name helpful to identify the component in the list of scene components.
  146321. */
  146322. readonly name: string;
  146323. /**
  146324. * The scene the component belongs to.
  146325. */
  146326. scene: Scene;
  146327. /**
  146328. * Creates a new instance of the component for the given scene
  146329. * @param scene Defines the scene to register the component in
  146330. */
  146331. constructor(scene: Scene);
  146332. /**
  146333. * Registers the component in a given scene
  146334. */
  146335. register(): void;
  146336. /**
  146337. * Rebuilds the elements related to this component in case of
  146338. * context lost for instance.
  146339. */
  146340. rebuild(): void;
  146341. /**
  146342. * Disposes the component and the associated ressources
  146343. */
  146344. dispose(): void;
  146345. private _gatherRenderTargets;
  146346. }
  146347. }
  146348. declare module BABYLON {
  146349. /** @hidden */
  146350. export var motionBlurPixelShader: {
  146351. name: string;
  146352. shader: string;
  146353. };
  146354. }
  146355. declare module BABYLON {
  146356. /**
  146357. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  146358. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  146359. * As an example, all you have to do is to create the post-process:
  146360. * var mb = new BABYLON.MotionBlurPostProcess(
  146361. * 'mb', // The name of the effect.
  146362. * scene, // The scene containing the objects to blur according to their velocity.
  146363. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146364. * camera // The camera to apply the render pass to.
  146365. * );
  146366. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146367. */
  146368. export class MotionBlurPostProcess extends PostProcess {
  146369. /**
  146370. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146371. */
  146372. motionStrength: number;
  146373. /**
  146374. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146375. */
  146376. get motionBlurSamples(): number;
  146377. /**
  146378. * Sets the number of iterations to be used for motion blur quality
  146379. */
  146380. set motionBlurSamples(samples: number);
  146381. private _motionBlurSamples;
  146382. private _geometryBufferRenderer;
  146383. /**
  146384. * Creates a new instance MotionBlurPostProcess
  146385. * @param name The name of the effect.
  146386. * @param scene The scene containing the objects to blur according to their velocity.
  146387. * @param options The required width/height ratio to downsize to before computing the render pass.
  146388. * @param camera The camera to apply the render pass to.
  146389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146390. * @param engine The engine which the post process will be applied. (default: current engine)
  146391. * @param reusable If the post process can be reused on the same frame. (default: false)
  146392. * @param textureType Type of textures used when performing the post process. (default: 0)
  146393. * @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)
  146394. */
  146395. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146396. /**
  146397. * Excludes the given skinned mesh from computing bones velocities.
  146398. * 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.
  146399. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146400. */
  146401. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146402. /**
  146403. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146404. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146405. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146406. */
  146407. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146408. /**
  146409. * Disposes the post process.
  146410. * @param camera The camera to dispose the post process on.
  146411. */
  146412. dispose(camera?: Camera): void;
  146413. }
  146414. }
  146415. declare module BABYLON {
  146416. /** @hidden */
  146417. export var refractionPixelShader: {
  146418. name: string;
  146419. shader: string;
  146420. };
  146421. }
  146422. declare module BABYLON {
  146423. /**
  146424. * Post process which applies a refractin texture
  146425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146426. */
  146427. export class RefractionPostProcess extends PostProcess {
  146428. /** the base color of the refraction (used to taint the rendering) */
  146429. color: Color3;
  146430. /** simulated refraction depth */
  146431. depth: number;
  146432. /** the coefficient of the base color (0 to remove base color tainting) */
  146433. colorLevel: number;
  146434. private _refTexture;
  146435. private _ownRefractionTexture;
  146436. /**
  146437. * Gets or sets the refraction texture
  146438. * Please note that you are responsible for disposing the texture if you set it manually
  146439. */
  146440. get refractionTexture(): Texture;
  146441. set refractionTexture(value: Texture);
  146442. /**
  146443. * Initializes the RefractionPostProcess
  146444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146445. * @param name The name of the effect.
  146446. * @param refractionTextureUrl Url of the refraction texture to use
  146447. * @param color the base color of the refraction (used to taint the rendering)
  146448. * @param depth simulated refraction depth
  146449. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146450. * @param camera The camera to apply the render pass to.
  146451. * @param options The required width/height ratio to downsize to before computing the render pass.
  146452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146453. * @param engine The engine which the post process will be applied. (default: current engine)
  146454. * @param reusable If the post process can be reused on the same frame. (default: false)
  146455. */
  146456. constructor(name: string, refractionTextureUrl: string,
  146457. /** the base color of the refraction (used to taint the rendering) */
  146458. color: Color3,
  146459. /** simulated refraction depth */
  146460. depth: number,
  146461. /** the coefficient of the base color (0 to remove base color tainting) */
  146462. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146463. /**
  146464. * Disposes of the post process
  146465. * @param camera Camera to dispose post process on
  146466. */
  146467. dispose(camera: Camera): void;
  146468. }
  146469. }
  146470. declare module BABYLON {
  146471. /** @hidden */
  146472. export var sharpenPixelShader: {
  146473. name: string;
  146474. shader: string;
  146475. };
  146476. }
  146477. declare module BABYLON {
  146478. /**
  146479. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146480. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146481. */
  146482. export class SharpenPostProcess extends PostProcess {
  146483. /**
  146484. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146485. */
  146486. colorAmount: number;
  146487. /**
  146488. * How much sharpness should be applied (default: 0.3)
  146489. */
  146490. edgeAmount: number;
  146491. /**
  146492. * Creates a new instance ConvolutionPostProcess
  146493. * @param name The name of the effect.
  146494. * @param options The required width/height ratio to downsize to before computing the render pass.
  146495. * @param camera The camera to apply the render pass to.
  146496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146497. * @param engine The engine which the post process will be applied. (default: current engine)
  146498. * @param reusable If the post process can be reused on the same frame. (default: false)
  146499. * @param textureType Type of textures used when performing the post process. (default: 0)
  146500. * @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)
  146501. */
  146502. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146503. }
  146504. }
  146505. declare module BABYLON {
  146506. /**
  146507. * PostProcessRenderPipeline
  146508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146509. */
  146510. export class PostProcessRenderPipeline {
  146511. private engine;
  146512. private _renderEffects;
  146513. private _renderEffectsForIsolatedPass;
  146514. /**
  146515. * List of inspectable custom properties (used by the Inspector)
  146516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146517. */
  146518. inspectableCustomProperties: IInspectable[];
  146519. /**
  146520. * @hidden
  146521. */
  146522. protected _cameras: Camera[];
  146523. /** @hidden */
  146524. _name: string;
  146525. /**
  146526. * Gets pipeline name
  146527. */
  146528. get name(): string;
  146529. /** Gets the list of attached cameras */
  146530. get cameras(): Camera[];
  146531. /**
  146532. * Initializes a PostProcessRenderPipeline
  146533. * @param engine engine to add the pipeline to
  146534. * @param name name of the pipeline
  146535. */
  146536. constructor(engine: Engine, name: string);
  146537. /**
  146538. * Gets the class name
  146539. * @returns "PostProcessRenderPipeline"
  146540. */
  146541. getClassName(): string;
  146542. /**
  146543. * If all the render effects in the pipeline are supported
  146544. */
  146545. get isSupported(): boolean;
  146546. /**
  146547. * Adds an effect to the pipeline
  146548. * @param renderEffect the effect to add
  146549. */
  146550. addEffect(renderEffect: PostProcessRenderEffect): void;
  146551. /** @hidden */
  146552. _rebuild(): void;
  146553. /** @hidden */
  146554. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146555. /** @hidden */
  146556. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146557. /** @hidden */
  146558. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146559. /** @hidden */
  146560. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146561. /** @hidden */
  146562. _attachCameras(cameras: Camera, unique: boolean): void;
  146563. /** @hidden */
  146564. _attachCameras(cameras: Camera[], unique: boolean): void;
  146565. /** @hidden */
  146566. _detachCameras(cameras: Camera): void;
  146567. /** @hidden */
  146568. _detachCameras(cameras: Nullable<Camera[]>): void;
  146569. /** @hidden */
  146570. _update(): void;
  146571. /** @hidden */
  146572. _reset(): void;
  146573. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146574. /**
  146575. * Disposes of the pipeline
  146576. */
  146577. dispose(): void;
  146578. }
  146579. }
  146580. declare module BABYLON {
  146581. /**
  146582. * PostProcessRenderPipelineManager class
  146583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146584. */
  146585. export class PostProcessRenderPipelineManager {
  146586. private _renderPipelines;
  146587. /**
  146588. * Initializes a PostProcessRenderPipelineManager
  146589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146590. */
  146591. constructor();
  146592. /**
  146593. * Gets the list of supported render pipelines
  146594. */
  146595. get supportedPipelines(): PostProcessRenderPipeline[];
  146596. /**
  146597. * Adds a pipeline to the manager
  146598. * @param renderPipeline The pipeline to add
  146599. */
  146600. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146601. /**
  146602. * Attaches a camera to the pipeline
  146603. * @param renderPipelineName The name of the pipeline to attach to
  146604. * @param cameras the camera to attach
  146605. * @param unique if the camera can be attached multiple times to the pipeline
  146606. */
  146607. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146608. /**
  146609. * Detaches a camera from the pipeline
  146610. * @param renderPipelineName The name of the pipeline to detach from
  146611. * @param cameras the camera to detach
  146612. */
  146613. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146614. /**
  146615. * Enables an effect by name on a pipeline
  146616. * @param renderPipelineName the name of the pipeline to enable the effect in
  146617. * @param renderEffectName the name of the effect to enable
  146618. * @param cameras the cameras that the effect should be enabled on
  146619. */
  146620. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146621. /**
  146622. * Disables an effect by name on a pipeline
  146623. * @param renderPipelineName the name of the pipeline to disable the effect in
  146624. * @param renderEffectName the name of the effect to disable
  146625. * @param cameras the cameras that the effect should be disabled on
  146626. */
  146627. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146628. /**
  146629. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146630. */
  146631. update(): void;
  146632. /** @hidden */
  146633. _rebuild(): void;
  146634. /**
  146635. * Disposes of the manager and pipelines
  146636. */
  146637. dispose(): void;
  146638. }
  146639. }
  146640. declare module BABYLON {
  146641. interface Scene {
  146642. /** @hidden (Backing field) */
  146643. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146644. /**
  146645. * Gets the postprocess render pipeline manager
  146646. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146647. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146648. */
  146649. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146650. }
  146651. /**
  146652. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146653. */
  146654. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146655. /**
  146656. * The component name helpfull to identify the component in the list of scene components.
  146657. */
  146658. readonly name: string;
  146659. /**
  146660. * The scene the component belongs to.
  146661. */
  146662. scene: Scene;
  146663. /**
  146664. * Creates a new instance of the component for the given scene
  146665. * @param scene Defines the scene to register the component in
  146666. */
  146667. constructor(scene: Scene);
  146668. /**
  146669. * Registers the component in a given scene
  146670. */
  146671. register(): void;
  146672. /**
  146673. * Rebuilds the elements related to this component in case of
  146674. * context lost for instance.
  146675. */
  146676. rebuild(): void;
  146677. /**
  146678. * Disposes the component and the associated ressources
  146679. */
  146680. dispose(): void;
  146681. private _gatherRenderTargets;
  146682. }
  146683. }
  146684. declare module BABYLON {
  146685. /**
  146686. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146687. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146688. */
  146689. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146690. private _scene;
  146691. private _camerasToBeAttached;
  146692. /**
  146693. * ID of the sharpen post process,
  146694. */
  146695. private readonly SharpenPostProcessId;
  146696. /**
  146697. * @ignore
  146698. * ID of the image processing post process;
  146699. */
  146700. readonly ImageProcessingPostProcessId: string;
  146701. /**
  146702. * @ignore
  146703. * ID of the Fast Approximate Anti-Aliasing post process;
  146704. */
  146705. readonly FxaaPostProcessId: string;
  146706. /**
  146707. * ID of the chromatic aberration post process,
  146708. */
  146709. private readonly ChromaticAberrationPostProcessId;
  146710. /**
  146711. * ID of the grain post process
  146712. */
  146713. private readonly GrainPostProcessId;
  146714. /**
  146715. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146716. */
  146717. sharpen: SharpenPostProcess;
  146718. private _sharpenEffect;
  146719. private bloom;
  146720. /**
  146721. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146722. */
  146723. depthOfField: DepthOfFieldEffect;
  146724. /**
  146725. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146726. */
  146727. fxaa: FxaaPostProcess;
  146728. /**
  146729. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146730. */
  146731. imageProcessing: ImageProcessingPostProcess;
  146732. /**
  146733. * Chromatic aberration post process which will shift rgb colors in the image
  146734. */
  146735. chromaticAberration: ChromaticAberrationPostProcess;
  146736. private _chromaticAberrationEffect;
  146737. /**
  146738. * Grain post process which add noise to the image
  146739. */
  146740. grain: GrainPostProcess;
  146741. private _grainEffect;
  146742. /**
  146743. * Glow post process which adds a glow to emissive areas of the image
  146744. */
  146745. private _glowLayer;
  146746. /**
  146747. * Animations which can be used to tweak settings over a period of time
  146748. */
  146749. animations: Animation[];
  146750. private _imageProcessingConfigurationObserver;
  146751. private _sharpenEnabled;
  146752. private _bloomEnabled;
  146753. private _depthOfFieldEnabled;
  146754. private _depthOfFieldBlurLevel;
  146755. private _fxaaEnabled;
  146756. private _imageProcessingEnabled;
  146757. private _defaultPipelineTextureType;
  146758. private _bloomScale;
  146759. private _chromaticAberrationEnabled;
  146760. private _grainEnabled;
  146761. private _buildAllowed;
  146762. /**
  146763. * Gets active scene
  146764. */
  146765. get scene(): Scene;
  146766. /**
  146767. * Enable or disable the sharpen process from the pipeline
  146768. */
  146769. set sharpenEnabled(enabled: boolean);
  146770. get sharpenEnabled(): boolean;
  146771. private _resizeObserver;
  146772. private _hardwareScaleLevel;
  146773. private _bloomKernel;
  146774. /**
  146775. * Specifies the size of the bloom blur kernel, relative to the final output size
  146776. */
  146777. get bloomKernel(): number;
  146778. set bloomKernel(value: number);
  146779. /**
  146780. * Specifies the weight of the bloom in the final rendering
  146781. */
  146782. private _bloomWeight;
  146783. /**
  146784. * Specifies the luma threshold for the area that will be blurred by the bloom
  146785. */
  146786. private _bloomThreshold;
  146787. private _hdr;
  146788. /**
  146789. * The strength of the bloom.
  146790. */
  146791. set bloomWeight(value: number);
  146792. get bloomWeight(): number;
  146793. /**
  146794. * The strength of the bloom.
  146795. */
  146796. set bloomThreshold(value: number);
  146797. get bloomThreshold(): number;
  146798. /**
  146799. * The scale of the bloom, lower value will provide better performance.
  146800. */
  146801. set bloomScale(value: number);
  146802. get bloomScale(): number;
  146803. /**
  146804. * Enable or disable the bloom from the pipeline
  146805. */
  146806. set bloomEnabled(enabled: boolean);
  146807. get bloomEnabled(): boolean;
  146808. private _rebuildBloom;
  146809. /**
  146810. * If the depth of field is enabled.
  146811. */
  146812. get depthOfFieldEnabled(): boolean;
  146813. set depthOfFieldEnabled(enabled: boolean);
  146814. /**
  146815. * Blur level of the depth of field effect. (Higher blur will effect performance)
  146816. */
  146817. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  146818. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  146819. /**
  146820. * If the anti aliasing is enabled.
  146821. */
  146822. set fxaaEnabled(enabled: boolean);
  146823. get fxaaEnabled(): boolean;
  146824. private _samples;
  146825. /**
  146826. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146827. */
  146828. set samples(sampleCount: number);
  146829. get samples(): number;
  146830. /**
  146831. * If image processing is enabled.
  146832. */
  146833. set imageProcessingEnabled(enabled: boolean);
  146834. get imageProcessingEnabled(): boolean;
  146835. /**
  146836. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146837. */
  146838. set glowLayerEnabled(enabled: boolean);
  146839. get glowLayerEnabled(): boolean;
  146840. /**
  146841. * Gets the glow layer (or null if not defined)
  146842. */
  146843. get glowLayer(): Nullable<GlowLayer>;
  146844. /**
  146845. * Enable or disable the chromaticAberration process from the pipeline
  146846. */
  146847. set chromaticAberrationEnabled(enabled: boolean);
  146848. get chromaticAberrationEnabled(): boolean;
  146849. /**
  146850. * Enable or disable the grain process from the pipeline
  146851. */
  146852. set grainEnabled(enabled: boolean);
  146853. get grainEnabled(): boolean;
  146854. /**
  146855. * @constructor
  146856. * @param name - The rendering pipeline name (default: "")
  146857. * @param hdr - If high dynamic range textures should be used (default: true)
  146858. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146859. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146860. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146861. */
  146862. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146863. /**
  146864. * Get the class name
  146865. * @returns "DefaultRenderingPipeline"
  146866. */
  146867. getClassName(): string;
  146868. /**
  146869. * Force the compilation of the entire pipeline.
  146870. */
  146871. prepare(): void;
  146872. private _hasCleared;
  146873. private _prevPostProcess;
  146874. private _prevPrevPostProcess;
  146875. private _setAutoClearAndTextureSharing;
  146876. private _depthOfFieldSceneObserver;
  146877. private _buildPipeline;
  146878. private _disposePostProcesses;
  146879. /**
  146880. * Adds a camera to the pipeline
  146881. * @param camera the camera to be added
  146882. */
  146883. addCamera(camera: Camera): void;
  146884. /**
  146885. * Removes a camera from the pipeline
  146886. * @param camera the camera to remove
  146887. */
  146888. removeCamera(camera: Camera): void;
  146889. /**
  146890. * Dispose of the pipeline and stop all post processes
  146891. */
  146892. dispose(): void;
  146893. /**
  146894. * Serialize the rendering pipeline (Used when exporting)
  146895. * @returns the serialized object
  146896. */
  146897. serialize(): any;
  146898. /**
  146899. * Parse the serialized pipeline
  146900. * @param source Source pipeline.
  146901. * @param scene The scene to load the pipeline to.
  146902. * @param rootUrl The URL of the serialized pipeline.
  146903. * @returns An instantiated pipeline from the serialized object.
  146904. */
  146905. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146906. }
  146907. }
  146908. declare module BABYLON {
  146909. /** @hidden */
  146910. export var lensHighlightsPixelShader: {
  146911. name: string;
  146912. shader: string;
  146913. };
  146914. }
  146915. declare module BABYLON {
  146916. /** @hidden */
  146917. export var depthOfFieldPixelShader: {
  146918. name: string;
  146919. shader: string;
  146920. };
  146921. }
  146922. declare module BABYLON {
  146923. /**
  146924. * BABYLON.JS Chromatic Aberration GLSL Shader
  146925. * Author: Olivier Guyot
  146926. * Separates very slightly R, G and B colors on the edges of the screen
  146927. * Inspired by Francois Tarlier & Martins Upitis
  146928. */
  146929. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146930. /**
  146931. * @ignore
  146932. * The chromatic aberration PostProcess id in the pipeline
  146933. */
  146934. LensChromaticAberrationEffect: string;
  146935. /**
  146936. * @ignore
  146937. * The highlights enhancing PostProcess id in the pipeline
  146938. */
  146939. HighlightsEnhancingEffect: string;
  146940. /**
  146941. * @ignore
  146942. * The depth-of-field PostProcess id in the pipeline
  146943. */
  146944. LensDepthOfFieldEffect: string;
  146945. private _scene;
  146946. private _depthTexture;
  146947. private _grainTexture;
  146948. private _chromaticAberrationPostProcess;
  146949. private _highlightsPostProcess;
  146950. private _depthOfFieldPostProcess;
  146951. private _edgeBlur;
  146952. private _grainAmount;
  146953. private _chromaticAberration;
  146954. private _distortion;
  146955. private _highlightsGain;
  146956. private _highlightsThreshold;
  146957. private _dofDistance;
  146958. private _dofAperture;
  146959. private _dofDarken;
  146960. private _dofPentagon;
  146961. private _blurNoise;
  146962. /**
  146963. * @constructor
  146964. *
  146965. * Effect parameters are as follow:
  146966. * {
  146967. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146968. * edge_blur: number; // from 0 to x (1 for realism)
  146969. * distortion: number; // from 0 to x (1 for realism)
  146970. * grain_amount: number; // from 0 to 1
  146971. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146972. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146973. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146974. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146975. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146976. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146977. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146978. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146979. * }
  146980. * Note: if an effect parameter is unset, effect is disabled
  146981. *
  146982. * @param name The rendering pipeline name
  146983. * @param parameters - An object containing all parameters (see above)
  146984. * @param scene The scene linked to this pipeline
  146985. * @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)
  146986. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146987. */
  146988. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146989. /**
  146990. * Get the class name
  146991. * @returns "LensRenderingPipeline"
  146992. */
  146993. getClassName(): string;
  146994. /**
  146995. * Gets associated scene
  146996. */
  146997. get scene(): Scene;
  146998. /**
  146999. * Gets or sets the edge blur
  147000. */
  147001. get edgeBlur(): number;
  147002. set edgeBlur(value: number);
  147003. /**
  147004. * Gets or sets the grain amount
  147005. */
  147006. get grainAmount(): number;
  147007. set grainAmount(value: number);
  147008. /**
  147009. * Gets or sets the chromatic aberration amount
  147010. */
  147011. get chromaticAberration(): number;
  147012. set chromaticAberration(value: number);
  147013. /**
  147014. * Gets or sets the depth of field aperture
  147015. */
  147016. get dofAperture(): number;
  147017. set dofAperture(value: number);
  147018. /**
  147019. * Gets or sets the edge distortion
  147020. */
  147021. get edgeDistortion(): number;
  147022. set edgeDistortion(value: number);
  147023. /**
  147024. * Gets or sets the depth of field distortion
  147025. */
  147026. get dofDistortion(): number;
  147027. set dofDistortion(value: number);
  147028. /**
  147029. * Gets or sets the darken out of focus amount
  147030. */
  147031. get darkenOutOfFocus(): number;
  147032. set darkenOutOfFocus(value: number);
  147033. /**
  147034. * Gets or sets a boolean indicating if blur noise is enabled
  147035. */
  147036. get blurNoise(): boolean;
  147037. set blurNoise(value: boolean);
  147038. /**
  147039. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147040. */
  147041. get pentagonBokeh(): boolean;
  147042. set pentagonBokeh(value: boolean);
  147043. /**
  147044. * Gets or sets the highlight grain amount
  147045. */
  147046. get highlightsGain(): number;
  147047. set highlightsGain(value: number);
  147048. /**
  147049. * Gets or sets the highlight threshold
  147050. */
  147051. get highlightsThreshold(): number;
  147052. set highlightsThreshold(value: number);
  147053. /**
  147054. * Sets the amount of blur at the edges
  147055. * @param amount blur amount
  147056. */
  147057. setEdgeBlur(amount: number): void;
  147058. /**
  147059. * Sets edge blur to 0
  147060. */
  147061. disableEdgeBlur(): void;
  147062. /**
  147063. * Sets the amout of grain
  147064. * @param amount Amount of grain
  147065. */
  147066. setGrainAmount(amount: number): void;
  147067. /**
  147068. * Set grain amount to 0
  147069. */
  147070. disableGrain(): void;
  147071. /**
  147072. * Sets the chromatic aberration amount
  147073. * @param amount amount of chromatic aberration
  147074. */
  147075. setChromaticAberration(amount: number): void;
  147076. /**
  147077. * Sets chromatic aberration amount to 0
  147078. */
  147079. disableChromaticAberration(): void;
  147080. /**
  147081. * Sets the EdgeDistortion amount
  147082. * @param amount amount of EdgeDistortion
  147083. */
  147084. setEdgeDistortion(amount: number): void;
  147085. /**
  147086. * Sets edge distortion to 0
  147087. */
  147088. disableEdgeDistortion(): void;
  147089. /**
  147090. * Sets the FocusDistance amount
  147091. * @param amount amount of FocusDistance
  147092. */
  147093. setFocusDistance(amount: number): void;
  147094. /**
  147095. * Disables depth of field
  147096. */
  147097. disableDepthOfField(): void;
  147098. /**
  147099. * Sets the Aperture amount
  147100. * @param amount amount of Aperture
  147101. */
  147102. setAperture(amount: number): void;
  147103. /**
  147104. * Sets the DarkenOutOfFocus amount
  147105. * @param amount amount of DarkenOutOfFocus
  147106. */
  147107. setDarkenOutOfFocus(amount: number): void;
  147108. private _pentagonBokehIsEnabled;
  147109. /**
  147110. * Creates a pentagon bokeh effect
  147111. */
  147112. enablePentagonBokeh(): void;
  147113. /**
  147114. * Disables the pentagon bokeh effect
  147115. */
  147116. disablePentagonBokeh(): void;
  147117. /**
  147118. * Enables noise blur
  147119. */
  147120. enableNoiseBlur(): void;
  147121. /**
  147122. * Disables noise blur
  147123. */
  147124. disableNoiseBlur(): void;
  147125. /**
  147126. * Sets the HighlightsGain amount
  147127. * @param amount amount of HighlightsGain
  147128. */
  147129. setHighlightsGain(amount: number): void;
  147130. /**
  147131. * Sets the HighlightsThreshold amount
  147132. * @param amount amount of HighlightsThreshold
  147133. */
  147134. setHighlightsThreshold(amount: number): void;
  147135. /**
  147136. * Disables highlights
  147137. */
  147138. disableHighlights(): void;
  147139. /**
  147140. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147141. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147142. */
  147143. dispose(disableDepthRender?: boolean): void;
  147144. private _createChromaticAberrationPostProcess;
  147145. private _createHighlightsPostProcess;
  147146. private _createDepthOfFieldPostProcess;
  147147. private _createGrainTexture;
  147148. }
  147149. }
  147150. declare module BABYLON {
  147151. /** @hidden */
  147152. export var ssao2PixelShader: {
  147153. name: string;
  147154. shader: string;
  147155. };
  147156. }
  147157. declare module BABYLON {
  147158. /** @hidden */
  147159. export var ssaoCombinePixelShader: {
  147160. name: string;
  147161. shader: string;
  147162. };
  147163. }
  147164. declare module BABYLON {
  147165. /**
  147166. * Render pipeline to produce ssao effect
  147167. */
  147168. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147169. /**
  147170. * @ignore
  147171. * The PassPostProcess id in the pipeline that contains the original scene color
  147172. */
  147173. SSAOOriginalSceneColorEffect: string;
  147174. /**
  147175. * @ignore
  147176. * The SSAO PostProcess id in the pipeline
  147177. */
  147178. SSAORenderEffect: string;
  147179. /**
  147180. * @ignore
  147181. * The horizontal blur PostProcess id in the pipeline
  147182. */
  147183. SSAOBlurHRenderEffect: string;
  147184. /**
  147185. * @ignore
  147186. * The vertical blur PostProcess id in the pipeline
  147187. */
  147188. SSAOBlurVRenderEffect: string;
  147189. /**
  147190. * @ignore
  147191. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147192. */
  147193. SSAOCombineRenderEffect: string;
  147194. /**
  147195. * The output strength of the SSAO post-process. Default value is 1.0.
  147196. */
  147197. totalStrength: number;
  147198. /**
  147199. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147200. */
  147201. maxZ: number;
  147202. /**
  147203. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147204. */
  147205. minZAspect: number;
  147206. private _samples;
  147207. /**
  147208. * Number of samples used for the SSAO calculations. Default value is 8
  147209. */
  147210. set samples(n: number);
  147211. get samples(): number;
  147212. private _textureSamples;
  147213. /**
  147214. * Number of samples to use for antialiasing
  147215. */
  147216. set textureSamples(n: number);
  147217. get textureSamples(): number;
  147218. /**
  147219. * Ratio object used for SSAO ratio and blur ratio
  147220. */
  147221. private _ratio;
  147222. /**
  147223. * Dynamically generated sphere sampler.
  147224. */
  147225. private _sampleSphere;
  147226. /**
  147227. * Blur filter offsets
  147228. */
  147229. private _samplerOffsets;
  147230. private _expensiveBlur;
  147231. /**
  147232. * If bilateral blur should be used
  147233. */
  147234. set expensiveBlur(b: boolean);
  147235. get expensiveBlur(): boolean;
  147236. /**
  147237. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147238. */
  147239. radius: number;
  147240. /**
  147241. * The base color of the SSAO post-process
  147242. * The final result is "base + ssao" between [0, 1]
  147243. */
  147244. base: number;
  147245. /**
  147246. * Support test.
  147247. */
  147248. static get IsSupported(): boolean;
  147249. private _scene;
  147250. private _depthTexture;
  147251. private _normalTexture;
  147252. private _randomTexture;
  147253. private _originalColorPostProcess;
  147254. private _ssaoPostProcess;
  147255. private _blurHPostProcess;
  147256. private _blurVPostProcess;
  147257. private _ssaoCombinePostProcess;
  147258. /**
  147259. * Gets active scene
  147260. */
  147261. get scene(): Scene;
  147262. /**
  147263. * @constructor
  147264. * @param name The rendering pipeline name
  147265. * @param scene The scene linked to this pipeline
  147266. * @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 }
  147267. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147268. */
  147269. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147270. /**
  147271. * Get the class name
  147272. * @returns "SSAO2RenderingPipeline"
  147273. */
  147274. getClassName(): string;
  147275. /**
  147276. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147277. */
  147278. dispose(disableGeometryBufferRenderer?: boolean): void;
  147279. private _createBlurPostProcess;
  147280. /** @hidden */
  147281. _rebuild(): void;
  147282. private _bits;
  147283. private _radicalInverse_VdC;
  147284. private _hammersley;
  147285. private _hemisphereSample_uniform;
  147286. private _generateHemisphere;
  147287. private _createSSAOPostProcess;
  147288. private _createSSAOCombinePostProcess;
  147289. private _createRandomTexture;
  147290. /**
  147291. * Serialize the rendering pipeline (Used when exporting)
  147292. * @returns the serialized object
  147293. */
  147294. serialize(): any;
  147295. /**
  147296. * Parse the serialized pipeline
  147297. * @param source Source pipeline.
  147298. * @param scene The scene to load the pipeline to.
  147299. * @param rootUrl The URL of the serialized pipeline.
  147300. * @returns An instantiated pipeline from the serialized object.
  147301. */
  147302. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  147303. }
  147304. }
  147305. declare module BABYLON {
  147306. /** @hidden */
  147307. export var ssaoPixelShader: {
  147308. name: string;
  147309. shader: string;
  147310. };
  147311. }
  147312. declare module BABYLON {
  147313. /**
  147314. * Render pipeline to produce ssao effect
  147315. */
  147316. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  147317. /**
  147318. * @ignore
  147319. * The PassPostProcess id in the pipeline that contains the original scene color
  147320. */
  147321. SSAOOriginalSceneColorEffect: string;
  147322. /**
  147323. * @ignore
  147324. * The SSAO PostProcess id in the pipeline
  147325. */
  147326. SSAORenderEffect: string;
  147327. /**
  147328. * @ignore
  147329. * The horizontal blur PostProcess id in the pipeline
  147330. */
  147331. SSAOBlurHRenderEffect: string;
  147332. /**
  147333. * @ignore
  147334. * The vertical blur PostProcess id in the pipeline
  147335. */
  147336. SSAOBlurVRenderEffect: string;
  147337. /**
  147338. * @ignore
  147339. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147340. */
  147341. SSAOCombineRenderEffect: string;
  147342. /**
  147343. * The output strength of the SSAO post-process. Default value is 1.0.
  147344. */
  147345. totalStrength: number;
  147346. /**
  147347. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  147348. */
  147349. radius: number;
  147350. /**
  147351. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  147352. * Must not be equal to fallOff and superior to fallOff.
  147353. * Default value is 0.0075
  147354. */
  147355. area: number;
  147356. /**
  147357. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  147358. * Must not be equal to area and inferior to area.
  147359. * Default value is 0.000001
  147360. */
  147361. fallOff: number;
  147362. /**
  147363. * The base color of the SSAO post-process
  147364. * The final result is "base + ssao" between [0, 1]
  147365. */
  147366. base: number;
  147367. private _scene;
  147368. private _depthTexture;
  147369. private _randomTexture;
  147370. private _originalColorPostProcess;
  147371. private _ssaoPostProcess;
  147372. private _blurHPostProcess;
  147373. private _blurVPostProcess;
  147374. private _ssaoCombinePostProcess;
  147375. private _firstUpdate;
  147376. /**
  147377. * Gets active scene
  147378. */
  147379. get scene(): Scene;
  147380. /**
  147381. * @constructor
  147382. * @param name - The rendering pipeline name
  147383. * @param scene - The scene linked to this pipeline
  147384. * @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 }
  147385. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147386. */
  147387. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147388. /**
  147389. * Get the class name
  147390. * @returns "SSAORenderingPipeline"
  147391. */
  147392. getClassName(): string;
  147393. /**
  147394. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147395. */
  147396. dispose(disableDepthRender?: boolean): void;
  147397. private _createBlurPostProcess;
  147398. /** @hidden */
  147399. _rebuild(): void;
  147400. private _createSSAOPostProcess;
  147401. private _createSSAOCombinePostProcess;
  147402. private _createRandomTexture;
  147403. }
  147404. }
  147405. declare module BABYLON {
  147406. /** @hidden */
  147407. export var screenSpaceReflectionPixelShader: {
  147408. name: string;
  147409. shader: string;
  147410. };
  147411. }
  147412. declare module BABYLON {
  147413. /**
  147414. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147415. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147416. */
  147417. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147418. /**
  147419. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147420. */
  147421. threshold: number;
  147422. /**
  147423. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147424. */
  147425. strength: number;
  147426. /**
  147427. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147428. */
  147429. reflectionSpecularFalloffExponent: number;
  147430. /**
  147431. * 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]
  147432. */
  147433. step: number;
  147434. /**
  147435. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147436. */
  147437. roughnessFactor: number;
  147438. private _geometryBufferRenderer;
  147439. private _enableSmoothReflections;
  147440. private _reflectionSamples;
  147441. private _smoothSteps;
  147442. /**
  147443. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147444. * @param name The name of the effect.
  147445. * @param scene The scene containing the objects to calculate reflections.
  147446. * @param options The required width/height ratio to downsize to before computing the render pass.
  147447. * @param camera The camera to apply the render pass to.
  147448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147449. * @param engine The engine which the post process will be applied. (default: current engine)
  147450. * @param reusable If the post process can be reused on the same frame. (default: false)
  147451. * @param textureType Type of textures used when performing the post process. (default: 0)
  147452. * @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)
  147453. */
  147454. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147455. /**
  147456. * Gets wether or not smoothing reflections is enabled.
  147457. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147458. */
  147459. get enableSmoothReflections(): boolean;
  147460. /**
  147461. * Sets wether or not smoothing reflections is enabled.
  147462. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147463. */
  147464. set enableSmoothReflections(enabled: boolean);
  147465. /**
  147466. * Gets the number of samples taken while computing reflections. More samples count is high,
  147467. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147468. */
  147469. get reflectionSamples(): number;
  147470. /**
  147471. * Sets the number of samples taken while computing reflections. More samples count is high,
  147472. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147473. */
  147474. set reflectionSamples(samples: number);
  147475. /**
  147476. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147477. * more the post-process will require GPU power and can generate a drop in FPS.
  147478. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147479. */
  147480. get smoothSteps(): number;
  147481. set smoothSteps(steps: number);
  147482. private _updateEffectDefines;
  147483. }
  147484. }
  147485. declare module BABYLON {
  147486. /** @hidden */
  147487. export var standardPixelShader: {
  147488. name: string;
  147489. shader: string;
  147490. };
  147491. }
  147492. declare module BABYLON {
  147493. /**
  147494. * Standard rendering pipeline
  147495. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147496. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147497. */
  147498. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147499. /**
  147500. * Public members
  147501. */
  147502. /**
  147503. * Post-process which contains the original scene color before the pipeline applies all the effects
  147504. */
  147505. originalPostProcess: Nullable<PostProcess>;
  147506. /**
  147507. * Post-process used to down scale an image x4
  147508. */
  147509. downSampleX4PostProcess: Nullable<PostProcess>;
  147510. /**
  147511. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147512. */
  147513. brightPassPostProcess: Nullable<PostProcess>;
  147514. /**
  147515. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147516. */
  147517. blurHPostProcesses: PostProcess[];
  147518. /**
  147519. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147520. */
  147521. blurVPostProcesses: PostProcess[];
  147522. /**
  147523. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147524. */
  147525. textureAdderPostProcess: Nullable<PostProcess>;
  147526. /**
  147527. * Post-process used to create volumetric lighting effect
  147528. */
  147529. volumetricLightPostProcess: Nullable<PostProcess>;
  147530. /**
  147531. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147532. */
  147533. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147534. /**
  147535. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147536. */
  147537. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147538. /**
  147539. * Post-process used to merge the volumetric light effect and the real scene color
  147540. */
  147541. volumetricLightMergePostProces: Nullable<PostProcess>;
  147542. /**
  147543. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147544. */
  147545. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147546. /**
  147547. * Base post-process used to calculate the average luminance of the final image for HDR
  147548. */
  147549. luminancePostProcess: Nullable<PostProcess>;
  147550. /**
  147551. * Post-processes used to create down sample post-processes in order to get
  147552. * the average luminance of the final image for HDR
  147553. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147554. */
  147555. luminanceDownSamplePostProcesses: PostProcess[];
  147556. /**
  147557. * Post-process used to create a HDR effect (light adaptation)
  147558. */
  147559. hdrPostProcess: Nullable<PostProcess>;
  147560. /**
  147561. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147562. */
  147563. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147564. /**
  147565. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147566. */
  147567. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147568. /**
  147569. * Post-process used to merge the final HDR post-process and the real scene color
  147570. */
  147571. hdrFinalPostProcess: Nullable<PostProcess>;
  147572. /**
  147573. * Post-process used to create a lens flare effect
  147574. */
  147575. lensFlarePostProcess: Nullable<PostProcess>;
  147576. /**
  147577. * Post-process that merges the result of the lens flare post-process and the real scene color
  147578. */
  147579. lensFlareComposePostProcess: Nullable<PostProcess>;
  147580. /**
  147581. * Post-process used to create a motion blur effect
  147582. */
  147583. motionBlurPostProcess: Nullable<PostProcess>;
  147584. /**
  147585. * Post-process used to create a depth of field effect
  147586. */
  147587. depthOfFieldPostProcess: Nullable<PostProcess>;
  147588. /**
  147589. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147590. */
  147591. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147592. /**
  147593. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147594. */
  147595. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147596. /**
  147597. * Represents the brightness threshold in order to configure the illuminated surfaces
  147598. */
  147599. brightThreshold: number;
  147600. /**
  147601. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147602. */
  147603. blurWidth: number;
  147604. /**
  147605. * Sets if the blur for highlighted surfaces must be only horizontal
  147606. */
  147607. horizontalBlur: boolean;
  147608. /**
  147609. * Gets the overall exposure used by the pipeline
  147610. */
  147611. get exposure(): number;
  147612. /**
  147613. * Sets the overall exposure used by the pipeline
  147614. */
  147615. set exposure(value: number);
  147616. /**
  147617. * Texture used typically to simulate "dirty" on camera lens
  147618. */
  147619. lensTexture: Nullable<Texture>;
  147620. /**
  147621. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147622. */
  147623. volumetricLightCoefficient: number;
  147624. /**
  147625. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147626. */
  147627. volumetricLightPower: number;
  147628. /**
  147629. * Used the set the blur intensity to smooth the volumetric lights
  147630. */
  147631. volumetricLightBlurScale: number;
  147632. /**
  147633. * Light (spot or directional) used to generate the volumetric lights rays
  147634. * The source light must have a shadow generate so the pipeline can get its
  147635. * depth map
  147636. */
  147637. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147638. /**
  147639. * For eye adaptation, represents the minimum luminance the eye can see
  147640. */
  147641. hdrMinimumLuminance: number;
  147642. /**
  147643. * For eye adaptation, represents the decrease luminance speed
  147644. */
  147645. hdrDecreaseRate: number;
  147646. /**
  147647. * For eye adaptation, represents the increase luminance speed
  147648. */
  147649. hdrIncreaseRate: number;
  147650. /**
  147651. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147652. */
  147653. get hdrAutoExposure(): boolean;
  147654. /**
  147655. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147656. */
  147657. set hdrAutoExposure(value: boolean);
  147658. /**
  147659. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147660. */
  147661. lensColorTexture: Nullable<Texture>;
  147662. /**
  147663. * The overall strengh for the lens flare effect
  147664. */
  147665. lensFlareStrength: number;
  147666. /**
  147667. * Dispersion coefficient for lens flare ghosts
  147668. */
  147669. lensFlareGhostDispersal: number;
  147670. /**
  147671. * Main lens flare halo width
  147672. */
  147673. lensFlareHaloWidth: number;
  147674. /**
  147675. * Based on the lens distortion effect, defines how much the lens flare result
  147676. * is distorted
  147677. */
  147678. lensFlareDistortionStrength: number;
  147679. /**
  147680. * Configures the blur intensity used for for lens flare (halo)
  147681. */
  147682. lensFlareBlurWidth: number;
  147683. /**
  147684. * Lens star texture must be used to simulate rays on the flares and is available
  147685. * in the documentation
  147686. */
  147687. lensStarTexture: Nullable<Texture>;
  147688. /**
  147689. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147690. * flare effect by taking account of the dirt texture
  147691. */
  147692. lensFlareDirtTexture: Nullable<Texture>;
  147693. /**
  147694. * Represents the focal length for the depth of field effect
  147695. */
  147696. depthOfFieldDistance: number;
  147697. /**
  147698. * Represents the blur intensity for the blurred part of the depth of field effect
  147699. */
  147700. depthOfFieldBlurWidth: number;
  147701. /**
  147702. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147703. */
  147704. get motionStrength(): number;
  147705. /**
  147706. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147707. */
  147708. set motionStrength(strength: number);
  147709. /**
  147710. * Gets wether or not the motion blur post-process is object based or screen based.
  147711. */
  147712. get objectBasedMotionBlur(): boolean;
  147713. /**
  147714. * Sets wether or not the motion blur post-process should be object based or screen based
  147715. */
  147716. set objectBasedMotionBlur(value: boolean);
  147717. /**
  147718. * List of animations for the pipeline (IAnimatable implementation)
  147719. */
  147720. animations: Animation[];
  147721. /**
  147722. * Private members
  147723. */
  147724. private _scene;
  147725. private _currentDepthOfFieldSource;
  147726. private _basePostProcess;
  147727. private _fixedExposure;
  147728. private _currentExposure;
  147729. private _hdrAutoExposure;
  147730. private _hdrCurrentLuminance;
  147731. private _motionStrength;
  147732. private _isObjectBasedMotionBlur;
  147733. private _floatTextureType;
  147734. private _camerasToBeAttached;
  147735. private _ratio;
  147736. private _bloomEnabled;
  147737. private _depthOfFieldEnabled;
  147738. private _vlsEnabled;
  147739. private _lensFlareEnabled;
  147740. private _hdrEnabled;
  147741. private _motionBlurEnabled;
  147742. private _fxaaEnabled;
  147743. private _screenSpaceReflectionsEnabled;
  147744. private _motionBlurSamples;
  147745. private _volumetricLightStepsCount;
  147746. private _samples;
  147747. /**
  147748. * @ignore
  147749. * Specifies if the bloom pipeline is enabled
  147750. */
  147751. get BloomEnabled(): boolean;
  147752. set BloomEnabled(enabled: boolean);
  147753. /**
  147754. * @ignore
  147755. * Specifies if the depth of field pipeline is enabed
  147756. */
  147757. get DepthOfFieldEnabled(): boolean;
  147758. set DepthOfFieldEnabled(enabled: boolean);
  147759. /**
  147760. * @ignore
  147761. * Specifies if the lens flare pipeline is enabed
  147762. */
  147763. get LensFlareEnabled(): boolean;
  147764. set LensFlareEnabled(enabled: boolean);
  147765. /**
  147766. * @ignore
  147767. * Specifies if the HDR pipeline is enabled
  147768. */
  147769. get HDREnabled(): boolean;
  147770. set HDREnabled(enabled: boolean);
  147771. /**
  147772. * @ignore
  147773. * Specifies if the volumetric lights scattering effect is enabled
  147774. */
  147775. get VLSEnabled(): boolean;
  147776. set VLSEnabled(enabled: boolean);
  147777. /**
  147778. * @ignore
  147779. * Specifies if the motion blur effect is enabled
  147780. */
  147781. get MotionBlurEnabled(): boolean;
  147782. set MotionBlurEnabled(enabled: boolean);
  147783. /**
  147784. * Specifies if anti-aliasing is enabled
  147785. */
  147786. get fxaaEnabled(): boolean;
  147787. set fxaaEnabled(enabled: boolean);
  147788. /**
  147789. * Specifies if screen space reflections are enabled.
  147790. */
  147791. get screenSpaceReflectionsEnabled(): boolean;
  147792. set screenSpaceReflectionsEnabled(enabled: boolean);
  147793. /**
  147794. * Specifies the number of steps used to calculate the volumetric lights
  147795. * Typically in interval [50, 200]
  147796. */
  147797. get volumetricLightStepsCount(): number;
  147798. set volumetricLightStepsCount(count: number);
  147799. /**
  147800. * Specifies the number of samples used for the motion blur effect
  147801. * Typically in interval [16, 64]
  147802. */
  147803. get motionBlurSamples(): number;
  147804. set motionBlurSamples(samples: number);
  147805. /**
  147806. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147807. */
  147808. get samples(): number;
  147809. set samples(sampleCount: number);
  147810. /**
  147811. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147812. * @constructor
  147813. * @param name The rendering pipeline name
  147814. * @param scene The scene linked to this pipeline
  147815. * @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)
  147816. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  147817. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147818. */
  147819. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  147820. private _buildPipeline;
  147821. private _createDownSampleX4PostProcess;
  147822. private _createBrightPassPostProcess;
  147823. private _createBlurPostProcesses;
  147824. private _createTextureAdderPostProcess;
  147825. private _createVolumetricLightPostProcess;
  147826. private _createLuminancePostProcesses;
  147827. private _createHdrPostProcess;
  147828. private _createLensFlarePostProcess;
  147829. private _createDepthOfFieldPostProcess;
  147830. private _createMotionBlurPostProcess;
  147831. private _getDepthTexture;
  147832. private _disposePostProcesses;
  147833. /**
  147834. * Dispose of the pipeline and stop all post processes
  147835. */
  147836. dispose(): void;
  147837. /**
  147838. * Serialize the rendering pipeline (Used when exporting)
  147839. * @returns the serialized object
  147840. */
  147841. serialize(): any;
  147842. /**
  147843. * Parse the serialized pipeline
  147844. * @param source Source pipeline.
  147845. * @param scene The scene to load the pipeline to.
  147846. * @param rootUrl The URL of the serialized pipeline.
  147847. * @returns An instantiated pipeline from the serialized object.
  147848. */
  147849. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147850. /**
  147851. * Luminance steps
  147852. */
  147853. static LuminanceSteps: number;
  147854. }
  147855. }
  147856. declare module BABYLON {
  147857. /** @hidden */
  147858. export var stereoscopicInterlacePixelShader: {
  147859. name: string;
  147860. shader: string;
  147861. };
  147862. }
  147863. declare module BABYLON {
  147864. /**
  147865. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147866. */
  147867. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147868. private _stepSize;
  147869. private _passedProcess;
  147870. /**
  147871. * Initializes a StereoscopicInterlacePostProcessI
  147872. * @param name The name of the effect.
  147873. * @param rigCameras The rig cameras to be appled to the post process
  147874. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147875. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147877. * @param engine The engine which the post process will be applied. (default: current engine)
  147878. * @param reusable If the post process can be reused on the same frame. (default: false)
  147879. */
  147880. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147881. }
  147882. /**
  147883. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147884. */
  147885. export class StereoscopicInterlacePostProcess extends PostProcess {
  147886. private _stepSize;
  147887. private _passedProcess;
  147888. /**
  147889. * Initializes a StereoscopicInterlacePostProcess
  147890. * @param name The name of the effect.
  147891. * @param rigCameras The rig cameras to be appled to the post process
  147892. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147894. * @param engine The engine which the post process will be applied. (default: current engine)
  147895. * @param reusable If the post process can be reused on the same frame. (default: false)
  147896. */
  147897. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147898. }
  147899. }
  147900. declare module BABYLON {
  147901. /** @hidden */
  147902. export var tonemapPixelShader: {
  147903. name: string;
  147904. shader: string;
  147905. };
  147906. }
  147907. declare module BABYLON {
  147908. /** Defines operator used for tonemapping */
  147909. export enum TonemappingOperator {
  147910. /** Hable */
  147911. Hable = 0,
  147912. /** Reinhard */
  147913. Reinhard = 1,
  147914. /** HejiDawson */
  147915. HejiDawson = 2,
  147916. /** Photographic */
  147917. Photographic = 3
  147918. }
  147919. /**
  147920. * Defines a post process to apply tone mapping
  147921. */
  147922. export class TonemapPostProcess extends PostProcess {
  147923. private _operator;
  147924. /** Defines the required exposure adjustement */
  147925. exposureAdjustment: number;
  147926. /**
  147927. * Creates a new TonemapPostProcess
  147928. * @param name defines the name of the postprocess
  147929. * @param _operator defines the operator to use
  147930. * @param exposureAdjustment defines the required exposure adjustement
  147931. * @param camera defines the camera to use (can be null)
  147932. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147933. * @param engine defines the hosting engine (can be ignore if camera is set)
  147934. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147935. */
  147936. constructor(name: string, _operator: TonemappingOperator,
  147937. /** Defines the required exposure adjustement */
  147938. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147939. }
  147940. }
  147941. declare module BABYLON {
  147942. /** @hidden */
  147943. export var volumetricLightScatteringPixelShader: {
  147944. name: string;
  147945. shader: string;
  147946. };
  147947. }
  147948. declare module BABYLON {
  147949. /** @hidden */
  147950. export var volumetricLightScatteringPassVertexShader: {
  147951. name: string;
  147952. shader: string;
  147953. };
  147954. }
  147955. declare module BABYLON {
  147956. /** @hidden */
  147957. export var volumetricLightScatteringPassPixelShader: {
  147958. name: string;
  147959. shader: string;
  147960. };
  147961. }
  147962. declare module BABYLON {
  147963. /**
  147964. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147965. */
  147966. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147967. private _volumetricLightScatteringPass;
  147968. private _volumetricLightScatteringRTT;
  147969. private _viewPort;
  147970. private _screenCoordinates;
  147971. private _cachedDefines;
  147972. /**
  147973. * If not undefined, the mesh position is computed from the attached node position
  147974. */
  147975. attachedNode: {
  147976. position: Vector3;
  147977. };
  147978. /**
  147979. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147980. */
  147981. customMeshPosition: Vector3;
  147982. /**
  147983. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147984. */
  147985. useCustomMeshPosition: boolean;
  147986. /**
  147987. * If the post-process should inverse the light scattering direction
  147988. */
  147989. invert: boolean;
  147990. /**
  147991. * The internal mesh used by the post-process
  147992. */
  147993. mesh: Mesh;
  147994. /**
  147995. * @hidden
  147996. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147997. */
  147998. get useDiffuseColor(): boolean;
  147999. set useDiffuseColor(useDiffuseColor: boolean);
  148000. /**
  148001. * Array containing the excluded meshes not rendered in the internal pass
  148002. */
  148003. excludedMeshes: AbstractMesh[];
  148004. /**
  148005. * Controls the overall intensity of the post-process
  148006. */
  148007. exposure: number;
  148008. /**
  148009. * Dissipates each sample's contribution in range [0, 1]
  148010. */
  148011. decay: number;
  148012. /**
  148013. * Controls the overall intensity of each sample
  148014. */
  148015. weight: number;
  148016. /**
  148017. * Controls the density of each sample
  148018. */
  148019. density: number;
  148020. /**
  148021. * @constructor
  148022. * @param name The post-process name
  148023. * @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)
  148024. * @param camera The camera that the post-process will be attached to
  148025. * @param mesh The mesh used to create the light scattering
  148026. * @param samples The post-process quality, default 100
  148027. * @param samplingModeThe post-process filtering mode
  148028. * @param engine The babylon engine
  148029. * @param reusable If the post-process is reusable
  148030. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148031. */
  148032. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148033. /**
  148034. * Returns the string "VolumetricLightScatteringPostProcess"
  148035. * @returns "VolumetricLightScatteringPostProcess"
  148036. */
  148037. getClassName(): string;
  148038. private _isReady;
  148039. /**
  148040. * Sets the new light position for light scattering effect
  148041. * @param position The new custom light position
  148042. */
  148043. setCustomMeshPosition(position: Vector3): void;
  148044. /**
  148045. * Returns the light position for light scattering effect
  148046. * @return Vector3 The custom light position
  148047. */
  148048. getCustomMeshPosition(): Vector3;
  148049. /**
  148050. * Disposes the internal assets and detaches the post-process from the camera
  148051. */
  148052. dispose(camera: Camera): void;
  148053. /**
  148054. * Returns the render target texture used by the post-process
  148055. * @return the render target texture used by the post-process
  148056. */
  148057. getPass(): RenderTargetTexture;
  148058. private _meshExcluded;
  148059. private _createPass;
  148060. private _updateMeshScreenCoordinates;
  148061. /**
  148062. * Creates a default mesh for the Volumeric Light Scattering post-process
  148063. * @param name The mesh name
  148064. * @param scene The scene where to create the mesh
  148065. * @return the default mesh
  148066. */
  148067. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148068. }
  148069. }
  148070. declare module BABYLON {
  148071. interface Scene {
  148072. /** @hidden (Backing field) */
  148073. _boundingBoxRenderer: BoundingBoxRenderer;
  148074. /** @hidden (Backing field) */
  148075. _forceShowBoundingBoxes: boolean;
  148076. /**
  148077. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148078. */
  148079. forceShowBoundingBoxes: boolean;
  148080. /**
  148081. * Gets the bounding box renderer associated with the scene
  148082. * @returns a BoundingBoxRenderer
  148083. */
  148084. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148085. }
  148086. interface AbstractMesh {
  148087. /** @hidden (Backing field) */
  148088. _showBoundingBox: boolean;
  148089. /**
  148090. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148091. */
  148092. showBoundingBox: boolean;
  148093. }
  148094. /**
  148095. * Component responsible of rendering the bounding box of the meshes in a scene.
  148096. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148097. */
  148098. export class BoundingBoxRenderer implements ISceneComponent {
  148099. /**
  148100. * The component name helpfull to identify the component in the list of scene components.
  148101. */
  148102. readonly name: string;
  148103. /**
  148104. * The scene the component belongs to.
  148105. */
  148106. scene: Scene;
  148107. /**
  148108. * Color of the bounding box lines placed in front of an object
  148109. */
  148110. frontColor: Color3;
  148111. /**
  148112. * Color of the bounding box lines placed behind an object
  148113. */
  148114. backColor: Color3;
  148115. /**
  148116. * Defines if the renderer should show the back lines or not
  148117. */
  148118. showBackLines: boolean;
  148119. /**
  148120. * Observable raised before rendering a bounding box
  148121. */
  148122. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148123. /**
  148124. * Observable raised after rendering a bounding box
  148125. */
  148126. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148127. /**
  148128. * @hidden
  148129. */
  148130. renderList: SmartArray<BoundingBox>;
  148131. private _colorShader;
  148132. private _vertexBuffers;
  148133. private _indexBuffer;
  148134. private _fillIndexBuffer;
  148135. private _fillIndexData;
  148136. /**
  148137. * Instantiates a new bounding box renderer in a scene.
  148138. * @param scene the scene the renderer renders in
  148139. */
  148140. constructor(scene: Scene);
  148141. /**
  148142. * Registers the component in a given scene
  148143. */
  148144. register(): void;
  148145. private _evaluateSubMesh;
  148146. private _activeMesh;
  148147. private _prepareRessources;
  148148. private _createIndexBuffer;
  148149. /**
  148150. * Rebuilds the elements related to this component in case of
  148151. * context lost for instance.
  148152. */
  148153. rebuild(): void;
  148154. /**
  148155. * @hidden
  148156. */
  148157. reset(): void;
  148158. /**
  148159. * Render the bounding boxes of a specific rendering group
  148160. * @param renderingGroupId defines the rendering group to render
  148161. */
  148162. render(renderingGroupId: number): void;
  148163. /**
  148164. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148165. * @param mesh Define the mesh to render the occlusion bounding box for
  148166. */
  148167. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148168. /**
  148169. * Dispose and release the resources attached to this renderer.
  148170. */
  148171. dispose(): void;
  148172. }
  148173. }
  148174. declare module BABYLON {
  148175. interface Scene {
  148176. /** @hidden (Backing field) */
  148177. _depthRenderer: {
  148178. [id: string]: DepthRenderer;
  148179. };
  148180. /**
  148181. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148182. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148183. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148184. * @returns the created depth renderer
  148185. */
  148186. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148187. /**
  148188. * Disables a depth renderer for a given camera
  148189. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148190. */
  148191. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148192. }
  148193. /**
  148194. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148195. * in several rendering techniques.
  148196. */
  148197. export class DepthRendererSceneComponent implements ISceneComponent {
  148198. /**
  148199. * The component name helpfull to identify the component in the list of scene components.
  148200. */
  148201. readonly name: string;
  148202. /**
  148203. * The scene the component belongs to.
  148204. */
  148205. scene: Scene;
  148206. /**
  148207. * Creates a new instance of the component for the given scene
  148208. * @param scene Defines the scene to register the component in
  148209. */
  148210. constructor(scene: Scene);
  148211. /**
  148212. * Registers the component in a given scene
  148213. */
  148214. register(): void;
  148215. /**
  148216. * Rebuilds the elements related to this component in case of
  148217. * context lost for instance.
  148218. */
  148219. rebuild(): void;
  148220. /**
  148221. * Disposes the component and the associated ressources
  148222. */
  148223. dispose(): void;
  148224. private _gatherRenderTargets;
  148225. private _gatherActiveCameraRenderTargets;
  148226. }
  148227. }
  148228. declare module BABYLON {
  148229. /** @hidden */
  148230. export var outlinePixelShader: {
  148231. name: string;
  148232. shader: string;
  148233. };
  148234. }
  148235. declare module BABYLON {
  148236. /** @hidden */
  148237. export var outlineVertexShader: {
  148238. name: string;
  148239. shader: string;
  148240. };
  148241. }
  148242. declare module BABYLON {
  148243. interface Scene {
  148244. /** @hidden */
  148245. _outlineRenderer: OutlineRenderer;
  148246. /**
  148247. * Gets the outline renderer associated with the scene
  148248. * @returns a OutlineRenderer
  148249. */
  148250. getOutlineRenderer(): OutlineRenderer;
  148251. }
  148252. interface AbstractMesh {
  148253. /** @hidden (Backing field) */
  148254. _renderOutline: boolean;
  148255. /**
  148256. * Gets or sets a boolean indicating if the outline must be rendered as well
  148257. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  148258. */
  148259. renderOutline: boolean;
  148260. /** @hidden (Backing field) */
  148261. _renderOverlay: boolean;
  148262. /**
  148263. * Gets or sets a boolean indicating if the overlay must be rendered as well
  148264. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  148265. */
  148266. renderOverlay: boolean;
  148267. }
  148268. /**
  148269. * This class is responsible to draw bothe outline/overlay of meshes.
  148270. * It should not be used directly but through the available method on mesh.
  148271. */
  148272. export class OutlineRenderer implements ISceneComponent {
  148273. /**
  148274. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  148275. */
  148276. private static _StencilReference;
  148277. /**
  148278. * The name of the component. Each component must have a unique name.
  148279. */
  148280. name: string;
  148281. /**
  148282. * The scene the component belongs to.
  148283. */
  148284. scene: Scene;
  148285. /**
  148286. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  148287. */
  148288. zOffset: number;
  148289. private _engine;
  148290. private _effect;
  148291. private _cachedDefines;
  148292. private _savedDepthWrite;
  148293. /**
  148294. * Instantiates a new outline renderer. (There could be only one per scene).
  148295. * @param scene Defines the scene it belongs to
  148296. */
  148297. constructor(scene: Scene);
  148298. /**
  148299. * Register the component to one instance of a scene.
  148300. */
  148301. register(): void;
  148302. /**
  148303. * Rebuilds the elements related to this component in case of
  148304. * context lost for instance.
  148305. */
  148306. rebuild(): void;
  148307. /**
  148308. * Disposes the component and the associated ressources.
  148309. */
  148310. dispose(): void;
  148311. /**
  148312. * Renders the outline in the canvas.
  148313. * @param subMesh Defines the sumesh to render
  148314. * @param batch Defines the batch of meshes in case of instances
  148315. * @param useOverlay Defines if the rendering is for the overlay or the outline
  148316. */
  148317. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  148318. /**
  148319. * Returns whether or not the outline renderer is ready for a given submesh.
  148320. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  148321. * @param subMesh Defines the submesh to check readyness for
  148322. * @param useInstances Defines wheter wee are trying to render instances or not
  148323. * @returns true if ready otherwise false
  148324. */
  148325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148326. private _beforeRenderingMesh;
  148327. private _afterRenderingMesh;
  148328. }
  148329. }
  148330. declare module BABYLON {
  148331. /**
  148332. * Defines the basic options interface of a Sprite Frame Source Size.
  148333. */
  148334. export interface ISpriteJSONSpriteSourceSize {
  148335. /**
  148336. * number of the original width of the Frame
  148337. */
  148338. w: number;
  148339. /**
  148340. * number of the original height of the Frame
  148341. */
  148342. h: number;
  148343. }
  148344. /**
  148345. * Defines the basic options interface of a Sprite Frame Data.
  148346. */
  148347. export interface ISpriteJSONSpriteFrameData {
  148348. /**
  148349. * number of the x offset of the Frame
  148350. */
  148351. x: number;
  148352. /**
  148353. * number of the y offset of the Frame
  148354. */
  148355. y: number;
  148356. /**
  148357. * number of the width of the Frame
  148358. */
  148359. w: number;
  148360. /**
  148361. * number of the height of the Frame
  148362. */
  148363. h: number;
  148364. }
  148365. /**
  148366. * Defines the basic options interface of a JSON Sprite.
  148367. */
  148368. export interface ISpriteJSONSprite {
  148369. /**
  148370. * string name of the Frame
  148371. */
  148372. filename: string;
  148373. /**
  148374. * ISpriteJSONSpriteFrame basic object of the frame data
  148375. */
  148376. frame: ISpriteJSONSpriteFrameData;
  148377. /**
  148378. * boolean to flag is the frame was rotated.
  148379. */
  148380. rotated: boolean;
  148381. /**
  148382. * boolean to flag is the frame was trimmed.
  148383. */
  148384. trimmed: boolean;
  148385. /**
  148386. * ISpriteJSONSpriteFrame basic object of the source data
  148387. */
  148388. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148389. /**
  148390. * ISpriteJSONSpriteFrame basic object of the source data
  148391. */
  148392. sourceSize: ISpriteJSONSpriteSourceSize;
  148393. }
  148394. /**
  148395. * Defines the basic options interface of a JSON atlas.
  148396. */
  148397. export interface ISpriteJSONAtlas {
  148398. /**
  148399. * Array of objects that contain the frame data.
  148400. */
  148401. frames: Array<ISpriteJSONSprite>;
  148402. /**
  148403. * object basic object containing the sprite meta data.
  148404. */
  148405. meta?: object;
  148406. }
  148407. }
  148408. declare module BABYLON {
  148409. /** @hidden */
  148410. export var spriteMapPixelShader: {
  148411. name: string;
  148412. shader: string;
  148413. };
  148414. }
  148415. declare module BABYLON {
  148416. /** @hidden */
  148417. export var spriteMapVertexShader: {
  148418. name: string;
  148419. shader: string;
  148420. };
  148421. }
  148422. declare module BABYLON {
  148423. /**
  148424. * Defines the basic options interface of a SpriteMap
  148425. */
  148426. export interface ISpriteMapOptions {
  148427. /**
  148428. * Vector2 of the number of cells in the grid.
  148429. */
  148430. stageSize?: Vector2;
  148431. /**
  148432. * Vector2 of the size of the output plane in World Units.
  148433. */
  148434. outputSize?: Vector2;
  148435. /**
  148436. * Vector3 of the position of the output plane in World Units.
  148437. */
  148438. outputPosition?: Vector3;
  148439. /**
  148440. * Vector3 of the rotation of the output plane.
  148441. */
  148442. outputRotation?: Vector3;
  148443. /**
  148444. * number of layers that the system will reserve in resources.
  148445. */
  148446. layerCount?: number;
  148447. /**
  148448. * number of max animation frames a single cell will reserve in resources.
  148449. */
  148450. maxAnimationFrames?: number;
  148451. /**
  148452. * number cell index of the base tile when the system compiles.
  148453. */
  148454. baseTile?: number;
  148455. /**
  148456. * boolean flip the sprite after its been repositioned by the framing data.
  148457. */
  148458. flipU?: boolean;
  148459. /**
  148460. * Vector3 scalar of the global RGB values of the SpriteMap.
  148461. */
  148462. colorMultiply?: Vector3;
  148463. }
  148464. /**
  148465. * Defines the IDisposable interface in order to be cleanable from resources.
  148466. */
  148467. export interface ISpriteMap extends IDisposable {
  148468. /**
  148469. * String name of the SpriteMap.
  148470. */
  148471. name: string;
  148472. /**
  148473. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148474. */
  148475. atlasJSON: ISpriteJSONAtlas;
  148476. /**
  148477. * Texture of the SpriteMap.
  148478. */
  148479. spriteSheet: Texture;
  148480. /**
  148481. * The parameters to initialize the SpriteMap with.
  148482. */
  148483. options: ISpriteMapOptions;
  148484. }
  148485. /**
  148486. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148487. */
  148488. export class SpriteMap implements ISpriteMap {
  148489. /** The Name of the spriteMap */
  148490. name: string;
  148491. /** The JSON file with the frame and meta data */
  148492. atlasJSON: ISpriteJSONAtlas;
  148493. /** The systems Sprite Sheet Texture */
  148494. spriteSheet: Texture;
  148495. /** Arguments passed with the Constructor */
  148496. options: ISpriteMapOptions;
  148497. /** Public Sprite Storage array, parsed from atlasJSON */
  148498. sprites: Array<ISpriteJSONSprite>;
  148499. /** Returns the Number of Sprites in the System */
  148500. get spriteCount(): number;
  148501. /** Returns the Position of Output Plane*/
  148502. get position(): Vector3;
  148503. /** Returns the Position of Output Plane*/
  148504. set position(v: Vector3);
  148505. /** Returns the Rotation of Output Plane*/
  148506. get rotation(): Vector3;
  148507. /** Returns the Rotation of Output Plane*/
  148508. set rotation(v: Vector3);
  148509. /** Sets the AnimationMap*/
  148510. get animationMap(): RawTexture;
  148511. /** Sets the AnimationMap*/
  148512. set animationMap(v: RawTexture);
  148513. /** Scene that the SpriteMap was created in */
  148514. private _scene;
  148515. /** Texture Buffer of Float32 that holds tile frame data*/
  148516. private _frameMap;
  148517. /** Texture Buffers of Float32 that holds tileMap data*/
  148518. private _tileMaps;
  148519. /** Texture Buffer of Float32 that holds Animation Data*/
  148520. private _animationMap;
  148521. /** Custom ShaderMaterial Central to the System*/
  148522. private _material;
  148523. /** Custom ShaderMaterial Central to the System*/
  148524. private _output;
  148525. /** Systems Time Ticker*/
  148526. private _time;
  148527. /**
  148528. * Creates a new SpriteMap
  148529. * @param name defines the SpriteMaps Name
  148530. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148531. * @param spriteSheet is the Texture that the Sprites are on.
  148532. * @param options a basic deployment configuration
  148533. * @param scene The Scene that the map is deployed on
  148534. */
  148535. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148536. /**
  148537. * Returns tileID location
  148538. * @returns Vector2 the cell position ID
  148539. */
  148540. getTileID(): Vector2;
  148541. /**
  148542. * Gets the UV location of the mouse over the SpriteMap.
  148543. * @returns Vector2 the UV position of the mouse interaction
  148544. */
  148545. getMousePosition(): Vector2;
  148546. /**
  148547. * Creates the "frame" texture Buffer
  148548. * -------------------------------------
  148549. * Structure of frames
  148550. * "filename": "Falling-Water-2.png",
  148551. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148552. * "rotated": true,
  148553. * "trimmed": true,
  148554. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148555. * "sourceSize": {"w":32,"h":32}
  148556. * @returns RawTexture of the frameMap
  148557. */
  148558. private _createFrameBuffer;
  148559. /**
  148560. * Creates the tileMap texture Buffer
  148561. * @param buffer normally and array of numbers, or a false to generate from scratch
  148562. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148563. * @returns RawTexture of the tileMap
  148564. */
  148565. private _createTileBuffer;
  148566. /**
  148567. * Modifies the data of the tileMaps
  148568. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148569. * @param pos is the iVector2 Coordinates of the Tile
  148570. * @param tile The SpriteIndex of the new Tile
  148571. */
  148572. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148573. /**
  148574. * Creates the animationMap texture Buffer
  148575. * @param buffer normally and array of numbers, or a false to generate from scratch
  148576. * @returns RawTexture of the animationMap
  148577. */
  148578. private _createTileAnimationBuffer;
  148579. /**
  148580. * Modifies the data of the animationMap
  148581. * @param cellID is the Index of the Sprite
  148582. * @param _frame is the target Animation frame
  148583. * @param toCell is the Target Index of the next frame of the animation
  148584. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148585. * @param speed is a global scalar of the time variable on the map.
  148586. */
  148587. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148588. /**
  148589. * Exports the .tilemaps file
  148590. */
  148591. saveTileMaps(): void;
  148592. /**
  148593. * Imports the .tilemaps file
  148594. * @param url of the .tilemaps file
  148595. */
  148596. loadTileMaps(url: string): void;
  148597. /**
  148598. * Release associated resources
  148599. */
  148600. dispose(): void;
  148601. }
  148602. }
  148603. declare module BABYLON {
  148604. /**
  148605. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148606. * @see http://doc.babylonjs.com/babylon101/sprites
  148607. */
  148608. export class SpritePackedManager extends SpriteManager {
  148609. /** defines the packed manager's name */
  148610. name: string;
  148611. /**
  148612. * Creates a new sprite manager from a packed sprite sheet
  148613. * @param name defines the manager's name
  148614. * @param imgUrl defines the sprite sheet url
  148615. * @param capacity defines the maximum allowed number of sprites
  148616. * @param scene defines the hosting scene
  148617. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148618. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148619. * @param samplingMode defines the smapling mode to use with spritesheet
  148620. * @param fromPacked set to true; do not alter
  148621. */
  148622. constructor(
  148623. /** defines the packed manager's name */
  148624. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148625. }
  148626. }
  148627. declare module BABYLON {
  148628. /**
  148629. * Defines the list of states available for a task inside a AssetsManager
  148630. */
  148631. export enum AssetTaskState {
  148632. /**
  148633. * Initialization
  148634. */
  148635. INIT = 0,
  148636. /**
  148637. * Running
  148638. */
  148639. RUNNING = 1,
  148640. /**
  148641. * Done
  148642. */
  148643. DONE = 2,
  148644. /**
  148645. * Error
  148646. */
  148647. ERROR = 3
  148648. }
  148649. /**
  148650. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148651. */
  148652. export abstract class AbstractAssetTask {
  148653. /**
  148654. * Task name
  148655. */ name: string;
  148656. /**
  148657. * Callback called when the task is successful
  148658. */
  148659. onSuccess: (task: any) => void;
  148660. /**
  148661. * Callback called when the task is not successful
  148662. */
  148663. onError: (task: any, message?: string, exception?: any) => void;
  148664. /**
  148665. * Creates a new AssetsManager
  148666. * @param name defines the name of the task
  148667. */
  148668. constructor(
  148669. /**
  148670. * Task name
  148671. */ name: string);
  148672. private _isCompleted;
  148673. private _taskState;
  148674. private _errorObject;
  148675. /**
  148676. * Get if the task is completed
  148677. */
  148678. get isCompleted(): boolean;
  148679. /**
  148680. * Gets the current state of the task
  148681. */
  148682. get taskState(): AssetTaskState;
  148683. /**
  148684. * Gets the current error object (if task is in error)
  148685. */
  148686. get errorObject(): {
  148687. message?: string;
  148688. exception?: any;
  148689. };
  148690. /**
  148691. * Internal only
  148692. * @hidden
  148693. */
  148694. _setErrorObject(message?: string, exception?: any): void;
  148695. /**
  148696. * Execute the current task
  148697. * @param scene defines the scene where you want your assets to be loaded
  148698. * @param onSuccess is a callback called when the task is successfully executed
  148699. * @param onError is a callback called if an error occurs
  148700. */
  148701. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148702. /**
  148703. * Execute the current task
  148704. * @param scene defines the scene where you want your assets to be loaded
  148705. * @param onSuccess is a callback called when the task is successfully executed
  148706. * @param onError is a callback called if an error occurs
  148707. */
  148708. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148709. /**
  148710. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148711. * This can be used with failed tasks that have the reason for failure fixed.
  148712. */
  148713. reset(): void;
  148714. private onErrorCallback;
  148715. private onDoneCallback;
  148716. }
  148717. /**
  148718. * Define the interface used by progress events raised during assets loading
  148719. */
  148720. export interface IAssetsProgressEvent {
  148721. /**
  148722. * Defines the number of remaining tasks to process
  148723. */
  148724. remainingCount: number;
  148725. /**
  148726. * Defines the total number of tasks
  148727. */
  148728. totalCount: number;
  148729. /**
  148730. * Defines the task that was just processed
  148731. */
  148732. task: AbstractAssetTask;
  148733. }
  148734. /**
  148735. * Class used to share progress information about assets loading
  148736. */
  148737. export class AssetsProgressEvent implements IAssetsProgressEvent {
  148738. /**
  148739. * Defines the number of remaining tasks to process
  148740. */
  148741. remainingCount: number;
  148742. /**
  148743. * Defines the total number of tasks
  148744. */
  148745. totalCount: number;
  148746. /**
  148747. * Defines the task that was just processed
  148748. */
  148749. task: AbstractAssetTask;
  148750. /**
  148751. * Creates a AssetsProgressEvent
  148752. * @param remainingCount defines the number of remaining tasks to process
  148753. * @param totalCount defines the total number of tasks
  148754. * @param task defines the task that was just processed
  148755. */
  148756. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  148757. }
  148758. /**
  148759. * Define a task used by AssetsManager to load meshes
  148760. */
  148761. export class MeshAssetTask extends AbstractAssetTask {
  148762. /**
  148763. * Defines the name of the task
  148764. */
  148765. name: string;
  148766. /**
  148767. * Defines the list of mesh's names you want to load
  148768. */
  148769. meshesNames: any;
  148770. /**
  148771. * Defines the root url to use as a base to load your meshes and associated resources
  148772. */
  148773. rootUrl: string;
  148774. /**
  148775. * Defines the filename or File of the scene to load from
  148776. */
  148777. sceneFilename: string | File;
  148778. /**
  148779. * Gets the list of loaded meshes
  148780. */
  148781. loadedMeshes: Array<AbstractMesh>;
  148782. /**
  148783. * Gets the list of loaded particle systems
  148784. */
  148785. loadedParticleSystems: Array<IParticleSystem>;
  148786. /**
  148787. * Gets the list of loaded skeletons
  148788. */
  148789. loadedSkeletons: Array<Skeleton>;
  148790. /**
  148791. * Gets the list of loaded animation groups
  148792. */
  148793. loadedAnimationGroups: Array<AnimationGroup>;
  148794. /**
  148795. * Callback called when the task is successful
  148796. */
  148797. onSuccess: (task: MeshAssetTask) => void;
  148798. /**
  148799. * Callback called when the task is successful
  148800. */
  148801. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  148802. /**
  148803. * Creates a new MeshAssetTask
  148804. * @param name defines the name of the task
  148805. * @param meshesNames defines the list of mesh's names you want to load
  148806. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  148807. * @param sceneFilename defines the filename or File of the scene to load from
  148808. */
  148809. constructor(
  148810. /**
  148811. * Defines the name of the task
  148812. */
  148813. name: string,
  148814. /**
  148815. * Defines the list of mesh's names you want to load
  148816. */
  148817. meshesNames: any,
  148818. /**
  148819. * Defines the root url to use as a base to load your meshes and associated resources
  148820. */
  148821. rootUrl: string,
  148822. /**
  148823. * Defines the filename or File of the scene to load from
  148824. */
  148825. sceneFilename: string | File);
  148826. /**
  148827. * Execute the current task
  148828. * @param scene defines the scene where you want your assets to be loaded
  148829. * @param onSuccess is a callback called when the task is successfully executed
  148830. * @param onError is a callback called if an error occurs
  148831. */
  148832. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148833. }
  148834. /**
  148835. * Define a task used by AssetsManager to load text content
  148836. */
  148837. export class TextFileAssetTask extends AbstractAssetTask {
  148838. /**
  148839. * Defines the name of the task
  148840. */
  148841. name: string;
  148842. /**
  148843. * Defines the location of the file to load
  148844. */
  148845. url: string;
  148846. /**
  148847. * Gets the loaded text string
  148848. */
  148849. text: string;
  148850. /**
  148851. * Callback called when the task is successful
  148852. */
  148853. onSuccess: (task: TextFileAssetTask) => void;
  148854. /**
  148855. * Callback called when the task is successful
  148856. */
  148857. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148858. /**
  148859. * Creates a new TextFileAssetTask object
  148860. * @param name defines the name of the task
  148861. * @param url defines the location of the file to load
  148862. */
  148863. constructor(
  148864. /**
  148865. * Defines the name of the task
  148866. */
  148867. name: string,
  148868. /**
  148869. * Defines the location of the file to load
  148870. */
  148871. url: string);
  148872. /**
  148873. * Execute the current task
  148874. * @param scene defines the scene where you want your assets to be loaded
  148875. * @param onSuccess is a callback called when the task is successfully executed
  148876. * @param onError is a callback called if an error occurs
  148877. */
  148878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148879. }
  148880. /**
  148881. * Define a task used by AssetsManager to load binary data
  148882. */
  148883. export class BinaryFileAssetTask extends AbstractAssetTask {
  148884. /**
  148885. * Defines the name of the task
  148886. */
  148887. name: string;
  148888. /**
  148889. * Defines the location of the file to load
  148890. */
  148891. url: string;
  148892. /**
  148893. * Gets the lodaded data (as an array buffer)
  148894. */
  148895. data: ArrayBuffer;
  148896. /**
  148897. * Callback called when the task is successful
  148898. */
  148899. onSuccess: (task: BinaryFileAssetTask) => void;
  148900. /**
  148901. * Callback called when the task is successful
  148902. */
  148903. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148904. /**
  148905. * Creates a new BinaryFileAssetTask object
  148906. * @param name defines the name of the new task
  148907. * @param url defines the location of the file to load
  148908. */
  148909. constructor(
  148910. /**
  148911. * Defines the name of the task
  148912. */
  148913. name: string,
  148914. /**
  148915. * Defines the location of the file to load
  148916. */
  148917. url: string);
  148918. /**
  148919. * Execute the current task
  148920. * @param scene defines the scene where you want your assets to be loaded
  148921. * @param onSuccess is a callback called when the task is successfully executed
  148922. * @param onError is a callback called if an error occurs
  148923. */
  148924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148925. }
  148926. /**
  148927. * Define a task used by AssetsManager to load images
  148928. */
  148929. export class ImageAssetTask extends AbstractAssetTask {
  148930. /**
  148931. * Defines the name of the task
  148932. */
  148933. name: string;
  148934. /**
  148935. * Defines the location of the image to load
  148936. */
  148937. url: string;
  148938. /**
  148939. * Gets the loaded images
  148940. */
  148941. image: HTMLImageElement;
  148942. /**
  148943. * Callback called when the task is successful
  148944. */
  148945. onSuccess: (task: ImageAssetTask) => void;
  148946. /**
  148947. * Callback called when the task is successful
  148948. */
  148949. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148950. /**
  148951. * Creates a new ImageAssetTask
  148952. * @param name defines the name of the task
  148953. * @param url defines the location of the image to load
  148954. */
  148955. constructor(
  148956. /**
  148957. * Defines the name of the task
  148958. */
  148959. name: string,
  148960. /**
  148961. * Defines the location of the image to load
  148962. */
  148963. url: string);
  148964. /**
  148965. * Execute the current task
  148966. * @param scene defines the scene where you want your assets to be loaded
  148967. * @param onSuccess is a callback called when the task is successfully executed
  148968. * @param onError is a callback called if an error occurs
  148969. */
  148970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148971. }
  148972. /**
  148973. * Defines the interface used by texture loading tasks
  148974. */
  148975. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148976. /**
  148977. * Gets the loaded texture
  148978. */
  148979. texture: TEX;
  148980. }
  148981. /**
  148982. * Define a task used by AssetsManager to load 2D textures
  148983. */
  148984. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148985. /**
  148986. * Defines the name of the task
  148987. */
  148988. name: string;
  148989. /**
  148990. * Defines the location of the file to load
  148991. */
  148992. url: string;
  148993. /**
  148994. * Defines if mipmap should not be generated (default is false)
  148995. */
  148996. noMipmap?: boolean | undefined;
  148997. /**
  148998. * Defines if texture must be inverted on Y axis (default is true)
  148999. */
  149000. invertY: boolean;
  149001. /**
  149002. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149003. */
  149004. samplingMode: number;
  149005. /**
  149006. * Gets the loaded texture
  149007. */
  149008. texture: Texture;
  149009. /**
  149010. * Callback called when the task is successful
  149011. */
  149012. onSuccess: (task: TextureAssetTask) => void;
  149013. /**
  149014. * Callback called when the task is successful
  149015. */
  149016. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  149017. /**
  149018. * Creates a new TextureAssetTask object
  149019. * @param name defines the name of the task
  149020. * @param url defines the location of the file to load
  149021. * @param noMipmap defines if mipmap should not be generated (default is false)
  149022. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149024. */
  149025. constructor(
  149026. /**
  149027. * Defines the name of the task
  149028. */
  149029. name: string,
  149030. /**
  149031. * Defines the location of the file to load
  149032. */
  149033. url: string,
  149034. /**
  149035. * Defines if mipmap should not be generated (default is false)
  149036. */
  149037. noMipmap?: boolean | undefined,
  149038. /**
  149039. * Defines if texture must be inverted on Y axis (default is true)
  149040. */
  149041. invertY?: boolean,
  149042. /**
  149043. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149044. */
  149045. samplingMode?: number);
  149046. /**
  149047. * Execute the current task
  149048. * @param scene defines the scene where you want your assets to be loaded
  149049. * @param onSuccess is a callback called when the task is successfully executed
  149050. * @param onError is a callback called if an error occurs
  149051. */
  149052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149053. }
  149054. /**
  149055. * Define a task used by AssetsManager to load cube textures
  149056. */
  149057. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  149058. /**
  149059. * Defines the name of the task
  149060. */
  149061. name: string;
  149062. /**
  149063. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149064. */
  149065. url: string;
  149066. /**
  149067. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149068. */
  149069. extensions?: string[] | undefined;
  149070. /**
  149071. * Defines if mipmaps should not be generated (default is false)
  149072. */
  149073. noMipmap?: boolean | undefined;
  149074. /**
  149075. * Defines the explicit list of files (undefined by default)
  149076. */
  149077. files?: string[] | undefined;
  149078. /**
  149079. * Gets the loaded texture
  149080. */
  149081. texture: CubeTexture;
  149082. /**
  149083. * Callback called when the task is successful
  149084. */
  149085. onSuccess: (task: CubeTextureAssetTask) => void;
  149086. /**
  149087. * Callback called when the task is successful
  149088. */
  149089. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  149090. /**
  149091. * Creates a new CubeTextureAssetTask
  149092. * @param name defines the name of the task
  149093. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149094. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149095. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149096. * @param files defines the explicit list of files (undefined by default)
  149097. */
  149098. constructor(
  149099. /**
  149100. * Defines the name of the task
  149101. */
  149102. name: string,
  149103. /**
  149104. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149105. */
  149106. url: string,
  149107. /**
  149108. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149109. */
  149110. extensions?: string[] | undefined,
  149111. /**
  149112. * Defines if mipmaps should not be generated (default is false)
  149113. */
  149114. noMipmap?: boolean | undefined,
  149115. /**
  149116. * Defines the explicit list of files (undefined by default)
  149117. */
  149118. files?: string[] | undefined);
  149119. /**
  149120. * Execute the current task
  149121. * @param scene defines the scene where you want your assets to be loaded
  149122. * @param onSuccess is a callback called when the task is successfully executed
  149123. * @param onError is a callback called if an error occurs
  149124. */
  149125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149126. }
  149127. /**
  149128. * Define a task used by AssetsManager to load HDR cube textures
  149129. */
  149130. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  149131. /**
  149132. * Defines the name of the task
  149133. */
  149134. name: string;
  149135. /**
  149136. * Defines the location of the file to load
  149137. */
  149138. url: string;
  149139. /**
  149140. * Defines the desired size (the more it increases the longer the generation will be)
  149141. */
  149142. size: number;
  149143. /**
  149144. * Defines if mipmaps should not be generated (default is false)
  149145. */
  149146. noMipmap: boolean;
  149147. /**
  149148. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149149. */
  149150. generateHarmonics: boolean;
  149151. /**
  149152. * 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)
  149153. */
  149154. gammaSpace: boolean;
  149155. /**
  149156. * Internal Use Only
  149157. */
  149158. reserved: boolean;
  149159. /**
  149160. * Gets the loaded texture
  149161. */
  149162. texture: HDRCubeTexture;
  149163. /**
  149164. * Callback called when the task is successful
  149165. */
  149166. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  149167. /**
  149168. * Callback called when the task is successful
  149169. */
  149170. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  149171. /**
  149172. * Creates a new HDRCubeTextureAssetTask object
  149173. * @param name defines the name of the task
  149174. * @param url defines the location of the file to load
  149175. * @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.
  149176. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149177. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149178. * @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)
  149179. * @param reserved Internal use only
  149180. */
  149181. constructor(
  149182. /**
  149183. * Defines the name of the task
  149184. */
  149185. name: string,
  149186. /**
  149187. * Defines the location of the file to load
  149188. */
  149189. url: string,
  149190. /**
  149191. * Defines the desired size (the more it increases the longer the generation will be)
  149192. */
  149193. size: number,
  149194. /**
  149195. * Defines if mipmaps should not be generated (default is false)
  149196. */
  149197. noMipmap?: boolean,
  149198. /**
  149199. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149200. */
  149201. generateHarmonics?: boolean,
  149202. /**
  149203. * 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)
  149204. */
  149205. gammaSpace?: boolean,
  149206. /**
  149207. * Internal Use Only
  149208. */
  149209. reserved?: boolean);
  149210. /**
  149211. * Execute the current task
  149212. * @param scene defines the scene where you want your assets to be loaded
  149213. * @param onSuccess is a callback called when the task is successfully executed
  149214. * @param onError is a callback called if an error occurs
  149215. */
  149216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149217. }
  149218. /**
  149219. * Define a task used by AssetsManager to load Equirectangular cube textures
  149220. */
  149221. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  149222. /**
  149223. * Defines the name of the task
  149224. */
  149225. name: string;
  149226. /**
  149227. * Defines the location of the file to load
  149228. */
  149229. url: string;
  149230. /**
  149231. * Defines the desired size (the more it increases the longer the generation will be)
  149232. */
  149233. size: number;
  149234. /**
  149235. * Defines if mipmaps should not be generated (default is false)
  149236. */
  149237. noMipmap: boolean;
  149238. /**
  149239. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149240. * but the standard material would require them in Gamma space) (default is true)
  149241. */
  149242. gammaSpace: boolean;
  149243. /**
  149244. * Gets the loaded texture
  149245. */
  149246. texture: EquiRectangularCubeTexture;
  149247. /**
  149248. * Callback called when the task is successful
  149249. */
  149250. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  149251. /**
  149252. * Callback called when the task is successful
  149253. */
  149254. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  149255. /**
  149256. * Creates a new EquiRectangularCubeTextureAssetTask object
  149257. * @param name defines the name of the task
  149258. * @param url defines the location of the file to load
  149259. * @param size defines the desired size (the more it increases the longer the generation will be)
  149260. * If the size is omitted this implies you are using a preprocessed cubemap.
  149261. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149262. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  149263. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  149264. * (default is true)
  149265. */
  149266. constructor(
  149267. /**
  149268. * Defines the name of the task
  149269. */
  149270. name: string,
  149271. /**
  149272. * Defines the location of the file to load
  149273. */
  149274. url: string,
  149275. /**
  149276. * Defines the desired size (the more it increases the longer the generation will be)
  149277. */
  149278. size: number,
  149279. /**
  149280. * Defines if mipmaps should not be generated (default is false)
  149281. */
  149282. noMipmap?: boolean,
  149283. /**
  149284. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149285. * but the standard material would require them in Gamma space) (default is true)
  149286. */
  149287. gammaSpace?: boolean);
  149288. /**
  149289. * Execute the current task
  149290. * @param scene defines the scene where you want your assets to be loaded
  149291. * @param onSuccess is a callback called when the task is successfully executed
  149292. * @param onError is a callback called if an error occurs
  149293. */
  149294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149295. }
  149296. /**
  149297. * This class can be used to easily import assets into a scene
  149298. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  149299. */
  149300. export class AssetsManager {
  149301. private _scene;
  149302. private _isLoading;
  149303. protected _tasks: AbstractAssetTask[];
  149304. protected _waitingTasksCount: number;
  149305. protected _totalTasksCount: number;
  149306. /**
  149307. * Callback called when all tasks are processed
  149308. */
  149309. onFinish: (tasks: AbstractAssetTask[]) => void;
  149310. /**
  149311. * Callback called when a task is successful
  149312. */
  149313. onTaskSuccess: (task: AbstractAssetTask) => void;
  149314. /**
  149315. * Callback called when a task had an error
  149316. */
  149317. onTaskError: (task: AbstractAssetTask) => void;
  149318. /**
  149319. * Callback called when a task is done (whatever the result is)
  149320. */
  149321. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  149322. /**
  149323. * Observable called when all tasks are processed
  149324. */
  149325. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  149326. /**
  149327. * Observable called when a task had an error
  149328. */
  149329. onTaskErrorObservable: Observable<AbstractAssetTask>;
  149330. /**
  149331. * Observable called when all tasks were executed
  149332. */
  149333. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  149334. /**
  149335. * Observable called when a task is done (whatever the result is)
  149336. */
  149337. onProgressObservable: Observable<IAssetsProgressEvent>;
  149338. /**
  149339. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  149340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  149341. */
  149342. useDefaultLoadingScreen: boolean;
  149343. /**
  149344. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  149345. * when all assets have been downloaded.
  149346. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  149347. */
  149348. autoHideLoadingUI: boolean;
  149349. /**
  149350. * Creates a new AssetsManager
  149351. * @param scene defines the scene to work on
  149352. */
  149353. constructor(scene: Scene);
  149354. /**
  149355. * Add a MeshAssetTask to the list of active tasks
  149356. * @param taskName defines the name of the new task
  149357. * @param meshesNames defines the name of meshes to load
  149358. * @param rootUrl defines the root url to use to locate files
  149359. * @param sceneFilename defines the filename of the scene file
  149360. * @returns a new MeshAssetTask object
  149361. */
  149362. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149363. /**
  149364. * Add a TextFileAssetTask to the list of active tasks
  149365. * @param taskName defines the name of the new task
  149366. * @param url defines the url of the file to load
  149367. * @returns a new TextFileAssetTask object
  149368. */
  149369. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149370. /**
  149371. * Add a BinaryFileAssetTask to the list of active tasks
  149372. * @param taskName defines the name of the new task
  149373. * @param url defines the url of the file to load
  149374. * @returns a new BinaryFileAssetTask object
  149375. */
  149376. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149377. /**
  149378. * Add a ImageAssetTask to the list of active tasks
  149379. * @param taskName defines the name of the new task
  149380. * @param url defines the url of the file to load
  149381. * @returns a new ImageAssetTask object
  149382. */
  149383. addImageTask(taskName: string, url: string): ImageAssetTask;
  149384. /**
  149385. * Add a TextureAssetTask to the list of active tasks
  149386. * @param taskName defines the name of the new task
  149387. * @param url defines the url of the file to load
  149388. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149389. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149390. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149391. * @returns a new TextureAssetTask object
  149392. */
  149393. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149394. /**
  149395. * Add a CubeTextureAssetTask to the list of active tasks
  149396. * @param taskName defines the name of the new task
  149397. * @param url defines the url of the file to load
  149398. * @param extensions defines the extension to use to load the cube map (can be null)
  149399. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149400. * @param files defines the list of files to load (can be null)
  149401. * @returns a new CubeTextureAssetTask object
  149402. */
  149403. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149404. /**
  149405. *
  149406. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149407. * @param taskName defines the name of the new task
  149408. * @param url defines the url of the file to load
  149409. * @param size defines the size you want for the cubemap (can be null)
  149410. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149411. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149412. * @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)
  149413. * @param reserved Internal use only
  149414. * @returns a new HDRCubeTextureAssetTask object
  149415. */
  149416. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149417. /**
  149418. *
  149419. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149420. * @param taskName defines the name of the new task
  149421. * @param url defines the url of the file to load
  149422. * @param size defines the size you want for the cubemap (can be null)
  149423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149424. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149425. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149426. * @returns a new EquiRectangularCubeTextureAssetTask object
  149427. */
  149428. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149429. /**
  149430. * Remove a task from the assets manager.
  149431. * @param task the task to remove
  149432. */
  149433. removeTask(task: AbstractAssetTask): void;
  149434. private _decreaseWaitingTasksCount;
  149435. private _runTask;
  149436. /**
  149437. * Reset the AssetsManager and remove all tasks
  149438. * @return the current instance of the AssetsManager
  149439. */
  149440. reset(): AssetsManager;
  149441. /**
  149442. * Start the loading process
  149443. * @return the current instance of the AssetsManager
  149444. */
  149445. load(): AssetsManager;
  149446. /**
  149447. * Start the loading process as an async operation
  149448. * @return a promise returning the list of failed tasks
  149449. */
  149450. loadAsync(): Promise<void>;
  149451. }
  149452. }
  149453. declare module BABYLON {
  149454. /**
  149455. * Wrapper class for promise with external resolve and reject.
  149456. */
  149457. export class Deferred<T> {
  149458. /**
  149459. * The promise associated with this deferred object.
  149460. */
  149461. readonly promise: Promise<T>;
  149462. private _resolve;
  149463. private _reject;
  149464. /**
  149465. * The resolve method of the promise associated with this deferred object.
  149466. */
  149467. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149468. /**
  149469. * The reject method of the promise associated with this deferred object.
  149470. */
  149471. get reject(): (reason?: any) => void;
  149472. /**
  149473. * Constructor for this deferred object.
  149474. */
  149475. constructor();
  149476. }
  149477. }
  149478. declare module BABYLON {
  149479. /**
  149480. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149481. */
  149482. export class MeshExploder {
  149483. private _centerMesh;
  149484. private _meshes;
  149485. private _meshesOrigins;
  149486. private _toCenterVectors;
  149487. private _scaledDirection;
  149488. private _newPosition;
  149489. private _centerPosition;
  149490. /**
  149491. * Explodes meshes from a center mesh.
  149492. * @param meshes The meshes to explode.
  149493. * @param centerMesh The mesh to be center of explosion.
  149494. */
  149495. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149496. private _setCenterMesh;
  149497. /**
  149498. * Get class name
  149499. * @returns "MeshExploder"
  149500. */
  149501. getClassName(): string;
  149502. /**
  149503. * "Exploded meshes"
  149504. * @returns Array of meshes with the centerMesh at index 0.
  149505. */
  149506. getMeshes(): Array<Mesh>;
  149507. /**
  149508. * Explodes meshes giving a specific direction
  149509. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149510. */
  149511. explode(direction?: number): void;
  149512. }
  149513. }
  149514. declare module BABYLON {
  149515. /**
  149516. * Class used to help managing file picking and drag'n'drop
  149517. */
  149518. export class FilesInput {
  149519. /**
  149520. * List of files ready to be loaded
  149521. */
  149522. static get FilesToLoad(): {
  149523. [key: string]: File;
  149524. };
  149525. /**
  149526. * Callback called when a file is processed
  149527. */
  149528. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  149529. private _engine;
  149530. private _currentScene;
  149531. private _sceneLoadedCallback;
  149532. private _progressCallback;
  149533. private _additionalRenderLoopLogicCallback;
  149534. private _textureLoadingCallback;
  149535. private _startingProcessingFilesCallback;
  149536. private _onReloadCallback;
  149537. private _errorCallback;
  149538. private _elementToMonitor;
  149539. private _sceneFileToLoad;
  149540. private _filesToLoad;
  149541. /**
  149542. * Creates a new FilesInput
  149543. * @param engine defines the rendering engine
  149544. * @param scene defines the hosting scene
  149545. * @param sceneLoadedCallback callback called when scene is loaded
  149546. * @param progressCallback callback called to track progress
  149547. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149548. * @param textureLoadingCallback callback called when a texture is loading
  149549. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149550. * @param onReloadCallback callback called when a reload is requested
  149551. * @param errorCallback callback call if an error occurs
  149552. */
  149553. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  149554. private _dragEnterHandler;
  149555. private _dragOverHandler;
  149556. private _dropHandler;
  149557. /**
  149558. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149559. * @param elementToMonitor defines the DOM element to track
  149560. */
  149561. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149562. /**
  149563. * Release all associated resources
  149564. */
  149565. dispose(): void;
  149566. private renderFunction;
  149567. private drag;
  149568. private drop;
  149569. private _traverseFolder;
  149570. private _processFiles;
  149571. /**
  149572. * Load files from a drop event
  149573. * @param event defines the drop event to use as source
  149574. */
  149575. loadFiles(event: any): void;
  149576. private _processReload;
  149577. /**
  149578. * Reload the current scene from the loaded files
  149579. */
  149580. reload(): void;
  149581. }
  149582. }
  149583. declare module BABYLON {
  149584. /**
  149585. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149586. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149587. */
  149588. export class SceneOptimization {
  149589. /**
  149590. * Defines the priority of this optimization (0 by default which means first in the list)
  149591. */
  149592. priority: number;
  149593. /**
  149594. * Gets a string describing the action executed by the current optimization
  149595. * @returns description string
  149596. */
  149597. getDescription(): string;
  149598. /**
  149599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149600. * @param scene defines the current scene where to apply this optimization
  149601. * @param optimizer defines the current optimizer
  149602. * @returns true if everything that can be done was applied
  149603. */
  149604. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149605. /**
  149606. * Creates the SceneOptimization object
  149607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149608. * @param desc defines the description associated with the optimization
  149609. */
  149610. constructor(
  149611. /**
  149612. * Defines the priority of this optimization (0 by default which means first in the list)
  149613. */
  149614. priority?: number);
  149615. }
  149616. /**
  149617. * Defines an optimization used to reduce the size of render target textures
  149618. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149619. */
  149620. export class TextureOptimization extends SceneOptimization {
  149621. /**
  149622. * Defines the priority of this optimization (0 by default which means first in the list)
  149623. */
  149624. priority: number;
  149625. /**
  149626. * 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
  149627. */
  149628. maximumSize: number;
  149629. /**
  149630. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149631. */
  149632. step: number;
  149633. /**
  149634. * Gets a string describing the action executed by the current optimization
  149635. * @returns description string
  149636. */
  149637. getDescription(): string;
  149638. /**
  149639. * Creates the TextureOptimization object
  149640. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149641. * @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
  149642. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149643. */
  149644. constructor(
  149645. /**
  149646. * Defines the priority of this optimization (0 by default which means first in the list)
  149647. */
  149648. priority?: number,
  149649. /**
  149650. * 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
  149651. */
  149652. maximumSize?: number,
  149653. /**
  149654. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149655. */
  149656. step?: number);
  149657. /**
  149658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149659. * @param scene defines the current scene where to apply this optimization
  149660. * @param optimizer defines the current optimizer
  149661. * @returns true if everything that can be done was applied
  149662. */
  149663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149664. }
  149665. /**
  149666. * Defines an optimization used to increase or decrease the rendering resolution
  149667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149668. */
  149669. export class HardwareScalingOptimization extends SceneOptimization {
  149670. /**
  149671. * Defines the priority of this optimization (0 by default which means first in the list)
  149672. */
  149673. priority: number;
  149674. /**
  149675. * Defines the maximum scale to use (2 by default)
  149676. */
  149677. maximumScale: number;
  149678. /**
  149679. * Defines the step to use between two passes (0.5 by default)
  149680. */
  149681. step: number;
  149682. private _currentScale;
  149683. private _directionOffset;
  149684. /**
  149685. * Gets a string describing the action executed by the current optimization
  149686. * @return description string
  149687. */
  149688. getDescription(): string;
  149689. /**
  149690. * Creates the HardwareScalingOptimization object
  149691. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149692. * @param maximumScale defines the maximum scale to use (2 by default)
  149693. * @param step defines the step to use between two passes (0.5 by default)
  149694. */
  149695. constructor(
  149696. /**
  149697. * Defines the priority of this optimization (0 by default which means first in the list)
  149698. */
  149699. priority?: number,
  149700. /**
  149701. * Defines the maximum scale to use (2 by default)
  149702. */
  149703. maximumScale?: number,
  149704. /**
  149705. * Defines the step to use between two passes (0.5 by default)
  149706. */
  149707. step?: number);
  149708. /**
  149709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149710. * @param scene defines the current scene where to apply this optimization
  149711. * @param optimizer defines the current optimizer
  149712. * @returns true if everything that can be done was applied
  149713. */
  149714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149715. }
  149716. /**
  149717. * Defines an optimization used to remove shadows
  149718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149719. */
  149720. export class ShadowsOptimization extends SceneOptimization {
  149721. /**
  149722. * Gets a string describing the action executed by the current optimization
  149723. * @return description string
  149724. */
  149725. getDescription(): string;
  149726. /**
  149727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149728. * @param scene defines the current scene where to apply this optimization
  149729. * @param optimizer defines the current optimizer
  149730. * @returns true if everything that can be done was applied
  149731. */
  149732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149733. }
  149734. /**
  149735. * Defines an optimization used to turn post-processes off
  149736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149737. */
  149738. export class PostProcessesOptimization extends SceneOptimization {
  149739. /**
  149740. * Gets a string describing the action executed by the current optimization
  149741. * @return description string
  149742. */
  149743. getDescription(): string;
  149744. /**
  149745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149746. * @param scene defines the current scene where to apply this optimization
  149747. * @param optimizer defines the current optimizer
  149748. * @returns true if everything that can be done was applied
  149749. */
  149750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149751. }
  149752. /**
  149753. * Defines an optimization used to turn lens flares off
  149754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149755. */
  149756. export class LensFlaresOptimization extends SceneOptimization {
  149757. /**
  149758. * Gets a string describing the action executed by the current optimization
  149759. * @return description string
  149760. */
  149761. getDescription(): string;
  149762. /**
  149763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149764. * @param scene defines the current scene where to apply this optimization
  149765. * @param optimizer defines the current optimizer
  149766. * @returns true if everything that can be done was applied
  149767. */
  149768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149769. }
  149770. /**
  149771. * Defines an optimization based on user defined callback.
  149772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149773. */
  149774. export class CustomOptimization extends SceneOptimization {
  149775. /**
  149776. * Callback called to apply the custom optimization.
  149777. */
  149778. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  149779. /**
  149780. * Callback called to get custom description
  149781. */
  149782. onGetDescription: () => string;
  149783. /**
  149784. * Gets a string describing the action executed by the current optimization
  149785. * @returns description string
  149786. */
  149787. getDescription(): string;
  149788. /**
  149789. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149790. * @param scene defines the current scene where to apply this optimization
  149791. * @param optimizer defines the current optimizer
  149792. * @returns true if everything that can be done was applied
  149793. */
  149794. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149795. }
  149796. /**
  149797. * Defines an optimization used to turn particles off
  149798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149799. */
  149800. export class ParticlesOptimization extends SceneOptimization {
  149801. /**
  149802. * Gets a string describing the action executed by the current optimization
  149803. * @return description string
  149804. */
  149805. getDescription(): string;
  149806. /**
  149807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149808. * @param scene defines the current scene where to apply this optimization
  149809. * @param optimizer defines the current optimizer
  149810. * @returns true if everything that can be done was applied
  149811. */
  149812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149813. }
  149814. /**
  149815. * Defines an optimization used to turn render targets off
  149816. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149817. */
  149818. export class RenderTargetsOptimization extends SceneOptimization {
  149819. /**
  149820. * Gets a string describing the action executed by the current optimization
  149821. * @return description string
  149822. */
  149823. getDescription(): string;
  149824. /**
  149825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149826. * @param scene defines the current scene where to apply this optimization
  149827. * @param optimizer defines the current optimizer
  149828. * @returns true if everything that can be done was applied
  149829. */
  149830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149831. }
  149832. /**
  149833. * Defines an optimization used to merge meshes with compatible materials
  149834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149835. */
  149836. export class MergeMeshesOptimization extends SceneOptimization {
  149837. private static _UpdateSelectionTree;
  149838. /**
  149839. * Gets or sets a boolean which defines if optimization octree has to be updated
  149840. */
  149841. static get UpdateSelectionTree(): boolean;
  149842. /**
  149843. * Gets or sets a boolean which defines if optimization octree has to be updated
  149844. */
  149845. static set UpdateSelectionTree(value: boolean);
  149846. /**
  149847. * Gets a string describing the action executed by the current optimization
  149848. * @return description string
  149849. */
  149850. getDescription(): string;
  149851. private _canBeMerged;
  149852. /**
  149853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149854. * @param scene defines the current scene where to apply this optimization
  149855. * @param optimizer defines the current optimizer
  149856. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149857. * @returns true if everything that can be done was applied
  149858. */
  149859. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149860. }
  149861. /**
  149862. * Defines a list of options used by SceneOptimizer
  149863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149864. */
  149865. export class SceneOptimizerOptions {
  149866. /**
  149867. * Defines the target frame rate to reach (60 by default)
  149868. */
  149869. targetFrameRate: number;
  149870. /**
  149871. * Defines the interval between two checkes (2000ms by default)
  149872. */
  149873. trackerDuration: number;
  149874. /**
  149875. * Gets the list of optimizations to apply
  149876. */
  149877. optimizations: SceneOptimization[];
  149878. /**
  149879. * Creates a new list of options used by SceneOptimizer
  149880. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149881. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149882. */
  149883. constructor(
  149884. /**
  149885. * Defines the target frame rate to reach (60 by default)
  149886. */
  149887. targetFrameRate?: number,
  149888. /**
  149889. * Defines the interval between two checkes (2000ms by default)
  149890. */
  149891. trackerDuration?: number);
  149892. /**
  149893. * Add a new optimization
  149894. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149895. * @returns the current SceneOptimizerOptions
  149896. */
  149897. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149898. /**
  149899. * Add a new custom optimization
  149900. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149901. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149902. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149903. * @returns the current SceneOptimizerOptions
  149904. */
  149905. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149906. /**
  149907. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149908. * @param targetFrameRate defines the target frame rate (60 by default)
  149909. * @returns a SceneOptimizerOptions object
  149910. */
  149911. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149912. /**
  149913. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149914. * @param targetFrameRate defines the target frame rate (60 by default)
  149915. * @returns a SceneOptimizerOptions object
  149916. */
  149917. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149918. /**
  149919. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149920. * @param targetFrameRate defines the target frame rate (60 by default)
  149921. * @returns a SceneOptimizerOptions object
  149922. */
  149923. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149924. }
  149925. /**
  149926. * Class used to run optimizations in order to reach a target frame rate
  149927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149928. */
  149929. export class SceneOptimizer implements IDisposable {
  149930. private _isRunning;
  149931. private _options;
  149932. private _scene;
  149933. private _currentPriorityLevel;
  149934. private _targetFrameRate;
  149935. private _trackerDuration;
  149936. private _currentFrameRate;
  149937. private _sceneDisposeObserver;
  149938. private _improvementMode;
  149939. /**
  149940. * Defines an observable called when the optimizer reaches the target frame rate
  149941. */
  149942. onSuccessObservable: Observable<SceneOptimizer>;
  149943. /**
  149944. * Defines an observable called when the optimizer enables an optimization
  149945. */
  149946. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149947. /**
  149948. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149949. */
  149950. onFailureObservable: Observable<SceneOptimizer>;
  149951. /**
  149952. * Gets a boolean indicating if the optimizer is in improvement mode
  149953. */
  149954. get isInImprovementMode(): boolean;
  149955. /**
  149956. * Gets the current priority level (0 at start)
  149957. */
  149958. get currentPriorityLevel(): number;
  149959. /**
  149960. * Gets the current frame rate checked by the SceneOptimizer
  149961. */
  149962. get currentFrameRate(): number;
  149963. /**
  149964. * Gets or sets the current target frame rate (60 by default)
  149965. */
  149966. get targetFrameRate(): number;
  149967. /**
  149968. * Gets or sets the current target frame rate (60 by default)
  149969. */
  149970. set targetFrameRate(value: number);
  149971. /**
  149972. * Gets or sets the current interval between two checks (every 2000ms by default)
  149973. */
  149974. get trackerDuration(): number;
  149975. /**
  149976. * Gets or sets the current interval between two checks (every 2000ms by default)
  149977. */
  149978. set trackerDuration(value: number);
  149979. /**
  149980. * Gets the list of active optimizations
  149981. */
  149982. get optimizations(): SceneOptimization[];
  149983. /**
  149984. * Creates a new SceneOptimizer
  149985. * @param scene defines the scene to work on
  149986. * @param options defines the options to use with the SceneOptimizer
  149987. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149988. * @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)
  149989. */
  149990. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149991. /**
  149992. * Stops the current optimizer
  149993. */
  149994. stop(): void;
  149995. /**
  149996. * Reset the optimizer to initial step (current priority level = 0)
  149997. */
  149998. reset(): void;
  149999. /**
  150000. * Start the optimizer. By default it will try to reach a specific framerate
  150001. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150002. */
  150003. start(): void;
  150004. private _checkCurrentState;
  150005. /**
  150006. * Release all resources
  150007. */
  150008. dispose(): void;
  150009. /**
  150010. * Helper function to create a SceneOptimizer with one single line of code
  150011. * @param scene defines the scene to work on
  150012. * @param options defines the options to use with the SceneOptimizer
  150013. * @param onSuccess defines a callback to call on success
  150014. * @param onFailure defines a callback to call on failure
  150015. * @returns the new SceneOptimizer object
  150016. */
  150017. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  150018. }
  150019. }
  150020. declare module BABYLON {
  150021. /**
  150022. * Class used to serialize a scene into a string
  150023. */
  150024. export class SceneSerializer {
  150025. /**
  150026. * Clear cache used by a previous serialization
  150027. */
  150028. static ClearCache(): void;
  150029. /**
  150030. * Serialize a scene into a JSON compatible object
  150031. * @param scene defines the scene to serialize
  150032. * @returns a JSON compatible object
  150033. */
  150034. static Serialize(scene: Scene): any;
  150035. /**
  150036. * Serialize a mesh into a JSON compatible object
  150037. * @param toSerialize defines the mesh to serialize
  150038. * @param withParents defines if parents must be serialized as well
  150039. * @param withChildren defines if children must be serialized as well
  150040. * @returns a JSON compatible object
  150041. */
  150042. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  150043. }
  150044. }
  150045. declare module BABYLON {
  150046. /**
  150047. * Class used to host texture specific utilities
  150048. */
  150049. export class TextureTools {
  150050. /**
  150051. * Uses the GPU to create a copy texture rescaled at a given size
  150052. * @param texture Texture to copy from
  150053. * @param width defines the desired width
  150054. * @param height defines the desired height
  150055. * @param useBilinearMode defines if bilinear mode has to be used
  150056. * @return the generated texture
  150057. */
  150058. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  150059. }
  150060. }
  150061. declare module BABYLON {
  150062. /**
  150063. * This represents the different options available for the video capture.
  150064. */
  150065. export interface VideoRecorderOptions {
  150066. /** Defines the mime type of the video. */
  150067. mimeType: string;
  150068. /** Defines the FPS the video should be recorded at. */
  150069. fps: number;
  150070. /** Defines the chunk size for the recording data. */
  150071. recordChunckSize: number;
  150072. /** The audio tracks to attach to the recording. */
  150073. audioTracks?: MediaStreamTrack[];
  150074. }
  150075. /**
  150076. * This can help with recording videos from BabylonJS.
  150077. * This is based on the available WebRTC functionalities of the browser.
  150078. *
  150079. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  150080. */
  150081. export class VideoRecorder {
  150082. private static readonly _defaultOptions;
  150083. /**
  150084. * Returns whether or not the VideoRecorder is available in your browser.
  150085. * @param engine Defines the Babylon Engine.
  150086. * @returns true if supported otherwise false.
  150087. */
  150088. static IsSupported(engine: Engine): boolean;
  150089. private readonly _options;
  150090. private _canvas;
  150091. private _mediaRecorder;
  150092. private _recordedChunks;
  150093. private _fileName;
  150094. private _resolve;
  150095. private _reject;
  150096. /**
  150097. * True when a recording is already in progress.
  150098. */
  150099. get isRecording(): boolean;
  150100. /**
  150101. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  150102. * @param engine Defines the BabylonJS Engine you wish to record.
  150103. * @param options Defines options that can be used to customize the capture.
  150104. */
  150105. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  150106. /**
  150107. * Stops the current recording before the default capture timeout passed in the startRecording function.
  150108. */
  150109. stopRecording(): void;
  150110. /**
  150111. * Starts recording the canvas for a max duration specified in parameters.
  150112. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  150113. * If null no automatic download will start and you can rely on the promise to get the data back.
  150114. * @param maxDuration Defines the maximum recording time in seconds.
  150115. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  150116. * @return A promise callback at the end of the recording with the video data in Blob.
  150117. */
  150118. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  150119. /**
  150120. * Releases internal resources used during the recording.
  150121. */
  150122. dispose(): void;
  150123. private _handleDataAvailable;
  150124. private _handleError;
  150125. private _handleStop;
  150126. }
  150127. }
  150128. declare module BABYLON {
  150129. /**
  150130. * Class containing a set of static utilities functions for screenshots
  150131. */
  150132. export class ScreenshotTools {
  150133. /**
  150134. * Captures a screenshot of the current rendering
  150135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150136. * @param engine defines the rendering engine
  150137. * @param camera defines the source camera
  150138. * @param size This parameter can be set to a single number or to an object with the
  150139. * following (optional) properties: precision, width, height. If a single number is passed,
  150140. * it will be used for both width and height. If an object is passed, the screenshot size
  150141. * will be derived from the parameters. The precision property is a multiplier allowing
  150142. * rendering at a higher or lower resolution
  150143. * @param successCallback defines the callback receives a single parameter which contains the
  150144. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150145. * src parameter of an <img> to display it
  150146. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150147. * Check your browser for supported MIME types
  150148. */
  150149. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  150150. /**
  150151. * Captures a screenshot of the current rendering
  150152. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150153. * @param engine defines the rendering engine
  150154. * @param camera defines the source camera
  150155. * @param size This parameter can be set to a single number or to an object with the
  150156. * following (optional) properties: precision, width, height. If a single number is passed,
  150157. * it will be used for both width and height. If an object is passed, the screenshot size
  150158. * will be derived from the parameters. The precision property is a multiplier allowing
  150159. * rendering at a higher or lower resolution
  150160. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150161. * Check your browser for supported MIME types
  150162. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150163. * to the src parameter of an <img> to display it
  150164. */
  150165. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  150166. /**
  150167. * Generates an image screenshot from the specified camera.
  150168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150169. * @param engine The engine to use for rendering
  150170. * @param camera The camera to use for rendering
  150171. * @param size This parameter can be set to a single number or to an object with the
  150172. * following (optional) properties: precision, width, height. If a single number is passed,
  150173. * it will be used for both width and height. If an object is passed, the screenshot size
  150174. * will be derived from the parameters. The precision property is a multiplier allowing
  150175. * rendering at a higher or lower resolution
  150176. * @param successCallback The callback receives a single parameter which contains the
  150177. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150178. * src parameter of an <img> to display it
  150179. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150180. * Check your browser for supported MIME types
  150181. * @param samples Texture samples (default: 1)
  150182. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150183. * @param fileName A name for for the downloaded file.
  150184. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150185. */
  150186. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  150187. /**
  150188. * Generates an image screenshot from the specified camera.
  150189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150190. * @param engine The engine to use for rendering
  150191. * @param camera The camera to use for rendering
  150192. * @param size This parameter can be set to a single number or to an object with the
  150193. * following (optional) properties: precision, width, height. If a single number is passed,
  150194. * it will be used for both width and height. If an object is passed, the screenshot size
  150195. * will be derived from the parameters. The precision property is a multiplier allowing
  150196. * rendering at a higher or lower resolution
  150197. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150198. * Check your browser for supported MIME types
  150199. * @param samples Texture samples (default: 1)
  150200. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150201. * @param fileName A name for for the downloaded file.
  150202. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150203. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150204. * to the src parameter of an <img> to display it
  150205. */
  150206. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  150207. /**
  150208. * Gets height and width for screenshot size
  150209. * @private
  150210. */
  150211. private static _getScreenshotSize;
  150212. }
  150213. }
  150214. declare module BABYLON {
  150215. /**
  150216. * Interface for a data buffer
  150217. */
  150218. export interface IDataBuffer {
  150219. /**
  150220. * Reads bytes from the data buffer.
  150221. * @param byteOffset The byte offset to read
  150222. * @param byteLength The byte length to read
  150223. * @returns A promise that resolves when the bytes are read
  150224. */
  150225. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  150226. /**
  150227. * The byte length of the buffer.
  150228. */
  150229. readonly byteLength: number;
  150230. }
  150231. /**
  150232. * Utility class for reading from a data buffer
  150233. */
  150234. export class DataReader {
  150235. /**
  150236. * The data buffer associated with this data reader.
  150237. */
  150238. readonly buffer: IDataBuffer;
  150239. /**
  150240. * The current byte offset from the beginning of the data buffer.
  150241. */
  150242. byteOffset: number;
  150243. private _dataView;
  150244. private _dataByteOffset;
  150245. /**
  150246. * Constructor
  150247. * @param buffer The buffer to read
  150248. */
  150249. constructor(buffer: IDataBuffer);
  150250. /**
  150251. * Loads the given byte length.
  150252. * @param byteLength The byte length to load
  150253. * @returns A promise that resolves when the load is complete
  150254. */
  150255. loadAsync(byteLength: number): Promise<void>;
  150256. /**
  150257. * Read a unsigned 32-bit integer from the currently loaded data range.
  150258. * @returns The 32-bit integer read
  150259. */
  150260. readUint32(): number;
  150261. /**
  150262. * Read a byte array from the currently loaded data range.
  150263. * @param byteLength The byte length to read
  150264. * @returns The byte array read
  150265. */
  150266. readUint8Array(byteLength: number): Uint8Array;
  150267. /**
  150268. * Read a string from the currently loaded data range.
  150269. * @param byteLength The byte length to read
  150270. * @returns The string read
  150271. */
  150272. readString(byteLength: number): string;
  150273. /**
  150274. * Skips the given byte length the currently loaded data range.
  150275. * @param byteLength The byte length to skip
  150276. */
  150277. skipBytes(byteLength: number): void;
  150278. }
  150279. }
  150280. declare module BABYLON {
  150281. /**
  150282. * Class for storing data to local storage if available or in-memory storage otherwise
  150283. */
  150284. export class DataStorage {
  150285. private static _Storage;
  150286. private static _GetStorage;
  150287. /**
  150288. * Reads a string from the data storage
  150289. * @param key The key to read
  150290. * @param defaultValue The value if the key doesn't exist
  150291. * @returns The string value
  150292. */
  150293. static ReadString(key: string, defaultValue: string): string;
  150294. /**
  150295. * Writes a string to the data storage
  150296. * @param key The key to write
  150297. * @param value The value to write
  150298. */
  150299. static WriteString(key: string, value: string): void;
  150300. /**
  150301. * Reads a boolean from the data storage
  150302. * @param key The key to read
  150303. * @param defaultValue The value if the key doesn't exist
  150304. * @returns The boolean value
  150305. */
  150306. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  150307. /**
  150308. * Writes a boolean to the data storage
  150309. * @param key The key to write
  150310. * @param value The value to write
  150311. */
  150312. static WriteBoolean(key: string, value: boolean): void;
  150313. /**
  150314. * Reads a number from the data storage
  150315. * @param key The key to read
  150316. * @param defaultValue The value if the key doesn't exist
  150317. * @returns The number value
  150318. */
  150319. static ReadNumber(key: string, defaultValue: number): number;
  150320. /**
  150321. * Writes a number to the data storage
  150322. * @param key The key to write
  150323. * @param value The value to write
  150324. */
  150325. static WriteNumber(key: string, value: number): void;
  150326. }
  150327. }
  150328. declare module BABYLON {
  150329. /**
  150330. * An interface for all Hit test features
  150331. */
  150332. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  150333. /**
  150334. * Triggered when new babylon (transformed) hit test results are available
  150335. */
  150336. onHitTestResultObservable: Observable<T[]>;
  150337. }
  150338. /**
  150339. * Options used for hit testing
  150340. */
  150341. export interface IWebXRLegacyHitTestOptions {
  150342. /**
  150343. * Only test when user interacted with the scene. Default - hit test every frame
  150344. */
  150345. testOnPointerDownOnly?: boolean;
  150346. /**
  150347. * The node to use to transform the local results to world coordinates
  150348. */
  150349. worldParentNode?: TransformNode;
  150350. }
  150351. /**
  150352. * Interface defining the babylon result of raycasting/hit-test
  150353. */
  150354. export interface IWebXRLegacyHitResult {
  150355. /**
  150356. * Transformation matrix that can be applied to a node that will put it in the hit point location
  150357. */
  150358. transformationMatrix: Matrix;
  150359. /**
  150360. * The native hit test result
  150361. */
  150362. xrHitResult: XRHitResult | XRHitTestResult;
  150363. }
  150364. /**
  150365. * The currently-working hit-test module.
  150366. * Hit test (or Ray-casting) is used to interact with the real world.
  150367. * For further information read here - https://github.com/immersive-web/hit-test
  150368. */
  150369. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150370. /**
  150371. * options to use when constructing this feature
  150372. */
  150373. readonly options: IWebXRLegacyHitTestOptions;
  150374. private _direction;
  150375. private _mat;
  150376. private _onSelectEnabled;
  150377. private _origin;
  150378. /**
  150379. * The module's name
  150380. */
  150381. static readonly Name: string;
  150382. /**
  150383. * The (Babylon) version of this module.
  150384. * This is an integer representing the implementation version.
  150385. * This number does not correspond to the WebXR specs version
  150386. */
  150387. static readonly Version: number;
  150388. /**
  150389. * Populated with the last native XR Hit Results
  150390. */
  150391. lastNativeXRHitResults: XRHitResult[];
  150392. /**
  150393. * Triggered when new babylon (transformed) hit test results are available
  150394. */
  150395. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150396. /**
  150397. * Creates a new instance of the (legacy version) hit test feature
  150398. * @param _xrSessionManager an instance of WebXRSessionManager
  150399. * @param options options to use when constructing this feature
  150400. */
  150401. constructor(_xrSessionManager: WebXRSessionManager,
  150402. /**
  150403. * options to use when constructing this feature
  150404. */
  150405. options?: IWebXRLegacyHitTestOptions);
  150406. /**
  150407. * execute a hit test with an XR Ray
  150408. *
  150409. * @param xrSession a native xrSession that will execute this hit test
  150410. * @param xrRay the ray (position and direction) to use for ray-casting
  150411. * @param referenceSpace native XR reference space to use for the hit-test
  150412. * @param filter filter function that will filter the results
  150413. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150414. */
  150415. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150416. /**
  150417. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150418. * @param event the (select) event to use to select with
  150419. * @param referenceSpace the reference space to use for this hit test
  150420. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150421. */
  150422. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150423. /**
  150424. * attach this feature
  150425. * Will usually be called by the features manager
  150426. *
  150427. * @returns true if successful.
  150428. */
  150429. attach(): boolean;
  150430. /**
  150431. * detach this feature.
  150432. * Will usually be called by the features manager
  150433. *
  150434. * @returns true if successful.
  150435. */
  150436. detach(): boolean;
  150437. /**
  150438. * Dispose this feature and all of the resources attached
  150439. */
  150440. dispose(): void;
  150441. protected _onXRFrame(frame: XRFrame): void;
  150442. private _onHitTestResults;
  150443. private _onSelect;
  150444. }
  150445. }
  150446. declare module BABYLON {
  150447. /**
  150448. * Options used for hit testing (version 2)
  150449. */
  150450. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150451. /**
  150452. * Do not create a permanent hit test. Will usually be used when only
  150453. * transient inputs are needed.
  150454. */
  150455. disablePermanentHitTest?: boolean;
  150456. /**
  150457. * Enable transient (for example touch-based) hit test inspections
  150458. */
  150459. enableTransientHitTest?: boolean;
  150460. /**
  150461. * Offset ray for the permanent hit test
  150462. */
  150463. offsetRay?: Vector3;
  150464. /**
  150465. * Offset ray for the transient hit test
  150466. */
  150467. transientOffsetRay?: Vector3;
  150468. /**
  150469. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150470. */
  150471. useReferenceSpace?: boolean;
  150472. }
  150473. /**
  150474. * Interface defining the babylon result of hit-test
  150475. */
  150476. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150477. /**
  150478. * The input source that generated this hit test (if transient)
  150479. */
  150480. inputSource?: XRInputSource;
  150481. /**
  150482. * Is this a transient hit test
  150483. */
  150484. isTransient?: boolean;
  150485. /**
  150486. * Position of the hit test result
  150487. */
  150488. position: Vector3;
  150489. /**
  150490. * Rotation of the hit test result
  150491. */
  150492. rotationQuaternion: Quaternion;
  150493. /**
  150494. * The native hit test result
  150495. */
  150496. xrHitResult: XRHitTestResult;
  150497. }
  150498. /**
  150499. * The currently-working hit-test module.
  150500. * Hit test (or Ray-casting) is used to interact with the real world.
  150501. * For further information read here - https://github.com/immersive-web/hit-test
  150502. *
  150503. * Tested on chrome (mobile) 80.
  150504. */
  150505. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150506. /**
  150507. * options to use when constructing this feature
  150508. */
  150509. readonly options: IWebXRHitTestOptions;
  150510. private _tmpMat;
  150511. private _tmpPos;
  150512. private _tmpQuat;
  150513. private _transientXrHitTestSource;
  150514. private _xrHitTestSource;
  150515. private initHitTestSource;
  150516. /**
  150517. * The module's name
  150518. */
  150519. static readonly Name: string;
  150520. /**
  150521. * The (Babylon) version of this module.
  150522. * This is an integer representing the implementation version.
  150523. * This number does not correspond to the WebXR specs version
  150524. */
  150525. static readonly Version: number;
  150526. /**
  150527. * When set to true, each hit test will have its own position/rotation objects
  150528. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150529. * the developers will clone them or copy them as they see fit.
  150530. */
  150531. autoCloneTransformation: boolean;
  150532. /**
  150533. * Triggered when new babylon (transformed) hit test results are available
  150534. */
  150535. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150536. /**
  150537. * Use this to temporarily pause hit test checks.
  150538. */
  150539. paused: boolean;
  150540. /**
  150541. * Creates a new instance of the hit test feature
  150542. * @param _xrSessionManager an instance of WebXRSessionManager
  150543. * @param options options to use when constructing this feature
  150544. */
  150545. constructor(_xrSessionManager: WebXRSessionManager,
  150546. /**
  150547. * options to use when constructing this feature
  150548. */
  150549. options?: IWebXRHitTestOptions);
  150550. /**
  150551. * attach this feature
  150552. * Will usually be called by the features manager
  150553. *
  150554. * @returns true if successful.
  150555. */
  150556. attach(): boolean;
  150557. /**
  150558. * detach this feature.
  150559. * Will usually be called by the features manager
  150560. *
  150561. * @returns true if successful.
  150562. */
  150563. detach(): boolean;
  150564. /**
  150565. * Dispose this feature and all of the resources attached
  150566. */
  150567. dispose(): void;
  150568. protected _onXRFrame(frame: XRFrame): void;
  150569. private _processWebXRHitTestResult;
  150570. }
  150571. }
  150572. declare module BABYLON {
  150573. /**
  150574. * Configuration options of the anchor system
  150575. */
  150576. export interface IWebXRAnchorSystemOptions {
  150577. /**
  150578. * a node that will be used to convert local to world coordinates
  150579. */
  150580. worldParentNode?: TransformNode;
  150581. /**
  150582. * If set to true a reference of the created anchors will be kept until the next session starts
  150583. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150584. */
  150585. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150586. }
  150587. /**
  150588. * A babylon container for an XR Anchor
  150589. */
  150590. export interface IWebXRAnchor {
  150591. /**
  150592. * A babylon-assigned ID for this anchor
  150593. */
  150594. id: number;
  150595. /**
  150596. * Transformation matrix to apply to an object attached to this anchor
  150597. */
  150598. transformationMatrix: Matrix;
  150599. /**
  150600. * The native anchor object
  150601. */
  150602. xrAnchor: XRAnchor;
  150603. /**
  150604. * if defined, this object will be constantly updated by the anchor's position and rotation
  150605. */
  150606. attachedNode?: TransformNode;
  150607. }
  150608. /**
  150609. * An implementation of the anchor system for WebXR.
  150610. * For further information see https://github.com/immersive-web/anchors/
  150611. */
  150612. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150613. private _options;
  150614. private _lastFrameDetected;
  150615. private _trackedAnchors;
  150616. private _referenceSpaceForFrameAnchors;
  150617. private _futureAnchors;
  150618. /**
  150619. * The module's name
  150620. */
  150621. static readonly Name: string;
  150622. /**
  150623. * The (Babylon) version of this module.
  150624. * This is an integer representing the implementation version.
  150625. * This number does not correspond to the WebXR specs version
  150626. */
  150627. static readonly Version: number;
  150628. /**
  150629. * Observers registered here will be executed when a new anchor was added to the session
  150630. */
  150631. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150632. /**
  150633. * Observers registered here will be executed when an anchor was removed from the session
  150634. */
  150635. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150636. /**
  150637. * Observers registered here will be executed when an existing anchor updates
  150638. * This can execute N times every frame
  150639. */
  150640. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150641. /**
  150642. * Set the reference space to use for anchor creation, when not using a hit test.
  150643. * Will default to the session's reference space if not defined
  150644. */
  150645. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150646. /**
  150647. * constructs a new anchor system
  150648. * @param _xrSessionManager an instance of WebXRSessionManager
  150649. * @param _options configuration object for this feature
  150650. */
  150651. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150652. private _tmpVector;
  150653. private _tmpQuaternion;
  150654. private _populateTmpTransformation;
  150655. /**
  150656. * Create a new anchor point using a hit test result at a specific point in the scene
  150657. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150658. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150659. *
  150660. * @param hitTestResult The hit test result to use for this anchor creation
  150661. * @param position an optional position offset for this anchor
  150662. * @param rotationQuaternion an optional rotation offset for this anchor
  150663. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150664. */
  150665. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150666. /**
  150667. * Add a new anchor at a specific position and rotation
  150668. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150669. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150670. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150671. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150672. *
  150673. * @param position the position in which to add an anchor
  150674. * @param rotationQuaternion an optional rotation for the anchor transformation
  150675. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150676. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150677. */
  150678. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150679. /**
  150680. * detach this feature.
  150681. * Will usually be called by the features manager
  150682. *
  150683. * @returns true if successful.
  150684. */
  150685. detach(): boolean;
  150686. /**
  150687. * Dispose this feature and all of the resources attached
  150688. */
  150689. dispose(): void;
  150690. protected _onXRFrame(frame: XRFrame): void;
  150691. /**
  150692. * avoiding using Array.find for global support.
  150693. * @param xrAnchor the plane to find in the array
  150694. */
  150695. private _findIndexInAnchorArray;
  150696. private _updateAnchorWithXRFrame;
  150697. private _createAnchorAtTransformation;
  150698. }
  150699. }
  150700. declare module BABYLON {
  150701. /**
  150702. * Options used in the plane detector module
  150703. */
  150704. export interface IWebXRPlaneDetectorOptions {
  150705. /**
  150706. * The node to use to transform the local results to world coordinates
  150707. */
  150708. worldParentNode?: TransformNode;
  150709. /**
  150710. * If set to true a reference of the created planes will be kept until the next session starts
  150711. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150712. */
  150713. doNotRemovePlanesOnSessionEnded?: boolean;
  150714. }
  150715. /**
  150716. * A babylon interface for a WebXR plane.
  150717. * A Plane is actually a polygon, built from N points in space
  150718. *
  150719. * Supported in chrome 79, not supported in canary 81 ATM
  150720. */
  150721. export interface IWebXRPlane {
  150722. /**
  150723. * a babylon-assigned ID for this polygon
  150724. */
  150725. id: number;
  150726. /**
  150727. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150728. */
  150729. polygonDefinition: Array<Vector3>;
  150730. /**
  150731. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150732. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150733. */
  150734. transformationMatrix: Matrix;
  150735. /**
  150736. * the native xr-plane object
  150737. */
  150738. xrPlane: XRPlane;
  150739. }
  150740. /**
  150741. * The plane detector is used to detect planes in the real world when in AR
  150742. * For more information see https://github.com/immersive-web/real-world-geometry/
  150743. */
  150744. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  150745. private _options;
  150746. private _detectedPlanes;
  150747. private _enabled;
  150748. private _lastFrameDetected;
  150749. /**
  150750. * The module's name
  150751. */
  150752. static readonly Name: string;
  150753. /**
  150754. * The (Babylon) version of this module.
  150755. * This is an integer representing the implementation version.
  150756. * This number does not correspond to the WebXR specs version
  150757. */
  150758. static readonly Version: number;
  150759. /**
  150760. * Observers registered here will be executed when a new plane was added to the session
  150761. */
  150762. onPlaneAddedObservable: Observable<IWebXRPlane>;
  150763. /**
  150764. * Observers registered here will be executed when a plane is no longer detected in the session
  150765. */
  150766. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  150767. /**
  150768. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  150769. * This can execute N times every frame
  150770. */
  150771. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  150772. /**
  150773. * construct a new Plane Detector
  150774. * @param _xrSessionManager an instance of xr Session manager
  150775. * @param _options configuration to use when constructing this feature
  150776. */
  150777. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  150778. /**
  150779. * detach this feature.
  150780. * Will usually be called by the features manager
  150781. *
  150782. * @returns true if successful.
  150783. */
  150784. detach(): boolean;
  150785. /**
  150786. * Dispose this feature and all of the resources attached
  150787. */
  150788. dispose(): void;
  150789. protected _onXRFrame(frame: XRFrame): void;
  150790. private _init;
  150791. private _updatePlaneWithXRPlane;
  150792. /**
  150793. * avoiding using Array.find for global support.
  150794. * @param xrPlane the plane to find in the array
  150795. */
  150796. private findIndexInPlaneArray;
  150797. }
  150798. }
  150799. declare module BABYLON {
  150800. /**
  150801. * Options interface for the background remover plugin
  150802. */
  150803. export interface IWebXRBackgroundRemoverOptions {
  150804. /**
  150805. * Further background meshes to disable when entering AR
  150806. */
  150807. backgroundMeshes?: AbstractMesh[];
  150808. /**
  150809. * flags to configure the removal of the environment helper.
  150810. * If not set, the entire background will be removed. If set, flags should be set as well.
  150811. */
  150812. environmentHelperRemovalFlags?: {
  150813. /**
  150814. * Should the skybox be removed (default false)
  150815. */
  150816. skyBox?: boolean;
  150817. /**
  150818. * Should the ground be removed (default false)
  150819. */
  150820. ground?: boolean;
  150821. };
  150822. /**
  150823. * don't disable the environment helper
  150824. */
  150825. ignoreEnvironmentHelper?: boolean;
  150826. }
  150827. /**
  150828. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  150829. */
  150830. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  150831. /**
  150832. * read-only options to be used in this module
  150833. */
  150834. readonly options: IWebXRBackgroundRemoverOptions;
  150835. /**
  150836. * The module's name
  150837. */
  150838. static readonly Name: string;
  150839. /**
  150840. * The (Babylon) version of this module.
  150841. * This is an integer representing the implementation version.
  150842. * This number does not correspond to the WebXR specs version
  150843. */
  150844. static readonly Version: number;
  150845. /**
  150846. * registered observers will be triggered when the background state changes
  150847. */
  150848. onBackgroundStateChangedObservable: Observable<boolean>;
  150849. /**
  150850. * constructs a new background remover module
  150851. * @param _xrSessionManager the session manager for this module
  150852. * @param options read-only options to be used in this module
  150853. */
  150854. constructor(_xrSessionManager: WebXRSessionManager,
  150855. /**
  150856. * read-only options to be used in this module
  150857. */
  150858. options?: IWebXRBackgroundRemoverOptions);
  150859. /**
  150860. * attach this feature
  150861. * Will usually be called by the features manager
  150862. *
  150863. * @returns true if successful.
  150864. */
  150865. attach(): boolean;
  150866. /**
  150867. * detach this feature.
  150868. * Will usually be called by the features manager
  150869. *
  150870. * @returns true if successful.
  150871. */
  150872. detach(): boolean;
  150873. /**
  150874. * Dispose this feature and all of the resources attached
  150875. */
  150876. dispose(): void;
  150877. protected _onXRFrame(_xrFrame: XRFrame): void;
  150878. private _setBackgroundState;
  150879. }
  150880. }
  150881. declare module BABYLON {
  150882. /**
  150883. * Options for the controller physics feature
  150884. */
  150885. export class IWebXRControllerPhysicsOptions {
  150886. /**
  150887. * Should the headset get its own impostor
  150888. */
  150889. enableHeadsetImpostor?: boolean;
  150890. /**
  150891. * Optional parameters for the headset impostor
  150892. */
  150893. headsetImpostorParams?: {
  150894. /**
  150895. * The type of impostor to create. Default is sphere
  150896. */
  150897. impostorType: number;
  150898. /**
  150899. * the size of the impostor. Defaults to 10cm
  150900. */
  150901. impostorSize?: number | {
  150902. width: number;
  150903. height: number;
  150904. depth: number;
  150905. };
  150906. /**
  150907. * Friction definitions
  150908. */
  150909. friction?: number;
  150910. /**
  150911. * Restitution
  150912. */
  150913. restitution?: number;
  150914. };
  150915. /**
  150916. * The physics properties of the future impostors
  150917. */
  150918. physicsProperties?: {
  150919. /**
  150920. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150921. * Note that this requires a physics engine that supports mesh impostors!
  150922. */
  150923. useControllerMesh?: boolean;
  150924. /**
  150925. * The type of impostor to create. Default is sphere
  150926. */
  150927. impostorType?: number;
  150928. /**
  150929. * the size of the impostor. Defaults to 10cm
  150930. */
  150931. impostorSize?: number | {
  150932. width: number;
  150933. height: number;
  150934. depth: number;
  150935. };
  150936. /**
  150937. * Friction definitions
  150938. */
  150939. friction?: number;
  150940. /**
  150941. * Restitution
  150942. */
  150943. restitution?: number;
  150944. };
  150945. /**
  150946. * the xr input to use with this pointer selection
  150947. */
  150948. xrInput: WebXRInput;
  150949. }
  150950. /**
  150951. * Add physics impostor to your webxr controllers,
  150952. * including naive calculation of their linear and angular velocity
  150953. */
  150954. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150955. private readonly _options;
  150956. private _attachController;
  150957. private _controllers;
  150958. private _debugMode;
  150959. private _delta;
  150960. private _headsetImpostor?;
  150961. private _headsetMesh?;
  150962. private _lastTimestamp;
  150963. private _tmpQuaternion;
  150964. private _tmpVector;
  150965. /**
  150966. * The module's name
  150967. */
  150968. static readonly Name: string;
  150969. /**
  150970. * The (Babylon) version of this module.
  150971. * This is an integer representing the implementation version.
  150972. * This number does not correspond to the webxr specs version
  150973. */
  150974. static readonly Version: number;
  150975. /**
  150976. * Construct a new Controller Physics Feature
  150977. * @param _xrSessionManager the corresponding xr session manager
  150978. * @param _options options to create this feature with
  150979. */
  150980. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150981. /**
  150982. * @hidden
  150983. * enable debugging - will show console outputs and the impostor mesh
  150984. */
  150985. _enablePhysicsDebug(): void;
  150986. /**
  150987. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150988. * @param xrController the controller to add
  150989. */
  150990. addController(xrController: WebXRInputSource): void;
  150991. /**
  150992. * attach this feature
  150993. * Will usually be called by the features manager
  150994. *
  150995. * @returns true if successful.
  150996. */
  150997. attach(): boolean;
  150998. /**
  150999. * detach this feature.
  151000. * Will usually be called by the features manager
  151001. *
  151002. * @returns true if successful.
  151003. */
  151004. detach(): boolean;
  151005. /**
  151006. * Get the headset impostor, if enabled
  151007. * @returns the impostor
  151008. */
  151009. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151010. /**
  151011. * Get the physics impostor of a specific controller.
  151012. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  151013. * @param controller the controller or the controller id of which to get the impostor
  151014. * @returns the impostor or null
  151015. */
  151016. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  151017. /**
  151018. * Update the physics properties provided in the constructor
  151019. * @param newProperties the new properties object
  151020. */
  151021. setPhysicsProperties(newProperties: {
  151022. impostorType?: number;
  151023. impostorSize?: number | {
  151024. width: number;
  151025. height: number;
  151026. depth: number;
  151027. };
  151028. friction?: number;
  151029. restitution?: number;
  151030. }): void;
  151031. protected _onXRFrame(_xrFrame: any): void;
  151032. private _detachController;
  151033. }
  151034. }
  151035. declare module BABYLON {
  151036. /**
  151037. * The motion controller class for all microsoft mixed reality controllers
  151038. */
  151039. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  151040. protected readonly _mapping: {
  151041. defaultButton: {
  151042. valueNodeName: string;
  151043. unpressedNodeName: string;
  151044. pressedNodeName: string;
  151045. };
  151046. defaultAxis: {
  151047. valueNodeName: string;
  151048. minNodeName: string;
  151049. maxNodeName: string;
  151050. };
  151051. buttons: {
  151052. "xr-standard-trigger": {
  151053. rootNodeName: string;
  151054. componentProperty: string;
  151055. states: string[];
  151056. };
  151057. "xr-standard-squeeze": {
  151058. rootNodeName: string;
  151059. componentProperty: string;
  151060. states: string[];
  151061. };
  151062. "xr-standard-touchpad": {
  151063. rootNodeName: string;
  151064. labelAnchorNodeName: string;
  151065. touchPointNodeName: string;
  151066. };
  151067. "xr-standard-thumbstick": {
  151068. rootNodeName: string;
  151069. componentProperty: string;
  151070. states: string[];
  151071. };
  151072. };
  151073. axes: {
  151074. "xr-standard-touchpad": {
  151075. "x-axis": {
  151076. rootNodeName: string;
  151077. };
  151078. "y-axis": {
  151079. rootNodeName: string;
  151080. };
  151081. };
  151082. "xr-standard-thumbstick": {
  151083. "x-axis": {
  151084. rootNodeName: string;
  151085. };
  151086. "y-axis": {
  151087. rootNodeName: string;
  151088. };
  151089. };
  151090. };
  151091. };
  151092. /**
  151093. * The base url used to load the left and right controller models
  151094. */
  151095. static MODEL_BASE_URL: string;
  151096. /**
  151097. * The name of the left controller model file
  151098. */
  151099. static MODEL_LEFT_FILENAME: string;
  151100. /**
  151101. * The name of the right controller model file
  151102. */
  151103. static MODEL_RIGHT_FILENAME: string;
  151104. profileId: string;
  151105. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151106. protected _getFilenameAndPath(): {
  151107. filename: string;
  151108. path: string;
  151109. };
  151110. protected _getModelLoadingConstraints(): boolean;
  151111. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151112. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151113. protected _updateModel(): void;
  151114. }
  151115. }
  151116. declare module BABYLON {
  151117. /**
  151118. * The motion controller class for oculus touch (quest, rift).
  151119. * This class supports legacy mapping as well the standard xr mapping
  151120. */
  151121. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  151122. private _forceLegacyControllers;
  151123. private _modelRootNode;
  151124. /**
  151125. * The base url used to load the left and right controller models
  151126. */
  151127. static MODEL_BASE_URL: string;
  151128. /**
  151129. * The name of the left controller model file
  151130. */
  151131. static MODEL_LEFT_FILENAME: string;
  151132. /**
  151133. * The name of the right controller model file
  151134. */
  151135. static MODEL_RIGHT_FILENAME: string;
  151136. /**
  151137. * Base Url for the Quest controller model.
  151138. */
  151139. static QUEST_MODEL_BASE_URL: string;
  151140. profileId: string;
  151141. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  151142. protected _getFilenameAndPath(): {
  151143. filename: string;
  151144. path: string;
  151145. };
  151146. protected _getModelLoadingConstraints(): boolean;
  151147. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151148. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151149. protected _updateModel(): void;
  151150. /**
  151151. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  151152. * between the touch and touch 2.
  151153. */
  151154. private _isQuest;
  151155. }
  151156. }
  151157. declare module BABYLON {
  151158. /**
  151159. * The motion controller class for the standard HTC-Vive controllers
  151160. */
  151161. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  151162. private _modelRootNode;
  151163. /**
  151164. * The base url used to load the left and right controller models
  151165. */
  151166. static MODEL_BASE_URL: string;
  151167. /**
  151168. * File name for the controller model.
  151169. */
  151170. static MODEL_FILENAME: string;
  151171. profileId: string;
  151172. /**
  151173. * Create a new Vive motion controller object
  151174. * @param scene the scene to use to create this controller
  151175. * @param gamepadObject the corresponding gamepad object
  151176. * @param handedness the handedness of the controller
  151177. */
  151178. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151179. protected _getFilenameAndPath(): {
  151180. filename: string;
  151181. path: string;
  151182. };
  151183. protected _getModelLoadingConstraints(): boolean;
  151184. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151185. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151186. protected _updateModel(): void;
  151187. }
  151188. }
  151189. declare module BABYLON {
  151190. /**
  151191. * A cursor which tracks a point on a path
  151192. */
  151193. export class PathCursor {
  151194. private path;
  151195. /**
  151196. * Stores path cursor callbacks for when an onchange event is triggered
  151197. */
  151198. private _onchange;
  151199. /**
  151200. * The value of the path cursor
  151201. */
  151202. value: number;
  151203. /**
  151204. * The animation array of the path cursor
  151205. */
  151206. animations: Animation[];
  151207. /**
  151208. * Initializes the path cursor
  151209. * @param path The path to track
  151210. */
  151211. constructor(path: Path2);
  151212. /**
  151213. * Gets the cursor point on the path
  151214. * @returns A point on the path cursor at the cursor location
  151215. */
  151216. getPoint(): Vector3;
  151217. /**
  151218. * Moves the cursor ahead by the step amount
  151219. * @param step The amount to move the cursor forward
  151220. * @returns This path cursor
  151221. */
  151222. moveAhead(step?: number): PathCursor;
  151223. /**
  151224. * Moves the cursor behind by the step amount
  151225. * @param step The amount to move the cursor back
  151226. * @returns This path cursor
  151227. */
  151228. moveBack(step?: number): PathCursor;
  151229. /**
  151230. * Moves the cursor by the step amount
  151231. * If the step amount is greater than one, an exception is thrown
  151232. * @param step The amount to move the cursor
  151233. * @returns This path cursor
  151234. */
  151235. move(step: number): PathCursor;
  151236. /**
  151237. * Ensures that the value is limited between zero and one
  151238. * @returns This path cursor
  151239. */
  151240. private ensureLimits;
  151241. /**
  151242. * Runs onchange callbacks on change (used by the animation engine)
  151243. * @returns This path cursor
  151244. */
  151245. private raiseOnChange;
  151246. /**
  151247. * Executes a function on change
  151248. * @param f A path cursor onchange callback
  151249. * @returns This path cursor
  151250. */
  151251. onchange(f: (cursor: PathCursor) => void): PathCursor;
  151252. }
  151253. }
  151254. declare module BABYLON {
  151255. /** @hidden */
  151256. export var blurPixelShader: {
  151257. name: string;
  151258. shader: string;
  151259. };
  151260. }
  151261. declare module BABYLON {
  151262. /** @hidden */
  151263. export var pointCloudVertexDeclaration: {
  151264. name: string;
  151265. shader: string;
  151266. };
  151267. }
  151268. // Mixins
  151269. interface Window {
  151270. mozIndexedDB: IDBFactory;
  151271. webkitIndexedDB: IDBFactory;
  151272. msIndexedDB: IDBFactory;
  151273. webkitURL: typeof URL;
  151274. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  151275. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  151276. WebGLRenderingContext: WebGLRenderingContext;
  151277. MSGesture: MSGesture;
  151278. CANNON: any;
  151279. AudioContext: AudioContext;
  151280. webkitAudioContext: AudioContext;
  151281. PointerEvent: any;
  151282. Math: Math;
  151283. Uint8Array: Uint8ArrayConstructor;
  151284. Float32Array: Float32ArrayConstructor;
  151285. mozURL: typeof URL;
  151286. msURL: typeof URL;
  151287. VRFrameData: any; // WebVR, from specs 1.1
  151288. DracoDecoderModule: any;
  151289. setImmediate(handler: (...args: any[]) => void): number;
  151290. }
  151291. interface HTMLCanvasElement {
  151292. requestPointerLock(): void;
  151293. msRequestPointerLock?(): void;
  151294. mozRequestPointerLock?(): void;
  151295. webkitRequestPointerLock?(): void;
  151296. /** Track wether a record is in progress */
  151297. isRecording: boolean;
  151298. /** Capture Stream method defined by some browsers */
  151299. captureStream(fps?: number): MediaStream;
  151300. }
  151301. interface CanvasRenderingContext2D {
  151302. msImageSmoothingEnabled: boolean;
  151303. }
  151304. interface MouseEvent {
  151305. mozMovementX: number;
  151306. mozMovementY: number;
  151307. webkitMovementX: number;
  151308. webkitMovementY: number;
  151309. msMovementX: number;
  151310. msMovementY: number;
  151311. }
  151312. interface Navigator {
  151313. mozGetVRDevices: (any: any) => any;
  151314. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151315. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151316. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151317. webkitGetGamepads(): Gamepad[];
  151318. msGetGamepads(): Gamepad[];
  151319. webkitGamepads(): Gamepad[];
  151320. }
  151321. interface HTMLVideoElement {
  151322. mozSrcObject: any;
  151323. }
  151324. interface Math {
  151325. fround(x: number): number;
  151326. imul(a: number, b: number): number;
  151327. }
  151328. interface WebGLRenderingContext {
  151329. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  151330. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  151331. vertexAttribDivisor(index: number, divisor: number): void;
  151332. createVertexArray(): any;
  151333. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  151334. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  151335. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  151336. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  151337. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  151338. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  151339. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  151340. // Queries
  151341. createQuery(): WebGLQuery;
  151342. deleteQuery(query: WebGLQuery): void;
  151343. beginQuery(target: number, query: WebGLQuery): void;
  151344. endQuery(target: number): void;
  151345. getQueryParameter(query: WebGLQuery, pname: number): any;
  151346. getQuery(target: number, pname: number): any;
  151347. MAX_SAMPLES: number;
  151348. RGBA8: number;
  151349. READ_FRAMEBUFFER: number;
  151350. DRAW_FRAMEBUFFER: number;
  151351. UNIFORM_BUFFER: number;
  151352. HALF_FLOAT_OES: number;
  151353. RGBA16F: number;
  151354. RGBA32F: number;
  151355. R32F: number;
  151356. RG32F: number;
  151357. RGB32F: number;
  151358. R16F: number;
  151359. RG16F: number;
  151360. RGB16F: number;
  151361. RED: number;
  151362. RG: number;
  151363. R8: number;
  151364. RG8: number;
  151365. UNSIGNED_INT_24_8: number;
  151366. DEPTH24_STENCIL8: number;
  151367. MIN: number;
  151368. MAX: number;
  151369. /* Multiple Render Targets */
  151370. drawBuffers(buffers: number[]): void;
  151371. readBuffer(src: number): void;
  151372. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151373. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151374. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151375. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151376. // Occlusion Query
  151377. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151378. ANY_SAMPLES_PASSED: number;
  151379. QUERY_RESULT_AVAILABLE: number;
  151380. QUERY_RESULT: number;
  151381. }
  151382. interface WebGLProgram {
  151383. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151384. }
  151385. interface EXT_disjoint_timer_query {
  151386. QUERY_COUNTER_BITS_EXT: number;
  151387. TIME_ELAPSED_EXT: number;
  151388. TIMESTAMP_EXT: number;
  151389. GPU_DISJOINT_EXT: number;
  151390. QUERY_RESULT_EXT: number;
  151391. QUERY_RESULT_AVAILABLE_EXT: number;
  151392. queryCounterEXT(query: WebGLQuery, target: number): void;
  151393. createQueryEXT(): WebGLQuery;
  151394. beginQueryEXT(target: number, query: WebGLQuery): void;
  151395. endQueryEXT(target: number): void;
  151396. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151397. deleteQueryEXT(query: WebGLQuery): void;
  151398. }
  151399. interface WebGLUniformLocation {
  151400. _currentState: any;
  151401. }
  151402. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151403. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151404. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151405. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151406. interface WebGLRenderingContext {
  151407. readonly RASTERIZER_DISCARD: number;
  151408. readonly DEPTH_COMPONENT24: number;
  151409. readonly TEXTURE_3D: number;
  151410. readonly TEXTURE_2D_ARRAY: number;
  151411. readonly TEXTURE_COMPARE_FUNC: number;
  151412. readonly TEXTURE_COMPARE_MODE: number;
  151413. readonly COMPARE_REF_TO_TEXTURE: number;
  151414. readonly TEXTURE_WRAP_R: number;
  151415. readonly HALF_FLOAT: number;
  151416. readonly RGB8: number;
  151417. readonly RED_INTEGER: number;
  151418. readonly RG_INTEGER: number;
  151419. readonly RGB_INTEGER: number;
  151420. readonly RGBA_INTEGER: number;
  151421. readonly R8_SNORM: number;
  151422. readonly RG8_SNORM: number;
  151423. readonly RGB8_SNORM: number;
  151424. readonly RGBA8_SNORM: number;
  151425. readonly R8I: number;
  151426. readonly RG8I: number;
  151427. readonly RGB8I: number;
  151428. readonly RGBA8I: number;
  151429. readonly R8UI: number;
  151430. readonly RG8UI: number;
  151431. readonly RGB8UI: number;
  151432. readonly RGBA8UI: number;
  151433. readonly R16I: number;
  151434. readonly RG16I: number;
  151435. readonly RGB16I: number;
  151436. readonly RGBA16I: number;
  151437. readonly R16UI: number;
  151438. readonly RG16UI: number;
  151439. readonly RGB16UI: number;
  151440. readonly RGBA16UI: number;
  151441. readonly R32I: number;
  151442. readonly RG32I: number;
  151443. readonly RGB32I: number;
  151444. readonly RGBA32I: number;
  151445. readonly R32UI: number;
  151446. readonly RG32UI: number;
  151447. readonly RGB32UI: number;
  151448. readonly RGBA32UI: number;
  151449. readonly RGB10_A2UI: number;
  151450. readonly R11F_G11F_B10F: number;
  151451. readonly RGB9_E5: number;
  151452. readonly RGB10_A2: number;
  151453. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151454. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151455. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151456. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151457. readonly DEPTH_COMPONENT32F: number;
  151458. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151459. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151460. 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;
  151461. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151462. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151463. readonly TRANSFORM_FEEDBACK: number;
  151464. readonly INTERLEAVED_ATTRIBS: number;
  151465. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151466. createTransformFeedback(): WebGLTransformFeedback;
  151467. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151468. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151469. beginTransformFeedback(primitiveMode: number): void;
  151470. endTransformFeedback(): void;
  151471. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151472. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151473. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151474. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151475. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151476. }
  151477. interface ImageBitmap {
  151478. readonly width: number;
  151479. readonly height: number;
  151480. close(): void;
  151481. }
  151482. interface WebGLQuery extends WebGLObject {
  151483. }
  151484. declare var WebGLQuery: {
  151485. prototype: WebGLQuery;
  151486. new(): WebGLQuery;
  151487. };
  151488. interface WebGLSampler extends WebGLObject {
  151489. }
  151490. declare var WebGLSampler: {
  151491. prototype: WebGLSampler;
  151492. new(): WebGLSampler;
  151493. };
  151494. interface WebGLSync extends WebGLObject {
  151495. }
  151496. declare var WebGLSync: {
  151497. prototype: WebGLSync;
  151498. new(): WebGLSync;
  151499. };
  151500. interface WebGLTransformFeedback extends WebGLObject {
  151501. }
  151502. declare var WebGLTransformFeedback: {
  151503. prototype: WebGLTransformFeedback;
  151504. new(): WebGLTransformFeedback;
  151505. };
  151506. interface WebGLVertexArrayObject extends WebGLObject {
  151507. }
  151508. declare var WebGLVertexArrayObject: {
  151509. prototype: WebGLVertexArrayObject;
  151510. new(): WebGLVertexArrayObject;
  151511. };
  151512. // Type definitions for WebVR API
  151513. // Project: https://w3c.github.io/webvr/
  151514. // Definitions by: six a <https://github.com/lostfictions>
  151515. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151516. interface VRDisplay extends EventTarget {
  151517. /**
  151518. * Dictionary of capabilities describing the VRDisplay.
  151519. */
  151520. readonly capabilities: VRDisplayCapabilities;
  151521. /**
  151522. * z-depth defining the far plane of the eye view frustum
  151523. * enables mapping of values in the render target depth
  151524. * attachment to scene coordinates. Initially set to 10000.0.
  151525. */
  151526. depthFar: number;
  151527. /**
  151528. * z-depth defining the near plane of the eye view frustum
  151529. * enables mapping of values in the render target depth
  151530. * attachment to scene coordinates. Initially set to 0.01.
  151531. */
  151532. depthNear: number;
  151533. /**
  151534. * An identifier for this distinct VRDisplay. Used as an
  151535. * association point in the Gamepad API.
  151536. */
  151537. readonly displayId: number;
  151538. /**
  151539. * A display name, a user-readable name identifying it.
  151540. */
  151541. readonly displayName: string;
  151542. readonly isConnected: boolean;
  151543. readonly isPresenting: boolean;
  151544. /**
  151545. * If this VRDisplay supports room-scale experiences, the optional
  151546. * stage attribute contains details on the room-scale parameters.
  151547. */
  151548. readonly stageParameters: VRStageParameters | null;
  151549. /**
  151550. * Passing the value returned by `requestAnimationFrame` to
  151551. * `cancelAnimationFrame` will unregister the callback.
  151552. * @param handle Define the hanle of the request to cancel
  151553. */
  151554. cancelAnimationFrame(handle: number): void;
  151555. /**
  151556. * Stops presenting to the VRDisplay.
  151557. * @returns a promise to know when it stopped
  151558. */
  151559. exitPresent(): Promise<void>;
  151560. /**
  151561. * Return the current VREyeParameters for the given eye.
  151562. * @param whichEye Define the eye we want the parameter for
  151563. * @returns the eye parameters
  151564. */
  151565. getEyeParameters(whichEye: string): VREyeParameters;
  151566. /**
  151567. * Populates the passed VRFrameData with the information required to render
  151568. * the current frame.
  151569. * @param frameData Define the data structure to populate
  151570. * @returns true if ok otherwise false
  151571. */
  151572. getFrameData(frameData: VRFrameData): boolean;
  151573. /**
  151574. * Get the layers currently being presented.
  151575. * @returns the list of VR layers
  151576. */
  151577. getLayers(): VRLayer[];
  151578. /**
  151579. * Return a VRPose containing the future predicted pose of the VRDisplay
  151580. * when the current frame will be presented. The value returned will not
  151581. * change until JavaScript has returned control to the browser.
  151582. *
  151583. * The VRPose will contain the position, orientation, velocity,
  151584. * and acceleration of each of these properties.
  151585. * @returns the pose object
  151586. */
  151587. getPose(): VRPose;
  151588. /**
  151589. * Return the current instantaneous pose of the VRDisplay, with no
  151590. * prediction applied.
  151591. * @returns the current instantaneous pose
  151592. */
  151593. getImmediatePose(): VRPose;
  151594. /**
  151595. * The callback passed to `requestAnimationFrame` will be called
  151596. * any time a new frame should be rendered. When the VRDisplay is
  151597. * presenting the callback will be called at the native refresh
  151598. * rate of the HMD. When not presenting this function acts
  151599. * identically to how window.requestAnimationFrame acts. Content should
  151600. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151601. * asynchronously from other displays and at differing refresh rates.
  151602. * @param callback Define the eaction to run next frame
  151603. * @returns the request handle it
  151604. */
  151605. requestAnimationFrame(callback: FrameRequestCallback): number;
  151606. /**
  151607. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151608. * Repeat calls while already presenting will update the VRLayers being displayed.
  151609. * @param layers Define the list of layer to present
  151610. * @returns a promise to know when the request has been fulfilled
  151611. */
  151612. requestPresent(layers: VRLayer[]): Promise<void>;
  151613. /**
  151614. * Reset the pose for this display, treating its current position and
  151615. * orientation as the "origin/zero" values. VRPose.position,
  151616. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151617. * updated when calling resetPose(). This should be called in only
  151618. * sitting-space experiences.
  151619. */
  151620. resetPose(): void;
  151621. /**
  151622. * The VRLayer provided to the VRDisplay will be captured and presented
  151623. * in the HMD. Calling this function has the same effect on the source
  151624. * canvas as any other operation that uses its source image, and canvases
  151625. * created without preserveDrawingBuffer set to true will be cleared.
  151626. * @param pose Define the pose to submit
  151627. */
  151628. submitFrame(pose?: VRPose): void;
  151629. }
  151630. declare var VRDisplay: {
  151631. prototype: VRDisplay;
  151632. new(): VRDisplay;
  151633. };
  151634. interface VRLayer {
  151635. leftBounds?: number[] | Float32Array | null;
  151636. rightBounds?: number[] | Float32Array | null;
  151637. source?: HTMLCanvasElement | null;
  151638. }
  151639. interface VRDisplayCapabilities {
  151640. readonly canPresent: boolean;
  151641. readonly hasExternalDisplay: boolean;
  151642. readonly hasOrientation: boolean;
  151643. readonly hasPosition: boolean;
  151644. readonly maxLayers: number;
  151645. }
  151646. interface VREyeParameters {
  151647. /** @deprecated */
  151648. readonly fieldOfView: VRFieldOfView;
  151649. readonly offset: Float32Array;
  151650. readonly renderHeight: number;
  151651. readonly renderWidth: number;
  151652. }
  151653. interface VRFieldOfView {
  151654. readonly downDegrees: number;
  151655. readonly leftDegrees: number;
  151656. readonly rightDegrees: number;
  151657. readonly upDegrees: number;
  151658. }
  151659. interface VRFrameData {
  151660. readonly leftProjectionMatrix: Float32Array;
  151661. readonly leftViewMatrix: Float32Array;
  151662. readonly pose: VRPose;
  151663. readonly rightProjectionMatrix: Float32Array;
  151664. readonly rightViewMatrix: Float32Array;
  151665. readonly timestamp: number;
  151666. }
  151667. interface VRPose {
  151668. readonly angularAcceleration: Float32Array | null;
  151669. readonly angularVelocity: Float32Array | null;
  151670. readonly linearAcceleration: Float32Array | null;
  151671. readonly linearVelocity: Float32Array | null;
  151672. readonly orientation: Float32Array | null;
  151673. readonly position: Float32Array | null;
  151674. readonly timestamp: number;
  151675. }
  151676. interface VRStageParameters {
  151677. sittingToStandingTransform?: Float32Array;
  151678. sizeX?: number;
  151679. sizeY?: number;
  151680. }
  151681. interface Navigator {
  151682. getVRDisplays(): Promise<VRDisplay[]>;
  151683. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151684. }
  151685. interface Window {
  151686. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151687. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151688. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151689. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151690. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151691. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151692. }
  151693. interface Gamepad {
  151694. readonly displayId: number;
  151695. }
  151696. type XRSessionMode =
  151697. | "inline"
  151698. | "immersive-vr"
  151699. | "immersive-ar";
  151700. type XRReferenceSpaceType =
  151701. | "viewer"
  151702. | "local"
  151703. | "local-floor"
  151704. | "bounded-floor"
  151705. | "unbounded";
  151706. type XREnvironmentBlendMode =
  151707. | "opaque"
  151708. | "additive"
  151709. | "alpha-blend";
  151710. type XRVisibilityState =
  151711. | "visible"
  151712. | "visible-blurred"
  151713. | "hidden";
  151714. type XRHandedness =
  151715. | "none"
  151716. | "left"
  151717. | "right";
  151718. type XRTargetRayMode =
  151719. | "gaze"
  151720. | "tracked-pointer"
  151721. | "screen";
  151722. type XREye =
  151723. | "none"
  151724. | "left"
  151725. | "right";
  151726. type XREventType =
  151727. | "devicechange"
  151728. | "visibilitychange"
  151729. | "end"
  151730. | "inputsourceschange"
  151731. | "select"
  151732. | "selectstart"
  151733. | "selectend"
  151734. | "squeeze"
  151735. | "squeezestart"
  151736. | "squeezeend"
  151737. | "reset";
  151738. interface XRSpace extends EventTarget {
  151739. }
  151740. interface XRRenderState {
  151741. depthNear?: number;
  151742. depthFar?: number;
  151743. inlineVerticalFieldOfView?: number;
  151744. baseLayer?: XRWebGLLayer;
  151745. }
  151746. interface XRInputSource {
  151747. handedness: XRHandedness;
  151748. targetRayMode: XRTargetRayMode;
  151749. targetRaySpace: XRSpace;
  151750. gripSpace: XRSpace | undefined;
  151751. gamepad: Gamepad | undefined;
  151752. profiles: Array<string>;
  151753. }
  151754. interface XRSessionInit {
  151755. optionalFeatures?: string[];
  151756. requiredFeatures?: string[];
  151757. }
  151758. interface XRSession {
  151759. addEventListener: Function;
  151760. removeEventListener: Function;
  151761. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  151762. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  151763. requestAnimationFrame: Function;
  151764. end(): Promise<void>;
  151765. renderState: XRRenderState;
  151766. inputSources: Array<XRInputSource>;
  151767. // hit test
  151768. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  151769. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  151770. // legacy AR hit test
  151771. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151772. // legacy plane detection
  151773. updateWorldTrackingState(options: {
  151774. planeDetectionState?: { enabled: boolean; }
  151775. }): void;
  151776. }
  151777. interface XRReferenceSpace extends XRSpace {
  151778. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  151779. onreset: any;
  151780. }
  151781. type XRPlaneSet = Set<XRPlane>;
  151782. type XRAnchorSet = Set<XRAnchor>;
  151783. interface XRFrame {
  151784. session: XRSession;
  151785. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  151786. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  151787. // AR
  151788. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  151789. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  151790. // Anchors
  151791. trackedAnchors?: XRAnchorSet;
  151792. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  151793. // Planes
  151794. worldInformation: {
  151795. detectedPlanes?: XRPlaneSet;
  151796. };
  151797. }
  151798. interface XRViewerPose extends XRPose {
  151799. views: Array<XRView>;
  151800. }
  151801. interface XRPose {
  151802. transform: XRRigidTransform;
  151803. emulatedPosition: boolean;
  151804. }
  151805. interface XRWebGLLayerOptions {
  151806. antialias?: boolean;
  151807. depth?: boolean;
  151808. stencil?: boolean;
  151809. alpha?: boolean;
  151810. multiview?: boolean;
  151811. framebufferScaleFactor?: number;
  151812. }
  151813. declare var XRWebGLLayer: {
  151814. prototype: XRWebGLLayer;
  151815. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  151816. };
  151817. interface XRWebGLLayer {
  151818. framebuffer: WebGLFramebuffer;
  151819. framebufferWidth: number;
  151820. framebufferHeight: number;
  151821. getViewport: Function;
  151822. }
  151823. declare class XRRigidTransform {
  151824. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  151825. position: DOMPointReadOnly;
  151826. orientation: DOMPointReadOnly;
  151827. matrix: Float32Array;
  151828. inverse: XRRigidTransform;
  151829. }
  151830. interface XRView {
  151831. eye: XREye;
  151832. projectionMatrix: Float32Array;
  151833. transform: XRRigidTransform;
  151834. }
  151835. interface XRInputSourceChangeEvent {
  151836. session: XRSession;
  151837. removed: Array<XRInputSource>;
  151838. added: Array<XRInputSource>;
  151839. }
  151840. interface XRInputSourceEvent extends Event {
  151841. readonly frame: XRFrame;
  151842. readonly inputSource: XRInputSource;
  151843. }
  151844. // Experimental(er) features
  151845. declare class XRRay {
  151846. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151847. origin: DOMPointReadOnly;
  151848. direction: DOMPointReadOnly;
  151849. matrix: Float32Array;
  151850. }
  151851. declare enum XRHitTestTrackableType {
  151852. "point",
  151853. "plane"
  151854. }
  151855. interface XRHitResult {
  151856. hitMatrix: Float32Array;
  151857. }
  151858. interface XRTransientInputHitTestResult {
  151859. readonly inputSource: XRInputSource;
  151860. readonly results: Array<XRHitTestResult>;
  151861. }
  151862. interface XRHitTestResult {
  151863. getPose(baseSpace: XRSpace): XRPose | undefined;
  151864. // When anchor system is enabled
  151865. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151866. }
  151867. interface XRHitTestSource {
  151868. cancel(): void;
  151869. }
  151870. interface XRTransientInputHitTestSource {
  151871. cancel(): void;
  151872. }
  151873. interface XRHitTestOptionsInit {
  151874. space: XRSpace;
  151875. entityTypes?: Array<XRHitTestTrackableType>;
  151876. offsetRay?: XRRay;
  151877. }
  151878. interface XRTransientInputHitTestOptionsInit {
  151879. profile: string;
  151880. entityTypes?: Array<XRHitTestTrackableType>;
  151881. offsetRay?: XRRay;
  151882. }
  151883. interface XRAnchor {
  151884. anchorSpace: XRSpace;
  151885. delete(): void;
  151886. }
  151887. interface XRPlane {
  151888. orientation: "Horizontal" | "Vertical";
  151889. planeSpace: XRSpace;
  151890. polygon: Array<DOMPointReadOnly>;
  151891. lastChangedTime: number;
  151892. }